Skip to content

Commit

Permalink
Merge pull request #18 from ResilientGroup/TASK-4017/inheritResources
Browse files Browse the repository at this point in the history
TASK-4017 fixed resources not correctly working
  • Loading branch information
Wolf2323 authored Mar 27, 2024
2 parents 81382fa + edc49c0 commit 5307094
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 42 deletions.
26 changes: 0 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,3 @@ it is not guaranteed that the maven version you have installed on your system is
For that, a maven wrapper is recommended to be used.

It is strongly recommended to use the wrapper in any automated build process, as it ensures that the correct maven version is used.

## Adding resources to your jar
First of all, `scr/main/resources` is the default location for resources in a maven project,
and is already added to the jar in the parent pom.
The `build.resources` can not be used, as the merging with a parent pom actually overrides the resources from the parent pom.
Therefore, you need to use the `maven-resources-plugin`, to add more resources to the jar.
This is done by adding the following to your pom.xml:
```xml
<project>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<resources>
<resource>
<directory>MyResourceDir</directory>
</resource>
</resources>
</configuration>
</plugin>
</plugins>
</build>
</project>
```
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions Configs/pom.xml → configs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>works.reload.parent</groupId>
<artifactId>versions</artifactId>
<version>${revision}${changelist}</version>
<relativePath>../Versions/pom.xml</relativePath>
<relativePath>../versions/pom.xml</relativePath>
</parent>

<artifactId>configs</artifactId>
Expand All @@ -16,7 +16,7 @@

<properties>
<!-- project version -->
<revision>1.0.4</revision>
<revision>1.0.5</revision>
<changelist>-SNAPSHOT</changelist>
</properties>

Expand Down
File renamed without changes.
50 changes: 37 additions & 13 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>works.reload.parent</groupId>
<artifactId>versions</artifactId>
<version>${revision}${changelist}</version>
<relativePath>./Versions/pom.xml</relativePath>
<relativePath>./versions/pom.xml</relativePath>
</parent>

<groupId>works.reload</groupId>
Expand All @@ -18,7 +18,7 @@

<properties>
<!-- project version -->
<revision>1.0.4</revision>
<revision>1.0.5</revision>
<changelist>-SNAPSHOT</changelist>
<!-- dependencyManagement versions -->
<jetbrains-annotations.version>24.1.0</jetbrains-annotations.version>
Expand Down Expand Up @@ -49,8 +49,8 @@
</properties>

<modules>
<module>Versions</module>
<module>Configs</module>
<module>versions</module>
<module>configs</module>
</modules>

<pluginRepositories>
Expand Down Expand Up @@ -141,7 +141,6 @@
</dependencyManagement>

<build>
<finalName>${project.name}-${project.version}</finalName>
<pluginManagement>
<plugins>
<plugin>
Expand Down Expand Up @@ -315,14 +314,39 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<resources combine.children="append">
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
<executions>
<execution>
<id>copy-resources</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.outputDirectory}</outputDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
<execution>
<id>copy-test-resources</id>
<phase>process-test-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.testOutputDirectory}</outputDirectory>
<resources>
<resource>
<directory>src/test/resources</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
2 changes: 1 addition & 1 deletion Versions/pom.xml → versions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<properties>
<!-- project version -->
<revision>1.0.4</revision>
<revision>1.0.5</revision>
<changelist>-SNAPSHOT</changelist>
<!-- project settings -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down

0 comments on commit 5307094

Please sign in to comment.