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

孤街浪徒 提交于 2019-12-13 03:36:54

问题


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?


回答1:


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.




回答2:


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>


来源:https://stackoverflow.com/questions/10924298/in-playn-how-do-you-exclude-a-directory-from-being-compiled-by-maven

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!