Skip to content

Fix Jdk11 build #58

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

Merged
merged 4 commits into from
Nov 20, 2018
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ jdk:

- oraclejdk8
- oraclejdk9
- openjdk7
- oraclejdk11

script: "mvn --show-version --errors --batch-mode clean verify -DredirectTestOutputToFile=false"

cache:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,12 @@ public void testCompilingSources()

int numCompilerWarnings = messages.size() - numCompilerErrors;

if ( expectedErrors() != numCompilerErrors )
int expectedErrors = expectedErrors();

if ( expectedErrors != numCompilerErrors )
{
System.out.println( numCompilerErrors + " error(s) found:" );
List<String> errors = new ArrayList<>();
for ( CompilerMessage error : messages )
{
if ( !error.isError() )
Expand All @@ -129,13 +132,17 @@ public void testCompilingSources()
System.out.println( error.getFile() );
System.out.println( error.getMessage() );
System.out.println( "----" );
errors.add( error.getMessage() );
}

assertEquals( "Wrong number of compilation errors: " + messages, expectedErrors(), numCompilerErrors );
assertEquals( "Wrong number of compilation errors (" + numCompilerErrors + "/" + expectedErrors //
+ ") : " + errors, expectedErrors, numCompilerErrors );
}

if ( expectedWarnings() != numCompilerWarnings )
int expectedWarnings = expectedWarnings();
if ( expectedWarnings != numCompilerWarnings )
{
List<String> warnings = new ArrayList<>();
System.out.println( numCompilerWarnings + " warning(s) found:" );
for ( CompilerMessage error : messages )
{
Expand All @@ -148,9 +155,11 @@ public void testCompilingSources()
System.out.println( error.getFile() );
System.out.println( error.getMessage() );
System.out.println( "----" );
warnings.add( error.getMessage() );
}

assertEquals( "Wrong number of compilation warnings.", expectedWarnings(), numCompilerWarnings );
assertEquals( "Wrong number (" + numCompilerWarnings + "/" + expectedWarnings + ") of compilation warnings: " + warnings, //
expectedWarnings, numCompilerWarnings );
}

assertEquals( new TreeSet<>( normalizePaths( expectedOutputFiles() ) ), files );
Expand Down Expand Up @@ -224,7 +233,7 @@ public String getSourceVersion()

