Skip to content

Commit ebf54e2

Browse files
authored
Fix Jdk11 build (#58)
* jdk11 build Signed-off-by: olivier lamy <olamy@apache.org> * we cannot test anymore with jdk1.7 as aspectj do not support it anymore Signed-off-by: olivier lamy <olamy@apache.org> * add enforcer rule to force using 1.8 as minimum Signed-off-by: olivier lamy <olamy@apache.org> * oops fix typo Signed-off-by: olivier lamy <olamy@apache.org>
1 parent acbb668 commit ebf54e2

File tree

9 files changed

+97
-40
lines changed

9 files changed

+97
-40
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ jdk:
33

44
- oraclejdk8
55
- oraclejdk9
6-
- openjdk7
7-
6+
- oraclejdk11
7+
88
script: "mvn --show-version --errors --batch-mode clean verify -DredirectTestOutputToFile=false"
99

1010
cache:

plexus-compiler-test/src/main/java/org/codehaus/plexus/compiler/AbstractCompilerTest.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,12 @@ public void testCompilingSources()
115115

116116
int numCompilerWarnings = messages.size() - numCompilerErrors;
117117

118-
if ( expectedErrors() != numCompilerErrors )
118+
int expectedErrors = expectedErrors();
119+
120+
if ( expectedErrors != numCompilerErrors )
119121
{
120122
System.out.println( numCompilerErrors + " error(s) found:" );
123+
List<String> errors = new ArrayList<>();
121124
for ( CompilerMessage error : messages )
122125
{
123126
if ( !error.isError() )
@@ -129,13 +132,17 @@ public void testCompilingSources()
129132
System.out.println( error.getFile() );
130133
System.out.println( error.getMessage() );
131134
System.out.println( "----" );
135+
errors.add( error.getMessage() );
132136
}
133137

134-
assertEquals( "Wrong number of compilation errors: " + messages, expectedErrors(), numCompilerErrors );
138+
assertEquals( "Wrong number of compilation errors (" + numCompilerErrors + "/" + expectedErrors //
139+
+ ") : " + errors, expectedErrors, numCompilerErrors );
135140
}
136141

137-
if ( expectedWarnings() != numCompilerWarnings )
142+
int expectedWarnings = expectedWarnings();
143+
if ( expectedWarnings != numCompilerWarnings )
138144
{
145+
List<String> warnings = new ArrayList<>();
139146
System.out.println( numCompilerWarnings + " warning(s) found:" );
140147
for ( CompilerMessage error : messages )
141148
{
@@ -148,9 +155,11 @@ public void testCompilingSources()
148155
System.out.println( error.getFile() );
149156
System.out.println( error.getMessage() );
150157
System.out.println( "----" );
158+
warnings.add( error.getMessage() );
151159
}
152160

153-
assertEquals( "Wrong number of compilation warnings.", expectedWarnings(), numCompilerWarnings );
161+
assertEquals( "Wrong number (" + numCompilerWarnings + "/" + expectedWarnings + ") of compilation warnings: " + warnings, //
162+
expectedWarnings, numCompilerWarnings );
154163
}
155164

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

225234
private List<String> normalizePaths( Collection<String> relativePaths )
226235
{
227-
List<String> normalizedPaths = new ArrayList<String>();
236+
List<String> normalizedPaths = new ArrayList<>();
228237
for ( String relativePath : relativePaths )
229238
{
230239
normalizedPaths.add( relativePath.replace( File.separatorChar, '/' ) );

plexus-compilers/plexus-compiler-aspectj/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<description>AspectJ Compiler support for Plexus Compiler component.</description>
1515

1616
<properties>
17-
<aspectj.version>1.8.9</aspectj.version>
17+
<aspectj.version>1.9.2</aspectj.version>
1818
</properties>
1919

2020
<dependencies>

plexus-compilers/plexus-compiler-aspectj/src/main/java/org/codehaus/plexus/compiler/ajc/AspectJCompiler.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,9 +503,21 @@ private List<File> buildFileList( List<String> locations )
503503
private void setSourceVersion( AjBuildConfig buildConfig, String sourceVersion )
504504
throws CompilerException
505505
{
506-
if ( "1.9".equals( sourceVersion ) )
506+
if ( "11".equals( sourceVersion ) )
507507
{
508-
buildConfig.getOptions().sourceLevel = ClassFileConstants.JDK1_9;
508+
buildConfig.getOptions().sourceLevel = ClassFileConstants.JDK11;
509+
}
510+
else if ( "10".equals( sourceVersion ) )
511+
{
512+
buildConfig.getOptions().sourceLevel = ClassFileConstants.JDK10;
513+
}
514+
else if ( "9".equals( sourceVersion ) )
515+
{
516+
buildConfig.getOptions().sourceLevel = ClassFileConstants.JDK9;
517+
}
518+
else if ( "1.9".equals( sourceVersion ) )
519+
{
520+
buildConfig.getOptions().sourceLevel = ClassFileConstants.JDK9;
509521
}
510522
else if ( "1.8".equals( sourceVersion ) )
511523
{

plexus-compilers/plexus-compiler-aspectj/src/test/java/org/codehaus/plexus/compiler/ajc/AspectJCompilerTest.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ protected int expectedErrors()
2828
{
2929
// olamy well I agree it's hackhish but I don't want to waste too much time with aspectj which is probably
3030
// not used a lot anymore...
31-
if (getJavaVersion().startsWith( "9" ) || getJavaVersion().startsWith( "10" ))
31+
String javaVersion = getJavaVersion();
32+
if (javaVersion.equals( "11" ))
3233
{
3334
return 11;
3435
}
@@ -40,10 +41,10 @@ protected Collection<String> expectedOutputFiles()
4041
String javaVersion = System.getProperty( "java.version" );
4142
// olamy well I agree it's hackhish but I don't want to waste too much time with aspectj which is probably
4243
// not used a lot anymore...
43-
if (javaVersion.startsWith( "9" ) || javaVersion.startsWith( "10" ))
44-
{
45-
return Collections.emptyList();
46-
}
44+
// if (javaVersion.startsWith( "9" ) || javaVersion.startsWith( "10" ))
45+
// {
46+
// return Collections.emptyList();
47+
// }
4748
return Arrays.asList( new String[]{ "org/codehaus/foo/ExternalDeps.class", "org/codehaus/foo/Person.class" } );
4849
}
4950

plexus-compilers/plexus-compiler-eclipse/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<dependency>
2222
<groupId>org.eclipse.jdt</groupId>
2323
<artifactId>ecj</artifactId>
24-
<version>3.13.100</version>
24+
<version>3.15.1</version>
2525
</dependency>
2626
</dependencies>
2727

plexus-compilers/plexus-compiler-javac-errorprone/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<dependency>
3030
<groupId>com.google.errorprone</groupId>
3131
<artifactId>error_prone_core</artifactId>
32-
<version>2.2.0</version>
32+
<version>2.3.2</version>
3333
</dependency>
3434
</dependencies>
3535

plexus-compilers/plexus-compiler-javac/src/test/java/org/codehaus/plexus/compiler/javac/AbstractJavacCompilerTest.java

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,14 @@ protected String getRoleHint()
6060

6161
protected int expectedErrors()
6262
{
63-
64-
if (getJavaVersion().contains("9.0")){
63+
String javaVersion = getJavaVersion();
64+
if (javaVersion.contains("9.0")||javaVersion.contains("11")){
6565
// lots of new warnings about obsoletions for future releases
6666
return 5;
6767
}
6868

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

8080
protected int expectedWarnings()
8181
{
82-
if (getJavaVersion().contains("9.0")){
82+
String javaVersion = getJavaVersion();
83+
if (javaVersion.contains("11")){
84+
return 1;
85+
}
86+
if (javaVersion.contains("9.0")){
8387
// lots of new warnings about obsoletions for future releases
8488
return 8;
8589
}
8690

87-
88-
if (getJavaVersion().contains("1.8")){
91+
if (javaVersion.contains("1.8")){
8992
// lots of new warnings about obsoletions for future releases
9093
return 30;
9194
}
9295

93-
if ( "1.6".compareTo( getJavaVersion() ) < 0 )
96+
if ( "1.6".compareTo( javaVersion ) < 0 )
9497
{
9598
// with 1.7 some warning with bootstrap class path not set in conjunction with -source 1.3
9699
return 9;
@@ -102,24 +105,33 @@ protected int expectedWarnings()
102105
@Override
103106
public String getTargetVersion()
104107
{
105-
if (getJavaVersion().contains("9.0")){
108+
String javaVersion = getJavaVersion();
109+
if (javaVersion.contains("9.0")){
106110
return "1.7";
107111
}
112+
if (javaVersion.contains("11")){
113+
return "11";
114+
}
108115
return super.getTargetVersion();
109116
}
110117

111118
@Override
112119
public String getSourceVersion()
113120
{
114-
if (getJavaVersion().contains("9.0")){
121+
String javaVersion = getJavaVersion();
122+
if (javaVersion.contains("9.0")){
115123
return "1.7";
116124
}
125+
if (javaVersion.contains("11")){
126+
return "11";
127+
}
117128
return super.getTargetVersion();
118129
}
119130

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

143155
public void testBuildCompilerArgs13()
144156
{
145-
List<String> expectedArguments = new ArrayList<String>();
157+
List<String> expectedArguments = new ArrayList<>();
146158

147159
CompilerConfiguration compilerConfiguration = new CompilerConfiguration();
148160

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

156168
public void testBuildCompilerArgs14()
157169
{
158-
List<String> expectedArguments = new ArrayList<String>();
170+
List<String> expectedArguments = new ArrayList<>();
159171

160172
CompilerConfiguration compilerConfiguration = new CompilerConfiguration();
161173

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

169181
public void testBuildCompilerArgs15()
170182
{
171-
List<String> expectedArguments = new ArrayList<String>();
183+
List<String> expectedArguments = new ArrayList<>();
172184

173185
CompilerConfiguration compilerConfiguration = new CompilerConfiguration();
174186

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

182194
public void testBuildCompilerArgs18()
183195
{
184-
List<String> expectedArguments = new ArrayList<String>();
196+
List<String> expectedArguments = new ArrayList<>();
185197

186198
CompilerConfiguration compilerConfiguration = new CompilerConfiguration();
187199

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

195207
public void testBuildCompilerArgsUnspecifiedVersion()
196208
{
197-
List<String> expectedArguments = new ArrayList<String>();
209+
List<String> expectedArguments = new ArrayList<>();
198210

199211
CompilerConfiguration compilerConfiguration = new CompilerConfiguration();
200212

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

206218
public void testBuildCompilerDebugLevel()
207219
{
208-
List<String> expectedArguments = new ArrayList<String>();
220+
List<String> expectedArguments = new ArrayList<>();
209221

210222
CompilerConfiguration compilerConfiguration = new CompilerConfiguration();
211223

@@ -221,7 +233,7 @@ public void testBuildCompilerDebugLevel()
221233
// PLXCOMP-190
222234
public void testJRuntimeArguments()
223235
{
224-
List<String> expectedArguments = new ArrayList<String>();
236+
List<String> expectedArguments = new ArrayList<>();
225237

226238
CompilerConfiguration compilerConfiguration = new CompilerConfiguration();
227239

@@ -251,7 +263,7 @@ public void testJRuntimeArguments()
251263

252264
public void testModulePath() throws Exception
253265
{
254-
List<String> expectedArguments = new ArrayList<String>();
266+
List<String> expectedArguments = new ArrayList<>();
255267

256268
CompilerConfiguration compilerConfiguration = new CompilerConfiguration();
257269

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

279291
public void testModuleVersion()
280292
{
281-
List<String> expectedArguments = new ArrayList<String>();
293+
List<String> expectedArguments = new ArrayList<>();
282294

283295
CompilerConfiguration compilerConfiguration = new CompilerConfiguration();
284296

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

304316
public void testReleaseVersion()
305317
{
306-
List<String> expectedArguments = new ArrayList<String>();
318+
List<String> expectedArguments = new ArrayList<>();
307319

308320
CompilerConfiguration compilerConfiguration = new CompilerConfiguration();
309321

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

323335
public void testFailOnWarning()
324336
{
325-
List<String> expectedArguments = new ArrayList<String>();
337+
List<String> expectedArguments = new ArrayList<>();
326338

327339
CompilerConfiguration compilerConfiguration = new CompilerConfiguration();
328340

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

347359
public void testMultipleAddExports()
348360
{
349-
List<String> expectedArguments = new ArrayList<String>();
361+
List<String> expectedArguments = new ArrayList<>();
350362

351363
CompilerConfiguration compilerConfiguration = new CompilerConfiguration();
352364

pom.xml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
<plugin>
8686
<groupId>org.apache.maven.plugins</groupId>
8787
<artifactId>maven-surefire-plugin</artifactId>
88-
<version>2.20</version>
88+
<version>2.22.1</version>
8989
<configuration>
9090
<redirectTestOutputToFile>${redirectTestOutputToFile}</redirectTestOutputToFile>
9191
</configuration>
@@ -148,6 +148,29 @@
148148
</execution>
149149
</executions>
150150
</plugin>
151+
152+
<plugin>
153+
<groupId>org.apache.maven.plugins</groupId>
154+
<artifactId>maven-enforcer-plugin</artifactId>
155+
<version>3.0.0-M2</version>
156+
<executions>
157+
<execution>
158+
<id>enforce-java</id>
159+
<goals>
160+
<goal>enforce</goal>
161+
</goals>
162+
<configuration>
163+
<rules>
164+
<requireJavaVersion>
165+
<version>[1.8,)</version>
166+
<message>[ERROR] OLD JDK [${java.version}] in use. This projects requires JDK 8 or newer</message>
167+
</requireJavaVersion>
168+
</rules>
169+
</configuration>
170+
</execution>
171+
</executions>
172+
</plugin>
173+
151174
</plugins>
152175
</build>
153176

0 commit comments

Comments
 (0)