Skip to content

Commit

Permalink
Do not clone the session on maven >= 3.9.x, fixes takari#24
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed May 10, 2023
1 parent 0004c3a commit 9ced72c
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* the License.
*/

import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.apache.maven.execution.BuildFailure;
import org.apache.maven.execution.BuildSuccess;
import org.apache.maven.execution.BuildSummary;
Expand Down Expand Up @@ -200,7 +201,7 @@ private void submitAll(Set<MavenProject> readyProjects) {
logger.debug("STARTED build of project {}:{}", project.getGroupId(), project.getArtifactId());

try {
MavenSession copiedSession = rootSession.clone();
MavenSession copiedSession = needsSessionClone() ? rootSession.clone() : rootSession;
lifecycleModuleBuilder.buildProject(copiedSession, rootSession, reactorContext, project,
taskSegment);
} catch (RuntimeException ex) {
Expand All @@ -210,4 +211,15 @@ private void submitAll(Set<MavenProject> readyProjects) {
}
}

private static boolean needsSessionClone() {
String version = System.getProperty("maven.version");
if (version != null) {
DefaultArtifactVersion v = new DefaultArtifactVersion(version);
if (v.getMajorVersion() > 3 || (v.getMajorVersion() == 3 && v.getMinorVersion() >= 9)) {
return false;
}
}
return true;
}

}

0 comments on commit 9ced72c

Please sign in to comment.