diff --git a/m2e-maven-runtime/org.eclipse.m2e.maven.runtime/pom.xml b/m2e-maven-runtime/org.eclipse.m2e.maven.runtime/pom.xml index f1da94c522..f2e99daf4e 100644 --- a/m2e-maven-runtime/org.eclipse.m2e.maven.runtime/pom.xml +++ b/m2e-maven-runtime/org.eclipse.m2e.maven.runtime/pom.xml @@ -19,7 +19,7 @@ org.eclipse.m2e.maven.runtime - 3.8.701-SNAPSHOT + 3.8.702-SNAPSHOT jar M2E Embedded Maven Runtime (includes Incubating components) @@ -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 --> 1.6.3 - - 0.0.7 0.17.8 @@ -76,10 +74,17 @@ org.eclipse.sisu org.eclipse.sisu.plexus + org.sonatype.plexus plexus-build-api - ${plexus-build-api.version} + 0.0.7 + + + + org.codehaus.plexus + plexus-build-api + 1.0.0 io.takari.aether diff --git a/org.eclipse.m2e.core/META-INF/MANIFEST.MF b/org.eclipse.m2e.core/META-INF/MANIFEST.MF index 8b0f5af7cd..b22d5b8078 100644 --- a/org.eclipse.m2e.core/META-INF/MANIFEST.MF +++ b/org.eclipse.m2e.core/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name Bundle-SymbolicName: org.eclipse.m2e.core;singleton:=true -Bundle-Version: 2.0.7.qualifier +Bundle-Version: 2.0.8.qualifier Bundle-Activator: org.eclipse.m2e.core.internal.MavenPluginActivator Bundle-Vendor: %Bundle-Vendor Bundle-Localization: plugin diff --git a/org.eclipse.m2e.core/pom.xml b/org.eclipse.m2e.core/pom.xml index eaf86f28ab..ec9e5d9a26 100644 --- a/org.eclipse.m2e.core/pom.xml +++ b/org.eclipse.m2e.core/pom.xml @@ -19,7 +19,7 @@ org.eclipse.m2e.core - 2.0.7-SNAPSHOT + 2.0.8-SNAPSHOT eclipse-plugin Maven Integration for Eclipse Core Plug-in diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/EclipseClassRealmManagerDelegate.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/EclipseClassRealmManagerDelegate.java index 04ef2d8226..2ac8acfd7f 100644 --- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/EclipseClassRealmManagerDelegate.java +++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/EclipseClassRealmManagerDelegate.java @@ -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(); @@ -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 @@ -73,24 +73,37 @@ 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$ } } private boolean supportsBuildApi(List constituents) { + boolean hasBuildApi = false; for(Iterator it = constituents.iterator(); it.hasNext();) { ClassRealmConstituent constituent = it.next(); 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(); + hasBuildApi = 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(); + hasBuildApi = true; } - return compatible; } } - return false; + return hasBuildApi; } } diff --git a/org.eclipse.m2e.feature/feature.xml b/org.eclipse.m2e.feature/feature.xml index a2441a76a4..61484ccf8e 100644 --- a/org.eclipse.m2e.feature/feature.xml +++ b/org.eclipse.m2e.feature/feature.xml @@ -2,7 +2,7 @@ + 4.0.0 + + org.eclipse.m2e + m2e-core + 2.1.0-SNAPSHOT + + + org.eclipse.m2e.tests.plugin + org.eclipse.m2e.tests.plugin + 1.0.0 + + maven-plugin + M2Eclipse Test Maven Plugin + This is a mavenplugin that implements some mojos used in m2e tests to test certain mojo behaviour. + + 11 + 11 + + + + org.apache.maven + maven-core + 3.8.5 + + + org.apache.maven + maven-plugin-api + 3.8.5 + + + org.apache.maven.plugin-tools + maven-plugin-annotations + 3.8.1 + + + org.codehaus.plexus + plexus-build-api + 1.0.0 + + + org.sonatype.plexus + plexus-build-api + 0.0.7 + + + + + + org.apache.maven.plugins + maven-install-plugin + 3.1.0 + + + force-install + verify + + install + + + + + + org.apache.maven.plugins + maven-plugin-plugin + 3.8.1 + + + + \ No newline at end of file diff --git a/org.eclipse.m2e.tests.plugin/src/main/java/org/eclipse/m2e/tests/plugin/PlexusBuildApiV0Mojo.java b/org.eclipse.m2e.tests.plugin/src/main/java/org/eclipse/m2e/tests/plugin/PlexusBuildApiV0Mojo.java new file mode 100644 index 0000000000..ea4fcf835e --- /dev/null +++ b/org.eclipse.m2e.tests.plugin/src/main/java/org/eclipse/m2e/tests/plugin/PlexusBuildApiV0Mojo.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (c) 2023 Christoph Läubrich + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Christoph Läubrich - initial API and implementation + *******************************************************************************/ +package org.eclipse.m2e.tests.plugin; + +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugins.annotations.Component; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.project.MavenProject; +import org.sonatype.plexus.build.incremental.BuildContext; + +/** + * This mojo test that we can use the V1 API + */ +@Mojo(name = "m2e-test-buildapi-v0") +public class PlexusBuildApiV0Mojo extends AbstractMojo { + + @Component + BuildContext buildContext; + + @Parameter(property = "project", readonly = true) + MavenProject mavenProject; + + public void execute() throws MojoExecutionException, MojoFailureException { + String msg = "The buildContext is: " + buildContext.getClass().getName(); + getLog().info(msg); + buildContext.addMessage(mavenProject.getBasedir(), 1, 0, msg, BuildContext.SEVERITY_WARNING, null); + // TODO we should have mojo parameter to do some usefull things for test... + } + +} diff --git a/org.eclipse.m2e.tests.plugin/src/main/java/org/eclipse/m2e/tests/plugin/PlexusBuildApiV1Mojo.java b/org.eclipse.m2e.tests.plugin/src/main/java/org/eclipse/m2e/tests/plugin/PlexusBuildApiV1Mojo.java new file mode 100644 index 0000000000..51e36ccb2f --- /dev/null +++ b/org.eclipse.m2e.tests.plugin/src/main/java/org/eclipse/m2e/tests/plugin/PlexusBuildApiV1Mojo.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (c) 2023 Christoph Läubrich + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Christoph Läubrich - initial API and implementation + *******************************************************************************/ +package org.eclipse.m2e.tests.plugin; + +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugins.annotations.Component; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.project.MavenProject; +import org.codehaus.plexus.build.BuildContext; + +/** + * This mojo test that we can use the V1 API + */ +@Mojo(name = "m2e-test-buildapi-v1") +public class PlexusBuildApiV1Mojo extends AbstractMojo { + + @Component + BuildContext buildContext; + + @Parameter(property = "project", readonly = true) + MavenProject mavenProject; + + public void execute() throws MojoExecutionException, MojoFailureException { + String msg = "The buildContext is: " + buildContext.getClass().getName(); + getLog().info(msg); + buildContext.addMessage(mavenProject.getBasedir(), 1, 0, msg, BuildContext.SEVERITY_WARNING, null); + // TODO we should have mojo parameter to do some usefull things for test... + } + +} diff --git a/pom.xml b/pom.xml index ac43f9cf12..72440967a4 100644 --- a/pom.xml +++ b/pom.xml @@ -39,6 +39,7 @@ target-platform + org.eclipse.m2e.tests.plugin m2e-maven-runtime org.eclipse.m2e.model.edit @@ -106,7 +107,7 @@ org.eclipse.m2e org.eclipse.m2e.maven.runtime - 3.8.701-SNAPSHOT + 3.8.702-SNAPSHOT