-
Notifications
You must be signed in to change notification settings - Fork 7
/
build.gradle.kts
174 lines (148 loc) · 5.51 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
plugins {
id("java-library")
kotlin("jvm") version "1.6.20"
id("maven-publish")
id("signing")
id("org.jetbrains.dokka") version "1.6.20"
id("jacoco")
id("org.jetbrains.kotlinx.binary-compatibility-validator") version "0.9.0"
id("org.jlleitschuh.gradle.ktlint") version "10.3.0"
// TODO: Configure and use this
id("com.diffplug.spotless") version "6.11.0"
// There are newer versions available, but they are not guaranteed to support Java 8.
id("io.github.gradle-nexus.publish-plugin") version "1.3.0"
}
repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
}
group = "com.amazon.ion"
version = "1.4.0-SNAPSHOT"
description = "An immutable in-memory representation of Amazon Ion for Kotlin"
val isCI: Boolean = System.getenv("CI") == "true"
val githubRepositoryUrl = "https://github.com/amazon-ion/ion-element-kotlin/"
val isReleaseVersion: Boolean = !version.toString().endsWith("SNAPSHOT")
dependencies {
api("com.amazon.ion:ion-java:[1.4.0,)")
compileOnly("com.amazon.ion:ion-java:1.4.0")
implementation("org.jetbrains.kotlinx:kotlinx-collections-immutable:0.3.4")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
testImplementation("org.jetbrains.kotlin:kotlin-test")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.6.2")
testImplementation("org.junit.jupiter:junit-jupiter-params:5.6.2")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.6.2")
// Use the Kotlin JUnit 5 integration.
testImplementation("org.jetbrains.kotlin:kotlin-test-junit5")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}
kotlin {
explicitApi()
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
lateinit var sourcesJar: AbstractArchiveTask
lateinit var javadocJar: AbstractArchiveTask
tasks {
compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
apiVersion = "1.3"
languageVersion = "1.4" // Can be read by 1.3 compiler, so consumers on kotlin 1.3 are still supported.
freeCompilerArgs = listOf(
"-opt-in=kotlin.RequiresOptIn" // Using RequiresOptIn requires opt-in itself, at least in kotlin-1.4
)
}
}
ktlint {
version.set("0.45.2")
outputToConsole.set(true)
}
sourcesJar = create<Jar>("sourcesJar") sourcesJar@{
archiveClassifier.set("sources")
from(sourceSets.main.get().allSource)
}
javadocJar = create<Jar>("javadocJar") javadocJar@{
archiveClassifier.set("javadoc")
from(javadoc)
}
withType<Sign> {
setOnlyIf { isReleaseVersion && gradle.taskGraph.hasTask(":publish") }
}
test {
useJUnitPlatform()
// report is always generated after tests run
finalizedBy(jacocoTestReport)
}
jacocoTestReport {
dependsOn(test)
reports {
xml.required.set(true)
html.required.set(true)
}
doLast {
logger.quiet("Coverage report written to file://${reports.html.outputLocation.get()}/index.html")
}
}
}
publishing {
publications.create<MavenPublication>("IonElement") {
artifactId = "ion-element"
artifact(tasks.jar)
artifact(sourcesJar)
artifact(javadocJar)
pom {
name.set("Ion Element Kotlin")
description.set(project.description)
url.set(githubRepositoryUrl)
scm {
connection.set("scm:git:[email protected]:amazon-ion/ion-element-kotlin.git")
developerConnection.set("scm:git:[email protected]:amazon-ion/ion-element-kotlin.git")
url.set("[email protected]:amazon-ion/ion-element-kotlin.git")
}
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
name.set("Amazon Ion Team")
email.set("[email protected]")
organization.set("Amazon Ion")
organizationUrl.set("https://github.com/amazon-ion")
}
}
}
}
}
signing {
// Allow publishing to maven local even if we don't have the signing keys
// This works because when not required, the signing task will be skipped
// if signing.keyId, signing.password, signing.secretKeyRingFile, etc are
// not present in gradle.properties.
isRequired = isReleaseVersion
if (isCI) {
val signingKeyId: String? by project
val signingKey: String? by project
val signingPassword: String? by project
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
}
sign(publishing.publications["IonElement"])
}
nexusPublishing {
// Documentation for this plugin, see https://github.com/gradle-nexus/publish-plugin/blob/v1.3.0/README.md
this.repositories {
sonatype {
nexusUrl.set(uri("https://aws.oss.sonatype.org/service/local/"))
// For CI environments, the username and password should be stored in
// ORG_GRADLE_PROJECT_sonatypeUsername and ORG_GRADLE_PROJECT_sonatypePassword respectively.
if (!isCI) {
username.set(properties["ossrhUsername"].toString())
password.set(properties["ossrhPassword"].toString())
}
}
}
}