0

我想使用 maven 从命令行构建我的游戏的 html 版本。但是,当我package为文件夹运行命令时core

mvn clean package -pl core,html

由于源路径中的一些单元测试,我收到以下错误:

[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

...

如何将包含这些测试文件的目录排除在编译中?

4

2 回答 2

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.

于 2012-06-07T04:15:53.733 回答
0

将以下块添加到plugins我的核心pom.xml文件部分,从编译中排除测试并允许构建成功:

  <plugin>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
      <excludes>
        <exclude>**/*Test*.java</exclude>
      </excludes>
    </configuration>
  </plugin>
于 2012-06-07T00:49:21.330 回答