private List<String> normalizePaths( Collection<String> relativePaths )
{
List<String> normalizedPaths = new ArrayList<String>();
List<String> normalizedPaths = new ArrayList<>();
for ( String relativePath : relativePaths )
{
normalizedPaths.add( relativePath.replace( File.separatorChar, '/' ) );
Expand Down
2 changes: 1 addition & 1 deletion plexus-compilers/plexus-compiler-aspectj/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<description>AspectJ Compiler support for Plexus Compiler component.</description>

<properties>
<aspectj.version>1.8.9</aspectj.version>
<aspectj.version>1.9.2</aspectj.version>
</properties>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -503,9 +503,21 @@ private List<File> buildFileList( List<String> locations )
private void setSourceVersion( AjBuildConfig buildConfig, String sourceVersion )
throws CompilerException
{
if ( "1.9".equals( sourceVersion ) )
if ( "11".equals( sourceVersion ) )
{
buildConfig.getOptions().sourceLevel = ClassFileConstants.JDK1_9;
buildConfig.getOptions().sourceLevel = ClassFileConstants.JDK11;
}
else if ( "10".equals( sourceVersion ) )
{
buildConfig.getOptions().sourceLevel = ClassFileConstants.JDK10;
}
else if ( "9".equals( sourceVersion ) )
{
buildConfig.getOptions().sourceLevel = ClassFileConstants.JDK9;
}
else if ( "1.9".equals( sourceVersion ) )
{
buildConfig.getOptions().sourceLevel = ClassFileConstants.JDK9;
}
else if ( "1.8".equals( sourceVersion ) )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ protected int expectedErrors()
{
// olamy well I agree it's hackhish but I don't want to waste too much time with aspectj which is probably
// not used a lot anymore...
if (getJavaVersion().startsWith( "9" ) || getJavaVersion().startsWith( "10" ))
String javaVersion = getJavaVersion();
if (javaVersion.equals( "11" ))
{
return 11;
}
Expand All @@ -40,10 +41,10 @@ protected Collection<String> expectedOutputFiles()
String javaVersion = System.getProperty( "java.version" );
// olamy well I agree it's hackhish but I don't want to waste too much time with aspectj which is probably
// not used a lot anymore...
if (javaVersion.startsWith( "9" ) || javaVersion.startsWith( "10" ))
{
return Collections.emptyList();
}
// if (javaVersion.startsWith( "9" ) || javaVersion.startsWith( "10" ))
// {
// return Collections.emptyList();
// }
return Arrays.asList( new String[]{ "org/codehaus/foo/ExternalDeps.class", "org/codehaus/foo/Person.class" } );
}

Expand Down
2 changes: 1 addition & 1 deletion plexus-compilers/plexus-compiler-eclipse/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<dependency>
<groupId>org.eclipse.jdt</groupId>
<artifactId>ecj</artifactId>
<version>3.13.100</version>
<version>3.15.1</version>
</dependency>
</dependencies>

Expand Down
2 changes: 1 addition & 1 deletion plexus-compilers/plexus-compiler-javac-errorprone/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<dependency>
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_core</artifactId>
<version>2.2.0</version>
<version>2.3.2</version>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ protected String getRoleHint()

protected int expectedErrors()
{

if (getJavaVersion().contains("9.0")){
String javaVersion = getJavaVersion();
if (javaVersion.contains("9.0")||javaVersion.contains("11")){
// lots of new warnings about obsoletions for future releases
return 5;
}

// javac output changed for misspelled modifiers starting in 1.6...they now generate 2 errors per occurrence, not one.
if ( "1.5".compareTo( getJavaVersion() ) < 0 )
if ( "1.5".compareTo( javaVersion ) < 0 )
{
return 4;
}
Expand All @@ -79,18 +79,21 @@ protected int expectedErrors()

protected int expectedWarnings()
{
if (getJavaVersion().contains("9.0")){
String javaVersion = getJavaVersion();
if (javaVersion.contains("11")){
return 1;
}
if (javaVersion.contains("9.0")){
// lots of new warnings about obsoletions for future releases
return 8;
}


if (getJavaVersion().contains("1.8")){
if (javaVersion.contains("1.8")){
// lots of new warnings about obsoletions for future releases
return 30;
}

if ( "1.6".compareTo( getJavaVersion() ) < 0 )
if ( "1.6".compareTo( javaVersion ) < 0 )
{
// with 1.7 some warning with bootstrap class path not set in conjunction with -source 1.3
return 9;
Expand All @@ -102,24 +105,33 @@ protected int expectedWarnings()
@Override
public String getTargetVersion()
{
if (getJavaVersion().contains("9.0")){
String javaVersion = getJavaVersion();
if (javaVersion.contains("9.0")){
return "1.7";
}
if (javaVersion.contains("11")){
return "11";
}
return super.getTargetVersion();
}

@Override
public String getSourceVersion()
{
if (getJavaVersion().contains("9.0")){
String javaVersion = getJavaVersion();
if (javaVersion.contains("9.0")){
return "1.7";
}
if (javaVersion.contains("11")){
return "11";
}
return super.getTargetVersion();
}

protected Collection<String> expectedOutputFiles()
{
if (getJavaVersion().contains("9.0")){
String javaVersion = getJavaVersion();
if (javaVersion.contains("9.0")||javaVersion.contains("11")){
return Arrays.asList( new String[]{ "org/codehaus/foo/Deprecation.class", "org/codehaus/foo/ExternalDeps.class",
"org/codehaus/foo/Person.class"} );
}
Expand All @@ -142,7 +154,7 @@ public void internalTest( CompilerConfiguration compilerConfiguration, List<Stri

public void testBuildCompilerArgs13()
{
List<String> expectedArguments = new ArrayList<String>();
List<String> expectedArguments = new ArrayList<>();

CompilerConfiguration compilerConfiguration = new CompilerConfiguration();

Expand All @@ -155,7 +167,7 @@ public void testBuildCompilerArgs13()

public void testBuildCompilerArgs14()
{
List<String> expectedArguments = new ArrayList<String>();
List<String> expectedArguments = new ArrayList<>();

CompilerConfiguration compilerConfiguration = new CompilerConfiguration();

Expand All @@ -168,7 +180,7 @@ public void testBuildCompilerArgs14()

public void testBuildCompilerArgs15()
{
List<String> expectedArguments = new ArrayList<String>();
List<String> expectedArguments = new ArrayList<>();

CompilerConfiguration compilerConfiguration = new CompilerConfiguration();

Expand All @@ -181,7 +193,7 @@ public void testBuildCompilerArgs15()

public void testBuildCompilerArgs18()
{
List<String> expectedArguments = new ArrayList<String>();
List<String> expectedArguments = new ArrayList<>();

CompilerConfiguration compilerConfiguration = new CompilerConfiguration();

Expand All @@ -194,7 +206,7 @@ public void testBuildCompilerArgs18()

public void testBuildCompilerArgsUnspecifiedVersion()
{
List<String> expectedArguments = new ArrayList<String>();
List<String> expectedArguments = new ArrayList<>();

CompilerConfiguration compilerConfiguration = new CompilerConfiguration();

Expand All @@ -205,7 +217,7 @@ public void testBuildCompilerArgsUnspecifiedVersion()

public void testBuildCompilerDebugLevel()
{
List<String> expectedArguments = new ArrayList<String>();
List<String> expectedArguments = new ArrayList<>();

CompilerConfiguration compilerConfiguration = new CompilerConfiguration();

Expand All @@ -221,7 +233,7 @@ public void testBuildCompilerDebugLevel()
// PLXCOMP-190
public void testJRuntimeArguments()
{
List<String> expectedArguments = new ArrayList<String>();
List<String> expectedArguments = new ArrayList<>();

CompilerConfiguration compilerConfiguration = new CompilerConfiguration();

Expand Down Expand Up @@ -251,7 +263,7 @@ public void testJRuntimeArguments()

public void testModulePath() throws Exception
{
List<String> expectedArguments = new ArrayList<String>();
List<String> expectedArguments = new ArrayList<>();

CompilerConfiguration compilerConfiguration = new CompilerConfiguration();

Expand All @@ -278,7 +290,7 @@ public void testModulePath() throws Exception

public void testModuleVersion()
{
List<String> expectedArguments = new ArrayList<String>();
List<String> expectedArguments = new ArrayList<>();

CompilerConfiguration compilerConfiguration = new CompilerConfiguration();

Expand All @@ -303,7 +315,7 @@ public void testModuleVersion()

public void testReleaseVersion()
{
List<String> expectedArguments = new ArrayList<String>();
List<String> expectedArguments = new ArrayList<>();

CompilerConfiguration compilerConfiguration = new CompilerConfiguration();

Expand All @@ -322,7 +334,7 @@ public void testReleaseVersion()

public void testFailOnWarning()
{
List<String> expectedArguments = new ArrayList<String>();
List<String> expectedArguments = new ArrayList<>();

CompilerConfiguration compilerConfiguration = new CompilerConfiguration();

Expand All @@ -346,7 +358,7 @@ public void testFailOnWarning()

public void testMultipleAddExports()
{
List<String> expectedArguments = new ArrayList<String>();
List<String> expectedArguments = new ArrayList<>();

CompilerConfiguration compilerConfiguration = new CompilerConfiguration();

Expand Down
25 changes: 24 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20</version>
<version>2.22.1</version>
<configuration>
<redirectTestOutputToFile>${redirectTestOutputToFile}</redirectTestOutputToFile>
</configuration>
Expand Down Expand Up @@ -148,6 +148,29 @@
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.0.0-M2</version>
<executions>
<execution>
<id>enforce-java</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireJavaVersion>
<version>[1.8,)</version>
<message>[ERROR] OLD JDK [${java.version}] in use. This projects requires JDK 8 or newer</message>
</requireJavaVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>

</plugins>
</build>

Expand Down