Skip to content

Commit 15c6365

Browse files
marko-bekhtakoentsje
authored andcommitted
HBX-3114 Include license file in the META-INF of published artifacts (#5459)
1 parent 262b733 commit 15c6365

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

gradle/plugin/build.gradle

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,15 @@ tasks.named('publishPlugins') {
7575
}
7676
}
7777

78+
var rootPath = findProperty("mavenRootDirectory")
79+
jar {
80+
metaInf {
81+
from(rootPath, {
82+
include "LICENSE.txt"
83+
})
84+
}
85+
}
86+
7887
publishing {
7988
publications {
8089
pluginMaven(MavenPublication) {

gradle/pom.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
<arguments>
8484
<argument>clean</argument>
8585
<argument>-Pversion=${project.version}</argument>
86+
<argument>-PmavenRootDirectory=${rootProject.directory}</argument>
8687
</arguments>
8788
</configuration>
8889
<goals>
@@ -119,6 +120,7 @@
119120
<argument>publishPluginMavenPublicationToStagingRepository</argument>
120121
<argument>-Pversion=${project.version}</argument>
121122
<argument>-Dmaven.repo.local=${settings.localRepository}</argument>
123+
<argument>-PmavenRootDirectory=${rootProject.directory}</argument>
122124
<argument>-PmavenStagingDirectory=${local.staging.releases.repo.url}</argument>
123125
</arguments>
124126
</configuration>

pom.xml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,18 @@
150150
<maven.min.version>${maven.version}</maven.min.version>
151151
<maven-core.version>${maven.version}</maven-core.version>
152152

153+
<!--
154+
The absolute path to the root project directory.
155+
This property is set by the build-helper plugin.
156+
We initialize it to some crude, potentially wrong value,
157+
because the Sonar Maven plugin uses this property indirectly,
158+
but ignores any change made by other plugins.
159+
This default value is the best we can do without the help of a Maven plugin.
160+
161+
Useful resources:
162+
- https://www.mojohaus.org/build-helper-maven-plugin/rootlocation-mojo.html
163+
-->
164+
<rootProject.directory>${user.dir}</rootProject.directory>
153165
</properties>
154166

155167
<dependencyManagement>
@@ -298,6 +310,20 @@
298310
</distributionManagement>
299311

300312
<build>
313+
<resources>
314+
<resource>
315+
<!-- The default resource dir: -->
316+
<directory>${project.basedir}/src/main/resources</directory>
317+
</resource>
318+
<resource>
319+
<!-- Extra dir to include the license file: -->
320+
<directory>${rootProject.directory}</directory>
321+
<includes>
322+
<include>LICENSE.txt</include>
323+
</includes>
324+
<targetPath>META-INF</targetPath>
325+
</resource>
326+
</resources>
301327
<pluginManagement>
302328
<plugins>
303329
<plugin>
@@ -369,6 +395,21 @@
369395
</execution>
370396
</executions>
371397
</plugin>
398+
<plugin>
399+
<groupId>org.codehaus.mojo</groupId>
400+
<artifactId>build-helper-maven-plugin</artifactId>
401+
<executions>
402+
<execution>
403+
<id>set-root-location-property</id>
404+
<goals>
405+
<goal>rootlocation</goal>
406+
</goals>
407+
<configuration>
408+
<rootLocationProperty>rootProject.directory</rootLocationProperty>
409+
</configuration>
410+
</execution>
411+
</executions>
412+
</plugin>
372413
</plugins>
373414
</build>
374415

0 commit comments

Comments
 (0)