Repository navigation
Expand file tree
/
Copy pathbuild.gradle
More file actions
182 lines (153 loc) · 5.96 KB
/
Copy pathbuild.gradle
File metadata and controls
182 lines (153 loc) · 5.96 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
import com.github.jk1.license.render.*
buildscript {
apply from: 'dependencies.gradle'
}
plugins {
id 'com.diffplug.spotless' version "${spotlessVersion}"
id 'com.google.protobuf' version "${protobufGradlePluginVersion}" apply false
id 'com.github.jk1.dependency-license-report' version "${jk1licenseVersion}"
}
licenseReport {
projects = [project] + project.subprojects
allowedLicensesFile = new File("$projectDir/.github/allowed-licenses.json")
configurations = ['runtimeClasspath', 'compileClasspath']
renderers = [new com.github.jk1.license.render.TextReportRenderer('licenses.txt')]
excludeGroups = ['org.junit', 'org.mockito', 'org.junit.platform']
}
subprojects {
tasks.withType(Jar).configureEach {
dependsOn ':generateLicenseReport'
// Third-party license report
from(rootProject.fileTree("${rootProject.buildDir}/reports/dependency-license") {
include 'licenses.txt'
}) {
rename { 'THIRD-PARTY-LICENSES.txt' }
into 'META-INF'
}
// All root LICENSE files
from(rootProject.projectDir) {
include("LICENSE*.md")
into("META-INF")
}
}
}
allprojects {
apply plugin: 'java'
apply plugin: 'checkstyle'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(25)
}
sourceCompatibility = JavaVersion.toVersion(25)
targetCompatibility = JavaVersion.toVersion(25)
}
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
repositories {
mavenCentral()
}
tasks.withType(JavaExec).configureEach {
dependsOn classes
standardInput = System.in
ignoreExitValue true
workingDir = rootProject.projectDir
jvmArgs '--enable-native-access=ALL-UNNAMED'
systemProperty 'BASELOGDIR', project.baseLogDir
systemProperty 'BASEREFLECTIONDIR', project.baseReflectionDir
}
clean {
delete project.baseLogDir
}
checkstyle {
configFile = rootProject.file('.checkstyle.xml')
ignoreFailures = false
maxWarnings = 0
}
// Declared as a dependency instead of `toolVersion` so that Dependabot updates it.
dependencies {
checkstyle rootProject.supportDependencies.checkstyle
}
tasks.withType(Checkstyle).configureEach {
group = 'verification'
}
// Generate an internal assets list for LibGDX (see https://lyze.dev/2021/04/29/libGDX-Internal-Assets-List/)
tasks.register('generateInternalAssetsList') {
group = 'assets'
description = 'Generate a newline-separated list of internal asset files under assets/ (relative paths)'
doLast {
def outDir = file("$buildDir/generated-resources/assets")
outDir.mkdirs()
def outFile = new File(outDir, 'internal_assets.txt')
def assetDirs = [] as Set
def visitedProjects = [] as Set
// Recursive function to collect assets from a project and its dependencies
def collectAssets
collectAssets = { proj ->
if (proj in visitedProjects) return
visitedProjects << proj
// Add asset directories using their configured resource-root semantics.
def projAssetsDir = new File(proj.projectDir, 'assets')
if (projAssetsDir.exists()) {
def configuredAssetDirs = proj.sourceSets.main.resources.srcDirs.findAll { dir ->
dir.toPath().normalize().startsWith(projAssetsDir.toPath().normalize())
}
assetDirs.addAll(configuredAssetDirs ?: [projAssetsDir])
}
// Recursively collect from project dependencies
proj.configurations.each { config ->
config.dependencies
.findAll { it instanceof ProjectDependency }
.each { dep ->
def dependencyProject = project.project(dep.path)
collectAssets(dependencyProject)
}
}
}
// Start collection from this project
collectAssets(project)
def paths = []
assetDirs.each { dir ->
dir.eachFileRecurse { f ->
// ignore markdown license files
if (f.isFile() && !f.name.endsWith('.md')) {
def rel = dir.toPath().relativize(f.toPath()).toString().replace('\\', '/')
paths << rel
}
}
}
paths = paths.unique().sort()
outFile.text = paths.join(System.lineSeparator())
println "Generated internal assets list with ${paths.size()} entries at: ${outFile}"
}
}
// Ensure resource processing includes the generated list and that generation runs beforehand
tasks.matching { it.name == 'processResources' }.configureEach {
from("$buildDir/generated-resources/assets") {
into('')
}
dependsOn tasks.named('generateInternalAssetsList')
}
// Make sure the list is generated before compilation as well (some builds expect resources ready early)
tasks.withType(JavaCompile).configureEach {
dependsOn tasks.named('generateInternalAssetsList')
}
}
tasks.named('clean') {
dependsOn subprojects.collect { it.tasks.named('clean') }
delete(
file("$rootDir/dungeon_config.json"),
file("$rootDir/system-recovery-save.json"),
file("$rootDir/last_session.dat"),
file("$rootDir/tracking-room-history.properties"),
file("$rootDir/tracking-outbox"),
fileTree(rootDir) {
include '**/*achievement-unlock.json'
}
)
}
spotless {
java {
targetExclude('build/generated-src/**')
googleJavaFormat()
target '**/*.java'
}
}