Skip to content

Complete fix to support Maven 4 #111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion takari-plugin-testing-its/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
<artifactItem>
<groupId>org.apache.maven</groupId>
<artifactId>apache-maven</artifactId>
<version>4.0.0-rc-3</version>
<version>4.0.0-rc-4-SNAPSHOT</version>
<classifier>bin</classifier>
<type>tar.gz</type>
</artifactItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
* <li>The test project is not able to resolve test harness from the reactor, hence the outer build
* must run at least install phase.</li>
* </ul>
*
* TODO: DOES NOT WORK WITH MAVEN 4!
*/
@RunWith(Parameterized.class)
public class IntegrationTest {
Expand All @@ -37,6 +35,7 @@ public static List<Object[]> versions() {
parameters.add(new Object[] {"3.6.3"});
parameters.add(new Object[] {"3.8.8"});
parameters.add(new Object[] {"3.9.9"});
parameters.add(new Object[] {"4.0.0-rc-4-SNAPSHOT"});
return parameters;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"target/maven-installation/apache-maven-3.6.3",
"target/maven-installation/apache-maven-3.8.8",
"target/maven-installation/apache-maven-3.9.9",
"target/maven-installation/apache-maven-4.0.0-rc-3"
"target/maven-installation/apache-maven-4.0.0-rc-4-SNAPSHOT"
})
public class JUnit5IntegrationTests {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
* <li>The test project is not able to resolve test harness from the reactor, hence the outer build
* must run at least install phase.</li>
* </ul>
*
* TODO: DOES NOT WORK WITH MAVEN 4!
*/
class JUnit5UnitTests {

Expand Down Expand Up @@ -88,7 +86,7 @@ void testUnitTestHarnessHonoursUserSettings(MavenRuntime maven, String version)
static final class MavenVersionsSource implements ArgumentsProvider {

private List<String> getMavenVersions() {
return Arrays.asList("3.6.3", "3.8.8", "3.9.9");
return Arrays.asList("3.6.3", "3.8.8", "3.9.9", "4.0.0-rc-4-SNAPSHOT");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@
<version>${mavenPluginPluginVersion}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
<scope>provided</scope>
</dependency>

<!-- test dependencies -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ protected MavenExecutionRequest newExecutionRequest() throws Exception {
systemProperties.putAll(System.getProperties()); // TODO not thread safe
systemProperties.setProperty("maven.version", mavenVersion);
systemProperties.setProperty("maven.build.version", mavenVersion);
System.getenv().forEach((k, v) -> systemProperties.setProperty("env." + k, v));

// request with initial configuration
MavenExecutionRequest request = new DefaultMavenExecutionRequest();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.nio.file.Files;
import java.util.Properties;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
Expand Down Expand Up @@ -89,7 +89,7 @@ public void addLoadFile(File file) {
}
} else {
try (InputStream is = new BufferedInputStream(
new FileInputStream(new File(file, MAVEN_CORE_POMPROPERTIES)))) {
Files.newInputStream(new File(file, MAVEN_CORE_POMPROPERTIES).toPath()))) {
version = getMavenVersion(is);
}
}
Expand All @@ -112,7 +112,7 @@ public void addLoadURL(URL url) {}
properties.setProperty(SYSPROP_MAVEN_MAIN_CLASS, MAVEN4_MAIN_CLASS); // must for maven4, ignored by maven3
properties.setProperty(SYSPROP_MAVEN_HOME, mavenHome.getCanonicalPath());
ConfigurationParser configParser = new ConfigurationParser(configHandler, properties);
try (InputStream is = new BufferedInputStream(new FileInputStream(classworldsConf))) {
try (InputStream is = new BufferedInputStream(Files.newInputStream(classworldsConf.toPath()))) {
configParser.parse(is);
}
} catch (IOException | ClassWorldException | ConfigurationException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public MavenRuntime build() throws Exception {

public static class ForkedMavenRuntimeBuilder extends MavenRuntimeBuilder {

private Map<String, String> environment;
private Map<String, String> environment = new HashMap<>(System.getenv());
private final List<String> jvmArgs = new ArrayList<>();

ForkedMavenRuntimeBuilder(File mavenHome, File classworldsConf) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public boolean supportsTestTemplate(ExtensionContext context) {
public Stream<TestTemplateInvocationContext> provideTestTemplateInvocationContexts(ExtensionContext context) {
String displayName = context.getDisplayName();
String[] installations = context.getTestClass()
.orElseThrow()
.orElseThrow(IllegalStateException::new)
.getAnnotation(MavenInstallations.class)
.value();
return Arrays.stream(installations)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public boolean supportsTestTemplate(ExtensionContext context) {
public Stream<TestTemplateInvocationContext> provideTestTemplateInvocationContexts(ExtensionContext context) {
String displayName = context.getDisplayName();
String[] versions = context.getTestClass()
.orElseThrow()
.orElseThrow(IllegalStateException::new)
.getAnnotation(MavenVersions.class)
.value();
List<TestTemplateInvocationContext> contexts = new ArrayList<>();
Expand Down
Loading