-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
146 lines (130 loc) · 4.12 KB
/
build.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
import java.text.SimpleDateFormat
import java.util.*
plugins {
id("java-library")
id("groovy")
id("maven-publish")
id("signing")
id("com.github.ben-manes.versions") version "0.51.0"
id("net.ossindex.audit") version "0.4.11"
id("io.freefair.maven-central.validate-poms") version "8.11"
id("io.github.gradle-nexus.publish-plugin") version "2.0.0"
}
repositories {
mavenCentral()
}
dependencies {
api("ch.qos.logback:logback-classic:[1.2,2)!!1.3.14")
implementation("org.slf4j:slf4j-api:[1.7,3)!!2.0.16")
testImplementation("org.spockframework:spock-core:2.3-groovy-4.0")
}
val dependencyVersions = listOf<String>()
val dependencyGroupVersions = mapOf<String, String>()
configurations.all {
resolutionStrategy {
failOnVersionConflict()
force(dependencyVersions)
eachDependency {
val forcedVersion = dependencyGroupVersions[requested.group]
if (forcedVersion != null) {
useVersion(forcedVersion)
}
}
}
}
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(8))
}
}
tasks {
withType<JavaCompile> {
options.encoding = "UTF-8"
}
withType<Test> {
useJUnitPlatform()
// for the de.gesellix.testutil.ResourceReaderTest
environment("ROOT_PROJECT_BUILD_DIRECTORY", rootProject.layout.buildDirectory.get())
}
}
val javadocJar by tasks.registering(Jar::class) {
dependsOn("classes")
archiveClassifier.set("javadoc")
from(tasks.javadoc)
}
val sourcesJar by tasks.registering(Jar::class) {
dependsOn("classes")
archiveClassifier.set("sources")
from(sourceSets.main.get().allSource)
}
artifacts {
add("archives", sourcesJar.get())
add("archives", javadocJar.get())
}
fun findProperty(s: String) = project.findProperty(s) as String?
val isSnapshot = project.version == "unspecified"
val artifactVersion = if (!isSnapshot) project.version as String else SimpleDateFormat("yyyy-MM-dd\'T\'HH-mm-ss").format(Date())!!
val publicationName = "testutil"
publishing {
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/${property("github.package-registry.owner")}/${property("github.package-registry.repository")}")
credentials {
username = System.getenv("GITHUB_ACTOR") ?: findProperty("github.package-registry.username")
password = System.getenv("GITHUB_TOKEN") ?: findProperty("github.package-registry.password")
}
}
}
publications {
register(publicationName, MavenPublication::class) {
pom {
name.set("testutil")
description.set("Test utilities for the docker-utils libraries")
url.set("https://github.com/docker-client/testutil")
licenses {
license {
name.set("MIT")
url.set("https://opensource.org/licenses/MIT")
}
}
developers {
developer {
id.set("gesellix")
name.set("Tobias Gesellchen")
email.set("[email protected]")
}
}
scm {
connection.set("scm:git:github.com/docker-client/testutil.git")
developerConnection.set("scm:git:ssh://github.com/docker-client/testutil.git")
url.set("https://github.com/docker-client/testutil")
}
}
artifactId = "testutil"
version = artifactVersion
from(components["java"])
artifact(sourcesJar.get())
artifact(javadocJar.get())
}
}
}
signing {
val signingKey: String? by project
val signingPassword: String? by project
useInMemoryPgpKeys(signingKey, signingPassword)
sign(publishing.publications[publicationName])
}
nexusPublishing {
repositories {
if (!isSnapshot) {
sonatype {
// custom repository name - 'sonatype' is pre-configured
// for Sonatype Nexus (OSSRH) which is used for The Central Repository
stagingProfileId.set(System.getenv("SONATYPE_STAGING_PROFILE_ID") ?: findProperty("sonatype.staging.profile.id")) //can reduce execution time by even 10 seconds
username.set(System.getenv("SONATYPE_USERNAME") ?: findProperty("sonatype.username"))
password.set(System.getenv("SONATYPE_PASSWORD") ?: findProperty("sonatype.password"))
}
}
}
}