Skip to content

Commit 0736845

Browse files
author
Vincent Potucek
committed
Pull #16981: Migrate to Java 21
1 parent 3706aa1 commit 0736845

File tree

203 files changed

+1029
-996
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

203 files changed

+1029
-996
lines changed

.github/workflows/maven.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
- name: Set up JDK
3434
uses: actions/setup-java@v4
3535
with:
36-
java-version: 17
36+
java-version: 21
3737
distribution: 'temurin'
3838

3939
- name: Checkout maven

apache-maven/pom.xml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,18 +116,21 @@ under the License.
116116
<artifactId>javax.inject</artifactId>
117117
</dependency>
118118
<dependency>
119-
<groupId>javax.annotation</groupId>
120-
<artifactId>javax.annotation-api</artifactId>
119+
<groupId>jakarta.annotation</groupId>
120+
<artifactId>jakarta.annotation-api</artifactId>
121+
<version>1.3.5</version>
121122
</dependency>
122123

123124
<!-- DI Runtime -->
124125
<dependency>
125126
<groupId>org.eclipse.sisu</groupId>
126127
<artifactId>org.eclipse.sisu.plexus</artifactId>
128+
<version>0.9.0.M3</version>
127129
</dependency>
128130
<dependency>
129131
<groupId>org.eclipse.sisu</groupId>
130132
<artifactId>org.eclipse.sisu.inject</artifactId>
133+
<version>0.9.0.M3</version>
131134
<classifier>no_asm</classifier>
132135
</dependency>
133136
<dependency>

apache-maven/src/main/appended-resources/META-INF/LICENSE.vm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ subject to the terms and conditions of the following licenses:
7272
#* *###
7373
#* *### copy license file to lib/$artifactId.license
7474
#* *##set ( $licFile = $directory + '/' + $project.artifact.artifactId + '.license' )
75-
#* *##set ( $downloaded = $locator.getResourceAsFile( "licenses/${spdx}.txt", "licenses/${licFile}" ) )
75+
#* *##set ( $downloaded = $locator.getResourceAsFile123( "licenses/${spdx}.txt", "licenses/${licFile}" ) )
7676

7777
#* *### add dependency info to output
7878

