javascalamavenscala-maven-plugin

How to prevent scala-maven-plugin from compiling Java sources?


There is a mixed (Java + Scala) Maven project.
Only a small part is written in Scala and it does not depend on Java code.
Java code depends on compilation results of the Scala part.

I'm looking for a way to compile in two steps:

  1. compile only Scala code (using scala-maven-plugin)
  2. compile only Java code (using maven-compiler-plugin)

By default scala-maven-plugin compiles everything in src/main/java, src/main/scala
and it would be great to have an option to alter this behaviour.

Tried to search in documentation, but did not manage to find any mentions of how to exclude sources from compilation.

How to configure scala-maven-plugin so it would compile only Scala source code?


Solution

  • From this snippet in an integration test:

    <configuration>
        <includes>
            <include>**/*.scala</include>
            <include>**/TestClass.java</include>
        </includes>
        <excludes>
            <exclude>bad.scala</exclude>
        </excludes>
    </configuration>
    

    It appears that you can probably use the <excludes> tag inside <configuration> to exclude src/main/java/**/*.java.