ccorsi commented on a change in pull request #36:
URL:
https://github.com/apache/maven-compiler-plugin/pull/36#discussion_r546883926
##########
File path: src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java
##########
@@ -319,7 +352,42 @@ else if ( Double.valueOf( getTarget() ) < Double.valueOf(
MODULE_INFO_TARGET ) )
if ( testModuleDescriptor != null )
{
modulepathElements = testPath;
- classpathElements = Collections.emptyList();
+ classpathElements = null;
+ for ( String path : modulepathElements )
+ {
+ File file = new File( path );
+ if ( file.exists() && ! file.isDirectory() &&
file.getName().endsWith( ".jar" ) )
+ {
+ // check if the jar file contains the module-info.class
+ try
+ {
+ JarFile jarFile = new JarFile( file );
+ if ( jarFile.getJarEntry( "module-info.class" ) ==
null )
+ {
+ if ( getLog().isDebugEnabled() )
+ {
+ getLog().debug( "Add non-module jar dependency
" + path
+ + " to class path." );
+ }
+ if ( classpathElements == null )
+ {
+ classpathElements = new ArrayList<String>();
+ }
+ // add the path to the classpathElements list.
+ classpathElements.add( path );
+ }
Review comment:
I went a step further, I ended up extracting the for loop into a
separate method.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]