I have a parent pom which defines profiles which shall be activated, when the defined folder exists:
<groupId>common</groupId>
<artifactId>common-build</artifactId>
<profiles>
<profile>
<id>dependency-profile-ejb</id>
<activation>
<file>
<exists>${basedir}/src/profile/dependency-ejb/</exists>
</file>
</activation>
<dependencies>[...]</dependencies>
</profile>
<profile>
<id>dependency-profile-jsf</id>
<activation>
<file>
<exists>${basedir}/src/profile/dependency-jsf/</exists>
</file>
</activation>
<dependencies>[...]</dependencies>
</profile>
</profiles>
I have a maven project with several submodules:
<parent>
<groupId>common</groupId>
<artifactId>common-build</artifactId>
</parent>
<groupId>project/groupId>
<artifactId>project-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<modules>
<module>project-child-one<module>
</modules>
In the child project I just define the parent dependency:
<parent>
<groupId>project</groupId>
<artifactId>project-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>project-child-one</artifactId>
and in this child project I have defined the folder src/profile/dependency-ejb
.
If I run the build of the projects in eclipse everything works as expected. I have then installed the project in jenkins, but the build fails. If I checkout the project-parent
into a clean directory and try to run a maven build, the build fails, too.
Why does the build run in eclipse but not in command line? Why is the profile definition in the parent pom of common-build
not respected?
After some further tests I found the solution. The build failed, because the folders for the profile activation were missing. I have added the project to git and forgot that git does not commit/push empty folders.
The solution is to add an empty .gitkeep
in the folders to force git to commit/push them.