-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
109 lines (100 loc) · 3.39 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
import java.util.Calendar
import org.cadixdev.gradle.licenser.Licenser
import java.time.Instant
import java.time.format.DateTimeFormatter
// Add plugins
plugins {
java
id("org.cadixdev.licenser")
}
// Cache some properties
internal val artifactGroup = extra["base.group"] as String
internal val fileEncoding = extra["file.encoding"] as String
internal val jUnitVersion: String = extra["junit.version"] as String
internal val headerFile: TextResource = resources.text.fromFile(rootProject.file("HEADER"))
internal val author = extra["base.author"] as String
internal val projectArtifact = extra["base.id"] as String
internal val projectName = extra["base.name"] as String
internal val year: Int = Calendar.getInstance().get(Calendar.YEAR)
internal val javaVersion = extra["java.version"] as String
subprojects {
// Java Settings
plugins.withType<JavaPlugin> {
group = artifactGroup
java {
toolchain.languageVersion.set(JavaLanguageVersion.of(javaVersion))
withSourcesJar()
withJavadocJar()
}
tasks.withType<JavaCompile>().configureEach {
options.encoding = fileEncoding
}
tasks.javadoc {
options {
encoding = fileEncoding
if (this is StandardJavadocDocletOptions)
tags(
"apiNote:a:API Note:",
"implSpec:a:Implementation Requirements:",
"implNote:a:Implementation Note:"
)
}
}
// Add common repositories
repositories {
mavenCentral()
maven {
name = "Minecraft Libraries"
url = uri("https://libraries.minecraft.net")
}
}
// Manifest Attributes
afterEvaluate {
tasks.jar {
from(rootProject.file("LICENSE")) {
expand(
mapOf(
"year" to year,
"author" to author
)
)
}
manifest.attributes(mapOf(
"Specification-Title" to projectArtifact,
"Specification-Vendor" to author,
"Specification-Version" to (project.version as String).split('-')[0],
"Implementation-Title" to base.archivesName.get(),
"Implementation-Vendor" to author,
"Implementation-Version" to project.version,
"Implementation-Timestamp" to DateTimeFormatter.ISO_INSTANT.format(Instant.now())
))
}
}
// Unit Tests
repositories {
mavenCentral()
}
tasks.test {
useJUnitPlatform()
}
dependencies {
testImplementation(platform(mapOf(
"group" to "org.junit",
"name" to "junit-bom",
"version" to jUnitVersion
)))
testImplementation(group = "org.junit.jupiter", name = "junit-jupiter")
}
}
// License Settings
plugins.withType<Licenser> {
license {
header.set(headerFile)
properties {
set("projectName", projectName)
set("author", author)
}
include("**/*.java")
}
}
}