Skip to content

Commit 6b69674

Browse files
committed
Compatibility Adjustments
1 parent 8d8a7d0 commit 6b69674

File tree

36 files changed

+489
-133
lines changed

36 files changed

+489
-133
lines changed

MAVEN4_UPGRADE_NOTES.md

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
# Maven 4 Upgrade Notes for m2e
2+
3+
This document describes the changes made to upgrade m2e's embedded Maven runtime from Maven 3.9.11 to Maven 4.0.0-rc-4.
4+
5+
## Compatibility Issues
6+
7+
- MavenCLI --> Constants
8+
- LifecycleExecutionPlanCalculator -> changed signatures
9+
- org.apache.maven.shared.utils.StringUtils -> replace
10+
- ReadonlyMavenExecutionRequest implements MavenExecutionReques --> needs to be part of runtime!
11+
- ExtensionResolutionException --> convert to plexus one helper method in runtime
12+
- ProjectSorter --> catch generic exception
13+
14+
15+
16+
## Changes Made
17+
18+
### 1. Maven Runtime Bundle (org.eclipse.m2e.maven.runtime)
19+
20+
#### Version Update
21+
- Updated `maven-core.version` from `3.9.11` to `4.0.0-rc-4`
22+
- Updated bundle version from `3.9.1100-SNAPSHOT` to `4.0.004-SNAPSHOT`
23+
24+
#### Dependency Changes
25+
26+
**Removed Dependencies:**
27+
- `org.fusesource.jansi:jansi` - Replaced with `org.jline:jansi-core` (Maven 4 uses JLine's jansi)
28+
- `org.apache.maven:maven-slf4j-provider` - Replaced with `org.apache.maven:maven-logging`
29+
- `org.apache.maven.resolver:maven-resolver-transport-http` - Replaced with `maven-resolver-transport-jdk`
30+
31+
**Added/Updated Dependencies:**
32+
- `org.apache.maven:maven-logging:4.0.0-rc-4` - New Maven 4 logging module
33+
- `org.apache.maven:maven-compat:4.0.0-rc-4` - Backward compatibility layer for Maven 3 APIs
34+
- `org.jline:jansi-core:3.30.4` - JLine's jansi implementation
35+
- `org.apache.maven.resolver:maven-resolver-transport-jdk:2.0.9` - Java 11+ HTTP client-based transport
36+
- Updated all resolver dependencies to version `2.0.9`
37+
- Updated `com.google.guava:failureaccess` to version `1.0.1`
38+
39+
#### Removed Source Files
40+
- `org.eclipse.m2e.slf4j2.provider.MavenSLF4JProvider` - No longer needed as Maven 4 provides its own SLF4J provider
41+
- `META-INF/services/org.slf4j.spi.SLF4JServiceProvider` - Service registration for the removed provider
42+
43+
#### BND Configuration Updates
44+
- Updated SLF4J binding jar name from `maven-slf4j-provider-${maven-core.version}.jar` to `maven-logging-${maven-core.version}.jar`
45+
46+
### 2. Runtime Target Platform (target-platform/m2e-runtimes.target)
47+
48+
- Updated to reference Maven runtime `3.9.1100.20241011-1318` from m2e release 2.2.1 for backward compatibility
49+
- This allows running tests with both Maven 3.9.11 and Maven 4.0.0-rc-4
50+
51+
### 3. Root POM (pom.xml)
52+
53+
- Updated maven.runtime dependency version from `3.9.1100-SNAPSHOT` to `4.0.004-SNAPSHOT`
54+
55+
## Maven 4 Architecture Changes
56+
57+
### New Modules in Maven 4
58+
Maven 4 introduces several new API modules:
59+
- `maven-api-core` - Core Maven 4 API
60+
- `maven-api-model` - Model API
61+
- `maven-api-plugin` - Plugin API
62+
- `maven-api-settings` - Settings API
63+
- `maven-api-toolchain` - Toolchain API
64+
- `maven-api-xml` - XML processing API
65+
- `maven-di` - Dependency injection module
66+
- `maven-impl` - Implementation module
67+
- `maven-jline` - JLine integration
68+
- `maven-logging` - Logging module (replaces maven-slf4j-provider)
69+
70+
### Backward Compatibility
71+
72+
Maven 4 provides the `maven-compat` module that maintains compatibility with Maven 3 APIs. This includes:
73+
- Support for Plexus Container API
74+
- Legacy Maven APIs from Maven 3.x
75+
- Compatibility layer for plugins built against Maven 3
76+
77+
## Code Compatibility Assessment
78+
79+
### PlexusContainer Usage
80+
81+
The following areas of m2e use PlexusContainer and related Plexus APIs:
82+
83+
1. **org.eclipse.m2e.core.internal.embedder.PlexusContainerManager**
84+
- Creates and manages PlexusContainer instances
85+
- Uses DefaultPlexusContainer, ContainerConfiguration
86+
- **Status**: Should work with maven-compat module
87+
88+
2. **org.eclipse.m2e.core.internal.embedder.IMavenPlexusContainer**
89+
- Interface for wrapping PlexusContainer
90+
- **Status**: Should work with maven-compat module
91+
92+
3. **Plexus Utility Classes**
93+
- `org.codehaus.plexus.util.xml.Xpp3Dom` - Used extensively for plugin configuration
94+
- `org.codehaus.plexus.util.dag.*` - DAG utilities for dependency ordering
95+
- `org.codehaus.plexus.util.Scanner` - Build context scanning
96+
- `org.codehaus.plexus.classworlds.ClassRealm` - ClassLoader management
97+
- **Status**: These are still available in Maven 4 (plexus-utils, plexus-classworlds)
98+
99+
4. **org.eclipse.m2e.tests.common.AbstractMavenProjectTestCase**
100+
- Test utilities that lookup PlexusContainer
101+
- **Status**: Should work with maven-compat module
102+
103+
5. **org.eclipse.m2e.core.ui.internal.archetype.ArchetypePlugin**
104+
- Uses DefaultPlexusContainer for archetype operations
105+
- **Status**: Should work with maven-compat module
106+
107+
## Testing Requirements
108+
109+
The following areas should be tested to ensure Maven 4 compatibility:
110+
111+
### Core Functionality
112+
1. [ ] Project import from existing Maven projects
113+
2. [ ] POM editing and validation
114+
3. [ ] Dependency resolution
115+
4. [ ] Plugin execution during builds
116+
5. [ ] Workspace resolution
117+
6. [ ] Maven lifecycle execution
118+
7. [ ] External Maven launches
119+
120+
### PlexusContainer Compatibility
121+
1. [ ] Container creation and disposal
122+
2. [ ] Component lookup
123+
3. [ ] Extension loading from .mvn/extensions.xml
124+
4. [ ] ClassRealm management
125+
5. [ ] Plugin realm creation
126+
127+
### Build and Test Infrastructure
128+
1. [ ] Maven runtime bundle builds successfully
129+
2. [ ] All m2e modules compile against Maven 4 APIs
130+
3. [ ] Unit tests pass
131+
4. [ ] Integration tests pass
132+
5. [ ] UI tests pass
133+
134+
### Maven 4 Specific Features
135+
1. [ ] New Maven 4 API usage (if any)
136+
2. [ ] Maven 4 resolver transport (JDK HTTP client)
137+
3. [ ] Maven 4 logging integration with Eclipse
138+
4. [ ] Maven 4 dependency injection (Guice/Sisu)
139+
140+
## Known Issues and Limitations
141+
142+
### Build Environment
143+
- The current build requires access to repo.eclipse.org which may not be available in all environments
144+
- Tycho 4.0.13 may have issues with JavaSE-21 execution environment
145+
146+
### Potential API Changes
147+
The following Maven APIs may have changed between Maven 3 and Maven 4:
148+
1. **Resolver APIs** - Updated from 1.x to 2.x
149+
- New transport mechanism (JDK HTTP client vs Apache HttpClient)
150+
- May affect custom repository configurations
151+
152+
2. **Logging** - New maven-logging module
153+
- Uses SLF4J 2.x
154+
- May affect log filtering and configuration
155+
156+
3. **Plugin API** - New maven-api-plugin module
157+
- May affect plugin descriptor reading
158+
- May affect mojo parameter injection
159+
160+
## Recommendations
161+
162+
### Short Term
163+
1. Complete full build and test cycle to identify any runtime issues
164+
2. Test with real-world projects to validate Maven 4 compatibility
165+
3. Document any API incompatibilities found during testing
166+
4. Consider keeping Maven 3.9.11 runtime as an alternative for users
167+
168+
### Long Term
169+
1. Consider migrating to Maven 4 APIs where beneficial
170+
2. Deprecate Maven 3-specific workarounds that are no longer needed
171+
3. Take advantage of Maven 4's improved dependency injection
172+
4. Explore Maven 4's new features (e.g., build cache, consumer POM)
173+
174+
## References
175+
176+
- Maven 4.0.0-rc-4 Release: https://repo.maven.apache.org/maven2/org/apache/maven/maven/4.0.0-rc-4/
177+
- Maven Resolver 2.0.9: https://maven.apache.org/resolver/
178+
- Maven 4 Migration Guide: https://maven.apache.org/docs/4.0.0/

org.eclipse.m2e.apt.core/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.27.0,4.0.0)",
1010
org.eclipse.jdt.apt.core;bundle-version="3.7.50",
1111
org.eclipse.m2e.core;bundle-version="[2.0.0,3.0.0)",
1212
org.eclipse.m2e.jdt;bundle-version="[2.0.0,3.0.0)",
13-
org.eclipse.m2e.maven.runtime;bundle-version="[3.8.6,4.0.0)"
13+
org.eclipse.m2e.maven.runtime;bundle-version="[3.8.6,5.0.0)"
1414
Eclipse-LazyStart: true
1515
Bundle-RequiredExecutionEnvironment: JavaSE-21
1616
Bundle-Vendor: %Bundle-Vendor

