-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
117 lines (99 loc) · 3.67 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
import java.util.Calendar
import org.cadixdev.gradle.licenser.Licenser
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.time.Instant
import java.time.format.DateTimeFormatter
// Add common plugins
plugins {
java
alias(libs.plugins.licenser)
alias(libs.plugins.kotlin.jvm) apply false
idea
}
// Cache properties
internal val projectId: String = extra["base.id"] as String
internal val projectName: String = extra["base.name"] as String
internal val projectVersion: String = extra["base.version"] as String
internal val author: String = extra["base.author"] as String
internal val artifactGroup: String = extra["base.group"] as String
internal val javaVersion: String = extra["java.version"] as String
internal val fileEncoding: String = extra["file.encoding"] as String
internal val licenseHeader: TextResource = resources.text.fromFile(rootProject.file("HEADER"))
internal val licenseId: String = extra["license.id"] as String
internal val startYear: String = extra["base.year.start"] as String
internal val currentYear: Int = Calendar.getInstance().get(Calendar.YEAR)
// For all subprojects
subprojects {
// Java Settings
plugins.withType<JavaPlugin> {
group = artifactGroup
java {
toolchain.languageVersion.set(JavaLanguageVersion.of(javaVersion))
withSourcesJar()
withJavadocJar()
}
tasks.withType<JavaCompile> {
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:"
)
}
}
}
afterEvaluate {
tasks.withType<Jar> {
from(rootProject.file("LICENSE"))
manifest.attributes(
mapOf(
"Specification-Title" to projectId,
"Specification-Vendor" to author,
"Specification-Version" to projectVersion,
"Implementation-Title" to base.archivesName.get(),
"Implementation-Vendor" to author,
"Implementation-Version" to project.version,
"Implementation-Timestamp" to DateTimeFormatter.ISO_INSTANT.format(Instant.now())
)
)
}
tasks.named<Copy>("processResources") {
inputs.property("version", project.version.toString())
filesMatching(listOf("**/mods.toml", "**/fabric.mod.json", "**/quilt.mod.json")) {
expand(
mapOf(
"version" to project.version.toString()
)
)
}
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
}
}
// Kotlin Settings
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = javaVersion
}
// License Settings
plugins.withType<Licenser> {
license {
header.set(licenseHeader)
properties {
set("projectName", projectName)
set("startYear", startYear)
set("year", currentYear)
set("author", author)
set("license", licenseId)
}
include("**/*.java")
include("**/*.kt")
include("**/*.scala")
include("**/*.groovy")
}
}
}