Skip to content

Commit 3c15470

Browse files
committed
Sign artifacts and publish with mavenDeployer
1 parent f793612 commit 3c15470

File tree

1 file changed

+139
-7
lines changed

1 file changed

+139
-7
lines changed

kotlinx-collections-immutable/build.gradle

Lines changed: 139 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ buildscript {
1010
}
1111
}
1212

13+
description 'Kotlin experimental immutable collection interfaces and implementations'
14+
1315
allprojects {
1416
apply plugin: 'kotlin'
1517
group = 'org.jetbrains.kotlinx'
@@ -35,9 +37,8 @@ configurations {
3537

3638
dependencies {
3739
shadow "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
38-
40+
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
3941
shadowed project(':pcollections')
40-
4142
}
4243

4344
project('tests') {
@@ -52,11 +53,12 @@ compileKotlin {
5253

5354

5455

55-
apply plugin: 'maven-publish'
56+
apply plugin: 'signing'
57+
//apply plugin: 'maven-publish'
58+
apply plugin: 'maven'
59+
60+
5661

57-
jar {
58-
// baseName "${parent.name}-${project.name}"
59-
}
6062

6163
shadowJar {
6264
classifier = null
@@ -69,15 +71,145 @@ task sourcesJar(type: Jar) {
6971
classifier "sources"
7072
}
7173

74+
task emptyJavadoc(type: Javadoc) {
75+
source = sourceSets.main.java
76+
failOnError = false
77+
}
78+
79+
task javadocJar(type: Jar, dependsOn: emptyJavadoc) {
80+
classifier = 'javadoc'
81+
from emptyJavadoc.destinationDir
82+
}
83+
84+
artifacts {
85+
archives shadowJar
86+
archives sourcesJar
87+
archives javadocJar
88+
}
89+
90+
signing {
91+
required { signatory != null }
92+
sign configurations.archives
93+
}
94+
95+
uploadArchives {
96+
repositories {
97+
mavenDeployer {
98+
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
99+
repository(url: "file://${buildDir}/repo")
100+
// repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
101+
// authentication(userName: ossrhUsername, password: ossrhPassword)
102+
// }
103+
//
104+
// snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
105+
// authentication(userName: ossrhUsername, password: ossrhPassword)
106+
// }
107+
pom.project {
108+
name "${project.group}:${project.name}"
109+
packaging 'jar'
110+
// optionally artifactId can be defined here
111+
description project.description
112+
url 'https://github.com/Kotlin/kotlinx.collections.immutable'
113+
licenses {
114+
license {
115+
name 'The Apache License, Version 2.0'
116+
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
117+
}
118+
}
119+
scm {
120+
url 'https://github.com/Kotlin/kotlinx.collections.immutable'
121+
connection 'scm:git:https://github.com/Kotlin/kotlinx.collections.immutable'
122+
developerConnection 'scm:git:https://github.com/Kotlin/kotlinx.collections.immutable'
123+
}
124+
developers {
125+
developer {
126+
name 'Ilya Gorbunov'
127+
128+
organization 'JetBrains'
129+
organizationUrl 'http://www.jetbrains.com'
130+
}
131+
}
132+
}
133+
}
134+
}
135+
}
136+
/*
137+
138+
// extract signature file and give them proper name
139+
def getSignatureFiles = {
140+
def allFiles = project.tasks.signArchives.signatureFiles.collect { it }
141+
def signedSources = allFiles.find { it.name.contains('-sources') }
142+
def signedJavadoc = allFiles.find { it.name.contains('-javadoc') }
143+
def signedJar = (allFiles - [signedSources, signedJavadoc])[0]
144+
return [
145+
[archive: signedSources, classifier: 'sources', extension: 'pom.asc'],
146+
[archive: signedJavadoc, classifier: 'javadoc', extension: 'pom.asc'],
147+
[archive: signedJar, classifier: null, extension: 'pom.asc']
148+
]
149+
}
150+
72151
publishing {
73152
publications {
74153
mainPublication(MavenPublication) {
75154
from components.shadow
76155
artifact sourcesJar
156+
artifact javadocJar
77157
78158
pom.withXml {
79-
asNode().dependencies.'*'.each { it.scope*.value = 'compile'}
159+
Node node = asNode()
160+
161+
node.dependencies.'*'.each { it.scope*.value = 'compile'}
162+
163+
node.children().last() + {
164+
resolveStrategy = Closure.DELEGATE_FIRST
165+
packaging 'jar'
166+
name "${project.group}:${project.name}"
167+
description project.description
168+
url 'https://github.com/Kotlin/kotlinx.collections.immutable'
169+
licenses {
170+
license {
171+
name 'The Apache License, Version 2.0'
172+
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
173+
}
174+
}
175+
scm {
176+
url 'https://github.com/Kotlin/kotlinx.collections.immutable'
177+
connection 'scm:git:https://github.com/Kotlin/kotlinx.collections.immutable'
178+
developerConnection 'scm:git:https://github.com/Kotlin/kotlinx.collections.immutable'
179+
}
180+
developers {
181+
developer {
182+
name 'Ilya Gorbunov'
183+
184+
organization 'JetBrains'
185+
organizationUrl 'http://www.jetbrains.com'
186+
}
187+
}
188+
}
189+
}
190+
191+
if (signing.required) {
192+
// Sign the pom.xml.
193+
def pomFile = project.file("$buildDir/publications/pom-for-signing.xml")
194+
pom.withXml {
195+
writeTo(pomFile)
196+
def pomAscFile = signing.sign(pomFile).signatureFiles[0]
197+
// artifact(pomAscFile) {
198+
// classifier = null
199+
// extension = 'pom.asc'
200+
// }
201+
pomFile.delete()
202+
}
203+
204+
// Sign the artifacts.
205+
getSignatureFiles().each { signature ->
206+
artifact (signature.archive) {
207+
classifier = signature.classifier
208+
extension = signature.extension
209+
}
210+
}
80211
}
81212
}
82213
}
83214
}
215+
*/

0 commit comments

Comments
 (0)