【问题标题】:maven-compiler-plugin excludemaven-compiler-plugin 排除
【发布时间】:2010-06-12 12:08:03
【问题描述】:

我有以下问题。 我想在测试编译阶段排除一些 .java 文件(**/jsfunit/*.java),另一方面我想在编译阶段包含它们(id 我用 tomcat:run 目标启动 tomcat )

我的 pom.xml

<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
                 <!-- <excludes>
                     <exclude>**/*JSFIntegration*.java</exclude>
                 </excludes> -->                    
            </configuration>
           <executions>
           <!-- <execution>
                        <id>default-compile</id>
                        <phase>compile</phase>
                        <goals>
                          <goal>compile</goal>
                        </goals>
                        <configuration>
                            <includes>
                                 <include>**/jsfunit/*.java</include>
                            </includes>
                        </configuration>
               </execution>-->
              <execution>
                        <id>default-testCompile</id>
                        <phase>test-compile</phase>
                        <configuration>
                            <excludes>
                                <exclude>**/jsfunit/*.java</exclude>
                            </excludes>
                        </configuration> 
                        <goals>

                <goal>testCompile</goal>
                        </goals>
                </execution>                  
             </executions>

        </plugin>

但它不起作用:default-testCompile 执行中的 exclude 不会过滤这些类。 如果我删除 cmets,那么所有匹配 **/jsfunit/*.java 的类都会被编译,但前提是我触摸它们!

【问题讨论】:

  • jsfunit 文件的具体路径是什么(相对于${basedir})?
  • src/main/java/de/hska/repo/ui/jsfunit
  • 我不明白。 compiler:testCompile 编译应用程序测试源(即src/test/main下的测试源),所以没有什么可以排除的。究竟是什么问题?你想解决什么问题?
  • 嗯..你是对的。我的问题是:jsfunit 使用 junit3,但我们的 junit 测试使用 junit4。在 pom.xml 中我不能包含 junit3 和 junit4 依赖项,如果我尝试运行 junit 测试,编译器无法从 jsfunit/package 编译文件,因为类路径中只有 junit4(但不是 junit3)
  • 但如果我运行 tomcat:run 目标,我需要 jsfunit 包中的类

标签: compilation maven-2


【解决方案1】:

要从 default-testCompile 阶段排除文件,您必须使用&lt;testExcludes&gt;。所以你上面的例子看起来像这样:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-compiler-plugin</artifactId>
  <configuration>
    <source>1.6</source>
    <target>1.6</target>
  </configuration>
  <executions>
    <execution>
      <id>default-testCompile</id>
      <phase>test-compile</phase>
      <configuration>
        <testExcludes>
          <exclude>**/jsfunit/*.java</exclude>
        </testExcludes>
      </configuration> 
      <goals>
        <goal>testCompile</goal>
      </goals>
    </execution>                  
  </executions>
</plugin>

【讨论】:

    猜你喜欢
    • 2015-06-13
    • 2020-12-22
    • 1970-01-01
    • 2014-02-23
    • 2014-03-10
    • 1970-01-01
    • 1970-01-01
    • 2013-01-14
    • 2016-09-17
    相关资源
    最近更新 更多