forked from FabLabsMC/fiber
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
114 lines (98 loc) · 3.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
import moe.nikky.counter.CounterExtension
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
plugins {
`java-library`
`maven-publish`
id("com.github.johnrengelman.shadow") version "5.2.0"
id("moe.nikky.persistentCounter") version "0.0.8-SNAPSHOT"
id("checkstyle")
}
val major: String by project
val minor : String by project
val patch: String by project
val branch = System.getenv("GIT_BRANCH")
?.takeUnless { it == "master" }
?.let { "-$it" }
?: ""
val isCI = System.getenv("BUILD_NUMBER") != null
val counter: CounterExtension = project.extensions.getByType()
val buildnumber = counter.variable(id = "buildnumber", key = "$major.$minor.$patch$branch")
group = "me.zeroeightsix"
version = "$major.$minor.$patch" + if (isCI) "-$buildnumber" else "-dev"
java {
sourceCompatibility = JavaVersion.VERSION_1_8
}
repositories {
mavenCentral()
}
configurations.api.get().extendsFrom(configurations.shadow.get())
dependencies {
shadow(group = "blue.endless", name = "jankson", version = "1.2.0")
compileOnly(group = "com.google.code.findbugs", name = "jsr305", version = "3.0.2")
testImplementation(group = "org.junit.jupiter", name = "junit-jupiter", version = "5.4.1")
}
checkstyle {
configFile = rootProject.file("checkstyle.xml")
toolVersion = "8.31"
}
tasks.withType<Test> {
useJUnitPlatform()
}
val shadowJar by tasks.getting(ShadowJar::class) {
archiveClassifier.set("")
configurations = listOf(
project.configurations.shadow.get()
)
exclude("META-INF")
}
val sourcesJar = tasks.create<Jar>("sourcesJar") {
archiveClassifier.set("sources")
from(sourceSets["main"].allSource)
}
val javadoc = tasks.getByName<Javadoc>("javadoc") {
val options = this.options
if(options is StandardJavadocDocletOptions) {
options.links = listOf(
"https://javadoc.io/doc/com.google.code.findbugs/jsr305/3.0.2/",
"https://docs.oracle.com/javase/8/docs/api/"
// could not find Jankson docs on the web
)
}
}
val javadocJar = tasks.create<Jar>("javadocJar") {
archiveClassifier.set("javadoc")
from(javadoc)
}
val processResources = tasks.getByName<ProcessResources>("processResources") {
filesMatching("fabric.mod.json") {
expand("version" to version)
}
}
publishing {
publications {
val main = create("main", MavenPublication::class.java) {
artifact(shadowJar)
artifact(sourcesJar)
artifact(javadocJar)
}
if(isCI) {
create("snapshot", MavenPublication::class.java) {
version = "$major.$minor.$patch-SNAPSHOT"
artifact(shadowJar)
artifact(sourcesJar)
artifact(javadocJar)
}
}
}
repositories {
maven(url = "http://mavenupload.modmuss50.me/") {
val mavenPass: String? = project.properties["mavenPass"] as String?
mavenPass?.let {
credentials {
username = "buildslave"
password = mavenPass
}
}
}
}
}