This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 214801 - Allow Mavenized Modules to Select Parent Suite/Application POM
Summary: Allow Mavenized Modules to Select Parent Suite/Application POM
Status: RESOLVED WONTFIX
Alias: None
Product: projects
Classification: Unclassified
Component: Maven (show other bugs)
Version: 7.3
Hardware: All All
: P3 normal with 1 vote (vote)
Assignee: Tomas Stupka
URL:
Keywords:
: 215441 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-06-26 14:25 UTC by slbmeh
Modified: 2016-07-07 08:37 UTC (History)
2 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description slbmeh 2012-06-26 14:25:58 UTC
Creating a new Mavenized module to add to an existing container project does not exist.  Currently support generates a standalone module application.

Adding support to allow for selection of a parent project would be a nice feature and could possibly automatically add the module as a dependency to the parent as well as configure the POM to use ${project.version} and ${netbeans.version} variables by default in the generated POM would provide a better user experience.

Example: Currently I am creating a Mavenized Platform Application based on RELEASE72-BETA, the modules generated in the initial wizard are built against the version I select from a dropdown.  Subsequent modules created with their own wizard are built against the IDE's version.
Comment 1 Milos Kleint 2012-06-26 14:45:03 UTC
the general problem is with archetypes. There is no guarantee that ${netbeans.version} is actually being used as a property expression.

When the project directory where the new project is generated is a pom maven project, the <parent and <module sections are generated in their respective pom.xml files. Done by archetype plugin. But I suppose you are asking for ways of determining that *inside* the wizard ui somehow, not ex post.

We definitely could make ${netbeans.version} (or anything else) to be the default version in the combo box based on the parent project's settings. 

Harder to achieve with ${project.version} (<version> element in child should probably not exist once delegating to parent).

The big challenge is to trim the <plugin>nbm-maven-plugin and other plugin configuration sections based on the configuration in the parent. That's a non trivial problem to solve. We can do it when creating the module along with the application because we know at that time what the app looks like.
Comment 2 slbmeh 2012-06-26 14:50:29 UTC
As it is right now there is no combo box selection for a new Maven Module Project.  

It just assumes to build against the current ide version.

Somewhere it already detects a parent by a POM placed in the folder it is
created within. It would be nice for this automatic detection to apply to more
aspects of the generated template add the dependency in the Project-app POM.

