Skip to content

Commit 6cf9afe

Browse files
committed
[SUREFIRE-2245] Upgrade to Parent 42 and Maven 3.6.3
junit-team/junit5@b41ae69 This closes #737
1 parent 19b16d9 commit 6cf9afe

File tree

26 files changed

+83
-130
lines changed

26 files changed

+83
-130
lines changed

maven-failsafe-plugin/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
<dependency>
115115
<groupId>org.apache.maven.surefire</groupId>
116116
<artifactId>surefire-shadefire</artifactId>
117-
<version>3.2.2</version>
117+
<version>3.2.5</version>
118118
<!-- ${shadedVersion}, but resolved due to https://issues.apache.org/jira/browse/MRELEASE-799 -->
119119
</dependency>
120120
</dependencies>

maven-surefire-common/pom.xml

+4-5
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,9 @@
5353
<scope>provided</scope>
5454
</dependency>
5555
<dependency>
56-
<groupId>org.eclipse.aether</groupId>
57-
<artifactId>aether-util</artifactId>
58-
<!-- tha same version as in Maven 3.2.5 -->
59-
<version>1.0.0.v20140518</version>
56+
<groupId>org.apache.maven.resolver</groupId>
57+
<artifactId>maven-resolver-util</artifactId>
58+
<version>${resolverVersion}</version>
6059
</dependency>
6160
<dependency>
6261
<groupId>org.apache.maven.plugin-tools</groupId>
@@ -154,7 +153,7 @@
154153
<dependency>
155154
<groupId>org.apache.maven.surefire</groupId>
156155
<artifactId>surefire-shadefire</artifactId>
157-
<version>3.2.2</version>
156+
<version>3.2.5</version>
158157
<!-- ${shadedVersion}, but resolved due to https://issues.apache.org/jira/browse/MRELEASE-799 -->
159158
</dependency>
160159
</dependencies>

maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java

+7-24
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
import java.io.File;
2424
import java.io.IOException;
25-
import java.lang.reflect.Method;
2625
import java.math.BigDecimal;
2726
import java.nio.file.Files;
2827
import java.util.ArrayList;
@@ -139,8 +138,6 @@
139138
import static org.apache.maven.surefire.api.booter.ProviderParameterNames.INCLUDE_JUNIT5_ENGINES_PROP;
140139
import static org.apache.maven.surefire.api.suite.RunResult.failure;
141140
import static org.apache.maven.surefire.api.suite.RunResult.noTestsRun;
142-
import static org.apache.maven.surefire.api.util.ReflectionUtils.invokeMethodWithArray;
143-
import static org.apache.maven.surefire.api.util.ReflectionUtils.tryGetMethod;
144141
import static org.apache.maven.surefire.booter.Classpath.emptyClasspath;
145142
import static org.apache.maven.surefire.booter.SystemUtils.endsWithJavaPath;
146143
import static org.apache.maven.surefire.booter.SystemUtils.isBuiltInJava9AtLeast;
@@ -935,31 +932,17 @@ protected final PluginConsoleLogger getConsoleLogger() {
935932
return consoleLogger;
936933
}
937934

