2012-05-21 52 views
2

我設法從 「的src/main/java的」 排除文件使用以下行:如何使用Maven從我的類路徑中的測試文件夾中排除源代碼?

<classpathentry excluding="**/MyExcludedFile.java" kind="src" output="target/classes" path="src/main/java"/> 
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/> 
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/> 
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/> 

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-compiler-plugin</artifactId> 
    <configuration> 
     <source>1.5</source> 
     <target>1.5</target> 
      <excludes> 
      <exclude>**/MyExcludedFile.java</exclude> 
     </excludes> 
    </configuration> 
</plugin> 

補充說,行家生成我.classpath文件的下列行後現在我該如何爲src/test/java做同樣的事情?

我期待這樣的事情在我的.classpath文件:

<classpathentry excluding="**/MyExcludedFile.java" kind="src" output="target/classes" path="src/main/java"/> 
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/> 
<classpathentry excluding="**/MyExcludedFileTest.java" kind="src" output="target/test-classes" path="src/test/java"/> 
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/> 

以在第三行看看。我希望這個 - > [exclude =「**/MyExcludedFileTest.java」]位於我的.classpath文件中。我該如何告訴maven做到這一點?

回答

3

使用<testExcludes>

Q&A應該幫助。

+0

謝謝合作!正是我需要的。 – supertonsky

0

對我來說,它沒有通過處理testExcludes而是直接新手修改eclipse插件配置

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-eclipse-plugin</artifactId> 
    <configuration> 
     <sourceExcludes> 
      <exclude>**/MyExcludedFile.java</exclude> 
     </sourceExcludes> 
    </configuration> 
</plugin> 
相關問題