diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfiguration.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfiguration.java index 8d4d84c68f..fc89016b5b 100644 --- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfiguration.java +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfiguration.java @@ -183,7 +183,7 @@ File createArgsFile( @Nonnull String moduleName, @Nonnull List modulePat for ( String pkg : packages ) { - args.append( "--add-exports" ) + args.append( "--add-opens" ) .append( NL ) .append( moduleName ) .append( '/' ) diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfigurationTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfigurationTest.java index 9a40a10689..14ea5623cd 100644 --- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfigurationTest.java +++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfigurationTest.java @@ -116,7 +116,7 @@ public void shouldCreateModularArgsFile() throws Exception .isEqualTo( "abc=\"" + replace( patchFile.getPath(), "\\", "\\\\" ) + "\"" ); assertThat( argsFileLines.get( 6 ) ) - .isEqualTo( "--add-exports" ); + .isEqualTo( "--add-opens" ); assertThat( argsFileLines.get( 7 ) ) .isEqualTo( "abc/org.apache.abc=ALL-UNNAMED" ); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/Junit5ModulePathIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/Junit5ModulePathIT.java new file mode 100644 index 0000000000..aafb230aba --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/Junit5ModulePathIT.java @@ -0,0 +1,69 @@ +package org.apache.maven.surefire.its; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.IOException; + +import org.apache.maven.surefire.its.fixture.AbstractJava9PlusIT; +import org.junit.Test; + +/** + * + */ +public class Junit5ModulePathIT + extends AbstractJava9PlusIT +{ + private String suffix; + + @Test + public void testModulePath() + throws IOException + { + assumeJava9() + .debugLogging() + .executeTest() + .verifyErrorFreeLog() + .assertTestSuiteResults( 2 ); + } + + @Test + public void testModulePathWithSpaces() + throws IOException + { + suffix = " with spaces"; + assumeJava9() + .debugLogging() + .executeTest() + .verifyErrorFreeLog() + .assertTestSuiteResults( 2 ); + } + + @Override + protected String getProjectDirectoryName() + { + return "junit5-modulepath"; + } + + @Override + protected String getSuffix() + { + return suffix; + } +} diff --git a/surefire-its/src/test/resources/junit5-modulepath/pom.xml b/surefire-its/src/test/resources/junit5-modulepath/pom.xml new file mode 100644 index 0000000000..bc14aa0965 --- /dev/null +++ b/surefire-its/src/test/resources/junit5-modulepath/pom.xml @@ -0,0 +1,46 @@ + + + 4.0.0 + + foo + app + 1.0.0-SNAPSHOT + + app + + + UTF-8 + ${java.specification.version} + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + + org.apache.maven.plugins + maven-surefire-plugin + ${surefire.version} + + + + + + + joda-time + joda-time + 2.9.9 + + + org.junit.jupiter + junit-jupiter-engine + 5.6.2 + test + + + + diff --git a/surefire-its/src/test/resources/junit5-modulepath/src/main/java/com/app/Main.java b/surefire-its/src/test/resources/junit5-modulepath/src/main/java/com/app/Main.java new file mode 100644 index 0000000000..51e145bbb8 --- /dev/null +++ b/surefire-its/src/test/resources/junit5-modulepath/src/main/java/com/app/Main.java @@ -0,0 +1,31 @@ +package com.app; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.joda.time.DateTime; + +public class Main +{ + public static void main( String... args ) + { + DateTime dt = new DateTime(); + System.out.println( dt ); + } +} diff --git a/surefire-its/src/test/resources/junit5-modulepath/src/main/java/module-info.java b/surefire-its/src/test/resources/junit5-modulepath/src/main/java/module-info.java new file mode 100644 index 0000000000..5f3eed410c --- /dev/null +++ b/surefire-its/src/test/resources/junit5-modulepath/src/main/java/module-info.java @@ -0,0 +1,21 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +module com.app { + requires joda.time; +} diff --git a/surefire-its/src/test/resources/junit5-modulepath/src/test/java/com/app/AppTest.java b/surefire-its/src/test/resources/junit5-modulepath/src/test/java/com/app/AppTest.java new file mode 100644 index 0000000000..8f2d3f537f --- /dev/null +++ b/surefire-its/src/test/resources/junit5-modulepath/src/test/java/com/app/AppTest.java @@ -0,0 +1,37 @@ +package com.app; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.junit.jupiter.api.Test; + +public class AppTest +{ + @Test + void testNoop() + throws Exception + { + } + + @Test + void testMain() + { + Main.main(); + } +}