Resolve "Improve provided licenses in standalone JAR (Github 173)"

This commit is contained in:
Philip Helger 2026-02-17 16:11:11 +01:00
parent c5c40c2009
commit 752ceb228d
9 changed files with 257 additions and 35 deletions

52
pom.xml
View file

@ -206,6 +206,33 @@
</configuration>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.4.0</version>
<executions>
<execution>
<id>copy-license-notice</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.outputDirectory}/META-INF</outputDirectory>
<resources>
<resource>
<directory>${project.basedir}</directory>
<includes>
<include>NOTICE</include>
</includes>
</resource>
</resources>
<overwrite>true</overwrite>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
@ -290,14 +317,39 @@
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>de.kosit.validationtool.cmd.CommandLineApplication</mainClass>
</transformer>
<!--
Some open source producers (including the Apache Software Foundation) include a copy of their
license in the META-INF directory. These are conventionally named either LICENSE,LICENSE.txt
or LICENSE.md. When merging these dependencies, adding these resources may cause confusion.
The ApacheLicenseResourceTransformer ensures that duplicate licenses (named according to this
convention) are not merged.
Technically it simply avoids adding them into the final JAR.
We don't need the detailed licensed in the shaded JAR.
-->
<transformer implementation="org.apache.maven.plugins.shade.resource.ApacheLicenseResourceTransformer" />
<!--
Some licenses (including the Apache License, Version 2) require that notices are preserved by
downstream distributors. ApacheNoticeResourceTransformer automates the assembly of an
appropriate NOTICE.
Technically it merges all NOTICE files together
-->
<transformer implementation="org.apache.maven.plugins.shade.resource.ApacheNoticeResourceTransformer">
<addHeader>false</addHeader>
</transformer>
</transformers>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<!-- E.g. MANIFEST.MF -->
<exclude>META-INF/*.MF</exclude>
<!-- Required for JAR signing artefacts -->
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
<!-- We're breaking the Java module system -->
<exclude>**/module-info.class</exclude>
</excludes>
</filter>