-
Notifications
You must be signed in to change notification settings - Fork 1
/
library-publishing-conventions.gradle.kts
78 lines (70 loc) · 2.67 KB
/
library-publishing-conventions.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import java.text.SimpleDateFormat
import java.util.*
plugins {
id("java-library")
id("maven-publish")
id("signing")
}
group = "io.github.gradle-nexus-e2e"
val versionTimestamp = SimpleDateFormat("yyyyMMdd-HHmmss").format(Date()) //See: https://issues.sonatype.org/browse/OSSRH-86532
var versionSuffix = if (isOnCIServer()) { "ci${System.getenv("GITHUB_RUN_NUMBER") ?: ""}-${versionTimestamp}" } else "local"
version = if (project.hasProperty("overriddenVersion")) { "${project.property("overriddenVersion")}" } else { "0.0.1-$versionSuffix" }
repositories {
mavenCentral()
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
withJavadocJar()
withSourcesJar()
}
publishing {
publications {
create<MavenPublication>("mavenJava") {
from(components["java"])
pom {
name.set("Minimal Nexus Publish E2E project")
description.set("Minimal project publishing artifacts to Nexus for E2E testing in gradle-nexus-publish-plugin")
url.set("https://github.com/gradle-nexus-e2e/nexus-publish-e2e-minimal")
inceptionYear.set("2020")
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
id.set("szpak")
name.set("Marcin Zajączkowski")
}
developer {
id.set("marcphilipp")
name.set("Marc Philipp")
}
}
scm {
connection.set("scm:https://github.com/gradle-nexus-e2e/nexus-publish-e2e-minimal.git")
developerConnection.set("scm:git@github.com:gradle-nexus-e2e/nexus-publish-e2e-minimal.git")
url.set("https://github.com/gradle-nexus-e2e/nexus-publish-e2e-minimal")
}
}
}
}
}
signing {
setRequired { !project.version.toString().endsWith("-SNAPSHOT") && !project.hasProperty("skipSigning") }
if (project.hasProperty("signingKey")) {
useInMemoryPgpKeys(properties["signingKey"].toString(), properties["signingPassword"].toString())
} else {
useGpgCmd()
}
sign(publishing.publications["mavenJava"])
}
tasks.javadoc {
if(JavaVersion.current().isJava9Compatible) {
(options as StandardJavadocDocletOptions).apply {
addBooleanOption("html5", true)
}
}
}
fun isOnCIServer() = System.getenv("CI") == "true"