org.eclipse.m2e.binaryproject.ui/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Require-Bundle: org.eclipse.ui,
99
org.eclipse.m2e.core.ui;bundle-version="[2.0.0,3.0.0)",
1010
org.eclipse.m2e.binaryproject;bundle-version="[2.0.0,3.0.0)",
1111
org.eclipse.m2e.core;bundle-version="[2.0.0,3.0.0)",
12-
org.eclipse.m2e.maven.runtime;bundle-version="[3.8.6,4.0.0)"
12+
org.eclipse.m2e.maven.runtime;bundle-version="[3.8.6,5.0.0)"
1313
Bundle-RequiredExecutionEnvironment: JavaSE-21
1414
Bundle-ActivationPolicy: lazy
1515
Automatic-Module-Name: org.eclipse.m2e.binaryproject.ui

org.eclipse.m2e.binaryproject/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Bundle-Version: 2.2.100.qualifier
55
Bundle-Vendor: Eclipse.org - m2e
66
Bundle-Name: M2E Binary Project Core
77
Require-Bundle: org.eclipse.m2e.core;bundle-version="[2.0.0,3.0.0)",
8-
org.eclipse.m2e.maven.runtime;bundle-version="[3.8.6,4.0.0)",
8+
org.eclipse.m2e.maven.runtime;bundle-version="[3.8.6,5.0.0)",
99
org.eclipse.m2e.sourcelookup;bundle-version="[2.0.0,3.0.0)",
1010
org.eclipse.m2e.jdt;bundle-version="[2.0.0,3.0.0)",
1111
org.eclipse.jdt.core;bundle-version="3.7.0",

