Skip to content
Draft
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
178 changes: 178 additions & 0 deletions MAVEN4_UPGRADE_NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
# Maven 4 Upgrade Notes for m2e

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.

## Compatibility Issues

- MavenCLI --> Constants
- LifecycleExecutionPlanCalculator -> changed signatures
- org.apache.maven.shared.utils.StringUtils -> replace
- ReadonlyMavenExecutionRequest implements MavenExecutionReques --> needs to be part of runtime!
- ExtensionResolutionException --> convert to plexus one helper method in runtime
- ProjectSorter --> catch generic exception



## Changes Made

### 1. Maven Runtime Bundle (org.eclipse.m2e.maven.runtime)

#### Version Update
- Updated `maven-core.version` from `3.9.11` to `4.0.0-rc-4`
- Updated bundle version from `3.9.1100-SNAPSHOT` to `4.0.004-SNAPSHOT`

#### Dependency Changes

**Removed Dependencies:**
- `org.fusesource.jansi:jansi` - Replaced with `org.jline:jansi-core` (Maven 4 uses JLine's jansi)
- `org.apache.maven:maven-slf4j-provider` - Replaced with `org.apache.maven:maven-logging`
- `org.apache.maven.resolver:maven-resolver-transport-http` - Replaced with `maven-resolver-transport-jdk`

**Added/Updated Dependencies:**
- `org.apache.maven:maven-logging:4.0.0-rc-4` - New Maven 4 logging module
- `org.apache.maven:maven-compat:4.0.0-rc-4` - Backward compatibility layer for Maven 3 APIs
- `org.jline:jansi-core:3.30.4` - JLine's jansi implementation
- `org.apache.maven.resolver:maven-resolver-transport-jdk:2.0.9` - Java 11+ HTTP client-based transport
- Updated all resolver dependencies to version `2.0.9`
- Updated `com.google.guava:failureaccess` to version `1.0.1`

#### Removed Source Files
- `org.eclipse.m2e.slf4j2.provider.MavenSLF4JProvider` - No longer needed as Maven 4 provides its own SLF4J provider
- `META-INF/services/org.slf4j.spi.SLF4JServiceProvider` - Service registration for the removed provider

#### BND Configuration Updates
- Updated SLF4J binding jar name from `maven-slf4j-provider-${maven-core.version}.jar` to `maven-logging-${maven-core.version}.jar`

### 2. Runtime Target Platform (target-platform/m2e-runtimes.target)

- Updated to reference Maven runtime `3.9.1100.20241011-1318` from m2e release 2.2.1 for backward compatibility
- This allows running tests with both Maven 3.9.11 and Maven 4.0.0-rc-4

### 3. Root POM (pom.xml)

- Updated maven.runtime dependency version from `3.9.1100-SNAPSHOT` to `4.0.004-SNAPSHOT`

## Maven 4 Architecture Changes

### New Modules in Maven 4
Maven 4 introduces several new API modules:
- `maven-api-core` - Core Maven 4 API
- `maven-api-model` - Model API
- `maven-api-plugin` - Plugin API
- `maven-api-settings` - Settings API
- `maven-api-toolchain` - Toolchain API
- `maven-api-xml` - XML processing API
- `maven-di` - Dependency injection module
- `maven-impl` - Implementation module
- `maven-jline` - JLine integration
- `maven-logging` - Logging module (replaces maven-slf4j-provider)

### Backward Compatibility

Maven 4 provides the `maven-compat` module that maintains compatibility with Maven 3 APIs. This includes:
- Support for Plexus Container API
- Legacy Maven APIs from Maven 3.x
- Compatibility layer for plugins built against Maven 3

## Code Compatibility Assessment

### PlexusContainer Usage

The following areas of m2e use PlexusContainer and related Plexus APIs:

1. **org.eclipse.m2e.core.internal.embedder.PlexusContainerManager**
- Creates and manages PlexusContainer instances
- Uses DefaultPlexusContainer, ContainerConfiguration
- **Status**: Should work with maven-compat module

2. **org.eclipse.m2e.core.internal.embedder.IMavenPlexusContainer**
- Interface for wrapping PlexusContainer
- **Status**: Should work with maven-compat module

3. **Plexus Utility Classes**
- `org.codehaus.plexus.util.xml.Xpp3Dom` - Used extensively for plugin configuration
- `org.codehaus.plexus.util.dag.*` - DAG utilities for dependency ordering
- `org.codehaus.plexus.util.Scanner` - Build context scanning
- `org.codehaus.plexus.classworlds.ClassRealm` - ClassLoader management
- **Status**: These are still available in Maven 4 (plexus-utils, plexus-classworlds)

4. **org.eclipse.m2e.tests.common.AbstractMavenProjectTestCase**
- Test utilities that lookup PlexusContainer
- **Status**: Should work with maven-compat module

5. **org.eclipse.m2e.core.ui.internal.archetype.ArchetypePlugin**
- Uses DefaultPlexusContainer for archetype operations
- **Status**: Should work with maven-compat module

## Testing Requirements

The following areas should be tested to ensure Maven 4 compatibility:

### Core Functionality
1. [ ] Project import from existing Maven projects
2. [ ] POM editing and validation
3. [ ] Dependency resolution
4. [ ] Plugin execution during builds
5. [ ] Workspace resolution
6. [ ] Maven lifecycle execution
7. [ ] External Maven launches

### PlexusContainer Compatibility
1. [ ] Container creation and disposal
2. [ ] Component lookup
3. [ ] Extension loading from .mvn/extensions.xml
4. [ ] ClassRealm management
5. [ ] Plugin realm creation

### Build and Test Infrastructure
1. [ ] Maven runtime bundle builds successfully
2. [ ] All m2e modules compile against Maven 4 APIs
3. [ ] Unit tests pass
4. [ ] Integration tests pass
5. [ ] UI tests pass

### Maven 4 Specific Features
1. [ ] New Maven 4 API usage (if any)
2. [ ] Maven 4 resolver transport (JDK HTTP client)
3. [ ] Maven 4 logging integration with Eclipse
4. [ ] Maven 4 dependency injection (Guice/Sisu)

## Known Issues and Limitations

### Build Environment
- The current build requires access to repo.eclipse.org which may not be available in all environments
- Tycho 4.0.13 may have issues with JavaSE-21 execution environment

### Potential API Changes
The following Maven APIs may have changed between Maven 3 and Maven 4:
1. **Resolver APIs** - Updated from 1.x to 2.x
- New transport mechanism (JDK HTTP client vs Apache HttpClient)
- May affect custom repository configurations

2. **Logging** - New maven-logging module
- Uses SLF4J 2.x
- May affect log filtering and configuration

3. **Plugin API** - New maven-api-plugin module
- May affect plugin descriptor reading
- May affect mojo parameter injection

## Recommendations

### Short Term
1. Complete full build and test cycle to identify any runtime issues
2. Test with real-world projects to validate Maven 4 compatibility
3. Document any API incompatibilities found during testing
4. Consider keeping Maven 3.9.11 runtime as an alternative for users

### Long Term
1. Consider migrating to Maven 4 APIs where beneficial
2. Deprecate Maven 3-specific workarounds that are no longer needed
3. Take advantage of Maven 4's improved dependency injection
4. Explore Maven 4's new features (e.g., build cache, consumer POM)

## References

- Maven 4.0.0-rc-4 Release: https://repo.maven.apache.org/maven2/org/apache/maven/maven/4.0.0-rc-4/
- Maven Resolver 2.0.9: https://maven.apache.org/resolver/
- Maven 4 Migration Guide: https://maven.apache.org/docs/4.0.0/
9 changes: 9 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Eclipse m2e - Release notes

## 3.0.0 (Planned)

* 📅 Release Date: TBD

### Embed and use Maven 4.0.0

Updated the embedded Maven from version 3.9.11 to 4.0.0, the first Maven 4 release.
Maven 4 includes the maven-compat module for backward compatibility with Maven 3 builds.

## 2.9.2

### Multi-Release-Jar support
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.m2e.apt.core/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.27.0,4.0.0)",
org.eclipse.jdt.apt.core;bundle-version="3.7.50",
org.eclipse.m2e.core;bundle-version="[2.0.0,3.0.0)",
org.eclipse.m2e.jdt;bundle-version="[2.0.0,3.0.0)",
org.eclipse.m2e.maven.runtime;bundle-version="[3.8.6,4.0.0)"
org.eclipse.m2e.maven.runtime;bundle-version="[3.8.6,5.0.0)"
Eclipse-LazyStart: true
Bundle-RequiredExecutionEnvironment: JavaSE-21
Bundle-Vendor: %Bundle-Vendor
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.m2e.binaryproject.ui/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.m2e.core.ui;bundle-version="[2.0.0,3.0.0)",
org.eclipse.m2e.binaryproject;bundle-version="[2.0.0,3.0.0)",
org.eclipse.m2e.core;bundle-version="[2.0.0,3.0.0)",
org.eclipse.m2e.maven.runtime;bundle-version="[3.8.6,4.0.0)"
org.eclipse.m2e.maven.runtime;bundle-version="[3.8.6,5.0.0)"
Bundle-RequiredExecutionEnvironment: JavaSE-21
Bundle-ActivationPolicy: lazy
Automatic-Module-Name: org.eclipse.m2e.binaryproject.ui
2 changes: 1 addition & 1 deletion org.eclipse.m2e.binaryproject/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Bundle-Version: 2.2.100.qualifier
Bundle-Vendor: Eclipse.org - m2e
Bundle-Name: M2E Binary Project Core
Require-Bundle: org.eclipse.m2e.core;bundle-version="[2.0.0,3.0.0)",
org.eclipse.m2e.maven.runtime;bundle-version="[3.8.6,4.0.0)",
org.eclipse.m2e.maven.runtime;bundle-version="[3.8.6,5.0.0)",
org.eclipse.m2e.sourcelookup;bundle-version="[2.0.0,3.0.0)",
org.eclipse.m2e.jdt;bundle-version="[2.0.0,3.0.0)",
org.eclipse.jdt.core;bundle-version="3.7.0",
Expand Down
3 changes: 2 additions & 1 deletion org.eclipse.m2e.core.tests/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ Bundle-SymbolicName: org.eclipse.m2e.core.tests
Bundle-Version: 2.0.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-21
Bundle-Vendor: Eclipse.org - m2e
Require-Bundle: org.eclipse.m2e.tests.common,
Require-Bundle: org.eclipse.m2e.maven.runtime;bundle-version="[4.0.0,5.0.0)",
org.eclipse.m2e.tests.common,
org.eclipse.core.runtime,
org.eclipse.m2e.launching,
org.eclipse.jdt.launching,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Hello Maven 4 Test Project

