|
| 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/ |
0 commit comments