1+ import com.vanniktech.maven.publish.JavaLibrary
2+ import com.vanniktech.maven.publish.JavadocJar
3+
14plugins {
25 id ' java-library'
36 // to unleash the lombok magic
47 id " io.freefair.lombok" version " 8.13.1"
58 // to make our tests output more fancy
69 id ' com.adarshr.test-logger' version ' 4.0.0'
7- // to publish packages
8- id ' maven-publish'
910 // code linting
1011 id " com.diffplug.spotless" version " 7.0.3"
1112 // test coverage
1213 id ' jacoco'
1314 id ' com.github.kt3k.coveralls' version ' 2.12.2'
14- // signing
15- id " signing"
16- // nexus publishing
17- id " io.github.gradle-nexus.publish-plugin" version " 2.0.0"
15+ // maven central publishing
16+ id " com.vanniktech.maven.publish" version " 0.34.0"
1817}
1918
2019compileJava {
@@ -28,7 +27,8 @@ spotless {
2827 }
2928}
3029
31- task createProperties (dependsOn : processResources) {
30+ tasks. register(' createProperties' ) {
31+ dependsOn processResources
3232 doLast {
3333 file(" ${ layout.buildDirectory.get()} /resources/main/truelayer-java.version.properties" ). withWriter { w ->
3434 Properties p = new Properties ()
@@ -147,66 +147,45 @@ jacocoTestReport {
147147 }
148148}
149149
150- task sourcesJar ( type : Jar ) {
150+ tasks . register( ' sourcesJar ' , Jar ) {
151151 from sourceSets. main. allJava
152152 archiveClassifier = ' sources'
153153}
154154
155- task javadocJar ( type : Jar ) {
155+ tasks . register( ' javadocJar ' , Jar ) {
156156 from javadoc
157157 archiveClassifier = ' javadoc'
158158}
159159
160- publishing {
161- publications {
162- mavenJava(MavenPublication ) {
163- from(components. java)
164- artifact sourcesJar
165- artifact javadocJar
166-
167- pom {
168- name = project_name
169- packaging = ' jar'
170- description = project_description
171- url = project_url
172- scm {
173- connection = project_scm
174- developerConnection = project_scm
175- url = project_url
176- }
177- licenses {
178- license {
179- name = project_license_name
180- url = project_license_url
181- }
182- }
183- developers {
184- developer {
185- id = project_developer
186- name = project_developer
187- }
188- }
189- }
190- }
191- }
192- }
160+ mavenPublishing {
161+ publishToMavenCentral(true )
162+ signAllPublications()
193163
194- ext. isReleaseVersion = ! version. endsWith(" SNAPSHOT" )
195- signing {
196- def signingKey = System . getenv(' SONATYPE_GPG_KEY' )
197- def signingPassword = System . getenv(' SONATYPE_GPG_PASSPHRASE' )
198- useInMemoryPgpKeys(signingKey, signingPassword)
199- sign publishing. publications. mavenJava
200- required { isReleaseVersion && gradle. taskGraph. hasTask(" publish" ) }
201- }
164+ // Use the sources and javadoc jars
165+ configure(new JavaLibrary (new JavadocJar.Javadoc (), true ))
202166
203- nexusPublishing {
204- repositories {
205- sonatype {
206- nexusUrl = uri(sonatype_repository_url)
207- snapshotRepositoryUrl = uri(sonatype_snapshot_repository_url)
208- username = System . getenv(" SONATYPE_USERNAME" )
209- password = System . getenv(" SONATYPE_PASSWORD" )
167+ pom {
168+ name = project_name
169+ packaging = ' jar'
170+ description = project_description
171+ url = project_url
172+ scm {
173+ connection = project_scm
174+ url = project_url
175+ }
176+ licenses {
177+ license {
178+ name = project_license_name
179+ url = project_license_url
180+ distribution = project_license_url
181+ }
182+ }
183+ developers {
184+ developer {
185+ id = developer_name
186+ name = developer_name
187+ url = developer_url
188+ }
210189 }
211190 }
212191}
0 commit comments