Skip to content

Commit b5df102

Browse files
authored
chore: clean up publishing workflow (#296)
1 parent 8255143 commit b5df102

File tree

2 files changed

+65
-64
lines changed

2 files changed

+65
-64
lines changed

codegen/smithy-aws-kotlin-codegen/build.gradle.kts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -102,18 +102,13 @@ val sourcesJar by tasks.creating(Jar::class) {
102102
from(sourceSets.getByName("main").allSource)
103103
}
104104

105-
if (
106-
!project.hasProperty("publishGroupName") ||
107-
group.toString().startsWith(project.property("publishGroupName") as String)
108-
) {
109-
publishing {
110-
publications {
111-
create<MavenPublication>("codegen") {
112-
from(components["java"])
113-
artifact(sourcesJar)
114-
}
105+
publishing {
106+
publications {
107+
create<MavenPublication>("codegen") {
108+
from(components["java"])
109+
artifact(sourcesJar)
115110
}
116111
}
112+
}
117113

118-
apply(from = rootProject.file("gradle/publish.gradle"))
119-
}
114+
apply(from = rootProject.file("gradle/publish.gradle"))

gradle/publish.gradle

Lines changed: 58 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -3,73 +3,79 @@
33
* SPDX-License-Identifier: Apache-2.0.
44
*/
55

6+
apply plugin: 'maven-publish'
7+
apply plugin: 'signing'
8+
69
// FIXME: Create a real "javadoc" JAR from the Dokka output
710
tasks.register("javadocJar", Jar) {
811
archiveClassifier.set("javadoc")
912
from()
1013
}
1114

12-
project.afterEvaluate {
13-
String publishGroupName = project.findProperty("publishGroupName")
14-
if (publishGroupName == null || project.group.startsWith(publishGroupName)) {
15-
apply plugin: 'maven-publish'
16-
apply plugin: 'signing'
17-
18-
publishing {
19-
repositories {
20-
maven { name = "testLocal"; url = "$rootProject.buildDir/m2" }
21-
maven {
22-
name = "awsCodeArtifact"
23-
url = project.findProperty("codeartifact.url")
24-
credentials {
25-
username = "aws"
26-
password = project.findProperty("codeartifact.token") ?: System.getenv("CODEARTIFACT_TOKEN")
27-
}
28-
}
15+
publishing {
16+
repositories {
17+
maven { name = "testLocal"; url = "$rootProject.buildDir/m2" }
18+
maven {
19+
name = "awsCodeArtifact"
20+
url = project.findProperty("codeartifact.url")
21+
credentials {
22+
username = "aws"
23+
password = project.findProperty("codeartifact.token") ?: System.getenv("CODEARTIFACT_TOKEN")
2924
}
25+
}
26+
}
3027

31-
publications.all {
32-
pom {
33-
name = project.name
34-
description = project.description
35-
url = "https://github.com/awslabs/aws-sdk-kotlin"
36-
licenses {
37-
license {
38-
name = "The Apache License, Version 2.0"
39-
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
40-
}
41-
}
42-
developers {
43-
developer {
44-
id = "aws-sdk-kotlin"
45-
name = "AWS SDK Kotlin Team"
46-
// TODO - team email?
47-
}
28+
publications.all {
29+
project.afterEvaluate {
30+
pom {
31+
name = project.name
32+
description = project.description
33+
url = "https://github.com/awslabs/aws-sdk-kotlin"
34+
licenses {
35+
license {
36+
name = "The Apache License, Version 2.0"
37+
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
4838
}
49-
scm {
50-
connection = "scm:git:git://github.com/awslabs/aws-sdk-kotlin.git"
51-
developerConnection = "scm:git:ssh://github.com/awslabs/aws-sdk-kotlin.git"
52-
url = "https://github.com/awslabs/aws-sdk-kotlin"
39+
}
40+
developers {
41+
developer {
42+
id = "aws-sdk-kotlin"
43+
name = "AWS SDK Kotlin Team"
44+
// TODO - team email?
5345
}
54-
55-
artifact(tasks["javadocJar"])
5646
}
57-
}
58-
59-
if (project.hasProperty("signingKey") && project.hasProperty("signingPassword")) {
60-
signing {
61-
useInMemoryPgpKeys(
62-
(String) project.property("signingKey"),
63-
(String) project.property("signingPassword")
64-
)
65-
sign(publications)
47+
scm {
48+
connection = "scm:git:git://github.com/awslabs/aws-sdk-kotlin.git"
49+
developerConnection = "scm:git:ssh://github.com/awslabs/aws-sdk-kotlin.git"
50+
url = "https://github.com/awslabs/aws-sdk-kotlin"
6651
}
52+
53+
artifact(tasks["javadocJar"])
6754
}
6855
}
56+
}
6957

70-
tasks.register('publishToAwsCodeArtifact') {
71-
dependsOn 'publishAllPublicationsToAwsCodeArtifactRepository'
72-
group 'publishing'
58+
if (project.hasProperty("signingKey") && project.hasProperty("signingPassword")) {
59+
signing {
60+
useInMemoryPgpKeys(
61+
(String) project.property("signingKey"),
62+
(String) project.property("signingPassword")
63+
)
64+
sign(publications)
7365
}
7466
}
7567
}
68+
69+
tasks.register('publishToAwsCodeArtifact') {
70+
dependsOn 'publishAllPublicationsToAwsCodeArtifactRepository'
71+
group 'publishing'
72+
}
73+
74+
def isAvailableForPublication(publication) {
75+
return !project.hasProperty("publishGroupName") ||
76+
publication.groupId.startsWith((String) project.property("publishGroupName"))
77+
}
78+
79+
tasks.withType(AbstractPublishToMaven).all {
80+
onlyIf { isAvailableForPublication(publication) }
81+
}

0 commit comments

Comments
 (0)