Set up Java 25 builds, quality checks and licensing
This commit is contained in:
commit
a318a03393
1 changed files with 774 additions and 0 deletions
140
build.gradle
Normal file
140
build.gradle
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
plugins {
|
||||
id 'java-library'
|
||||
id 'checkstyle'
|
||||
id 'net.neoforged.gradle.userdev' version '7.1.39'
|
||||
}
|
||||
|
||||
group = 'dev.quorate'
|
||||
version = '0.42.1'
|
||||
def modVersion = version.toString()
|
||||
|
||||
java {
|
||||
toolchain.languageVersion = JavaLanguageVersion.of(25)
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
repositories {
|
||||
ivy {
|
||||
url = 'https://github.com/tlaplus/tlaplus/releases/download'
|
||||
patternLayout { artifact '[revision]/[artifact].[ext]' }
|
||||
metadataSources { artifact() }
|
||||
content { includeModule 'org.lamport', 'tla2tools' }
|
||||
}
|
||||
mavenCentral()
|
||||
maven {
|
||||
url = 'https://maven.blamejared.com/'
|
||||
content { includeGroup 'com.hrznstudio' }
|
||||
}
|
||||
maven {
|
||||
url = 'https://modmaven.dev/'
|
||||
content { includeGroup 'mekanism' }
|
||||
}
|
||||
maven {
|
||||
url = 'https://www.cursemaven.com'
|
||||
content { includeGroup 'curse.maven' }
|
||||
}
|
||||
maven {
|
||||
url = 'https://api.modrinth.com/maven'
|
||||
content { includeGroup 'maven.modrinth' }
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
probe {
|
||||
compileClasspath += sourceSets.main.output + configurations.compileClasspath
|
||||
}
|
||||
}
|
||||
configurations { javafmt }
|
||||
dependencies {
|
||||
implementation 'net.neoforged:neoforge:21.1.250'
|
||||
compileOnly('mekanism:Mekanism:1.21.1-10.7.19.85') { transitive = false }
|
||||
compileOnly('curse.maven:functional-storage-556861:8459097') { transitive = false }
|
||||
compileOnly('maven.modrinth:refined-storage:lHHiI26k') { transitive = false }
|
||||
compileOnly 'org.jetbrains:annotations:24.1.0'
|
||||
compileOnly 'org.apiguardian:apiguardian-api:1.1.2'
|
||||
compileOnly 'io.github.llamalad7:mixinextras-neoforge:0.5.3'
|
||||
probeCompileOnly('com.hrznstudio:titanium:1.21-4.0.43') { transitive = false }
|
||||
testImplementation 'it.unimi.dsi:fastutil:8.5.12'
|
||||
testImplementation('org.lamport:tla2tools:v1.7.4') { transitive = false }
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter:5.11.4'
|
||||
testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.11.4'
|
||||
javafmt('com.google.googlejavaformat:google-java-format:1.37.0:all-deps') { transitive = false }
|
||||
}
|
||||
|
||||
checkstyle {
|
||||
toolVersion = '14.3.0'
|
||||
configFile = file('quality.xml')
|
||||
}
|
||||
|
||||
def javaSources = fileTree('src') { include '**/*.java' }
|
||||
['format': ['--replace'], 'formatCheck': ['--dry-run', '--set-exit-if-changed']].each { name, mode ->
|
||||
tasks.register(name, JavaExec) {
|
||||
javaLauncher = javaToolchains.launcherFor { languageVersion = JavaLanguageVersion.of(25) }
|
||||
classpath = configurations.javafmt
|
||||
mainClass = 'com.google.googlejavaformat.java.Main'
|
||||
jvmArgs = ['api', 'code', 'file', 'parser', 'tree', 'util'].collect {
|
||||
"--add-exports=jdk.compiler/com.sun.tools.javac.${it}=ALL-UNNAMED"
|
||||
}
|
||||
doFirst { args = ['--aosp'] + mode + javaSources.files.sort().collect { it.path } }
|
||||
}
|
||||
}
|
||||
tasks.named('formatCheck') { mustRunAfter 'format' }
|
||||
tasks.withType(Checkstyle).configureEach { mustRunAfter 'format' }
|
||||
tasks.register('quality') { dependsOn 'formatCheck', 'checkstyleMain', 'checkstyleTest', 'checkstyleProbe' }
|
||||
tasks.named('check') { dependsOn 'quality' }
|
||||
tasks.named('checkstyleProbe') {
|
||||
dependsOn 'compileProbeJava'
|
||||
classpath = sourceSets.probe.compileClasspath
|
||||
}
|
||||
|
||||
tasks.named('test') {
|
||||
dependsOn 'quality'
|
||||
inputs.dir('src/test/tla')
|
||||
useJUnitPlatform()
|
||||
maxHeapSize = '512m'
|
||||
jvmArgs '-XX:+UseZGC'
|
||||
}
|
||||
|
||||
tasks.named('processResources') {
|
||||
inputs.property 'version', modVersion
|
||||
filesMatching('META-INF/neoforge.mods.toml') { expand version: modVersion }
|
||||
}
|
||||
|
||||
['compileJava', 'compileTestJava', 'compileProbeJava'].each { name ->
|
||||
tasks.named(name, JavaCompile) {
|
||||
options.encoding = 'UTF-8'
|
||||
options.compilerArgs += ['-Xlint:all', '-Werror', '-proc:none']
|
||||
mustRunAfter 'format'
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(Jar).configureEach {
|
||||
preserveFileTimestamps = false
|
||||
reproducibleFileOrder = true
|
||||
from(['LICENSE.md', 'COPYING', 'COPYING.LESSER', 'NOTICE.md']) { into 'META-INF' }
|
||||
}
|
||||
|
||||
tasks.named('processProbeResources') {
|
||||
inputs.property 'version', modVersion
|
||||
filesMatching('META-INF/neoforge.mods.toml') { expand version: modVersion }
|
||||
dependsOn 'test'
|
||||
['Slots', 'SlotOverflow', 'Traits'].each { name ->
|
||||
from(layout.buildDirectory.dir("reports/models/${name}")) {
|
||||
include 'cases.jsonl', 'stats.json'
|
||||
eachFile { entry -> entry.path = "cases/${name}." + (entry.name == 'cases.jsonl' ? 'jsonl' : 'json') }
|
||||
}
|
||||
}
|
||||
from({ zipTree(configurations.compileClasspath.resolvedConfiguration.resolvedArtifacts.find {
|
||||
it.moduleVersion.id.group == 'mekanism' && it.name == 'Mekanism'
|
||||
}.file) }) {
|
||||
include 'mekanism/common/content/transporter/TransporterManager*.class'
|
||||
into 'baseline'
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register('probeJar', Jar) {
|
||||
dependsOn 'quality', 'probeClasses'
|
||||
archiveBaseName = 'mc-checks'
|
||||
destinationDirectory = layout.buildDirectory.dir('probe')
|
||||
from sourceSets.probe.output
|
||||
}
|
||||
Loading…
Reference in a new issue