## Overview
This is a demonstration project showcasing Maven 4 features for testing m2e compatibility.

## Project Structure
```
HelloMaven4/
├── pom.xml (parent)
├── hello-core/ (library subproject)
│ └── src/main/java/org/eclipse/m2e/tests/demo/core/
│ └── GreetingService.java
└── hello-app/ (application subproject)
└── src/main/java/org/eclipse/m2e/tests/demo/app/
└── HelloWorldApp.java
```

## Maven 4 Features Used

This project demonstrates the following Maven 4 features from [What's New in Maven 4](https://maven.apache.org/whatsnewinmaven4.html):

### 1. ✅ New Model Version 4.1.0
- **Feature**: Maven 4 introduces a new POM model version `4.1.0`
- **Usage**: All POMs use `<modelVersion>4.1.0</modelVersion>` and `xmlns="http://maven.apache.org/POM/4.1.0"` namespace
- **Location**: All `pom.xml` files
- **Status**: Demonstrated

### 2. ✅ Subprojects Instead of Modules
- **Feature**: Maven 4 uses `<subprojects>` instead of `<modules>` for better semantics
- **Usage**: Parent POM uses `<subprojects>` to declare child projects
- **Location**: `pom.xml` (parent)
- **Status**: Demonstrated

### 3. ✅ Inheritance of GroupId and Version
- **Feature**: Child projects can omit `<groupId>` and `<version>` when inheriting from parent
- **Usage**: Child POMs (`hello-core` and `hello-app`) omit these elements
- **Location**: `hello-core/pom.xml` and `hello-app/pom.xml`
- **Status**: Demonstrated

### 4. ⏳ Build/Consumer POM Split
- **Feature**: Maven 4 separates build-time and consumption-time concerns
- **Usage**: Not explicitly demonstrated in this simple project
- **Status**: Not applicable for this simple test case

### 5. ⏳ Better Java Version Handling
- **Feature**: Improved handling of Java versions with `maven.compiler.release`
- **Usage**: Uses `maven.compiler.release` property set to 11
- **Location**: Parent POM properties
- **Status**: Partially demonstrated

## Testing with Maven 4

This project is designed to be built with **Maven 4.0.0-rc-2** or later (Preview release).

To verify Maven 4 compatibility:
```bash
# Requires Maven 4.0.0-rc-2 or later
mvn clean install
```

## Purpose

This test project serves two main goals:

1. **Demonstrate Incompatibility**: Show that current m2e does NOT support Maven 4 features
2. **Validation Target**: Provide a test case to verify Maven 4 support as it's implemented

## References

- [Apache Maven 4 Downloads](https://maven.apache.org/download.cgi)
- [What's New in Maven 4](https://maven.apache.org/whatsnewinmaven4.html)
- [Maven 4 Announcement](https://lists.apache.org/thread/jnb3snhdm4b564gz8hbctp9rfk8fc67n)
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Maven 4 Subproject - demonstrates dependency on sibling subproject

This module also inherits groupId and version from parent
-->
<project xmlns="http://maven.apache.org/POM/4.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.1.0 https://maven.apache.org/xsd/maven-4.1.0.xsd">

<modelVersion>4.1.0</modelVersion>

<parent>
<groupId>org.eclipse.m2e.tests.demo</groupId>
<artifactId>hello-maven4-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>

<artifactId>hello-app</artifactId>

<name>Hello Maven 4 App</name>
<description>Application module demonstrating Maven 4 features</description>

<dependencies>
<dependency>
<groupId>org.eclipse.m2e.tests.demo</groupId>
<artifactId>hello-core</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.eclipse.m2e.tests.demo.app;

import org.eclipse.m2e.tests.demo.core.GreetingService;

/**
* Simple HelloWorld application demonstrating Maven 4 multi-subproject structure.
*/
public class HelloWorldApp {

public static void main(String[] args) {
GreetingService service = new GreetingService();

String name = args.length > 0 ? args[0] : "Maven 4 World";
String greeting = service.greet(name);

System.out.println(greeting);
System.out.println("Built with Maven 4!");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Maven 4 Subproject - demonstrates inheritance of groupId and version

Note: In Maven 4, child projects can omit groupId and version
when they inherit from parent, making the POM cleaner
-->
<project xmlns="http://maven.apache.org/POM/4.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.1.0 https://maven.apache.org/xsd/maven-4.1.0.xsd">

<modelVersion>4.1.0</modelVersion>

<parent>
<groupId>org.eclipse.m2e.tests.demo</groupId>
<artifactId>hello-maven4-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>

<artifactId>hello-core</artifactId>

<name>Hello Maven 4 Core</name>
<description>Core library module demonstrating Maven 4 features</description>
</project>
Loading
Loading