@@ -20,7 +20,7 @@ String findJavaCommand(String command) {
20
20
21
21
Boolean doSigning (String signingAllowed , Boolean doModule ) {
22
22
def b = signingAllowed. trim() == " true" && doModule
23
- // println("signModule: ${project.name} signingEnabled : $signingAllowed module : $doModule")
23
+ // println("signModule: ${project.name} signingAllowed : $signingAllowed doModule : $doModule")
24
24
b
25
25
}
26
26
@@ -31,50 +31,118 @@ void performSigning(String signingAllowed, Boolean doModule) {
31
31
}
32
32
}
33
33
34
- void configureUpload (String signingEnabled , Boolean signModule ) {
34
+ def customisePom (pom , gradleProject ) {
35
+ pom. withXml {
36
+ def root = asNode()
35
37
36
- uploadArchives {
37
- enabled = false
38
- repositories {
39
- mavenDeployer {
40
- if (doSigning(signingEnabled, signModule)) {
41
- beforeDeployment { MavenDeployment deployment -> signing. signPom(deployment) }
42
- }
38
+ // add all items necessary for maven central publication
39
+ root. children(). last() + {
40
+ resolveStrategy = Closure . DELEGATE_FIRST
43
41
44
- repository(url : sonatypeUploadUrl) {
45
- authentication(userName : sonatypeUsername, password : sonatypePassword)
42
+ name project. pomProjectName
43
+ description project. projectDescription
44
+ url project. projectUrl
45
+ organization {
46
+ name project. pomOrganisation
47
+ url project. projectUrl
48
+ }
49
+ issueManagement {
50
+ system ' GitHub'
51
+ url project. issueUrl
52
+ }
53
+ licenses {
54
+ license {
55
+ name project. licenseName
56
+ url project. licenseUrl
57
+ distribution ' repo'
46
58
}
47
- pom {
48
- groupId = project. group
49
- project {
50
- name pomProjectName
51
- packaging ' jar'
52
- description projectDescription
53
- url projectUrl
54
- organization {
55
- name pomOrganisation
56
- url projectUrl
57
- }
58
- scm {
59
- url scmUrl
60
- }
61
- licenses {
62
- license {
63
- name " The BSD3 License"
64
- url " https://github.com/functionaljava/functionaljava/blob/master/etc/LICENCE"
65
- distribution ' repo'
66
- }
59
+ }
60
+ scm {
61
+ url project. githubUrl
62
+ connection project. scmGitFile
63
+ developerConnection project. scmSshGitFile
64
+ }
65
+ }
66
+ }
67
+ }
68
+
69
+
70
+ void configureUpload (String signingEnabled , Boolean signModule ) {
71
+ publishing {
72
+
73
+ publications {
74
+
75
+ mavenJava(MavenPublication ) {
76
+ groupId project. group
77
+ artifactId project. name
78
+ version project. version
79
+
80
+ from components. java
81
+
82
+ customisePom(pom, rootProject)
83
+
84
+ artifact sourcesJar
85
+ artifact javadocJar
86
+
87
+ if (doSigning(signingEnabled, signModule)) {
88
+ // sign the pom
89
+ pom. withXml {
90
+ def pomFile = file(" ${ project.buildDir} /generated-pom.xml.asc" )
91
+ writeTo(pomFile)
92
+ def pomAscFile = signing. sign(pomFile). signatureFiles[0 ]
93
+ artifact(pomAscFile) {
94
+ classifier = null
95
+ extension = ' pom.asc'
67
96
}
68
- developers {
69
- developer {
70
- email primaryEmail
97
+ pomFile. delete()
98
+ }
99
+
100
+ // sign the artifacts
101
+ project. tasks. signArchives. signatureFiles. each {
102
+ artifact(it) {
103
+ def matcher = it. file =~ / -(sources|javadoc|jre8|jre9)\. jar\. asc$/
104
+ if (matcher. find()) {
105
+ classifier = matcher. group(1 )
106
+ } else {
107
+ classifier = null
71
108
}
109
+ extension = ' jar.asc'
72
110
}
73
111
}
74
112
}
113
+
114
+ }
115
+
116
+ }
117
+
118
+ repositories {
119
+ maven {
120
+ url project. sonatypeUploadUrl
121
+ credentials {
122
+ username sonatypeUsername
123
+ password sonatypePassword
124
+ }
75
125
}
76
126
}
127
+
128
+ }
129
+
130
+
131
+ model {
132
+ tasks. publishMavenJavaPublicationToMavenLocal {
133
+ dependsOn(project. tasks. signArchives)
134
+ }
135
+ tasks. publishMavenJavaPublicationToMavenRepository {
136
+ dependsOn(project. tasks. signArchives)
137
+ }
138
+ tasks. publish {
139
+ dependsOn(project. tasks. build)
140
+ }
141
+ // tasks.install {
142
+ // dependsOn(project.tasks.build)
143
+ // }
77
144
}
145
+
78
146
}
79
147
80
148
ext {
0 commit comments