added files.
This commit is contained in:
commit
834de66687
2839 files changed
+440385
No files matched your search
+182
@@ -0,0 +1,182 @@
|
||||
import groovy.json.JsonSlurper
|
||||
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'idea'
|
||||
id 'eclipse'
|
||||
}
|
||||
|
||||
group = 'com.doomsdayclient'
|
||||
version = '0.9.12'
|
||||
|
||||
def javaVersion = 17
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url = uri('https://libraries.minecraft.net') }
|
||||
}
|
||||
|
||||
configurations {
|
||||
apiGenerator
|
||||
}
|
||||
|
||||
def generatorClasses = layout.buildDirectory.dir('api-generator/classes')
|
||||
tasks.register('compileApiGenerator', JavaCompile) {
|
||||
source = files('gradle/GenerateCompileApis.java', 'gradle/GenerateSourceDeclarations.java')
|
||||
classpath = configurations.apiGenerator
|
||||
destinationDirectory = generatorClasses
|
||||
javaCompiler = javaToolchains.compilerFor { languageVersion = JavaLanguageVersion.of(javaVersion) }
|
||||
options.encoding = 'UTF-8'
|
||||
}
|
||||
|
||||
tasks.register('generateCompileApis', JavaExec) {
|
||||
group = 'build setup'
|
||||
description = 'Generates compile-only API headers from text declarations.'
|
||||
dependsOn tasks.named('compileApiGenerator')
|
||||
def schemas = fileTree('gradle/api-signatures') { include '**/*.json' }
|
||||
inputs.files(schemas)
|
||||
outputs.files(schemas.files.collect { schema ->
|
||||
def relative = file('gradle/api-signatures').toPath().relativize(schema.toPath()).toString()
|
||||
layout.buildDirectory.file("compile-apis/${relative.replaceAll(/\.json$/, '.jar')}")
|
||||
})
|
||||
classpath = files(generatorClasses) + configurations.apiGenerator
|
||||
javaLauncher = javaToolchains.launcherFor { languageVersion = JavaLanguageVersion.of(javaVersion) }
|
||||
mainClass = 'GenerateCompileApis'
|
||||
args file('gradle/api-signatures').absolutePath, layout.buildDirectory.dir('compile-apis').get().asFile.absolutePath
|
||||
}
|
||||
|
||||
def compileApi = { String name ->
|
||||
files(layout.buildDirectory.file("compile-apis/${name}.jar")).builtBy(tasks.named('generateCompileApis'))
|
||||
}
|
||||
|
||||
tasks.register('prepareIde') {
|
||||
group = 'ide'
|
||||
description = 'Generates the compile-only API headers used by the IDE import.'
|
||||
dependsOn tasks.named('generateCompileApis')
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion = JavaLanguageVersion.of(javaVersion)
|
||||
}
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
apiGenerator 'org.ow2.asm:asm:9.8'
|
||||
apiGenerator 'com.google.code.gson:gson:2.10.1'
|
||||
|
||||
compileOnly compileApi('minecraft-obf')
|
||||
compileOnly compileApi('minecraft-compat')
|
||||
compileOnly compileApi('unloaded-compat')
|
||||
|
||||
compileOnly 'org.lwjgl:lwjgl:3.4.3'
|
||||
compileOnly 'org.lwjgl:lwjgl-glfw:3.4.3'
|
||||
compileOnly 'org.lwjgl:lwjgl-opengl:3.4.3'
|
||||
compileOnly 'org.lwjgl:lwjgl-vulkan:3.4.3'
|
||||
compileOnly 'org.joml:joml:1.10.8'
|
||||
compileOnly 'org.lwjgl:lwjgl-sdl:3.4.3'
|
||||
compileOnly 'com.mojang:brigadier:1.3.11'
|
||||
compileOnly 'com.mojang:datafixerupper:6.0.8'
|
||||
compileOnly 'io.netty:netty-all:4.1.115.Final'
|
||||
compileOnly 'com.google.guava:guava:33.3.1-jre'
|
||||
compileOnly 'it.unimi.dsi:fastutil:8.5.14'
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
if (name != 'compileApiGenerator') {
|
||||
dependsOn tasks.named('generateCompileApis')
|
||||
}
|
||||
options.encoding = 'UTF-8'
|
||||
options.release = javaVersion
|
||||
options.compilerArgs += ['-Xlint:none', '-Xmaxerrs', '20000']
|
||||
}
|
||||
|
||||
tasks.withType(AbstractArchiveTask).configureEach {
|
||||
preserveFileTimestamps = false
|
||||
reproducibleFileOrder = true
|
||||
}
|
||||
|
||||
jar {
|
||||
manifest {
|
||||
attributes(
|
||||
'Implementation-Title': 'OpenDoomsday',
|
||||
'Implementation-Version': project.version)
|
||||
}
|
||||
}
|
||||
|
||||
idea {
|
||||
module {
|
||||
downloadSources = true
|
||||
downloadJavadoc = true
|
||||
}
|
||||
}
|
||||
|
||||
eclipse {
|
||||
classpath {
|
||||
downloadSources = true
|
||||
downloadJavadoc = true
|
||||
}
|
||||
}
|
||||
|
||||
// The MC_CLASS / MC_FIELD / MC_METHOD indices belong to a mapping version.
|
||||
// Compiling all variants against one merged API loses their inheritance and
|
||||
// selects unrelated method signatures. Each variant keeps its original names
|
||||
// and compiles against the verified declarations for its own mapping version.
|
||||
def variantGroups = new JsonSlurper().parse(file('gradle/source-variants.json')).groups
|
||||
def variantSourcePaths = variantGroups.values().flatten() as Set
|
||||
def sourceDeclarations = layout.buildDirectory.file('compile-apis/source-declarations.jar')
|
||||
|
||||
tasks.register('generateSourceDeclarations', JavaExec) {
|
||||
group = 'build setup'
|
||||
description = 'Creates compile-only declarations for cross-variant source references.'
|
||||
dependsOn tasks.named('generateCompileApis')
|
||||
inputs.files(fileTree('src/main/java') { include '**/*.java' })
|
||||
inputs.files(configurations.compileClasspath)
|
||||
inputs.file('gradle/source-variants.json')
|
||||
inputs.file('gradle/api-alias-types.json')
|
||||
outputs.file(sourceDeclarations)
|
||||
outputs.files(variantGroups.keySet().collect { layout.buildDirectory.file("compile-apis/versions/source-declarations-${it}.jar") })
|
||||
classpath = files(generatorClasses) + configurations.apiGenerator
|
||||
javaLauncher = javaToolchains.launcherFor { languageVersion = JavaLanguageVersion.of(javaVersion) }
|
||||
mainClass = 'GenerateSourceDeclarations'
|
||||
maxHeapSize = '4g'
|
||||
doFirst {
|
||||
args = [file('src/main/java').absolutePath,
|
||||
sourceDeclarations.get().asFile.absolutePath,
|
||||
configurations.compileClasspath.asPath,
|
||||
file('gradle/source-variants.json').absolutePath,
|
||||
file('gradle/api-alias-types.json').absolutePath]
|
||||
}
|
||||
}
|
||||
|
||||
tasks.named('compileJava', JavaCompile) {
|
||||
dependsOn tasks.named('generateSourceDeclarations')
|
||||
source = fileTree('src/main/java') {
|
||||
include '**/*.java'
|
||||
exclude { entry -> variantSourcePaths.contains(entry.relativePath.pathString) }
|
||||
}
|
||||
classpath += files(sourceDeclarations)
|
||||
options.sourcepath = files()
|
||||
options.compilerArgs += ['-implicit:none']
|
||||
}
|
||||
|
||||
variantGroups.each { versionName, paths ->
|
||||
def suffix = versionName.replace('.', '_')
|
||||
def variantOutput = layout.buildDirectory.dir("classes/java/minecraft-${versionName}")
|
||||
def variantTask = tasks.register("compileMinecraft${suffix}", JavaCompile) {
|
||||
group = 'build'
|
||||
description = "Compiles Minecraft ${versionName} mapping adapters."
|
||||
dependsOn tasks.named('compileJava'), tasks.named('generateSourceDeclarations')
|
||||
source = files(paths.collect { file("src/main/java/${it}") })
|
||||
classpath = files(layout.buildDirectory.file("compile-apis/versions/minecraft-${versionName}.jar")) +
|
||||
files(layout.buildDirectory.dir('classes/java/main')) +
|
||||
configurations.compileClasspath + files(layout.buildDirectory.file("compile-apis/versions/source-declarations-${versionName}.jar"))
|
||||
destinationDirectory = variantOutput
|
||||
javaCompiler = javaToolchains.compilerFor { languageVersion = JavaLanguageVersion.of(javaVersion) }
|
||||
options.sourcepath = files()
|
||||
options.compilerArgs += ['-implicit:none']
|
||||
}
|
||||
sourceSets.main.output.dir([builtBy: variantTask], variantOutput)
|
||||
tasks.named('classes') { dependsOn variantTask }
|
||||
}
|
||||
Reference in new issue
Block a user