I want to use a different source directory for a specific maven profile, however, when I try to specify it in the profile definition I get this error:
Unreco
See Maven model, it is not allowed to define a sourceDirectory
within a profile. The only thing you can do is specify the sourceDirectory within the plugin configuration, assuming it is available.
According to the documentation, you can change only few <build>
parameters in the profile and <sourceDirectory>
is not one of them.
I'd configure the main <build>
to take sources from path defined by some property (eg. src.dir
), set this property to src/main/java
and override it in the custom profile:
<project>
...
<properties>
<src.dir>src/main/java</src.dir>
</properties>
<build>
<sourceDirectory>${src.dir}</sourceDirectory>
...
</build>
<profiles>
<profile>
<id>development</id>
<properties>
<src.dir>${project.build.directory}/new-src</src.dir>
</properties>
</profile>
</profiles>
</project>