org.eclipse.m2e.core.tests/META-INF/MANIFEST.MF

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ Bundle-SymbolicName: org.eclipse.m2e.core.tests
66
Bundle-Version: 2.0.0.qualifier
77
Bundle-RequiredExecutionEnvironment: JavaSE-21
88
Bundle-Vendor: Eclipse.org - m2e
9-
Require-Bundle: org.eclipse.m2e.tests.common,
9+
Require-Bundle: org.eclipse.m2e.maven.runtime;bundle-version="[4.0.0,5.0.0)",
10+
org.eclipse.m2e.tests.common,
1011
org.eclipse.core.runtime,
1112
org.eclipse.m2e.launching,
1213
org.eclipse.jdt.launching,

org.eclipse.m2e.core.ui/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Require-Bundle: org.eclipse.m2e.core;bundle-version="[2.0.0,3.0.0)",
3232
org.eclipse.core.resources;bundle-version="3.5.2",
3333
org.eclipse.core.runtime;bundle-version="3.5.0",
3434
org.eclipse.m2e.model.edit;bundle-version="[2.0.0,3.0.0)";visibility:=reexport,
35-
org.eclipse.m2e.maven.runtime;bundle-version="[3.8.6,4.0.0)",
35+
org.eclipse.m2e.maven.runtime;bundle-version="[3.8.6,5.0.0)",
3636
org.eclipse.ui.console;bundle-version="3.4.0",
3737
org.eclipse.ui.ide;bundle-version="3.18.0",
3838
org.eclipse.core.filesystem;bundle-version="1.2.1",

org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/MavenSettingsPreferencePage.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
import org.eclipse.ui.ide.IDE;
6060