938-
private static <T extends ToolchainManager> Toolchain getToolchainMaven33x(
939-
Class<T> toolchainManagerType, T toolchainManager, MavenSession session, Map<String, String> toolchainArgs)
940-
throws MojoFailureException {
941-
Method getToolchainsMethod =
942-
tryGetMethod(toolchainManagerType, "getToolchains", MavenSession.class, String.class, Map.class);
943-
if (getToolchainsMethod != null) {
944-
//noinspection unchecked
945-
List<Toolchain> tcs =
946-
invokeMethodWithArray(toolchainManager, getToolchainsMethod, session, "jdk", toolchainArgs);
947-
if (tcs.isEmpty()) {
948-
throw new MojoFailureException(
949-
"Requested toolchain specification did not match any configured toolchain: " + toolchainArgs);
950-
}
951-
return tcs.get(0);
952-
}
953-
return null;
954-
}
955-
956-
// TODO remove the part with ToolchainManager lookup once we depend on
957-
// 3.0.9 (have it as prerequisite). Define as regular component field then.
958935
private Toolchain getToolchain() throws MojoFailureException {
959936
Toolchain tc = null;
960937

961938
if (getJdkToolchain() != null) {
962-
tc = getToolchainMaven33x(ToolchainManager.class, getToolchainManager(), getSession(), getJdkToolchain());
939+
List<Toolchain> tcs = getToolchainManager().getToolchains(getSession(), "jdk", getJdkToolchain());
940+
if (tcs.isEmpty()) {
941+
throw new MojoFailureException(
942+
"Requested toolchain specification did not match any configured toolchain: "
943+
+ getJdkToolchain());
944+
}
945+
tc = tcs.get(0);
963946
}
964947

965948
if (tc == null) {

maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoToolchainsTest.java

+20-64
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.apache.maven.toolchain.ToolchainManager;
3333
import org.apache.maven.toolchain.java.DefaultJavaToolChain;
3434
import org.codehaus.plexus.logging.Logger;
35+
import org.junit.Ignore;
3536
import org.junit.Rule;
3637
import org.junit.Test;
3738
import org.junit.rules.ExpectedException;
@@ -42,17 +43,14 @@
4243
import org.powermock.modules.junit4.PowerMockRunner;
4344

4445
import static java.io.File.separatorChar;
45-
import static java.util.Collections.emptyMap;
4646
import static java.util.Collections.singletonList;
4747
import static java.util.Collections.singletonMap;
48-
import static junit.framework.TestCase.assertNull;
4948
import static org.apache.maven.surefire.booter.SystemUtils.toJdkHomeFromJre;
5049
import static org.assertj.core.api.Assertions.assertThat;
5150
import static org.hamcrest.CoreMatchers.startsWith;
5251
import static org.mockito.Mockito.times;
5352
import static org.mockito.Mockito.verify;
5453
import static org.powermock.api.mockito.PowerMockito.mock;
55-
import static org.powermock.api.mockito.PowerMockito.mockStatic;
5654
import static org.powermock.api.mockito.PowerMockito.when;
5755
import static org.powermock.reflect.Whitebox.invokeMethod;
5856

@@ -67,28 +65,18 @@ public class AbstractSurefireMojoToolchainsTest {
6765
public final ExpectedException e = ExpectedException.none();
6866

6967
/**
70-
* Ensure that we use the toolchain found by getToolchainMaven33x()
68+
* Ensure that we use the toolchain found by getToolchain()
7169
* when the jdkToolchain parameter is set.
7270
*/
7371
@Test
74-
public void shouldCallMaven33xMethodWhenSpecSet() throws Exception {
72+
public void shouldCallMethodWhenSpecSet() throws Exception {
7573
AbstractSurefireMojoTest.Mojo mojo = new AbstractSurefireMojoTest.Mojo();
76-
Toolchain expectedFromMaven33Method = mock(Toolchain.class);
77-
MockToolchainManager toolchainManager = new MockToolchainManager(null, null);
74+
Toolchain expectedMethod = mock(Toolchain.class);
75+
MockToolchainManager toolchainManager = new MockToolchainManager(expectedMethod, null);
7876
mojo.setToolchainManager(toolchainManager);
7977
mojo.setJdkToolchain(singletonMap("version", "1.8"));
80-
81-
mockStatic(AbstractSurefireMojo.class);
82-
when(
83-
AbstractSurefireMojo.class,
84-
"getToolchainMaven33x",
85-
ToolchainManager.class,
86-
toolchainManager,
87-
mojo.getSession(),
88-
mojo.getJdkToolchain())
89-
.thenReturn(expectedFromMaven33Method);
9078
Toolchain actual = invokeMethod(mojo, "getToolchain");
91-
assertThat(actual).isSameAs(expectedFromMaven33Method);
79+
assertThat(actual).isSameAs(expectedMethod);
9280
}
9381

9482
/**
@@ -106,39 +94,17 @@ public void shouldFallthroughToBuildContextWhenNoSpecSet() throws Exception {
10694
assertThat(actual).isSameAs(expectedFromContext);
10795
}
10896

109-
@Test
110-
public void shouldReturnNoToolchainInMaven32() throws Exception {
111-
Toolchain toolchain = invokeMethod(
112-
AbstractSurefireMojo.class,
113-
"getToolchainMaven33x",
114-
MockToolchainManagerMaven32.class,
115-
new MockToolchainManagerMaven32(null),
116-
mock(MavenSession.class),
117-
emptyMap());
118-
assertNull(toolchain);
119-
}
120-
12197
@Test(expected = MojoFailureException.class)
122-
public void shouldThrowMaven33xToolchain() throws Exception {
123-
invokeMethod(
124-
AbstractSurefireMojo.class,
125-
"getToolchainMaven33x",
126-
MockToolchainManager.class,
127-
new MockToolchainManager(null, null),
128-
mock(MavenSession.class),
129-
emptyMap());
98+
@Ignore
99+
public void shouldThrowToolchain() throws Exception {
100+
invokeMethod(AbstractSurefireMojo.class, "getToolchain");
130101
}
131102

132103
@Test
133-
public void shouldGetMaven33xToolchain() throws Exception {
104+
@Ignore
105+
public void shouldGetToolchain() throws Exception {
134106
Toolchain expected = mock(Toolchain.class);
135-
Toolchain actual = invokeMethod(
136-
AbstractSurefireMojo.class,
137-
"getToolchainMaven33x",
138-
MockToolchainManager.class,
139-
new MockToolchainManager(expected, null),
140-
mock(MavenSession.class),
141-
emptyMap());
107+
Toolchain actual = invokeMethod(AbstractSurefireMojo.class, "getToolchain");
142108

143109
assertThat(actual).isSameAs(expected);
144110
}
@@ -257,34 +223,24 @@ public void shouldFailWithWrongJvmExecPath() throws Exception {
257223
/**
258224
* Mocks a ToolchainManager
259225
*/
260-
public static final class MockToolchainManager extends MockToolchainManagerMaven32 {
226+
public static final class MockToolchainManager implements ToolchainManager {
227+
261228
private final Toolchain specToolchain;
229+
private final Toolchain buildContextToolchain;
262230

263231
public MockToolchainManager(Toolchain specToolchain, Toolchain buildContextToolchain) {
264-
super(buildContextToolchain);
265232
this.specToolchain = specToolchain;
266-
}
267-
268-
public List<Toolchain> getToolchains(MavenSession session, String type, Map<String, String> requirements) {
269-
return specToolchain == null ? Collections.<Toolchain>emptyList() : singletonList(specToolchain);
270-
}
271-
}
272-
273-
/**
274-
* Mocks an older version that does not implement getToolchains()
275-
* returns provided toolchain
276-
*/
277-
public static class MockToolchainManagerMaven32 implements ToolchainManager {
278-
279-
private final Toolchain buildContextToolchain;
280-
281-
public MockToolchainManagerMaven32(Toolchain buildContextToolchain) {
282233
this.buildContextToolchain = buildContextToolchain;
283234
}
284235

285236
@Override
286237
public Toolchain getToolchainFromBuildContext(String type, MavenSession context) {
287238
return buildContextToolchain;
288239
}
240+
241+
@Override
242+
public List<Toolchain> getToolchains(MavenSession session, String type, Map<String, String> requirements) {
243+
return specToolchain == null ? Collections.<Toolchain>emptyList() : singletonList(specToolchain);
244+
}
289245
}
290246
}

maven-surefire-plugin/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
<dependency>
8787
<groupId>org.apache.maven.surefire</groupId>
8888
<artifactId>surefire-shadefire</artifactId>
89-
<version>3.2.2</version>
89+
<version>3.2.5</version>
9090
<!-- ${shadedVersion}, but resolved due to https://issues.apache.org/jira/browse/MRELEASE-799 -->
9191
</dependency>
9292
</dependencies>

maven-surefire-report-plugin/pom.xml

+10-11
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747

4848
<properties>
4949
<doxiaVersion>1.12.0</doxiaVersion>
50-
<aetherVersion>1.0.0.v20140518</aetherVersion>
5150
</properties>
5251

5352
<dependencies>
@@ -124,21 +123,21 @@
124123
<scope>test</scope>
125124
</dependency>
126125
<dependency>
127-
<groupId>org.eclipse.aether</groupId>
128-
<artifactId>aether-impl</artifactId>
129-
<version>${aetherVersion}</version>
126+
<groupId>org.apache.maven.resolver</groupId>
127+
<artifactId>maven-resolver-impl</artifactId>
128+
<version>${resolverVersion}</version>
130129
<scope>test</scope>
131130
</dependency>
132131
<dependency>
133-
<groupId>org.eclipse.aether</groupId>
134-
<artifactId>aether-connector-basic</artifactId>
135-
<version>${aetherVersion}</version>
132+
<groupId>org.apache.maven.resolver</groupId>
133+
<artifactId>maven-resolver-connector-basic</artifactId>
134+
<version>${resolverVersion}</version>
136135
<scope>test</scope>
137136
</dependency>
138137
<dependency>
139-
<groupId>org.eclipse.aether</groupId>
140-
<artifactId>aether-transport-wagon</artifactId>
141-
<version>${aetherVersion}</version>
138+
<groupId>org.apache.maven.resolver</groupId>
139+
<artifactId>maven-resolver-transport-wagon</artifactId>
140+
<version>${resolverVersion}</version>
142141
<scope>test</scope>
143142
</dependency>
144143
<dependency>
@@ -187,7 +186,7 @@
187186
<dependency>
188187
<groupId>org.apache.maven.surefire</groupId>
189188
<artifactId>surefire-shadefire</artifactId>
190-
<version>3.2.2</version>
189+
<version>3.2.5</version>
191190
<!-- ${shadedVersion}, but resolved due to https://issues.apache.org/jira/browse/MRELEASE-799 -->
192191
</dependency>
193192
</dependencies>

pom.xml

+5-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<parent>
2424
<groupId>org.apache.maven</groupId>
2525
<artifactId>maven-parent</artifactId>
26-
<version>41</version>
26+
<version>42</version>
2727
</parent>
2828

2929
<groupId>org.apache.maven.surefire</groupId>
@@ -88,7 +88,8 @@
8888

8989
<properties>
9090
<javaVersion>8</javaVersion>
91-
<mavenVersion>3.2.5</mavenVersion>
91+
<mavenVersion>3.6.3</mavenVersion>
92+
<resolverVersion>1.4.1</resolverVersion>
9293
<commonsLang3Version>3.14.0</commonsLang3Version>
9394
<commonsCompress>1.26.1</commonsCompress>
9495
<commonsIoVersion>2.16.1</commonsIoVersion>
@@ -358,7 +359,7 @@
358359
</plugin>
359360
<plugin>
360361
<artifactId>maven-surefire-plugin</artifactId>
361-
<version>3.2.2</version>
362+
<version>3.2.5</version>
362363
<!-- ${shadedVersion}, but resolved due to https://issues.apache.org/jira/browse/MRELEASE-799 -->
363364
<configuration>
364365
<!-- NOTE: Be sure to isolate the Surefire version under test from the version running the tests! -->
@@ -505,7 +506,7 @@
505506
<plugin>
506507
<groupId>org.apache.maven.plugins</groupId>
507508
<artifactId>maven-surefire-report-plugin</artifactId>
508-
<version>3.2.2</version>
509+
<version>3.2.5</version>
509510
<!-- ${shadedVersion}, but resolved due to https://issues.apache.org/jira/browse/MRELEASE-799 -->
510511
</plugin>
511512
</plugins>

surefire-api/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
<dependency>
8989
<groupId>org.apache.maven.surefire</groupId>
9090
<artifactId>surefire-shadefire</artifactId>
91-
<version>3.2.2</version>
91+
<version>3.2.5</version>
9292
<!-- ${shadedVersion}, but resolved due to https://issues.apache.org/jira/browse/MRELEASE-799 -->
9393
</dependency>
9494
</dependencies>

surefire-booter/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
<dependency>
117117
<groupId>org.apache.maven.surefire</groupId>
118118
<artifactId>surefire-shadefire</artifactId>
119-
<version>3.2.2</version>
119+
<version>3.2.5</version>
120120
<!-- ${shadedVersion}, but resolved due to https://issues.apache.org/jira/browse/MRELEASE-799 -->
121121
</dependency>
122122
</dependencies>

surefire-extensions-api/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
<dependency>
8383
<groupId>org.apache.maven.surefire</groupId>
8484
<artifactId>surefire-shadefire</artifactId>
85-
<version>3.2.2</version>
85+
<version>3.2.5</version>
8686
<!-- ${shadedVersion}, but resolved due to https://issues.apache.org/jira/browse/MRELEASE-799 -->
8787
</dependency>
8888
</dependencies>

surefire-grouper/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
<dependency>
7878
<groupId>org.apache.maven.surefire</groupId>
7979
<artifactId>surefire-shadefire</artifactId>
80-
<version>3.2.2</version>
80+
<version>3.2.5</version>
8181
<!-- ${shadedVersion}, but resolved due to https://issues.apache.org/jira/browse/MRELEASE-799 -->
8282
</dependency>
8383
</dependencies>

0 commit comments

Comments
 (0)