Skip to content

Commit

Permalink
[Runtime] Embed Maven 3.9.1
Browse files Browse the repository at this point in the history
Co-authored-by: Hannes Wellmann <[email protected]>
Signed-off-by: Yan Zhang <[email protected]>
  • Loading branch information
Eskibear and HannesWell committed Mar 29, 2023
1 parent 43bba83 commit 72ee8cd
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 45 deletions.
16 changes: 6 additions & 10 deletions m2e-maven-runtime/org.eclipse.m2e.maven.runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@
</parent>

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

<name>M2E Embedded Maven Runtime (includes Incubating components)</name>

<properties>
<!-- maven core version -->
<maven-core.version>3.8.7</maven-core.version>
<maven-core.version>3.9.1</maven-core.version>
<!-- NOTE: When maven-core.version changes, this may impact the versions of the maven-resolver-*
jars that export the org.eclipse.aether.* packages in the org.eclipse.m2e.maven.runtime
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>
<maven-resolver.version>1.9.7</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>
Expand All @@ -52,10 +52,6 @@
<groupId>org.checkerframework</groupId>
<artifactId>checker-compat-qual</artifactId>
</exclusion>
<exclusion>
<groupId>aopalliance</groupId>
<artifactId>aopalliance</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
Expand Down Expand Up @@ -156,8 +152,8 @@
<configuration>
<bnd><![CDATA[
# When launching a Maven build using this embedded runtime, we want the embedded SLF4J logger binding to be used.
# However when the this Maven runtime is used within the Eclipse-IDE(-JVM) we don't want it to use the embedded SLF4J-binding
# but instead use the SLF4J-binding provided by the Eclipse runtime. This is achived by making the embedded SLF4J-binding invisible
# However when the this Maven runtime is used within the Eclipse-IDE(-JVM) we don't want it to use the embedded SLF4J-binding
# but instead use the SLF4J-binding provided by the Eclipse runtime. This is achived by making the embedded SLF4J-binding invisible
# for OSGi, by simply NOT placing the binding's jar on the Bundle-ClassPath.
slf4jBinding=maven-slf4j-provider-${maven-core.version}.jar
M2E-SLF4JBinding=jars/${slf4jBinding}
Expand Down Expand Up @@ -185,7 +181,7 @@
Require-Bundle: \
com.google.guava
]]></bnd>
<!-- All direct dependencies specified as Require-Bundle or Import-package are added to the classpath of a launched
<!-- All direct dependencies specified as Require-Bundle or Import-package are added to the classpath of a launched
Maven-Build-JVM. See MavenEmbeddedRuntime for details. -->
</configuration>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,13 @@
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<version>3.0.0</version>
<configuration>
<trimStackTrace>true</trimStackTrace>
<forkNode implementation="org.apache.maven.plugin.surefire.extensions.SurefireForkNodeFactory"/>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
</project>
1 change: 1 addition & 0 deletions org.eclipse.m2e.core/forceQualifierUpdate.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# To force a version qualifier update add the bug here
Update build-qualifier because the compiled byte-code has changed, probably due to newer JDK minor version used in the CI
Last update: Wed Mar 22 15:45:13 CST 2023
2 changes: 1 addition & 1 deletion org.eclipse.m2e.feature/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<feature
id="org.eclipse.m2e.feature"
label="%featureName"
version="2.2.2.qualifier"
version="2.3.0.qualifier"
provider-name="%providerName"
plugin="org.eclipse.m2e.core"
license-feature="org.eclipse.license"
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.m2e.launching/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: org.eclipse.m2e.launching;singleton:=true
Bundle-Version: 2.0.400.qualifier
Bundle-Version: 2.0.500.qualifier
Bundle-Localization: plugin
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.core.variables,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package org.eclipse.m2e.internal.launch;

