-
-
Notifications
You must be signed in to change notification settings - Fork 15
/
build.gradle.kts
167 lines (150 loc) · 5.96 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
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
165
166
167
import com.github.vlsi.gradle.crlf.CrLfSpec
import com.github.vlsi.gradle.crlf.LineEndings
import com.github.vlsi.gradle.properties.dsl.props
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("com.diffplug.spotless")
id("com.github.vlsi.crlf")
id("com.github.vlsi.gradle-extensions")
id("org.ajoberstar.grgit")
kotlin("jvm") apply false
}
val skipSpotless by props()
val skipJavadoc by props()
val enableMavenLocal by props()
val enableGradleMetadata by props()
val String.v: String get() = rootProject.extra["$this.version"] as String
val buildVersion = "auto-dark-mode".v
val githubAccessToken by props("")
val currentBranch = System.getenv("GITHUB_HEAD_REF") ?: grgit.branch.current()?.name
allprojects {
group = "com.github.weisj"
version = buildVersion
repositories {
if (enableMavenLocal) {
mavenLocal()
}
mavenCentral()
maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots/") }
maven { url = uri("https://www.jetbrains.com/intellij-repository/releases") }
maven { url = uri("https://www.jetbrains.com/intellij-repository/snapshots") }
maven { url = uri("https://cache-redirector.jetbrains.com/intellij-dependencies") }
}
plugins.withType<UsePrebuiltBinariesWhenUnbuildablePlugin> {
prebuiltBinaries {
prebuiltLibrariesFolder = "pre-build-libraries"
github(
user = "weisj",
repository = "auto-dark-mode",
workflow = "libs.yml",
) {
failIfLibraryIsMissing = false
val currentBranch = currentBranch
branches = listOfNotNull(currentBranch, "master", "v$buildVersion", buildVersion)
accessToken = githubAccessToken
manualDownloadUrl =
"https://github.com/weisJ/auto-dark-mode/actions?query=workflow%3A%22Build+Native+Libraries%22+is%3Asuccess"
timeout = 50000
}
}
}
if (!skipSpotless) {
apply(plugin = "com.diffplug.spotless")
spotless {
val spotlessRatchet by props(default = true)
if (spotlessRatchet) {
ratchetFrom("origin/master")
}
kotlinGradle {
ktlint("ktlint".v)
}
format("markdown") {
target("*.md")
endWithNewline()
trimTrailingWhitespace()
}
format("svg") {
target("**/*.svg")
targetExclude("**/build/**/*.svg")
endWithNewline()
trimTrailingWhitespace()
eclipseWtp(com.diffplug.spotless.extra.wtp.EclipseWtpFormatterStep.XML)
}
plugins.withType<dev.nokee.platform.jni.internal.plugins.JniLibraryPlugin>().configureEach {
cpp {
target("**/*.cpp", "**/*.h")
targetExclude("**/objcpp/**")
endWithNewline()
trimTrailingWhitespace()
eclipseCdt().configFile("${project.rootDir}/config/cpp.eclipseformat.xml")
licenseHeaderFile("${project.rootDir}/config/LICENSE_HEADER_JAVA.txt")
}
}
plugins.withType<JavaPlugin>().configureEach {
java {
importOrder("java", "javax", "org", "com")
removeUnusedImports()
endWithNewline()
trimTrailingWhitespace()
eclipse().configFile("${project.rootDir}/config/java.eclipseformat.xml")
licenseHeaderFile("${project.rootDir}/config/LICENSE_HEADER_JAVA.txt")
}
}
}
}
tasks.withType<AbstractArchiveTask>().configureEach {
// Ensure builds are reproducible
isPreserveFileTimestamps = false
isReproducibleFileOrder = true
dirMode = "775".toInt(8)
fileMode = "664".toInt(8)
}
if (!enableGradleMetadata) {
tasks.withType<GenerateModuleMetadata> {
enabled = false
}
}
val javaVersion = JavaVersion.VERSION_17
tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
jvmTarget = javaVersion.toString()
freeCompilerArgs = listOf("-Xjvm-default=all-compatibility")
}
}
plugins.withType<JavaPlugin> {
configure<JavaPluginExtension> {
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
withSourcesJar()
}
tasks {
withType<JavaCompile>().configureEach {
options.encoding = "UTF-8"
}
withType<Jar>().configureEach {
manifest {
attributes["Bundle-License"] = "MIT"
attributes["Implementation-Title"] = project.name
attributes["Implementation-Version"] = project.version
attributes["Specification-Vendor"] = "Auto Dark Mode"
attributes["Specification-Version"] = project.version
attributes["Specification-Title"] = "Auto Dark Mode"
attributes["Implementation-Vendor"] = "Auto Dark Mode"
attributes["Implementation-Vendor-Id"] = "com.github.weisj"
}
CrLfSpec(LineEndings.LF).run {
into("META-INF") {
filteringCharset = "UTF-8"
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
// This includes either project-specific license, or a default one
if (file("$projectDir/LICENSE").exists()) {
textFrom("$projectDir/LICENSE")
} else {
textFrom("$rootDir/LICENSE")
}
}
}
}
}
}
}