5
5
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
6
6
*/
7
7
8
+ apply from : rootProject. file( ' gradle/releasable.gradle' )
8
9
apply from : rootProject. file( ' gradle/java-module.gradle' )
9
- apply from : rootProject. file( ' gradle/publishing.gradle' )
10
+ apply from : rootProject. file( ' gradle/publishing-pom .gradle' )
10
11
11
- tasks . register( " publishReleaseArtifacts " ) {
12
- // mirror for `:release:publishReleaseArtifacts`
13
- dependsOn tasks . release
14
- }
12
+ apply plugin : ' signing '
13
+
14
+ // Make sure that the publishReleaseArtifacts task of the release module runs the release task of this sub module
15
+ tasks . getByPath( ' :release:publishReleaseArtifacts ' ) . dependsOn tasks . release
15
16
16
17
configurations {
17
18
javadocSources {
18
- description = " All Java sources for the project's Javadoc"
19
- canBeConsumed = true
20
- canBeResolved = false
21
- visible = false
19
+ description ' Used to aggregate javadocs for the whole project'
22
20
}
23
21
}
24
22
@@ -38,16 +36,127 @@ java {
38
36
withSourcesJar()
39
37
}
40
38
39
+ publishing {
40
+ publications {
41
+ // main publication
42
+ publishedArtifacts {
43
+ from components. java
44
+ }
45
+
46
+ // relocation for the published artifacts based on the old groupId
47
+ relocationPom( MavenPublication ) {
48
+ pom {
49
+ name = project. name + ' - relocation'
50
+ groupId = ' org.hibernate'
51
+ artifactId = project. name
52
+ version = project. version
53
+
54
+ description = project. description
55
+ url = ' https://hibernate.org/orm'
56
+
57
+ organization {
58
+ name = ' Hibernate.org'
59
+ url = ' https://hibernate.org'
60
+ }
61
+
62
+ licenses {
63
+ license {
64
+ name = ' GNU Library General Public License v2.1 or later'
65
+ url = ' https://www.opensource.org/licenses/LGPL-2.1'
66
+ comments = ' See discussion at https://hibernate.org/community/license/ for more details.'
67
+ distribution = ' repo'
68
+ }
69
+ }
70
+
71
+ scm {
72
+ url = ' https://github.com/hibernate/hibernate-orm'
73
+ connection = ' scm:git:https://github.com/hibernate/hibernate-orm.git'
74
+ developerConnection
= ' scm:git:[email protected] :hibernate/hibernate-orm.git'
75
+ }
76
+
77
+ developers {
78
+ developer {
79
+ id = ' hibernate-team'
80
+ name = ' The Hibernate Development Team'
81
+ organization = ' Hibernate.org'
82
+ organizationUrl = ' https://hibernate.org'
83
+ }
84
+ }
85
+
86
+ issueManagement {
87
+ system = ' jira'
88
+ url = ' https://hibernate.atlassian.net/browse/HHH'
89
+ }
90
+
91
+ distributionManagement {
92
+ relocation {
93
+ groupId = ' org.hibernate.orm'
94
+ artifactId = project. name
95
+ version = project. version
96
+ }
97
+ }
98
+ }
99
+ }
100
+ }
101
+ }
102
+
103
+
104
+
105
+
106
+
41
107
42
108
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
43
- // Publishing
109
+ // Signing
110
+
44
111
112
+ def signingKey = resolveSigningKey()
113
+ def signingPassphrase = resolveSigningPassphrase()
114
+
115
+ var signingExtension = project. getExtensions(). getByType(SigningExtension ) as SigningExtension
45
116
var publishingExtension = project. getExtensions(). getByType(PublishingExtension ) as PublishingExtension
46
- publishingExtension. publications. named(" publishedArtifacts" , MavenPublication ) {
47
- // Add the Java component to the main publication
48
- from components. java
117
+ signingExtension. sign publishingExtension. publications. publishedArtifacts
118
+ signingExtension. useInMemoryPgpKeys(signingKey, signingPassphrase)
119
+
120
+ gradle. taskGraph. whenReady { TaskExecutionGraph graph ->
121
+ boolean wasPublishingRequested = false
122
+
123
+ graph. allTasks. each {task ->
124
+ if ( task instanceof PublishToMavenRepository ) {
125
+ wasPublishingRequested = true
126
+ }
127
+ }
128
+
129
+ if ( wasPublishingRequested ) {
130
+ def ossrhUser = System . getenv(). get( " ORG_GRADLE_PROJECT_sonatypeUsername" )
131
+ def ossrhPass = System . getenv(). get( " ORG_GRADLE_PROJECT_sonatypePassword" )
132
+ if ( ossrhUser == null || ossrhPass == null ) {
133
+ throw new RuntimeException ( " Cannot perform publishing to OSSRH without credentials." )
134
+ }
135
+ logger. lifecycle " Publishing {} : {} : {}" , project. group, project. name, project. version
136
+ signingExtension. required = true
137
+ }
138
+ else if ( signingKey == null || signingPassphrase == null ) {
139
+ tasks. withType( Sign ). each { t -> t. enabled = false }
140
+ }
141
+ }
142
+
143
+ static String resolveSigningKey () {
144
+ var key = System . getenv(). get( " SIGNING_GPG_PRIVATE_KEY" )
145
+ if ( key != null ) {
146
+ return key
147
+ }
148
+
149
+ var keyFile = System . getenv(). get( " SIGNING_GPG_PRIVATE_KEY_PATH" )
150
+ if ( keyFile != null ) {
151
+ return new File ( keyFile ). text
152
+ }
153
+
154
+ return null
49
155
}
50
156
157
+ static String resolveSigningPassphrase () {
158
+ return System . getenv(). get( " SIGNING_GPG_PASSPHRASE" )
159
+ }
51
160
52
161
53
162
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -62,6 +171,21 @@ tasks.release.dependsOn tasks.test, tasks.publishToSonatype
62
171
tasks. preVerifyRelease. dependsOn build
63
172
tasks. preVerifyRelease. dependsOn generateMetadataFileForPublishedArtifactsPublication
64
173
tasks. preVerifyRelease. dependsOn generatePomFileForPublishedArtifactsPublication
174
+ tasks. preVerifyRelease. dependsOn generatePomFileForRelocationPomPublication
65
175
66
176
tasks. publishToSonatype. mustRunAfter test
67
177
178
+
179
+ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
180
+ // Ancillary tasks
181
+
182
+ task showPublications {
183
+ doFirst {
184
+ project. publishing. publications. each { publication ->
185
+ println " Publication (${ publication.name} ): ${ publication.groupId} :${ publication.artifactId} :${ publication.version} "
186
+ publication. artifacts. each { artifact ->
187
+ println " > ${ artifact} "
188
+ }
189
+ }
190
+ }
191
+ }
0 commit comments