-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
125 lines (114 loc) · 4.16 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
import groovy.util.Node
import java.net.URI
import java.util.Properties
plugins {
id("java-library")
kotlin("jvm") version "1.3.72"
id("com.github.johnrengelman.shadow") version "5.1.0"
id("signing")
id("maven-publish")
}
dependencies {
compileOnly(gradleApi())
setOf(
"com.android.tools.build:gradle:3.6.3",
"org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.72",
// Do not update Jackson - 2.10.x has binary-incompatible changes that will break other plugins
"com.fasterxml.jackson.core:jackson-databind:2.9.9.3",
"com.fasterxml.jackson.module:jackson-module-kotlin:2.9.9",
"com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.9.9",
"org.ow2.asm:asm:6.0").forEach {
implementation(it)
shadow(it)
}
}
repositories {
google()
jcenter()
mavenCentral()
}
tasks {
compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
}
// The rest of this file is configuration for publishing to Maven Central
val sourceJar by tasks.registering(Jar::class) {
archiveClassifier.set("sources")
from(sourceSets["main"].allSource)
}
artifacts {
archives(tasks.getByName("jar"))
archives(sourceJar)
}
signing {
sign(configurations.getByName("archives")).forEach {
it.signatures.removeAll { oneSig ->
it.signatures.count { anotherSig -> oneSig.classifier == anotherSig.classifier } > 1
}
}
}
val properties = Properties().also { it.load(rootProject.file("local.properties").inputStream()) }
publishing {
publications {
register("mavenJava", MavenPublication::class) {
pom.withXml {
asNode().apply {
appendNode("description", "MP module manager")
appendNode("name", "eMPire")
appendNode("url", "https://github.com/cs125-illinois/eMPire")
Node(this, "licenses").apply {
Node(this, "license").apply {
appendNode("name", "Apache License 2.0")
appendNode("url", "https://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
Node(this, "scm").apply {
appendNode("url", "https://github.com/cs125-illinois/eMPire")
appendNode("connection", "scm:git:git://github.com/cs125-illinois/eMPire.git")
appendNode("developerConnection", "scm:git:ssh://[email protected]:cs125-illinois/eMPire.git")
}
Node(this, "developers").apply {
Node(this, "developer").apply {
appendNode("name", "CS 125")
}
}
}
}
groupId = "com.github.cs125-illinois"
artifactId = "empire"
version = "2020.1.5"
from(components.getByName("java"))
pom.withXml {
val pomFile = project.file("${project.buildDir}/generated-pom.xml")
pomFile.writeText(asString().toString().replace("<?xml version=\"1.0\"?>", "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"))
artifact(signing.sign(pomFile).signatureFiles.singleFile) {
classifier = null
extension = "pom.asc"
}
}
(tasks.getByName("signArchives") as Sign).signatureFiles.forEach {
artifact(it) {
classifier = if (it.name.replace(".jar.asc", "").endsWith("sources")) "sources" else null
extension = "jar.asc"
}
}
}
}
repositories {
maven {
url = URI("https://oss.sonatype.org/service/local/staging/deploy/maven2")
credentials {
username = properties["ossrh.username"] as? String
password = properties["ossrh.password"] as? String
}
}
}
}
afterEvaluate {
tasks.filter { it.name.startsWith("publishMavenJavaPublicationTo") }.forEach {
it.dependsOn("signArchives")
}
}