Skip to content

Commit 26147ba

Browse files
marko-bekhtakoentsje
authored andcommitted
HBX-3114 Include license file in the META-INF of published artifacts (#5459)
1 parent 667771c commit 26147ba

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
@@ -96,6 +96,15 @@ tasks.named('publishPlugins') {
9696
}
9797
}
9898

99+
var rootPath = findProperty("mavenRootDirectory")
100+
jar {
101+
metaInf {
102+
from(rootPath, {
103+
include "LICENSE.txt"
104+
})
105+
}
106+
}
107+
99108
publishing {
100109
publications {
101110
pluginMaven(MavenPublication) {

gradle/pom.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
<argument>-PprojectVersion=${project.version}</argument>
7171
<argument>-Ph2Version=${h2.version}</argument>
7272
<argument>-Dmaven.repo.local=${settings.localRepository}</argument>
73+
<argument>-PmavenRootDirectory=${rootProject.directory}</argument>
7374
</arguments>
7475
</configuration>
7576
<goals>
@@ -122,6 +123,7 @@
122123
<argument>-PprojectVersion=${project.version}</argument>
123124
<argument>-Ph2Version=${h2.version}</argument>
124125
<argument>-Dmaven.repo.local=${settings.localRepository}</argument>
126+
<argument>-PmavenRootDirectory=${rootProject.directory}</argument>
125127
<argument>-PmavenStagingDirectory=${local.staging.releases.repo.url}</argument>
126128
</arguments>
127129
</configuration>

pom.xml

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

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

157169
<dependencyManagement>
@@ -315,6 +327,20 @@
315327
</distributionManagement>
316328

317329
<build>
330+
<resources>
331+
<resource>
332+
<!-- The default resource dir: -->
333+
<directory>${project.basedir}/src/main/resources</directory>
334+
</resource>
335+
<resource>
336+
<!-- Extra dir to include the license file: -->
337+
<directory>${rootProject.directory}</directory>
338+
<includes>
339+
<include>LICENSE.txt</include>
340+
</includes>
341+
<targetPath>META-INF</targetPath>
342+
</resource>
343+
</resources>
318344
<pluginManagement>
319345
<plugins>
320346
<plugin>
@@ -386,6 +412,21 @@
386412
</execution>
387413
</executions>
388414
</plugin>
415+
<plugin>
416+
<groupId>org.codehaus.mojo</groupId>
417+
<artifactId>build-helper-maven-plugin</artifactId>
418+
<executions>
419+
<execution>
420+
<id>set-root-location-property</id>
421+
<goals>
422+
<goal>rootlocation</goal>
423+
</goals>
424+
<configuration>
425+
<rootLocationProperty>rootProject.directory</rootLocationProperty>
426+
</configuration>
427+
</execution>
428+
</executions>
429+
</plugin>
389430
</plugins>
390431
</build>
391432

0 commit comments

Comments
 (0)