import java.io.IOException;
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayDeque;
Expand Down Expand Up @@ -109,7 +110,7 @@ private static record ProjectReference(IProject project, MavenProjectBuildData b

private ProjectReference mavenProject;

private final Deque<IRegion> projectDefinitionLines = new ArrayDeque<>(2);
private final Deque<IRegion> projectDefinitionLines = new ArrayDeque<>(3);

private final List<int[]> removedLineLocations = new ArrayList<>();

Expand Down Expand Up @@ -190,42 +191,47 @@ private boolean isMavenProcess(ILaunchConfiguration launchConfiguration) {

private static final int VERSION = 1;

private static final Pattern FROM_FILE_LINE = Pattern.compile("^\\[INFO\\] +from ");

private static final Pattern PACKAGING_TYPE_LINE = Pattern.compile("^\\[INFO\\] -+\\[ [\\w\\-\\. ]+ \\]-+$");

private String getText(IRegion lineRegion) throws BadLocationException {
removedLineLocations.clear();
String line0 = getLineText(lineRegion, removedLineLocations);

if(projectDefinitionLines.size() < 2) {
if(projectDefinitionLines.size() < 3) {
projectDefinitionLines.add(lineRegion);
return line0;
}
// Read groupId, artifactId and version from a sequence like the following lines:
// [INFO] -----------< org.eclipse.m2e:org.eclipse.m2e.maven.runtime >------------
// [INFO] Building M2E Embedded Maven Runtime (includes Incubating components) 1.18.2-SNAPSHOT [4/5]
// [INFO] from pom.xml
// [INFO] ---------------------------[ eclipse-plugin ]---------------------------

if(PACKAGING_TYPE_LINE.matcher(line0).matches()) {
Iterator<IRegion> previousLines = projectDefinitionLines.descendingIterator();

IRegion line1Region = previousLines.next();
String line1 = getLineText(line1Region, null);

Matcher vMatcher = VERSION_LINE.matcher(line1);
if(vMatcher.matches()) {
String version = vMatcher.group(VERSION);

IRegion line2Region = previousLines.next();
List<int[]> removedLine2Locations = new ArrayList<>();
String line2 = getLineText(line2Region, removedLine2Locations);
Matcher gaMatcher = GROUP_ARTIFACT_LINE.matcher(line2);
if(gaMatcher.matches()) {
String groupId = gaMatcher.group(GROUP_ID);
String artifactId = gaMatcher.group(ARTIFACT_ID);

mavenProject = getProject(groupId, artifactId, version);
if(mavenProject != null) {
addProjectLink(line2Region, gaMatcher, GROUP_ID, ARTIFACT_ID, removedLine2Locations);
String line1 = getLineText(previousLines.next(), null);
if(FROM_FILE_LINE.matcher(line1).find()) {

String line2 = getLineText(previousLines.next(), null);
Matcher vMatcher = VERSION_LINE.matcher(line2);
if(vMatcher.matches()) {
String version = vMatcher.group(VERSION);

IRegion line3Region = previousLines.next();
List<int[]> removedLine3Locations = new ArrayList<>();
String line3 = getLineText(line3Region, removedLine3Locations);
Matcher gaMatcher = GROUP_ARTIFACT_LINE.matcher(line3);
if(gaMatcher.matches()) {
String groupId = gaMatcher.group(GROUP_ID);
String artifactId = gaMatcher.group(ARTIFACT_ID);

mavenProject = getProject(groupId, artifactId, version);
if(mavenProject != null) {
addProjectLink(line3Region, gaMatcher, GROUP_ID, ARTIFACT_ID, removedLine3Locations);
}
}
}
}
Expand Down Expand Up @@ -265,9 +271,9 @@ private ProjectReference getProject(String groupId, String artifactId, String ve
if(buildProject == null) {
return null;
}
Optional<IProject> project = Arrays
.stream(
ResourcesPlugin.getWorkspace().getRoot().findContainersForLocationURI(buildProject.projectBasedir.toUri()))
IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
URI basedirURI = buildProject.projectBasedir.toUri();
Optional<IProject> project = Arrays.stream(wsRoot.findContainersForLocationURI(basedirURI))
.filter(IProject.class::isInstance).map(IProject.class::cast).findFirst();
//if project is absent, the project build in Maven is not in the workspace
return project.isPresent() ? new ProjectReference(project.get(), buildProject) : null;
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.m2e.mavenarchiver/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: m2e connector for the mavenarchiver and pom properties
Bundle-SymbolicName: org.eclipse.m2e.mavenarchiver;singleton:=true
Bundle-Version: 2.0.300.qualifier
Bundle-Version: 2.0.301.qualifier
Bundle-Vendor: Eclipse.org - m2e
Bundle-RequiredExecutionEnvironment: JavaSE-17
Require-Bundle: org.eclipse.core.resources;bundle-version="[3.4.0,4.0.0)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
package org.eclipse.m2e.mavenarchiver.internal;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -466,7 +465,7 @@ private void reflectManifestGeneration(IMavenProjectFacade facade, MojoExecution
}

private void writeManifest(File manifestFile, Object manifest) throws UnsupportedEncodingException,
FileNotFoundException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
IllegalAccessException, IllegalArgumentException, InvocationTargetException, IOException {
Method write = getWriteMethod(manifest);
if (write != null) {
try (PrintWriter printWriter = new PrintWriter(
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.m2e.sdk.feature/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<feature
id="org.eclipse.m2e.sdk.feature"
label="%featureName"
version="2.2.2.qualifier"
version="2.3.0.qualifier"
provider-name="%providerName"
license-feature="org.eclipse.license"
license-feature-version="0.0.0">
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@
<module>org.eclipse.m2e.profiles.core.tests</module>
<module>org.eclipse.m2e.apt.tests</module>
<module>org.eclipse.m2e.pde.connector.tests</module>

<!-- products -->
<module>products</module>

<!-- UI/Integration tests -->
<module>org.eclipse.m2e.rcptt.tests</module>
</modules>
Expand All @@ -107,7 +107,7 @@
<dependency>
<groupId>org.eclipse.m2e</groupId>
<artifactId>org.eclipse.m2e.maven.runtime</artifactId>
<version>3.8.701-SNAPSHOT</version>
<version>3.9.100-SNAPSHOT</version>
</dependency>
</dependencies>

Expand Down

0 comments on commit 72ee8cd

Please sign in to comment.