I was thinking something along the lines of when you create a NetBeans Module that is not Mavenized it gives you a choice of Standalone which provides a dropdown of available platforms, or Add To Module Suite.  Is there anything preventing this functionality from being replicated to the Maven counterpart?
Comment 3 Milos Kleint 2012-06-26 15:01:33 UTC
(In reply to comment #2)
> I was thinking something along the lines of when you create a NetBeans Module
> that is not Mavenized it gives you a choice of Standalone which provides a
> dropdown of available platforms, or Add To Module Suite.  Is there anything
> preventing this functionality from being replicated to the Maven counterpart?

Mostly complexity of the decision tree that needs to examine the parent project in a non trivial way. Even figuring the value for dependency version is hard. The parent pom typically doesn't contain any dependencies on it's own that would hint in the right direction. So one would have to examine the existing modules of the parent as well.
Another problem is that the MavenProject instance that's associated with every maven project has all the expressions evaluated. So we would have to dive deep into maven internals are re-read the raw models in search of the expression used before it gets evaluated.

The complexity on the ant based project side is limited significantly as vast majority of  the build script is automatically generated by netbeans and only mostly harmless hooks are open for the user to modify.
Comment 4 Milos Kleint 2012-06-26 15:05:02 UTC
(In reply to comment #3)
> (In reply to comment #2)
> Another problem is that the MavenProject instance that's associated with every
> maven project has all the expressions evaluated. So we would have to dive deep
> into maven internals are re-read the raw models in search of the expression
> used before it gets evaluated.

That's why all the file wizards that add dependencies to the project will unfortunately also just set the resolved value to new dependencies, instead of the expression used by existing dependencies in the same project.
Comment 5 slbmeh 2012-06-26 15:08:39 UTC
(In reply to comment #2)
> As it is right now there is no combo box selection for a new Maven Module
> Project.  

I overlooked the combo box in step 2.  I was expecting something in step 1 a little more similar to a non-maven module.
Comment 6 slbmeh 2012-06-26 15:24:32 UTC
(In reply to comment #4)
> That's why all the file wizards that add dependencies to the project will
> unfortunately also just set the resolved value to new dependencies, instead of
> the expression used by existing dependencies in the same project.

How is the module created in the wizard for an application differ from a module created with its own wizard?

(In reply to comment #2)
> Somewhere it already detects a parent by a POM placed in the folder it is
> created within. It would be nice for this automatic detection to apply to more
> aspects of the generated template add the dependency in the Project-app POM.

Can't the wizard be modified to mimic the wizard of the ant based project to allow for selection of standalone providing a dropdown populated by versions in the repository vs add to existing which would provide a dropdown of mavenized application suites and force project creation in the same directory?

If a project is created within the same subdirectory the generated module receives a <parent> group of tags.  Additionally the parent project has a <module> tag added under the <modules> group.  Why can't the generated '-app' project have <dependency> tags added in the same way?

I apologize I am very unfamiliar with the complexity of maven archetypes, and I don't know where the line is between NetBeans generated and Maven generated POM modifications.  I think half of my enhancement suggestion would be solved by modifying the wizard to appear similar to the ant based wizard with functionality described in my first paragraph after referencing comment #2.
Comment 7 Milos Kleint 2012-06-26 15:31:55 UTC
(In reply to comment #6)
> (In reply to comment #4)
> > That's why all the file wizards that add dependencies to the project will
> > unfortunately also just set the resolved value to new dependencies, instead of
> > the expression used by existing dependencies in the same project.
> 
> How is the module created in the wizard for an application differ from a module
> created with its own wizard?

It differs in hardwired assumptions based on knowing what the application/parent pom looks like. We generate the maven archetype and then post-process it. We cannot assume anything for existing parent poms.



> 
> (In reply to comment #2)
> > Somewhere it already detects a parent by a POM placed in the folder it is
> > created within. It would be nice for this automatic detection to apply to more
> > aspects of the generated template add the dependency in the Project-app POM.
> 
> Can't the wizard be modified to mimic the wizard of the ant based project to
> allow for selection of standalone providing a dropdown populated by versions in
> the repository vs add to existing which would provide a dropdown of mavenized
> application suites and force project creation in the same directory?

That doesn't solve much except for allowing us to have 2 archetypes for the current 1. Also please note that there is no complete equivalent of ant suites in the maven world..


> 
> If a project is created within the same subdirectory the generated module
> receives a <parent> group of tags.  Additionally the parent project has a
> <module> tag added under the <modules> group.  Why can't the generated '-app'
> project have <dependency> tags added in the same way?

It can. The challenge is not the act of post-processing the generated pom, but extracting the values from existing environment.
Comment 8 slbmeh 2012-06-26 15:53:52 UTC
(In reply to comment #7)
> It differs in hardwired assumptions based on knowing what the
> application/parent pom looks like. We generate the maven archetype and then
> post-process it. We cannot assume anything for existing parent poms.


(In reply to comment #7)
> That doesn't solve much except for allowing us to have 2 archetypes for the
> current 1. Also please note that there is no complete equivalent of ant suites
> in the maven world..
Why would a separate archetype be needed to generate the same thing in a different subfolder?  NetBeans is capable of doing it right now as long as you put the module in the right project folder.

(In reply to comment #7)
> It can. The challenge is not the act of post-processing the generated pom, but
> extracting the values from existing environment.
Can the information not be obtained from the lookup or something similar?  I obtain the information that I manually place into the pom by hovering over the project node and reading the tooltip.
Comment 9 Milos Kleint 2012-08-23 11:21:33 UTC
*** Bug 215441 has been marked as a duplicate of this bug. ***
Comment 10 Martin Balin 2016-07-07 08:37:40 UTC
This old bug may not be relevant anymore. If you can still reproduce it in 8.2 development builds please reopen this issue.

Thanks for your cooperation,
NetBeans IDE 8.2 Release Boss