Skip to content

Commit ca0481e

Browse files
marko-bekhtakoentsje
authored andcommitted
HBX-3114 Include license file in the META-INF of published artifacts (hibernate#5459)
1 parent 4717078 commit ca0481e

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
@@ -79,6 +79,15 @@ tasks.named('publishPlugins') {
7979
}
8080
}
8181

82+
var rootPath = findProperty("mavenRootDirectory")
83+
jar {
84+
metaInf {
85+
from(rootPath, {
86+
include "LICENSE.txt"
87+
})
88+
}
89+
}
90+
8291
publishing {
8392
publications {
8493
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
@@ -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)