Skip to content

Commit b30df68

Browse files
committed
Changed approach on how to construct the MavenExecutionRequest for the nested Maven execution. Changed from creating one from scratch, towards basing it on the request from the session, copying it, removing unneeded aspect and changing others.
1 parent c2db550 commit b30df68

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

src/main/java/com/e_gineering/maven/gitflowhelper/OtherBranchVersionExtension.java

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -91,18 +91,14 @@ public void afterProjectsRead(final MavenSession session) throws MavenExecutionE
9191

9292
logger.info("Found top level project, but outside reactor: " + topLevelProject.getGroupId() + ":" + topLevelProject.getArtifactId() + " (" + topLevelProject.getFile() + ")");
9393

94-
// Initialization of the nested Maven execution
95-
final MavenExecutionRequest request = new DefaultMavenExecutionRequest()
96-
.setLocalRepository(session.getLocalRepository())
97-
.setPom(topLevelProject.getFile())
98-
.setBaseDirectory(topLevelProject.getBasedir())
99-
.setReactorFailureBehavior(MavenExecutionRequest.REACTOR_FAIL_NEVER)
100-
.setUserProperties(session.getUserProperties())
101-
.setMirrors(session.getRequest().getMirrors())
102-
.setRemoteRepositories(session.getRequest().getRemoteRepositories())
103-
.setPluginArtifactRepositories(session.getRequest().getPluginArtifactRepositories())
104-
.setServers(session.getRequest().getServers())
105-
.setProxies(session.getRequest().getProxies())
94+
// Initialization of the nested Maven execution, based on the current session's request
95+
final MavenExecutionRequest request = DefaultMavenExecutionRequest.copy(session.getRequest())
96+
.setExecutionListener(null) /* Disable the observer of the outer maven session */
97+
.setTransferListener(null) /* Disable the observer of the outer maven session */
98+
.setGoals(null) /* Disable the goals used to execute the outer maven session */
99+
.setReactorFailureBehavior(MavenExecutionRequest.REACTOR_FAIL_NEVER)
100+
.setPom(topLevelProject.getFile()) /* Use the pom file of the top-level project */
101+
.setBaseDirectory(topLevelProject.getBasedir()) /* Use the basedir of the top-level project */
106102
;
107103
// The following user property on the nested execution prevents this extension to activate
108104
// in the nested execution. This is needed, as the extension is not reentrant.

0 commit comments

Comments
 (0)