84 lines
2.6 KiB
Groovy
84 lines
2.6 KiB
Groovy
plugins {
|
|
id 'java'
|
|
id 'idea'
|
|
id 'eclipse'
|
|
}
|
|
|
|
group = 'it.ytnoos.lpx'
|
|
version = '3.9.1'
|
|
|
|
def javaVersion = 17
|
|
|
|
repositories {
|
|
mavenCentral()
|
|
maven { url = uri('https://hub.spigotmc.org/nexus/content/repositories/snapshots/') }
|
|
}
|
|
|
|
configurations {
|
|
apiGenerator
|
|
}
|
|
|
|
def generatorClasses = layout.buildDirectory.dir('api-generator/classes')
|
|
tasks.register('compileApiGenerator', JavaCompile) {
|
|
source = files('gradle/GenerateCompileApis.java')
|
|
classpath = configurations.apiGenerator
|
|
destinationDirectory = generatorClasses
|
|
javaCompiler = javaToolchains.compilerFor { languageVersion = JavaLanguageVersion.of(javaVersion) }
|
|
options.release = 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')
|
|
inputs.dir('gradle/api-signatures')
|
|
outputs.dir(layout.buildDirectory.dir('compile-apis'))
|
|
classpath = files(generatorClasses) + configurations.apiGenerator
|
|
javaLauncher = javaToolchains.launcherFor { languageVersion = JavaLanguageVersion.of(javaVersion) }
|
|
mainClass = 'GenerateCompileApis'
|
|
maxHeapSize = '2g'
|
|
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('lpx')
|
|
compileOnly 'org.jetbrains:annotations:26.0.2-1'
|
|
compileOnly 'org.jspecify:jspecify:1.0.0'
|
|
compileOnly 'org.checkerframework:checker-qual:3.49.3'
|
|
compileOnly 'com.google.code.gson:gson:2.10.1'
|
|
}
|
|
|
|
tasks.withType(JavaCompile).configureEach {
|
|
if (name != 'compileApiGenerator') {
|
|
dependsOn tasks.named('generateCompileApis')
|
|
}
|
|
options.release = javaVersion
|
|
options.encoding = 'UTF-8'
|
|
options.compilerArgs += ['-parameters', '-Xmaxerrs', '1500']
|
|
}
|
|
|
|
tasks.withType(AbstractArchiveTask).configureEach {
|
|
preserveFileTimestamps = false
|
|
reproducibleFileOrder = true
|
|
}
|
|
|
|
jar {
|
|
manifest.attributes('Implementation-Title': 'LPX', 'Implementation-Version': project.version)
|
|
}
|