-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
132 lines (107 loc) · 3.86 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
plugins {
kotlin("jvm").version("1.5.21")
id("org.jetbrains.dokka") version "1.5.0"
`maven-publish`
`signing`
}
group = "io.github.vfmunhoz"
version = "1.0.0"
val snapshotVersion: String =
if(project.hasProperty("snapshotVersion")) project.findProperty("snapshotVersion").toString()
else "true"
val sonatypeUsername: String? = System.getenv("SONATYPE_USERNAME")
val sonatypePassword: String? = System.getenv("SONATYPE_PASSWORD")
val repositoryId: String? = System.getenv("SONATYPE_REPOSITORY_ID")
val dokkaOutputDir = "$buildDir/dokka"
tasks.getByName<org.jetbrains.dokka.gradle.DokkaTask>("dokkaHtml") {
outputDirectory.set(file(dokkaOutputDir))
}
val deleteDokkaOutputDir by tasks.register<Delete>("deleteDokkaOutputDirectory") {
delete(dokkaOutputDir)
}
val javadocJar = tasks.register<Jar>("javadocJar") {
dependsOn(deleteDokkaOutputDir, tasks.dokkaHtml)
archiveClassifier.set("javadoc")
from(dokkaOutputDir)
}
val sourcesJar = tasks.register<Jar>("sourcesJar") {
archiveClassifier.set("sources")
from(sourceSets.getByName("main").allSource)
}
repositories {
mavenCentral()
}
signing {
useInMemoryPgpKeys(
System.getenv("GPG_PRIVATE_KEY"),
System.getenv("GPG_PRIVATE_PASSWORD")
)
sign(publishing.publications)
}
publishing {
repositories {
maven {
name = "oss"
val releasesRepoUrl = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
val snapshotsRepoUrl = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
if(snapshotVersion == "false" && version.toString().endsWith("SNAPSHOT")) {
throw Exception("To publish the release the version must not end with -SNAPSHOT")
}
url = if (snapshotVersion == "true") snapshotsRepoUrl else releasesRepoUrl
credentials {
username = sonatypeUsername
password = sonatypePassword
}
}
}
publications {
create<MavenPublication>("release") {
from(components["kotlin"])
}
withType<MavenPublication> {
artifact(javadocJar.get())
artifact(sourcesJar.get())
pom {
name.set("Kotlin ProtectedTypes")
description.set("KPT - Kotlin ProtectedTypes for JVM applications")
licenses {
license {
name.set("MIT")
url.set("https://opensource.org/licenses/MIT")
}
}
url.set("https://github.com/vfmunhoz/kotlin-protected-types")
issueManagement {
system.set("Github")
url.set("https://github.com/vfmunhoz/kotlin-protected-types/issues")
}
scm {
connection.set("https://github.com/vfmunhoz/kotlin-protected-types.git")
url.set("https://github.com/vfmunhoz/kotlin-protected-types")
}
developers {
developer {
name.set("Vinicius Montes Munhoz")
email.set("[email protected]")
}
}
}
}
}
}
dependencies {
implementation(kotlin("stdlib"))
implementation(kotlin("reflect"))
compileOnly("com.fasterxml.jackson.module:jackson-module-kotlin:2.12.+")
testImplementation(kotlin("test"))
testImplementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.12.+")
dokkaHtmlPlugin("org.jetbrains.dokka:kotlin-as-java-plugin:1.5.0")
}
tasks.test {
useJUnitPlatform()
}
// Suppressing test compile warnings since we intentionally
// cause an overflow on arithmetic operation for integer types.
tasks.compileTestKotlin {
kotlinOptions.suppressWarnings = true
}