Reputation: 11997
With javac, it is possible to implicitly compile java files to class files from a particular source tree. In other words, it's possible to point at a given source tree and only compile the java files that are required by the explicitly mentioned java files. Is it possible to get this same functionality when building with maven. And, if so, how would I go about doing this?
Edit: I am not speaking of defining a specific list of java source files. The standard java compiler allows for a switch which causes the compiler itself to determine the dependencies based upon the imports. If the imported classes cannot be found in the classpath, then the source path is examined to see if there is a java file for the given class. If there is, then that java file is added to the compilation.
Upvotes: 0
Views: 391
Reputation: 1888
For the maven-compiler-plugin you can use includes and excludes sets, where you can specify patters for file names for exclusion and inclusion to the compilation. You can also use Ant scripts.
For details see http://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html.
Upvotes: 0
Reputation: 7894
You will have to configure the maven compiler to set which files to include/exclude:
<project>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugi ns</groupId>
<artifactId>maven-compiler-plug in</artifactId>
<configuration>
<!-- put your configurations here -->
</configuration>
</plugin>
</plugins>
</build>
</project>
You could also do this for different maven profiles if you wanted to include/exclude different sets of files.
Upvotes: 1