Overlays for different maven Profiles

I want to have different configurations for different build types. I implemented my build types as maven profiles that mutually exclude each other with development as a default. My directory structure looks something like:
...
resources
development
...
testing
...
release
...
...
resources
development
...
testing
...
release
...
I tried to set the matching directory as the resource root. But that did not work at all... I was trying to find an example with the shade plugin, since it will be used anyways to build a fat jar. If you know of an example i would be glad. Nonetheless would I prefer to overlay the resource directory with the special build type directories. I am dumb in regards to maven, so I don't even know how to google for that. If there is nothing, I would be able to build my own plugin.
3 Replies
JavaBot
JavaBot2y ago
This post has been reserved for your question.
Hey @NeoCortex97! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
NeoCortex97
NeoCortex97OP2y ago
This is a simplified version of my pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.example</groupId>
<artifactId>mavenStructureTest</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<profiles>
<profile>
<id>release</id>
<activation>
<property><name>release</name><value>true</value></property>
</activation>
<build>
<resources>
<resource>
<directory>${project.basedir}/resources/release</directory>
<targetPath>${project.build.directory}</targetPath>
<includes><include>**/*</include></includes>
</resource>
</resources>
</build>
</profile>
<profile>
<id>debug</id>
<activation>
<activeByDefault>true</activeByDefault>
<property><name>release</<value>false</value></property>
</activation>
<build>
<resources>
<resource>
<directory>${project.basedir}/resources/debug</directory>
<targetPath>${project.build.directory}</targetPath>
<includes><include>**/*</include></includes>
</resource>
</resources>
</build>
</profile>
</profiles>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.example</groupId>
<artifactId>mavenStructureTest</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<profiles>
<profile>
<id>release</id>
<activation>
<property><name>release</name><value>true</value></property>
</activation>
<build>
<resources>
<resource>
<directory>${project.basedir}/resources/release</directory>
<targetPath>${project.build.directory}</targetPath>
<includes><include>**/*</include></includes>
</resource>
</resources>
</build>
</profile>
<profile>
<id>debug</id>
<activation>
<activeByDefault>true</activeByDefault>
<property><name>release</<value>false</value></property>
</activation>
<build>
<resources>
<resource>
<directory>${project.basedir}/resources/debug</directory>
<targetPath>${project.build.directory}</targetPath>
<includes><include>**/*</include></includes>
</resource>
</resources>
</build>
</profile>
</profiles>
</project>
JavaBot
JavaBot2y ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one.
Want results from more Discord servers?
Add your server