// It is possible that we are building a multi-version jar file in which the main classes are not module based.
if ( ! mainModuleDescriptorClassFile.exists() && release != null )
{
// @todo does it really matter that we check the version?
int version = Integer.valueOf( release );
if ( version >= 9 )
{
String releaseOutputDirectory = String.format( "%s%sMETA-INF%sversions%s%d",
getProject().getBuild().getOutputDirectory(), File.separator, File.separator,
File.separator, version );
// @todo how to add the releaseOutputDirectory automatically?
// testPath.add( releaseOutputDirectory );
mainModuleDescriptorClassFile = new File ( releaseOutputDirectory, "module-info.class" );
if ( getLog().isDebugEnabled() )
{
getLog().debug( "Updated main module " + mainModuleDescriptorClassFile );
}
}
}
This was add after the initial for loop for the master branch (3.9.0-SNAPSHOT). I was able to get around the initial exception but alas I was still having issues building the test source. I then was able to get around the issue by adding the following compilerArgs to my pom file:
<compilerArgs>
<compilerArg>--module-path</compilerArg>
<compilerArg>${project.basedir}/target/classes/META-INF/versions/9</compilerArg>
</compilerArgs>
This allowed me to build the test source for that specific test module.
I then was wondering if there is a better solution to this issue and I noticed that if I added the releaseOutputDirectory to the testPath collection then the above compilerArgs would not be required to be able to build the test sources. My question then is, "Is their a better way then adding the directory to the testPath?". I worry that the above solution will not work in all cases and can be a maintenance nightmare. It seems that being forced to include the compileArgs to the test source build is a better overall solution.
Any opinions or comments on the above proposal?
I've attach the test pom and patched TestCompilerMojo files.
Thanks,
--Claudio