Search code examples
mavenplayn

In PlayN, how do you exclude a directory from being compiled by Maven?


I want to build the html version of my game from the command line using maven. However, when I run the package command for the core folder:

mvn clean package -pl core,html

I get the following errors because of some unit tests in my source path:

[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /home/klenwell/projects/mygame/playn/mygame/core/src/main/java/mygame/playn/tests/unit/UserDataTest.java:[3,23] package org.junit does not exist

[ERROR] /home/klenwell/projects/mygame/playn/mygame/core/src/main/java/mygame/playn/tests/unit/UserDataTest.java:[7,16] package org.junit does not exist

...

How can I exclude the directory with these test files from being included in the compilation?


Solution

  • Adding the following block to the plugins section of my core pom.xml file excluded tests from compilation and allowed the build to succeed:

      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <excludes>
            <exclude>**/*Test*.java</exclude>
          </excludes>
        </configuration>
      </plugin>