Skip to content

Commit

Permalink
Changed approach on how to construct the MavenExecutionRequest for th…
Browse files Browse the repository at this point in the history
…e 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.
  • Loading branch information
glimmerveen committed Nov 26, 2020
1 parent c2db550 commit b30df68
Showing 1 changed file with 8 additions and 12 deletions.
Expand Up @@ -91,18 +91,14 @@ public void afterProjectsRead(final MavenSession session) throws MavenExecutionE

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

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

0 comments on commit b30df68

Please sign in to comment.