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' )
11-
12- apply plugin : ' signing'
9+ apply from : rootProject. file( ' gradle/publishing.gradle' )
1310
1411// Make sure that the publishReleaseArtifacts task of the release module runs the release task of this sub module
1512tasks. getByPath( ' :release:publishReleaseArtifacts' ). dependsOn tasks. release
1613
1714configurations {
1815 javadocSources {
19- description ' Used to aggregate javadocs for the whole project'
16+ description = " All Java sources for the project's Javadoc"
17+ canBeConsumed = true
18+ canBeResolved = false
19+ visible = false
2020 }
2121}
2222
@@ -36,65 +36,11 @@ java {
3636// Publishing
3737
3838var 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- }
45- }
46-
47-
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
39+ publishingExtension. publications. named(" publishedArtifacts" , MavenPublication ) {
40+ // Add the Java component to the main publication
41+ from components. java
9342}
9443
95- static String resolveSigningPassphrase () {
96- return System . getenv(). get( " SIGNING_GPG_PASSPHRASE" )
97- }
9844
9945
10046// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -112,17 +58,3 @@ tasks.preVerifyRelease.dependsOn generatePomFileForPublishedArtifactsPublication
11258
11359tasks. publishToSonatype. mustRunAfter test
11460
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