55 * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
66 */
77
8- apply from : rootProject. file( ' gradle/releasable.gradle' )
98apply from : rootProject. file( ' gradle/java-module.gradle' )
10- apply from : rootProject. file( ' gradle/publishing-pom .gradle' )
9+ apply from : rootProject. file( ' gradle/publishing.gradle' )
1110
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+ }
1615
1716configurations {
1817 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
2022 }
2123}
2224
@@ -36,66 +38,12 @@ java {
3638// Publishing
3739
3840var publishingExtension = project. getExtensions(). getByType(PublishingExtension ) as PublishingExtension
39- publishingExtension. publications {
40- // main publication
41- publishedArtifacts {
42- // Add the Java component to the main publication
43- from components. java
44- }
41+ publishingExtension. publications. named(" publishedArtifacts" , MavenPublication ) {
42+ // Add the Java component to the main publication
43+ from components. java
4544}
4645
4746
48- // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
49- // Signing
50-
51- def signingKey = resolveSigningKey()
52- def signingPassphrase = resolveSigningPassphrase()
53-
54- var signingExtension = project. getExtensions(). getByType(SigningExtension ) as SigningExtension
55- signingExtension. sign publishingExtension. publications. publishedArtifacts
56- signingExtension. useInMemoryPgpKeys(signingKey, signingPassphrase)
57-
58- gradle. taskGraph. whenReady { TaskExecutionGraph graph ->
59- boolean wasPublishingRequested = false
60-
61- graph. allTasks. each {task ->
62- if ( task instanceof PublishToMavenRepository ) {
63- wasPublishingRequested = true
64- }
65- }
66-
67- if ( wasPublishingRequested ) {
68- def ossrhUser = System . getenv(). get( " ORG_GRADLE_PROJECT_sonatypeUsername" )
69- def ossrhPass = System . getenv(). get( " ORG_GRADLE_PROJECT_sonatypePassword" )
70- if ( ossrhUser == null || ossrhPass == null ) {
71- throw new RuntimeException ( " Cannot perform publishing to OSSRH without credentials." )
72- }
73- logger. lifecycle " Publishing {} : {} : {}" , project. group, project. name, project. version
74- signingExtension. required = true
75- }
76- else if ( signingKey == null || signingPassphrase == null ) {
77- tasks. withType( Sign ). each { t -> t. enabled = false }
78- }
79- }
80-
81- static String resolveSigningKey () {
82- var key = System . getenv(). get( " SIGNING_GPG_PRIVATE_KEY" )
83- if ( key != null ) {
84- return key
85- }
86-
87- var keyFile = System . getenv(). get( " SIGNING_GPG_PRIVATE_KEY_PATH" )
88- if ( keyFile != null ) {
89- return new File ( keyFile ). text
90- }
91-
92- return null
93- }
94-
95- static String resolveSigningPassphrase () {
96- return System . getenv(). get( " SIGNING_GPG_PASSPHRASE" )
97- }
98-
9947
10048// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10149// Release / publishing tasks
@@ -112,17 +60,3 @@ tasks.preVerifyRelease.dependsOn generatePomFileForPublishedArtifactsPublication
11260
11361tasks. publishToSonatype. mustRunAfter test
11462
115-
116- // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
117- // Ancillary tasks
118-
119- tasks. register(' showPublications' ) {
120- doFirst {
121- project. publishing. publications. each { publication ->
122- println " Publication (${ publication.name} ): ${ publication.groupId} :${ publication.artifactId} :${ publication.version} "
123- publication. artifacts. each { artifact ->
124- println " > ${ artifact} "
125- }
126- }
127- }
128- }
0 commit comments