Skip to content

Commit

Permalink
Add support for the new plexus-build-api artifact
Browse files Browse the repository at this point in the history
  • Loading branch information
laeubi committed Mar 9, 2023
1 parent 3d0b6ac commit d09d976
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
13 changes: 9 additions & 4 deletions m2e-maven-runtime/org.eclipse.m2e.maven.runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</parent>

<artifactId>org.eclipse.m2e.maven.runtime</artifactId>
<version>3.8.701-SNAPSHOT</version>
<version>3.8.702-SNAPSHOT</version>
<packaging>jar</packaging>

<name>M2E Embedded Maven Runtime (includes Incubating components)</name>
Expand All @@ -32,8 +32,6 @@
bundle. So make sure the following variable has the value of the maven-resolver-* jars
https://bugs.eclipse.org/bugs/show_bug.cgi?id=529540 -->
<maven-resolver.version>1.6.3</maven-resolver.version>
<!-- below are m2e-specific addons -->
<plexus-build-api.version>0.0.7</plexus-build-api.version>
<okhttp-connector.version>0.17.8</okhttp-connector.version>
</properties>

Expand Down Expand Up @@ -76,10 +74,17 @@
<groupId>org.eclipse.sisu</groupId>
<artifactId>org.eclipse.sisu.plexus</artifactId>
</dependency>
<!-- the legacy plexus build API (old group/packages) -->
<dependency>
<groupId>org.sonatype.plexus</groupId>
<artifactId>plexus-build-api</artifactId>
<version>${plexus-build-api.version}</version>
<version>0.0.7</version>
</dependency>
<!-- the release v1 plexus build API (new group/packages) only -->
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-build-api</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>io.takari.aether</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class EclipseClassRealmManagerDelegate implements ClassRealmManagerDelega

private final PlexusContainer plexus;

private static final ArtifactVersion currentBuildApiVersion;
private static final ArtifactVersion legacytBuildApiVersion;

static {
Properties props = new Properties();
Expand All @@ -55,7 +55,7 @@ public class EclipseClassRealmManagerDelegate implements ClassRealmManagerDelega
} catch(IOException e) {
// TODO log
}
currentBuildApiVersion = new DefaultArtifactVersion(props.getProperty("api.version", "0.0.5")); //$NON-NLS-1$ //$NON-NLS-2$
legacytBuildApiVersion = new DefaultArtifactVersion(props.getProperty("api.version", "0.0.5")); //$NON-NLS-1$ //$NON-NLS-2$
}

@Inject
Expand All @@ -73,6 +73,7 @@ public void setupRealm(ClassRealm realm, ClassRealmRequest request) {
realm.importFrom(coreRealm, "org.codehaus.plexus.util.Scanner"); //$NON-NLS-1$

realm.importFrom(coreRealm, "org.sonatype.plexus.build.incremental"); //$NON-NLS-1$
realm.importFrom(coreRealm, "org.codehaus.plexus.build"); //$NON-NLS-1$
}
}

Expand All @@ -82,12 +83,23 @@ private boolean supportsBuildApi(List<ClassRealmConstituent> constituents) {
if("org.sonatype.plexus".equals(constituent.getGroupId()) //$NON-NLS-1$
&& "plexus-build-api".equals(constituent.getArtifactId())) { //$NON-NLS-1$
ArtifactVersion version = new DefaultArtifactVersion(constituent.getVersion());
boolean compatible = currentBuildApiVersion.compareTo(version) >= 0;
if(compatible) {
if(legacytBuildApiVersion.compareTo(version) >= 0) {
// removing the JAR from the plugin realm to prevent discovery of the DefaultBuildContext
it.remove();
return true;
}
}
if("org.codehaus.plexus.build".equals(constituent.getGroupId()) //$NON-NLS-1$
&& "plexus-build-api".equals(constituent.getArtifactId())) { //$NON-NLS-1$
ArtifactVersion version = new DefaultArtifactVersion(constituent.getVersion());
// currently we support only version 1, we want to design the API that it is always backward compatible for the client
// so even if we implements Version X and the client Version < X it can be used!
// for incompatible changes we need to use a different package then
if(version.getMajorVersion() >= 1 && version.getMajorVersion() <= 2) {
// removing the JAR from the plugin realm to prevent discovery of the default components
it.remove();
return true;
}
return compatible;
}
}
return false;
Expand Down

0 comments on commit d09d976

Please sign in to comment.