Commit e8d476db authored by Stephane Nicoll's avatar Stephane Nicoll

Fix use of `forceCreation` flag in `maven-jar-plugin`

parent fcb405eb
...@@ -2737,7 +2737,10 @@ Often if you have an executable and a non-executable jar as build products, the ...@@ -2737,7 +2737,10 @@ Often if you have an executable and a non-executable jar as build products, the
version will have additional configuration files that are not needed in a library jar. version will have additional configuration files that are not needed in a library jar.
E.g. the `application.yml` configuration file might excluded from the non-executable JAR. E.g. the `application.yml` configuration file might excluded from the non-executable JAR.
Here's how to do that in Maven: The `maven-jar-plugin` used to expose a `forceCreation` attribute that allows you to
create the jar _again_ once the `repackage` goal has ran. Arguably, this was a bit fragile
anyway since it was relying on the order of plugin executions. In Maven, the executable
jar must be the main artifact and you can add a classified jar for the library:
[source,xml,indent=0,subs="verbatim,quotes,attributes"] [source,xml,indent=0,subs="verbatim,quotes,attributes"]
---- ----
...@@ -2746,31 +2749,18 @@ Here's how to do that in Maven: ...@@ -2746,31 +2749,18 @@ Here's how to do that in Maven:
<plugin> <plugin>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId> <artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<classifier>exec</classifier>
</configuration>
</plugin> </plugin>
<plugin> <plugin>
<artifactId>maven-jar-plugin</artifactId> <artifactId>maven-jar-plugin</artifactId>
<executions> <executions>
<execution> <execution>
<id>exec</id> <id>lib</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>exec</classifier>
</configuration>
</execution>
<execution>
<phase>package</phase> <phase>package</phase>
<goals> <goals>
<goal>jar</goal> <goal>jar</goal>
</goals> </goals>
<configuration> <configuration>
<!-- Need this to ensure application.yml is excluded --> <classifier>lib</classifier>
<forceCreation>true</forceCreation>
<excludes> <excludes>
<exclude>application.yml</exclude> <exclude>application.yml</exclude>
</excludes> </excludes>
......
...@@ -34,31 +34,17 @@ ...@@ -34,31 +34,17 @@
<plugin> <plugin>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId> <artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<classifier>exec</classifier>
</configuration>
</plugin> </plugin>
<plugin> <plugin>
<artifactId>maven-jar-plugin</artifactId> <artifactId>maven-jar-plugin</artifactId>
<executions> <executions>
<execution> <execution>
<id>exec</id> <id>lib</id>
<phase>package</phase>
<goals> <goals>
<goal>jar</goal> <goal>jar</goal>
</goals> </goals>
<configuration> <configuration>
<classifier>exec</classifier> <classifier>lib</classifier>
</configuration>
</execution>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<!-- Need this to ensure application.yml is excluded -->
<forceCreation>true</forceCreation>
<excludes> <excludes>
<exclude>application.yml</exclude> <exclude>application.yml</exclude>
</excludes> </excludes>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment