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 197232 - "Build with Dependencies" fails when parent/relativePath != ../pom.xml
Summary: "Build with Dependencies" fails when parent/relativePath != ../pom.xml
Status: RESOLVED FIXED
Alias: None
Product: projects
Classification: Unclassified
Component: Maven (show other bugs)
Version: 7.0
Hardware: All All
: P3 normal (vote)
Assignee: Jesse Glick
URL:
Keywords: REGRESSION
Depends on:
Blocks:
 
Reported: 2011-03-30 13:51 UTC by matsa
Modified: 2011-08-10 21:32 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description matsa 2011-03-30 13:51:43 UTC
I have a project structured thusly:

- parent
-- pom.xml
- module1
-- src
-- pom.xml
- module2
-- src
-- pom.xml
- webmodule
-- src
-- pom.xml
pom.xml

The last pom serves as a maven reactor, defining all modules:

<modules>
  <module>parent</module>
  <module>module1</module>
  <module>module2</module>
  <module>web</module>
</modules>

In, up to and including, 6.9.1 I can click "Build with dependencies". The consequence is that it builds all dependencies as I expected.

In the 7.0 releases so far (including RC1) it fails. This seems to be because it changes directory to the parent module before running:

cd D:\xx\project\parent; JAVA_HOME=D:\\bin\\java\\x64\\jdk6 mvn.bat --also-make --projects <groupid>:<artifactid> install

I note that this would work if one uses only 1 pom.xml as both parent and reactor.
Comment 1 Jesse Glick 2011-03-30 15:59:28 UTC
ReactorChecker is looping on MavenProject.parent until it finds one whose parent has no basedir, then setting RunConfig.executionDirectory to the last basedir encountered. As you found, this will behave incorrectly in case parent/relativePath is not the default of ../pom.xml; would also fail if the parent did not list the child as a module.

(6.9 has a more simplistic version of BwD which just hardcodes executionDirectory=.., which will (a) fail for a project not inside a reactor, (b) not start "high enough" for a submodule in a big reactor like Glassfish.)

I guess the logic should rather be to walk up the directory hierarchy so long as the parent dir contains a valid pom.xml and that MavenProject.modules indeed lists the subdir. Even that could fail in case some element in modules is of the form ../x or x/y or otherwise not a simple subdirectory, though I guess this would be rare. A hybrid strategy would be to search parent/relativePath, and failing that ../pom.xml if different, looking for a project listing the current project as a module.

Another tricky point is deciding which profile(s) to apply when loading the parent MavenProject, since that can affect the list of modules; for example, https://svn.apache.org/repos/asf/felix/trunk/pom.xml needs to be in the packaging-bundle profile for BwD to work on .../framework/pom.xml but (since this profile is inactive by default) BwD will fail unless the IDE passes -Ppackaging-bundle and then that could interfere with other modules.
Comment 2 Jesse Glick 2011-03-30 16:01:43 UTC
Regression from 6.9, but probably not a P2 requiring backport to 7.0 since there is a straightforward workaround: run Build on the reactor root.
Comment 3 Jesse Glick 2011-07-29 22:16:21 UTC
core-main #c5d507c05c53
Comment 4 Quality Engineering 2011-07-30 13:48:09 UTC
Integrated into 'main-golden'
Changeset: http://hg.netbeans.org/main-golden/rev/c5d507c05c53
User: Jesse Glick <jglick@netbeans.org>
Log: #197232: "Build with Dependencies" fails when parent/relativePath != ../pom.xml
Comment 5 Quality Engineering 2011-08-10 21:32:02 UTC
Integrated into 'main-golden'
Changeset: http://hg.netbeans.org/main-golden/rev/3fcc85188c49
User: Jesse Glick <jglick@netbeans.org>
Log: #197232 (--also-make) tweaks.
1. Behave properly when the project is unloadable.
2. Skip -am/-amd + -pl when there is no distinct reactor root.