Skip to content
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

[SUREFIRE-1955] Switch project to Java 8 #415

Merged
merged 1 commit into from Dec 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 13 additions & 23 deletions Jenkinsfile
Expand Up @@ -32,7 +32,7 @@ properties(
final def oses = ['linux':'ubuntu', 'windows':'windows-he']
final def mavens = env.BRANCH_NAME == 'master' ? ['3.6.x', '3.2.x'] : ['3.2.x']
// all non-EOL versions and the first EA
final def jdks = [18, 17, 8, 7]
final def jdks = [18, 17, 8]

final def options = ['-e', '-V', '-B', '-nsu', '-P', 'run-its']
final def goals = ['clean', 'install']
Expand All @@ -44,37 +44,32 @@ oses.eachWithIndex { osMapping, indexOfOs ->
jdks.eachWithIndex { jdk, indexOfJdk ->
def os = osMapping.key
def label = osMapping.value
final String jdkTestName = jenkinsEnv.jdkFromVersion(os, jdk.toString())
final String jdkName = jenkinsEnv.jdkFromVersion(os, '8')
final String jdkName = jenkinsEnv.jdkFromVersion(os, jdk.toString())
final String mvnName = jenkinsEnv.mvnFromVersion(os, maven)
final String stageKey = "${os}-jdk${jdk}-maven${maven}"

// Referenses for TLS:
// https://central.sonatype.org/articles/2018/May/04/discontinued-support-for-tlsv11-and-below/?__hstc=31049440.ab2fd229e7f8b6176196d9f78621e1f5.1534324377408.1534324377408.1534324377408.1&__hssc=31049440.1.1534324377409&__hsfp=2729160845
def mavenOpts = '-Xms64m -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn'
mavenOpts += (os == 'linux' ? ' -Xmx1g' : ' -Xmx256m')

if (label == null || jdkTestName == null || mvnName == null) {
if (label == null || jdkName == null || mvnName == null) {
println "Skipping ${stageKey} as unsupported by Jenkins Environment."
return
}

println "${stageKey} ==> Label: ${label}, JDK: ${jdkTestName}, Maven: ${mvnName}."
println "${stageKey} ==> Label: ${label}, JDK: ${jdkName}, Maven: ${mvnName}."

stages[stageKey] = {
node(label) {
timestamps {
boolean first = indexOfOs == 0 && indexOfMaven == 0 && indexOfJdk == 0
def failsafeItPort = 8000 + 100 * indexOfMaven + 10 * indexOfJdk
def allOptions = options + ['-Djava.awt.headless=true', "-Dfailsafe-integration-test-port=${failsafeItPort}", "-Dfailsafe-integration-test-stop-port=${1 + failsafeItPort}"]
if (jdk == 7) {
allOptions += '-Dhttps.protocols=TLSv1.2'
}

if (!maven.startsWith('3.2') && !maven.startsWith('3.3') && !maven.startsWith('3.5')) {
allOptions += '--no-transfer-progress'
}
ws(dir: "${os == 'windows' ? "${TEMP}\\${BUILD_TAG}" : pwd()}") {
buildProcess(stageKey, jdkName, jdkTestName, mvnName, first ? goalsDepl : goals, allOptions, mavenOpts, first)
buildProcess(stageKey, jdkName, mvnName, first ? goalsDepl : goals, allOptions, mavenOpts, first)
}
}
}
Expand Down Expand Up @@ -118,7 +113,7 @@ timeout(time: 12, unit: 'HOURS') {
}
}

def buildProcess(String stageKey, String jdkName, String jdkTestName, String mvnName, goals, options, mavenOpts, boolean makeReports) {
def buildProcess(String stageKey, String jdkName, String mvnName, goals, options, mavenOpts, boolean makeReports) {
cleanWs()
def errorStatus = -99
try {
Expand All @@ -135,7 +130,6 @@ def buildProcess(String stageKey, String jdkName, String jdkTestName, String mvn
assert mvnLocalRepoDir != null : 'Local Maven Repository is undefined.'

def properties = ["-Djacoco.skip=${!makeReports}", "\"-Dmaven.repo.local=${mvnLocalRepoDir}\""]
println "Setting JDK for testing ${jdkTestName}"
def cmd = ['mvn'] + goals + options + properties

stage("build ${stageKey}") {
Expand All @@ -146,25 +140,21 @@ def buildProcess(String stageKey, String jdkName, String jdkTestName, String mvn

if (isUnix()) {
withEnv(["JAVA_HOME=${tool(jdkName)}",
"JAVA_HOME_IT=${tool(jdkTestName)}",
"MAVEN_OPTS=${mavenOpts}",
"PATH+MAVEN=${tool(mvnName)}/bin:${tool(jdkName)}/bin"
]) {
sh '$JAVA_HOME_IT/bin/java -version'
sh 'echo JAVA_HOME=$JAVA_HOME, JAVA_HOME_IT=$JAVA_HOME_IT, PATH=$PATH'
def script = cmd + ['\"-DjdkHome=$JAVA_HOME_IT\"']
errorStatus = sh(returnStatus: true, script: script.join(' '))
sh 'echo JAVA_HOME=$JAVA_HOME, PATH=$PATH'
sh '$JAVA_HOME/bin/java -version'
errorStatus = sh(returnStatus: true, script: cmd.join(' '))
}
} else {
withEnv(["JAVA_HOME=${tool(jdkName)}",
"JAVA_HOME_IT=${tool(jdkTestName)}",
"MAVEN_OPTS=${mavenOpts}",
"PATH+MAVEN=${tool(mvnName)}\\bin;${tool(jdkName)}\\bin"
]) {
bat '%JAVA_HOME_IT%\\bin\\java -version'
bat 'echo JAVA_HOME=%JAVA_HOME%, JAVA_HOME_IT=%JAVA_HOME_IT%, PATH=%PATH%'
def script = cmd + ['\"-DjdkHome=%JAVA_HOME_IT%\"']
errorStatus = bat(returnStatus: true, script: script.join(' '))
bat 'echo JAVA_HOME=%JAVA_HOME%, PATH=%PATH%'
bat '%JAVA_HOME%\\bin\\java -version'
errorStatus = bat(returnStatus: true, script: cmd.join(' '))
}
}

Expand Down
10 changes: 3 additions & 7 deletions README.md
Expand Up @@ -46,7 +46,7 @@ Usage of [maven-surefire-plugin], [maven-failsafe-plugin], [maven-surefire-repor

# Development Information

Build the Surefire project using **Maven 3.1.0+** and **JDK 1.8+**.
Build the Surefire project using **Maven 3.2.5+** and **JDK 1.8+**.

* In order to run tests for a release check during the Vote, the following memory requirements are needed:

Expand All @@ -59,13 +59,9 @@ Build the Surefire project using **Maven 3.1.0+** and **JDK 1.8+**.
set MAVEN_OPTS="-server -Xmx256m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=384m -XX:+UseG1GC -XX:+UseStringDeduplication -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -XX:SoftRefLRUPolicyMSPerMB=50 -Djava.awt.headless=true -Dhttps.protocols=TLSv1.2"
```

* In order to run the tests with **JDK 1.7** (on Linux/Unix modify the system property **jdkHome**):
* In order to build and run the tests:
```
mvn install site site:stage -P reporting,run-its "-DjdkHome=e:\Program Files\Java\jdk1.7.0_80\"
```
* In order to run the build and the tests with **JDK 1.8+**, e.g. JDK 11:
```
mvn install site site:stage -P reporting,run-its "-DjdkHome=e:\Program Files\Java\jdk11\"
mvn install site site:stage -P reporting,run-its
```


Expand Down
5 changes: 0 additions & 5 deletions maven-failsafe-plugin/pom.xml
Expand Up @@ -271,15 +271,10 @@
<properties>
<integration-test-port>${failsafe-integration-test-port}</integration-test-port>
<integration-test-stop-port>${failsafe-integration-test-stop-port}</integration-test-stop-port>
<https.protocols>${https.protocols}</https.protocols>
<jdk.tls.client.protocols>${https.protocols}</jdk.tls.client.protocols>
</properties>
</configuration>
</execution>
</executions>
<configuration>
<javaHome>${jdkHome}</javaHome>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
Expand Up @@ -172,15 +172,15 @@ public void noModuleDescriptorFile() throws Exception
assertThat( wrapper.getResolvePathResult() )
.isNull();

assertThat( invokeMethod( mojo, "existsModuleDescriptor", wrapper ) )
assertThat( (boolean) invokeMethod( mojo, "existsModuleDescriptor", wrapper ) )
.isEqualTo( false );

when( mojo.useModulePath() ).thenReturn( true );

File jvmExecutable = new File( jdkHome, IS_OS_WINDOWS ? "bin\\java.exe" : "bin/java" );
JdkAttributes jdkAttributes = new JdkAttributes( jvmExecutable, jdkHome, true );
Platform platform = new Platform().withJdkExecAttributesForTests( jdkAttributes );
assertThat( invokeMethod( mojo, "canExecuteProviderWithModularPath", platform, wrapper ) )
assertThat( (boolean) invokeMethod( mojo, "canExecuteProviderWithModularPath", platform, wrapper ) )
.isEqualTo( false );
}

Expand Down Expand Up @@ -217,27 +217,27 @@ public void correctModuleDescriptor() throws Exception
assertThat( wrapper.getResolvePathResult().getModuleDescriptor() )
.isSameAs( descriptor );

assertThat( invokeMethod( mojo, "existsModuleDescriptor", wrapper ) )
assertThat( (boolean) invokeMethod( mojo, "existsModuleDescriptor", wrapper ) )
.isEqualTo( true );

when( mojo.useModulePath() ).thenReturn( true );

File jvmExecutable = new File( jdkHome, IS_OS_WINDOWS ? "bin\\java.exe" : "bin/java" );
JdkAttributes jdkAttributes = new JdkAttributes( jvmExecutable, jdkHome, true );
Platform platform = new Platform().withJdkExecAttributesForTests( jdkAttributes );
assertThat( invokeMethod( mojo, "canExecuteProviderWithModularPath", platform, wrapper ) )
assertThat( (boolean) invokeMethod( mojo, "canExecuteProviderWithModularPath", platform, wrapper ) )
.isEqualTo( true );

jdkAttributes = new JdkAttributes( jvmExecutable, jdkHome, false );
platform = new Platform().withJdkExecAttributesForTests( jdkAttributes );
assertThat( invokeMethod( mojo, "canExecuteProviderWithModularPath", platform, wrapper ) )
assertThat( (boolean) invokeMethod( mojo, "canExecuteProviderWithModularPath", platform, wrapper ) )
.isEqualTo( false );

when( mojo.useModulePath() ).thenReturn( false );

jdkAttributes = new JdkAttributes( jvmExecutable, jdkHome, true );
platform = new Platform().withJdkExecAttributesForTests( jdkAttributes );
assertThat( invokeMethod( mojo, "canExecuteProviderWithModularPath", platform, wrapper ) )
assertThat( (boolean) invokeMethod( mojo, "canExecuteProviderWithModularPath", platform, wrapper ) )
.isEqualTo( false );
}

Expand Down Expand Up @@ -271,7 +271,7 @@ public void corruptedModuleDescriptor() throws Exception
assertThat( wrapper.getResolvePathResult() )
.isNull();

assertThat( invokeMethod( mojo, "existsModuleDescriptor", wrapper ) )
assertThat( (boolean) invokeMethod( mojo, "existsModuleDescriptor", wrapper ) )
.isEqualTo( false );
}

Expand Down
Expand Up @@ -19,16 +19,17 @@
* under the License.
*/

import org.apache.maven.surefire.extensions.ConsoleOutputReportEventListener;
import org.apache.maven.surefire.extensions.ConsoleOutputReporter;
import java.io.File;
import java.io.PrintStream;

import org.apache.maven.plugin.surefire.extensions.junit5.JUnit5ConsoleOutputReporter;
import org.apache.maven.plugin.surefire.report.ConsoleOutputFileReporter;
import org.apache.maven.plugin.surefire.report.DirectConsoleOutput;
import org.apache.maven.surefire.extensions.ConsoleOutputReportEventListener;
import org.apache.maven.surefire.extensions.ConsoleOutputReporter;
import org.fest.assertions.Assertions;
import org.junit.Test;

import java.io.File;

import static org.fest.assertions.Assertions.assertThat;
import static org.powermock.reflect.Whitebox.getInternalState;

Expand Down Expand Up @@ -73,9 +74,9 @@ public void shouldCreateConsoleListener()
ConsoleOutputReportEventListener listener1 = extension.createListener( System.out, System.err );
assertThat( listener1 )
.isInstanceOf( DirectConsoleOutput.class );
assertThat( getInternalState( listener1, "out" ) )
assertThat( (PrintStream) getInternalState( listener1, "out" ) )
.isSameAs( System.out );
assertThat( getInternalState( listener1, "err" ) )
assertThat( (PrintStream) getInternalState( listener1, "err" ) )
.isSameAs( System.err );

File target = new File( System.getProperty( "user.dir" ), "target" );
Expand All @@ -89,17 +90,17 @@ public void shouldCreateConsoleListener()
extension.createListener( reportsDirectory, reportNameSuffix, forkNumber );
assertThat( listener2 )
.isInstanceOf( ConsoleOutputFileReporter.class );
assertThat( getInternalState( listener2, "reportsDirectory" ) )
assertThat( (File) getInternalState( listener2, "reportsDirectory" ) )
.isSameAs( reportsDirectory );
assertThat( getInternalState( listener2, "reportNameSuffix" ) )
assertThat( (String) getInternalState( listener2, "reportNameSuffix" ) )
.isSameAs( reportNameSuffix );
assertThat( getInternalState( listener2, "usePhrasedFileName" ) )
assertThat( (boolean) getInternalState( listener2, "usePhrasedFileName" ) )
.isEqualTo( usePhrasedFileName );
assertThat( getInternalState( listener2, "forkNumber" ) )
assertThat( (Integer) getInternalState( listener2, "forkNumber" ) )
.isSameAs( forkNumber );
assertThat( getInternalState( listener2, "encoding" ) )
assertThat( (String) getInternalState( listener2, "encoding" ) )
.isSameAs( encoding );
assertThat( getInternalState( listener2, "reportEntryName" ) )
assertThat( (String) getInternalState( listener2, "reportEntryName" ) )
.isNull();
}

Expand Down Expand Up @@ -142,9 +143,9 @@ public void shouldCreateJUnit5ConsoleListener()
ConsoleOutputReportEventListener listener1 = extension.createListener( System.out, System.err );
assertThat( listener1 )
.isInstanceOf( DirectConsoleOutput.class );
assertThat( getInternalState( listener1, "out" ) )
assertThat( (PrintStream) getInternalState( listener1, "out" ) )
.isSameAs( System.out );
assertThat( getInternalState( listener1, "err" ) )
assertThat( (PrintStream) getInternalState( listener1, "err" ) )
.isSameAs( System.err );

File target = new File( System.getProperty( "user.dir" ), "target" );
Expand All @@ -159,17 +160,17 @@ public void shouldCreateJUnit5ConsoleListener()
extension.createListener( reportsDirectory, reportNameSuffix, forkNumber );
assertThat( listener2 )
.isInstanceOf( ConsoleOutputFileReporter.class );
assertThat( getInternalState( listener2, "reportsDirectory" ) )
assertThat( (File) getInternalState( listener2, "reportsDirectory" ) )
.isSameAs( reportsDirectory );
assertThat( getInternalState( listener2, "reportNameSuffix" ) )
assertThat( (String) getInternalState( listener2, "reportNameSuffix" ) )
.isSameAs( reportNameSuffix );
assertThat( getInternalState( listener2, "usePhrasedFileName" ) )
assertThat( (boolean) getInternalState( listener2, "usePhrasedFileName" ) )
.isEqualTo( usePhrasedFileName );
assertThat( getInternalState( listener2, "forkNumber" ) )
assertThat( (Integer) getInternalState( listener2, "forkNumber" ) )
.isSameAs( forkNumber );
assertThat( getInternalState( listener2, "encoding" ) )
assertThat( (String) getInternalState( listener2, "encoding" ) )
.isSameAs( encoding );
assertThat( getInternalState( listener2, "reportEntryName" ) )
assertThat( (String) getInternalState( listener2, "reportEntryName" ) )
.isNull();
}
}