Reputation: 528
In my pom.xml file, I have:
<build>
<sourceDirectory>src</sourceDirectory>
<resources> .. </resources>
<plugins> .. </plugins>
</build>
However, When I try to use maven profiles:
<profiles>
<profile>
<id>profileId</id>
<build>
<sourceDirectory>src</sourceDirectory>
<resources> .. </resources>
<plugins> .. </plugins>
</build>
</profile>
</profiles>
Maven gives me an error saying:
Unrecognised tag: 'sourceDirectory' (position: START_TAG seen ...<build>\r\n <sourceDirectory>... @14:34)
Why wouldn't it let me define a source directory within a profile? Is there a way to define sourceDirectory in profiles?
Upvotes: 1
Views: 3925
Reputation: 3799
According to the documentation, you can change only few 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
) and 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>
Upvotes: 2