2010-06-12 33 views
14

Tôi gặp vấn đề sau. Tôi muốn loại trừ một số tệp .java (**/jsfunit/*. Java) trong giai đoạn biên dịch thử nghiệm và ở phía bên kia tôi muốn bao gồm chúng trong giai đoạn biên dịch (id i start tomcat with tomcat: run khung thành)maven-compiler-plugin loại trừ

pom.xml My

<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> 

Nhưng nó không hoạt động: loại trừ trong mặc định-testCompile thực hiện không lọc các lớp này. Nếu tôi xóa các nhận xét thì tất cả các lớp khớp với **/jsfunit/*. Java sẽ được biên dịch nhưng chỉ khi tôi chạm vào chúng!

+0

Đường dẫn chính xác cho tệp jsfunit (liên quan đến '$ {basedir}') là gì? –

+0

src/main/java/de/hska/repo/ui/jsfunit – easyrider

+1

Tôi không hiểu. 'compiler: testCompile' * biên dịch các nguồn thử nghiệm ứng dụng * (tức là các nguồn thử nghiệm trong' src/test/main') do đó không có gì để loại trừ. Vấn đề chính xác là gì? Bạn đang cố gắng giải quyết vấn đề gì? –

Trả lời

29

Để loại trừ tệp khỏi giai đoạn mặc định-testCompile, bạn phải sử dụng <testExcludes>. Vì vậy, ví dụ của bạn ở trên sẽ trông giống như vậy:

<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>