-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
164 lines (142 loc) · 5.05 KB
/
build.gradle.kts
File metadata and controls
164 lines (142 loc) · 5.05 KB
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin
import org.cadixdev.gradle.licenser.LicenseExtension
import org.cadixdev.gradle.licenser.Licenser
@Suppress("DSL_SCOPE_VIOLATION")
plugins {
id("java")
id("java-library")
id("maven-publish")
id("signing")
alias(libs.plugins.shadow)
alias(libs.plugins.licenser)
alias(libs.plugins.lombok)
eclipse
idea
}
group = "com.whackdevelopment.utils"
version = "1.0-SNAPSHOT"
description = "Java JVM Utils WhackDevelopment"
fun commitHash(): String = try {
val runtime = Runtime.getRuntime()
val process = runtime.exec("git rev-parse --short HEAD")
val out = process.inputStream
out.bufferedReader().readText().trim()
} catch (ignored: Exception) {
"unknown"
}
val commit: String? = commitHash()
allprojects {
repositories {
mavenCentral()
maven { url = uri("https://plugins.gradle.org/m2/") }
mavenLocal()
}
}
subprojects {
group = rootProject.group
version = rootProject.version
apply {
plugin<JavaPlugin>()
plugin<JavaLibraryPlugin>()
plugin<MavenPublishPlugin>()
plugin<ShadowPlugin>()
plugin<Licenser>()
plugin<SigningPlugin>()
plugin<EclipsePlugin>()
plugin<IdeaPlugin>()
plugin("io.freefair.lombok")
}
tasks.compileJava.configure {
options.encoding = Charsets.UTF_8.name()
options.release.set(16)
}
configurations.all {
attributes.attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 16)
}
configure<LicenseExtension> {
header(rootProject.file("HEADER.txt"))
include("**/*.java")
newLine.set(true)
}
java {
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
}
val javaComponent = components["java"] as AdhocComponentWithVariants
javaComponent.withVariantsFromConfiguration(configurations["shadowRuntimeElements"]) {
skip()
}
signing {
if (!version.toString().endsWith("-SNAPSHOT")) {
val signingKey: String? by project
val signingPassword: String? by project
useInMemoryPgpKeys(signingKey, signingPassword)
signing.isRequired
sign(publishing.publications)
}
}
if (System.getProperty("publishName") != null && System.getProperty("publishPassword") != null) {
publishing {
(components["java"] as AdhocComponentWithVariants).withVariantsFromConfiguration(configurations["shadowRuntimeElements"]) {
skip()
}
publications {
create<MavenPublication>(project.name) {
from(components["java"])
pom {
name.set(project.name)
url.set("https://github.com/WhackDevelopment/WhackUtils-Java")
properties.put("inceptionYear", "2023")
licenses {
license {
name.set("General Public License (GPL v3.0)")
url.set("https://www.gnu.org/licenses/gpl-3.0.txt")
distribution.set("repo")
}
}
developers {
developer {
id.set("LuciferMorningstarDev")
name.set("Lucifer Morningstar")
email.set("contact@lucifer-morningstar.xyz")
}
}
}
}
repositories {
maven("https://repo.whckdevelopment.com/repository/maven-snapshot/") {
this.name = "whckdevelopment-snapshots"
credentials {
this.password = System.getProperty("publishPassword")
this.username = System.getProperty("publishName")
}
}
}
}
}
}
tasks {
withType<ProcessResources> {
filesMatching("*") {
expand(project.properties)
}
}
compileJava {
options.compilerArgs.addAll(arrayOf("-Xmaxerrs", "1000"))
options.compilerArgs.add("-Xlint:all")
for (disabledLint in arrayOf("processing", "path", "fallthrough", "serial")) options.compilerArgs.add("-Xlint:$disabledLint")
options.isDeprecation = true
options.encoding = Charsets.UTF_8.name()
}
jar {
this.archiveClassifier.set(null as String?)
this.archiveFileName.set("${project.name}-${project.version}-${commit}.${this.archiveExtension.getOrElse("jar")}")
this.destinationDirectory.set(file("$projectDir/../out/unshaded"))
}
processResources {
filteringCharset = Charsets.UTF_8.name()
}
named("build") {
dependsOn(named("shadowJar"))
}
}
}