1- apply from : " ../java_shared.gradle"
2-
3- task ciTest ( type : Test ) {
1+ plugins {
2+ id ' java-library'
3+ id ' signing'
4+ id ' maven-publish'
5+ id ' io.codearte.nexus-staging' version ' 0.21.1'
6+ id " de.marcphilipp.nexus-publish" version " 0.4.0"
47}
58
9+ task ciTest ( type : Test )
10+
611dependencies {
7- testCompile group : ' org.hamcrest' , name : ' java-hamcrest' , version : ' 2.0.0.0'
8- testCompile group : ' pl.pragmatists' , name : ' JUnitParams' , version :' 1.0.5'
9- testCompile group : ' junit' , name : ' junit' , version :' 4.12'
12+ testImplementation " org.hamcrest: java-hamcrest: 2.0.0.0"
13+ testImplementation group : ' pl.pragmatists' , name : ' JUnitParams' , version : ' 1.0.5'
14+ testImplementation group : ' junit' , name : ' junit' , version : ' 4.12'
1015}
1116
12- uploadArchives {
13- repositories {
14- mavenDeployer {
15- beforeDeployment { MavenDeployment deployment -> signing. signPom(deployment) }
17+ apply from : " ../java_shared.gradle"
1618
17- repository(url : publishRepo) {
18- authentication(userName : project. hasProperty(" ossrhUsername" ) ? project. ext[" ossrhUsername" ] : " " , password: project. hasProperty(" ossrhPassword" ) ? project. ext[" ossrhPassword" ] : " " )
19- }
19+ if (hasProperty(" ossrhPassword" )) {
20+ signing {
21+ sign configurations. archives
22+ }
2023
21- snapshotRepository(url : snapshotRepo) {
22- authentication(userName : project. hasProperty(" ossrhUsername" ) ? project. ext[" ossrhUsername" ] : " " , password: project. hasProperty(" ossrhPassword" ) ? project. ext[" ossrhPassword" ] : " " )
23- }
2424
25- pom. project {
26- groupId publishGroupId
27- artifactId ' cloudinary-core'
28- name ' Cloudinary Core Library'
29- description publishDescription
30- packaging jar
31- version version
25+ nexusStaging {
26+ packageGroup = group
27+ username = project. hasProperty(" ossrhUsername" ) ? project. ext[" ossrhUsername" ] : " "
28+ password = project. hasProperty(" ossrhPassword" ) ? project. ext[" ossrhPassword" ] : " "
29+ }
3230
33- url githubUrl
31+ publishing {
32+ publications {
33+ mavenJava(MavenPublication ) {
34+ from components. java
35+ artifact sourcesJar
36+ artifact javadocJar
37+ pom {
38+ name = ' Cloudinary Core Library'
39+ packaging = ' jar'
40+ groupId = publishGroupId
41+ artifactId = ' cloudinary-core'
42+ description = publishDescription
43+ url = githubUrl
44+ licenses {
45+ license {
46+ name = licenseName
47+ url = licenseUrl
48+ }
49+ }
3450
35- scm {
36- connection scmConnection
37- developerConnection scmDeveloperConnection
38- url scmUrl
51+ developers {
52+ developer {
53+ id = developerId
54+ name = developerName
55+ email = developerEmail
56+ }
57+ }
58+ scm {
59+ connection = scmConnection
60+ developerConnection = scmDeveloperConnection
61+ url = scmUrl
62+ }
3963 }
4064
41- licenses {
42- license {
43- name licenseName
44- url licenseUrl
65+ pom. withXml {
66+ def pomFile = file(" ${ project.buildDir} /generated-pom.xml" )
67+ writeTo(pomFile)
68+ def pomAscFile = signing. sign(pomFile). signatureFiles[0 ]
69+ artifact(pomAscFile) {
70+ classifier = null
71+ extension = ' pom.asc'
4572 }
4673 }
4774
48- developers {
49- developer {
50- id developerId
51- name developerName
52- email developerEmail
75+ // create the signed artifacts
76+ project. tasks. signArchives. signatureFiles. each {
77+ artifact(it) {
78+ def matcher = it. file =~ / -(sources|javadoc)\. jar\. asc$/
79+ if (matcher. find()) {
80+ classifier = matcher. group(1 )
81+ } else {
82+ classifier = null
83+ }
84+ extension = ' jar.asc'
5385 }
5486 }
5587 }
5688 }
89+
90+ nexusPublishing {
91+ repositories {
92+ sonatype {
93+ username = project. hasProperty(" ossrhUsername" ) ? project. ext[" ossrhUsername" ] : " "
94+ password = project. hasProperty(" ossrhPassword" ) ? project. ext[" ossrhPassword" ] : " "
95+ }
96+ }
97+ }
98+
99+ model {
100+ tasks. generatePomFileForMavenJavaPublication {
101+ destination = file(" $buildDir /generated-pom.xml" )
102+ }
103+ tasks. publishMavenJavaPublicationToMavenLocal {
104+ dependsOn project. tasks. signArchives
105+ }
106+ tasks. publishMavenJavaPublicationToSonatypeRepository {
107+ dependsOn project. tasks. signArchives
108+ }
109+ }
57110 }
58111}
0 commit comments