What the easiest/right way to conditionally exclude a java file from compilation in a maven project?
I would like to be able to set a ‘boolean’ properties in the pom.xml:
<properties>
<IncludeMayBe>true</IncludeMayBe>
</properties>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<excludes>
????
</excludes>
</configuration>
</plugin>
Is there a way to fiddle something with the compiler plugin? Or should I go for profiles? I feel like creating a profile is overkill, but may be this is the only solution…
EDIT:
We have established that profiles are the solution. For conditional activation from within the pom.xml, one can use the following:
<profiles>
<profile>
<activation>
<property>
<IncludeMayBe>true</IncludeMayBe>
</property>
</activation>
...
</profile>
</profiles>
I suggest you use the Build helper maven plugin.
Using this, you can have several source directories.
Then you can control what source directories are included using profiles.
Assuming you have your monitoring classes under src/monitoring/java you could add the following to the element in your pom.xml