6161
import org.apache.maven.building.Problem;
62-
import org.apache.maven.cli.MavenCli;
6362
import org.apache.maven.cli.configuration.SettingsXmlConfigurationProcessor;
6463
import org.apache.maven.repository.RepositorySystem;
6564
import org.apache.maven.settings.Settings;
@@ -69,6 +68,7 @@
6968
import org.eclipse.m2e.core.embedder.IMaven;
7069
import org.eclipse.m2e.core.embedder.IMavenConfiguration;
7170
import org.eclipse.m2e.core.internal.IMavenToolbox;
71+
import org.eclipse.m2e.core.internal.embedder.MavenCLICompat;
7272
import org.eclipse.m2e.core.project.IMavenProjectFacade;
7373
import org.eclipse.m2e.core.project.MavenUpdateRequest;
7474
import org.eclipse.m2e.core.ui.internal.Messages;
@@ -210,9 +210,9 @@ protected Control createContents(Composite parent) {
210210

211211
userToolchainsLink = createLink(composite, Messages.MavenSettingsPreferencePage_userToolchainslink2,
212212
Messages.MavenSettingsPreferencePage_userToolchainslink_tooltip, this::getUserToolchains,
213-
MavenCli.DEFAULT_USER_TOOLCHAINS_FILE);
213+
MavenCLICompat.DEFAULT_USER_TOOLCHAINS_FILE);
214214
userToolchainsText = createFileSelectionWidgets(composite, mavenConfiguration.getUserToolchainsFile(),
215-
MavenCli.DEFAULT_USER_TOOLCHAINS_FILE);
215+
MavenCLICompat.DEFAULT_USER_TOOLCHAINS_FILE);
216216

217217
Button updateSettings = new Button(composite, SWT.NONE);
218218
updateSettings.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
@@ -310,7 +310,7 @@ protected void checkSettings() {
310310
Messages.MavenSettingsPreferencePage_userSettingslink2, Messages.MavenSettingsPreferencePage_userSettingslink1);
311311

312312
String userToolchains = getUserToolchains();
313-
updateLink(userToolchainsLink, userToolchains, MavenCli.DEFAULT_USER_TOOLCHAINS_FILE,
313+
updateLink(userToolchainsLink, userToolchains, MavenCLICompat.DEFAULT_USER_TOOLCHAINS_FILE,
314314
Messages.MavenSettingsPreferencePage_userToolchainslink2,
315315
Messages.MavenSettingsPreferencePage_userToolchainslink1);
316316

org.eclipse.m2e.core/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Bundle-Version: 2.7.600.qualifier
66
Bundle-Activator: org.eclipse.m2e.core.internal.MavenPluginActivator
77
Bundle-Vendor: %Bundle-Vendor
88
Bundle-Localization: plugin
9-
Require-Bundle: org.eclipse.m2e.maven.runtime;bundle-version="[3.8.6,4.0.0)",
9+
Require-Bundle: org.eclipse.m2e.maven.runtime;bundle-version="[3.8.6,5.0.0)",
1010
org.eclipse.m2e.workspace.cli;bundle-version="0.1.0",
1111
org.eclipse.core.runtime;bundle-version="[3.27.0,4.0.0)",
1212
org.eclipse.core.resources;bundle-version="3.9.0",

org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/MavenPluginActivator.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@
3232

3333
import org.codehaus.plexus.PlexusContainer;
3434

35-
import org.apache.maven.project.DefaultProjectBuilder;
36-
3735
import org.eclipse.m2e.core.embedder.IMaven;
3836
import org.eclipse.m2e.core.embedder.IMavenConfiguration;
3937
import org.eclipse.m2e.core.embedder.MavenModelManager;
@@ -101,7 +99,8 @@ public void start(final BundleContext context) throws Exception {
10199
}
102100

103101
// Workaround MNG-6530
104-
System.setProperty(DefaultProjectBuilder.DISABLE_GLOBAL_MODEL_CACHE_SYSTEM_PROPERTY, Boolean.toString(true));
102+
//TODO is this still working for maven4?
103+
System.setProperty("maven.defaultProjectBuilder.disableGlobalModelCache", Boolean.toString(true));
105104
URLConnectionCaches.disable();
106105
// For static access, this also enables any of the services and keep them running forever...
107106
this.bundleContext = context;
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.eclipse.m2e.core.internal.embedder;
21+
22+
import java.io.File;
23+
24+
25+
/**
26+
* Some constants copied here for backward compatibility
27+
*/
28+
public class MavenCLICompat {
29+
public static final String LOCAL_REPO_PROPERTY = "maven.repo.local";
30+
31+
public static final String MULTIMODULE_PROJECT_DIRECTORY = "maven.multiModuleProjectDirectory";
32+
33+
public static final String USER_HOME = System.getProperty("user.home");
34+
35+
public static final File USER_MAVEN_CONFIGURATION_HOME = new File(USER_HOME, ".m2");
36+
37+
public static final File DEFAULT_USER_TOOLCHAINS_FILE = new File(USER_MAVEN_CONFIGURATION_HOME, "toolchains.xml");
38+
39+
public static final File DEFAULT_GLOBAL_TOOLCHAINS_FILE = new File(System.getProperty("maven.conf"),
40+
"toolchains.xml");
41+
}

0 commit comments

Comments
 (0)