Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven: excluding java files in compilation

Tags:

maven

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> 
like image 945
constantlearner Avatar asked Jul 29 '13 09:07

constantlearner


People also ask

Does maven compile Java?

The package goal will compile your Java code, run any tests, and finish by packaging the code up in a JAR file within the target directory. The name of the JAR file will be based on the project's <artifactId> and <version> . For example, given the minimal pom.

Does maven depend on Java?

Maven is a Java tool, so you must have Java installed in order to proceed. Depending upon your network setup, you may require extra configuration. Check out the Guide to Configuring Maven if necessary.

What is default compile in Maven?

The Compiler Plugin is used to compile the sources of your project. Since 3.0, the default compiler is javax. tools. JavaCompiler (if you are using java 1.6) and is used to compile Java sources.


2 Answers

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> 
like image 86
2 revs, 2 users 96%user1907906 Avatar answered Nov 24 '22 07:11

2 revs, 2 users 96%user1907906


Adding an exclude as the other answers suggested worked for me, except the path shouldn't include "src/main/java":

<build>   <plugins>     <plugin>       <groupId>org.apache.maven.plugins</groupId>       <artifactId>maven-compiler-plugin</artifactId>       <configuration>         <excludes>           <exclude>com/filosync/store/StoreMain.java</exclude>         </excludes>       </configuration>     </plugin>   </plugins> </build> 
like image 37
Stefan Avatar answered Nov 24 '22 07:11

Stefan