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