@@ -9,12 +9,6 @@ plugins {
9
9
signing
10
10
}
11
11
12
- java {
13
- // maven central requires these .jar files even if they are empty
14
- withSourcesJar()
15
- withJavadocJar()
16
- }
17
-
18
12
/* *
19
13
* Local configuration with credentials is stored in local.properties file that is not under vcs.
20
14
* local.properties file structure sample:
@@ -30,21 +24,25 @@ val localProperties = Properties().apply {
30
24
if (file.exists()) load(file.reader())
31
25
}
32
26
33
- publishing {
34
-
35
- val (resolvedGroupId, resolvedVersion) = if (project.group == Versions .libraryJitPackGroup) {
36
- // JitPack passes this in arguments
37
- project.group.toString() to project.version.toString()
38
- } else {
39
- rootProject.group.toString() to rootProject.version.toString()
27
+ afterEvaluate {
28
+ tasks.create<Jar >(" javadocJar" ) {
29
+ archiveClassifier.set(" javadoc" )
30
+ from(tasks.named(" dokkaHtml" ))
40
31
}
32
+ }
33
+
34
+ publishing {
35
+ val resolvedGroupId = if (project.group == Versions .libraryJitPackGroup)
36
+ project.group.toString() // JitPack passes this as arguments
37
+ else
38
+ rootProject.group.toString()
41
39
42
40
// Publication is created by multiplatform plugin itself
43
41
// this code references it and configures
44
42
publications.withType<MavenPublication > {
45
- artifactId = project.name
46
- groupId = resolvedGroupId
47
- version = resolvedVersion
43
+ afterEvaluate {
44
+ artifact(tasks.named( " javadocJar " ))
45
+ }
48
46
49
47
pom {
50
48
name.set(project.name)
@@ -97,7 +95,7 @@ publishing {
97
95
}
98
96
}
99
97
100
- private val executable = localProperties.getProperty(" signing.gnupg.executable" )
98
+ val executable = localProperties.getProperty(" signing.gnupg.executable" )
101
99
if (executable != null ) {
102
100
ext.set(" signing.gnupg.executable" , executable)
103
101
@@ -114,14 +112,19 @@ if (executable != null) {
114
112
}
115
113
}
116
114
} else { // try getting from environment (GitHub flow)
117
- val signingKeyId: String? by project // must be the last 8 digits of the key
118
115
val signingKey: String? by project
119
116
val signingPassword: String? by project
120
117
121
- if (signingKeyId != null && signingKey != null && signingPassword != null ) {
118
+ if (signingKey != null && signingPassword != null ) {
122
119
signing {
123
- useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
120
+ useInMemoryPgpKeys(signingKey, signingPassword)
124
121
sign(publishing.publications)
125
122
}
126
123
}
124
+ }
125
+
126
+ // workaround for gradle warning about task order. should be removed with gradle 8
127
+ val signingTasks = tasks.withType<Sign >()
128
+ tasks.withType<AbstractPublishToMaven >().configureEach {
129
+ dependsOn(signingTasks)
127
130
}
0 commit comments