Reputation: 145
We're currently migrating to JPMS setting up module-info.java for all modules in a maven multi-module project.
For us it would be ideal to have module-info.java already reside in "dev" branch but not affecting any builds. So idea is to exclude module-info.java by default and include it only in specific maven profiles.
Does that make sense?
Anyway, doesn't work for me, module-info.java is picked up even though in excludes section as follows:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${version.maven-compiler-plugin}</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<release>${maven.compiler.release}</release>
<compilerArgs>
<arg>-Xlint:${maven.compiler.warningsToIgnore}</arg>
</compilerArgs>
<excludes>
<exclude>**/module-info.java</exclude>
</excludes>
</configuration>
</plugin>
Any ideas?
PS: Idea was taken from How to exclude module-info.java in Netbeans (11)?
Upvotes: 2
Views: 1940
Reputation: 145
Still it's intersting that filter doesn't work for module-info.java, but looking the source of compiler plugin I guess that's just the way it is:
protected void preparePaths( Set<File> sourceFiles )
{
//assert compilePath != null;
File moduleDescriptorPath = null;
boolean hasModuleDescriptor = false;
for ( File sourceFile : sourceFiles )
{
if ( "module-info.java".equals( sourceFile.getName() ) )
{
moduleDescriptorPath = sourceFile;
hasModuleDescriptor = true;
break;
}
}
Upvotes: 2