api/maven-api-core/src/main/java/org/apache/maven/api/services/MessageBuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,15 +245,15 @@ default MessageBuilder newline() {
245245

246246
/**
247247
* Append formatted content to the buffer.
248-
* @see String#format(String, Object...)
248+
* @see String#formatted(Object...)
249249
*
250250
* @param pattern a <a href="../util/Formatter.html#syntax">format string</a>
251251
* @param args arguments referenced by the format specifiers in the format string
252252
* @return the current builder
253253
*/
254254
@Nonnull
255255
default MessageBuilder format(String pattern, Object... args) {
256-
return append(String.format(pattern, args));
256+
return append(pattern.formatted(args));
257257
}
258258

259259
/**

api/maven-api-core/src/main/java/org/apache/maven/api/services/ProblemCollector.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ private boolean dropProblemWithLowerSeverity(BuilderProblem.Severity severity) {
274274
List<P> problems = getProblems(s);
275275
while (!problems.isEmpty()) {
276276
try {
277-
return problems.remove(0) != null;
277+
return problems.removeFirst() != null;
278278
} catch (IndexOutOfBoundsException e) {
279279
// empty, continue
280280
}

api/maven-api-core/src/main/java/org/apache/maven/api/services/VersionRangeResolverResult.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public interface VersionRangeResolverResult extends Result<VersionRangeResolverR
6565
default Optional<Version> getLowestVersion() {
6666
return getVersions().isEmpty()
6767
? Optional.empty()
68-
: Optional.of(getVersions().get(0));
68+
: Optional.of(getVersions().getFirst());
6969
}
7070

7171
/**

api/maven-api-core/src/test/java/org/apache/maven/api/services/SourcesTest.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import java.io.InputStream;
2323
import java.nio.file.Files;
2424
import java.nio.file.Path;
25-
import java.nio.file.Paths;
2625

2726
import org.junit.jupiter.api.Test;
2827
import org.junit.jupiter.api.io.TempDir;
@@ -44,7 +43,7 @@ class SourcesTest {
4443

4544
@Test
4645
void testFromPath() {
47-
Path path = Paths.get("/tmp");
46+
Path path = Path.of("/tmp");
4847
Source source = Sources.fromPath(path);
4948

5049
assertNotNull(source);
@@ -54,7 +53,7 @@ void testFromPath() {
5453

5554
@Test
5655
void testBuildSource() {
57-
Path path = Paths.get("/tmp");
56+
Path path = Path.of("/tmp");
5857
ModelSource source = Sources.buildSource(path);
5958

6059
assertNotNull(source);
@@ -64,7 +63,7 @@ void testBuildSource() {
6463

6564
@Test
6665
void testResolvedSource() {
67-
Path path = Paths.get("/tmp");
66+
Path path = Path.of("/tmp");
6867
String location = "custom-location";
6968
ModelSource source = Sources.resolvedSource(path, location);
7069

@@ -77,7 +76,7 @@ void testResolvedSource() {
7776
@Test
7877
void testPathSourceFunctionality() {
7978
// Test basic source functionality
80-
Path path = Paths.get("/tmp");
79+
Path path = Path.of("/tmp");
8180
Sources.PathSource source = (Sources.PathSource) Sources.fromPath(path);
8281

8382
assertEquals(path.normalize(), source.getPath());
@@ -91,9 +90,9 @@ void testPathSourceFunctionality() {
9190
@Test
9291
void testBuildPathSourceFunctionality() {
9392
// Test build source functionality
94-
Path basePath = Paths.get("/tmp");
93+
Path basePath = Path.of("/tmp");
9594
ModelSource.ModelLocator locator = mock(ModelSource.ModelLocator.class);
96-
Path resolvedPath = Paths.get("/tmp/subproject/pom.xml");
95+
Path resolvedPath = Path.of("/tmp/subproject/pom.xml");
9796
when(locator.locateExistingPom(any(Path.class))).thenReturn(resolvedPath);
9897

9998
Sources.BuildPathSource source = (Sources.BuildPathSource) Sources.buildSource(basePath);
@@ -109,7 +108,7 @@ void testBuildPathSourceFunctionality() {
109108
@Test
110109
void testResolvedPathSourceFunctionality() {
111110
// Test resolved source functionality
112-
Path path = Paths.get("/tmp");
111+
Path path = Path.of("/tmp");
113112
String location = "custom-location";
114113
Sources.ResolvedPathSource source = (Sources.ResolvedPathSource) Sources.resolvedSource(path, location);
115114

api/maven-api-di/pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,11 @@
3333
<properties>
3434
<maven.compiler.proc>none</maven.compiler.proc>
3535
</properties>
36+
<dependencies>
37+
<dependency>
38+
<groupId>jakarta.annotation</groupId>
39+
<artifactId>jakarta.annotation-api</artifactId>
40+
<version>1.3.5</version>
41+
</dependency>
42+
</dependencies>
3643
</project>

api/maven-api-model/src/main/java/org/apache/maven/api/model/InputLocation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,6 @@ public interface StringFormatter {
201201

202202
@Override
203203
public String toString() {
204-
return String.format("%s @ %d:%d", source != null ? source.getLocation() : "n/a", lineNumber, columnNumber);
204+
return "%s @ %d:%d".formatted(source != null ? source.getLocation() : "n/a", lineNumber, columnNumber);
205205
}
206206
}

compat/maven-artifact/src/main/java/org/apache/maven/artifact/repository/ArtifactRepository.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
package org.apache.maven.artifact.repository;
2020

2121
import java.nio.file.Path;
22-
import java.nio.file.Paths;
2322
import java.util.List;
2423

2524
import org.apache.maven.artifact.Artifact;
@@ -48,7 +47,7 @@ public interface ArtifactRepository {
4847
String getBasedir();
4948

5049
default Path getBasedirPath() {
51-
return Paths.get(getBasedir());
50+
return Path.of(getBasedir());
5251
}
5352

5453
String getProtocol();

0 commit comments

Comments
 (0)