0

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?

klenwell
  • 6,978
  • 4
  • 45
  • 84

2 Answers2

3

It is not a good idea to mix source and test classes. As per maven convention, you should move the tests from src/main/java to src/test/java.

You should add the dependency for junit so that the tests can be compiled.

You can choose to skip the tests (if they are broken) by using the -DskipTests or similar while running maven.

Raghuram
  • 51,854
  • 11
  • 110
  • 122
0

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>
klenwell
  • 6,978
  • 4
  • 45
  • 84