maven

Maven: excluding java files in compilation


I have a folder of java sources which I wish to exclude from the compilation.

My folder is under qa/apitests/src/main/java/api/test/omi.

I added the following entry in the pom.xml under qa/bamtests but it didn't help. Is there an entry in addition I need to make?

       <build>
         <resources>
           <resource>
             <directory>src/main/java</directory>
             <includes>
               <include>**/*.properties</include>
               <include>**/*.xml</include>
               <include>**/*.xsd</include>
               <include>**/*.csv</include>
             </includes>
             <excludes>
               <exclude>src/main/java/api/test/omi</exclude>
             </excludes>
           </resource>
        </build>

Solution

  • Use the Maven Compiler Plugin.

    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-compiler-plugin</artifactId>
      <configuration>
        <excludes>
          <exclude>**/api/test/omi/*.java</exclude>
        </excludes>
      </configuration>
    </plugin>