mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-06-07 09:04:10 +00:00
Some "improvements" to our Gradle script
- Switch to plugins { ... } imports for Forge (FG finally supports it!) - Use FG's new fg.component to clean up our Maven metadata instead. We also mark JEI as optional (using Gradle's registerFeature), which means we've no stray deps inside our POM any more.
This commit is contained in:
parent
b7f698d6f7
commit
f9f8233ef4
115
build.gradle
115
build.gradle
@ -1,16 +1,3 @@
|
|||||||
buildscript {
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
maven { url = "https://maven.minecraftforge.net" }
|
|
||||||
maven { url = 'https://maven.parchmentmc.org' }
|
|
||||||
}
|
|
||||||
dependencies {
|
|
||||||
classpath 'net.minecraftforge.gradle:ForgeGradle:5.1.+'
|
|
||||||
classpath "org.spongepowered:mixingradle:0.7.+"
|
|
||||||
classpath 'org.parchmentmc:librarian:1.+'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id "checkstyle"
|
id "checkstyle"
|
||||||
id "jacoco"
|
id "jacoco"
|
||||||
@ -18,13 +5,17 @@ plugins {
|
|||||||
id "com.github.hierynomus.license" version "0.16.1"
|
id "com.github.hierynomus.license" version "0.16.1"
|
||||||
id "com.matthewprenger.cursegradle" version "1.4.0"
|
id "com.matthewprenger.cursegradle" version "1.4.0"
|
||||||
id "com.github.breadmoirai.github-release" version "2.2.12"
|
id "com.github.breadmoirai.github-release" version "2.2.12"
|
||||||
id "org.jetbrains.kotlin.jvm" version "1.6.0"
|
id 'org.jetbrains.kotlin.jvm' version '1.7.0'
|
||||||
id "com.modrinth.minotaur" version "1.2.1"
|
id "com.modrinth.minotaur" version "2.+"
|
||||||
|
id "net.minecraftforge.gradle" version "5.1.+"
|
||||||
|
id "org.spongepowered.mixin" version "0.7.+"
|
||||||
|
id "org.parchmentmc.librarian.forgegradle" version "1.+"
|
||||||
}
|
}
|
||||||
|
|
||||||
apply plugin: 'net.minecraftforge.gradle'
|
|
||||||
apply plugin: "org.spongepowered.mixin"
|
import com.hierynomus.gradle.license.tasks.LicenseCheck
|
||||||
apply plugin: 'org.parchmentmc.librarian.forgegradle'
|
import com.hierynomus.gradle.license.tasks.LicenseFormat
|
||||||
|
import org.apache.tools.ant.taskdefs.condition.Os
|
||||||
|
|
||||||
version = mod_version
|
version = mod_version
|
||||||
|
|
||||||
@ -39,12 +30,7 @@ java {
|
|||||||
|
|
||||||
withSourcesJar()
|
withSourcesJar()
|
||||||
withJavadocJar()
|
withJavadocJar()
|
||||||
}
|
registerFeature("extraMods") { usingSourceSet(sourceSets.main) }
|
||||||
|
|
||||||
tasks.withType(JavaExec).configureEach {
|
|
||||||
javaLauncher = javaToolchains.launcherFor {
|
|
||||||
languageVersion = javaVersion
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
@ -140,11 +126,11 @@ dependencies {
|
|||||||
minecraft "net.minecraftforge:forge:${mc_version}-${forge_version}"
|
minecraft "net.minecraftforge:forge:${mc_version}-${forge_version}"
|
||||||
annotationProcessor 'org.spongepowered:mixin:0.8.4:processor'
|
annotationProcessor 'org.spongepowered:mixin:0.8.4:processor'
|
||||||
|
|
||||||
compileOnly fg.deobf("mezz.jei:jei-1.16.5:7.7.0.104:api")
|
extraModsCompileOnly fg.deobf("mezz.jei:jei-1.16.5:7.7.0.104:api")
|
||||||
compileOnly fg.deobf("com.blamejared.crafttweaker:CraftTweaker-1.16.5:7.1.0.313")
|
extraModsRuntimeOnly fg.deobf("mezz.jei:jei-1.16.5:7.7.0.104")
|
||||||
compileOnly fg.deobf("commoble.morered:morered-1.16.5:2.1.1.0")
|
|
||||||
|
|
||||||
runtimeOnly fg.deobf("mezz.jei:jei-1.16.5:7.7.0.104")
|
extraModsCompileOnly fg.deobf("com.blamejared.crafttweaker:CraftTweaker-1.16.5:7.1.0.313")
|
||||||
|
extraModsCompileOnly fg.deobf("commoble.morered:morered-1.16.5:2.1.1.0")
|
||||||
|
|
||||||
shade 'org.squiddev:Cobalt:0.5.5'
|
shade 'org.squiddev:Cobalt:0.5.5'
|
||||||
|
|
||||||
@ -152,9 +138,8 @@ dependencies {
|
|||||||
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.7.0'
|
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.7.0'
|
||||||
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
|
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
|
||||||
testImplementation 'org.hamcrest:hamcrest:2.2'
|
testImplementation 'org.hamcrest:hamcrest:2.2'
|
||||||
testImplementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.0'
|
testImplementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.0'
|
||||||
testImplementation 'org.jetbrains.kotlin:kotlin-reflect:1.6.0'
|
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.2'
|
||||||
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2'
|
|
||||||
|
|
||||||
testModImplementation sourceSets.main.output
|
testModImplementation sourceSets.main.output
|
||||||
|
|
||||||
@ -205,6 +190,8 @@ jar {
|
|||||||
from configurations.shade.collect { it.isDirectory() ? it : zipTree(it) }
|
from configurations.shade.collect { it.isDirectory() ? it : zipTree(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jar.finalizedBy("reobfJar")
|
||||||
|
|
||||||
[compileJava, compileTestJava, compileTestModJava].forEach {
|
[compileJava, compileTestJava, compileTestModJava].forEach {
|
||||||
it.configure {
|
it.configure {
|
||||||
options.compilerArgs << "-Xlint" << "-Xlint:-processing"
|
options.compilerArgs << "-Xlint" << "-Xlint:-processing"
|
||||||
@ -274,11 +261,6 @@ sourcesJar {
|
|||||||
|
|
||||||
// Web tasks
|
// Web tasks
|
||||||
|
|
||||||
|
|
||||||
import com.hierynomus.gradle.license.tasks.LicenseCheck
|
|
||||||
import com.hierynomus.gradle.license.tasks.LicenseFormat
|
|
||||||
import org.apache.tools.ant.taskdefs.condition.Os
|
|
||||||
|
|
||||||
List<String> mkCommand(String command) {
|
List<String> mkCommand(String command) {
|
||||||
return Os.isFamily(Os.FAMILY_WINDOWS) ? ["cmd", "/c", command] : ["sh", "-c", command]
|
return Os.isFamily(Os.FAMILY_WINDOWS) ? ["cmd", "/c", command] : ["sh", "-c", command]
|
||||||
}
|
}
|
||||||
@ -360,7 +342,7 @@ jacocoTestReport {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
check.dependsOn jacocoTestReport
|
test.finalizedBy(jacocoTestReport)
|
||||||
|
|
||||||
license {
|
license {
|
||||||
mapping("java", "SLASHSTAR_STYLE")
|
mapping("java", "SLASHSTAR_STYLE")
|
||||||
@ -412,15 +394,15 @@ task setupServer(type: Copy) {
|
|||||||
into "test-files/server"
|
into "test-files/server"
|
||||||
}
|
}
|
||||||
|
|
||||||
["Client", "Server"].forEach { name ->
|
tasks.register("testServer", JavaExec.class).configure {
|
||||||
tasks.register("test$name", JavaExec.class).configure {
|
|
||||||
it.group('In-game tests')
|
it.group('In-game tests')
|
||||||
it.description("Runs tests on a temporary Minecraft instance.")
|
it.description("Runs tests on a temporary Minecraft instance.")
|
||||||
it.dependsOn(setupServer, "prepareRunTest$name", "cleanTest$name", 'compileTestModJava')
|
it.dependsOn(setupServer, "prepareRunTestServer", "cleanTestServer", 'compileTestModJava')
|
||||||
|
finalizedBy("jacocoTestServerReport")
|
||||||
|
|
||||||
// Copy from runTestServer. We do it in this slightly odd way as runTestServer
|
// Copy from runTestServer. We do it in this slightly odd way as runTestServer
|
||||||
// isn't created until the task is configured (which is no good for us).
|
// isn't created until the task is configured (which is no good for us).
|
||||||
JavaExec exec = tasks.getByName("runTest$name")
|
JavaExec exec = tasks.getByName("runTestServer")
|
||||||
exec.copyTo(it)
|
exec.copyTo(it)
|
||||||
it.setClasspath(exec.getClasspath())
|
it.setClasspath(exec.getClasspath())
|
||||||
it.mainClass = exec.mainClass
|
it.mainClass = exec.mainClass
|
||||||
@ -432,7 +414,7 @@ task setupServer(type: Copy) {
|
|||||||
// Jacoco and modlauncher don't play well together as the classes loaded in-game don't
|
// Jacoco and modlauncher don't play well together as the classes loaded in-game don't
|
||||||
// match up with those written to disk. We get Jacoco to dump all classes to disk, and
|
// match up with those written to disk. We get Jacoco to dump all classes to disk, and
|
||||||
// use that when generating the report.
|
// use that when generating the report.
|
||||||
def coverageOut = new File(buildDir, "jacocoClassDump/test$name")
|
def coverageOut = new File(buildDir, "jacocoClassDump/testServer")
|
||||||
jacoco.applyTo(it)
|
jacoco.applyTo(it)
|
||||||
it.jacoco.setIncludes(["dan200.computercraft.*"])
|
it.jacoco.setIncludes(["dan200.computercraft.*"])
|
||||||
it.jacoco.setClassDumpDir(coverageOut)
|
it.jacoco.setClassDumpDir(coverageOut)
|
||||||
@ -442,14 +424,14 @@ task setupServer(type: Copy) {
|
|||||||
it.jacoco.setIncludeNoLocationClasses(true)
|
it.jacoco.setIncludeNoLocationClasses(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.register("jacocoTest${name}Report", JacocoReport.class).configure {
|
tasks.register("jacocoTestServerReport", JacocoReport.class).configure {
|
||||||
it.group('In-game')
|
it.group('In-game')
|
||||||
it.description("Generate coverage reports for test$name")
|
it.description("Generate coverage reports for testServer")
|
||||||
it.dependsOn("test$name")
|
it.dependsOn("testServer")
|
||||||
|
|
||||||
it.executionData(new File(buildDir, "jacoco/test${name}.exec"))
|
it.executionData(new File(buildDir, "jacoco/testServer.exec"))
|
||||||
it.sourceDirectories.from(sourceSets.main.allJava.srcDirs)
|
it.sourceDirectories.from(sourceSets.main.allJava.srcDirs)
|
||||||
it.classDirectories.from(new File(buildDir, "jacocoClassDump/test$name"))
|
it.classDirectories.from(new File(buildDir, "jacocoClassDump/testServer"))
|
||||||
|
|
||||||
it.reports {
|
it.reports {
|
||||||
xml.enabled true
|
xml.enabled true
|
||||||
@ -457,13 +439,7 @@ task setupServer(type: Copy) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name != "Client" || project.findProperty('cc.tweaked.clientTests') == 'true') {
|
check.dependsOn("testServer")
|
||||||
// Don't run client tests unless explicitly opted into them. They're a bit of a faff
|
|
||||||
// to run and pretty flakey.
|
|
||||||
check.dependsOn("jacocoTest${name}Report")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Upload tasks
|
// Upload tasks
|
||||||
|
|
||||||
@ -507,42 +483,36 @@ task checkRelease {
|
|||||||
}
|
}
|
||||||
check.dependsOn checkRelease
|
check.dependsOn checkRelease
|
||||||
|
|
||||||
|
def isStable = true
|
||||||
|
|
||||||
curseforge {
|
curseforge {
|
||||||
apiKey = project.hasProperty('curseForgeApiKey') ? project.curseForgeApiKey : ''
|
apiKey = project.hasProperty('curseForgeApiKey') ? project.curseForgeApiKey : ''
|
||||||
project {
|
project {
|
||||||
id = '282001'
|
id = '282001'
|
||||||
releaseType = 'release'
|
releaseType = isStable ? 'release' : 'alpha'
|
||||||
changelog = "Release notes can be found on the GitHub repository (https://github.com/cc-tweaked/CC-Tweaked/releases/tag/v${mc_version}-${mod_version})."
|
changelog = "Release notes can be found on the GitHub repository (https://github.com/cc-tweaked/CC-Tweaked/releases/tag/v${mc_version}-${mod_version})."
|
||||||
|
|
||||||
addGameVersion "${mc_version}"
|
addGameVersion "${mc_version}"
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
import com.modrinth.minotaur.TaskModrinthUpload
|
modrinth {
|
||||||
tasks.register('publishModrinth', TaskModrinthUpload.class).configure {
|
|
||||||
dependsOn('assemble', 'reobfJar')
|
|
||||||
onlyIf {
|
|
||||||
project.hasProperty('modrinthApiKey')
|
|
||||||
}
|
|
||||||
|
|
||||||
token = project.hasProperty('modrinthApiKey') ? project.getProperty('modrinthApiKey') : ''
|
token = project.hasProperty('modrinthApiKey') ? project.getProperty('modrinthApiKey') : ''
|
||||||
projectId = 'gu7yAYhd'
|
projectId = 'gu7yAYhd'
|
||||||
versionNumber = "${project.mc_version}-${project.mod_version}"
|
versionNumber = "${project.mc_version}-${project.mod_version}"
|
||||||
|
versionType = isStable ? 'release' : 'alpha'
|
||||||
uploadFile = jar
|
uploadFile = jar
|
||||||
addGameVersion(project.mc_version)
|
gameVersions = [project.mc_version]
|
||||||
changelog = "Release notes can be found on the [GitHub repository](https://github.com/cc-tweaked/CC-Tweaked/releases/tag/v${mc_version}-${mod_version})."
|
changelog = "Release notes can be found on the [GitHub repository](https://github.com/cc-tweaked/CC-Tweaked/releases/tag/v${mc_version}-${mod_version})."
|
||||||
addLoader('forge')
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.withType(GenerateModuleMetadata) {
|
|
||||||
// We can't generate metadata as that includes Forge as a dependency.
|
|
||||||
enabled = false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
publications {
|
publications {
|
||||||
maven(MavenPublication) {
|
maven(MavenPublication) {
|
||||||
from components.java
|
from components.java
|
||||||
|
fg.component(it)
|
||||||
|
|
||||||
pom {
|
pom {
|
||||||
name = 'CC: Tweaked'
|
name = 'CC: Tweaked'
|
||||||
@ -561,11 +531,9 @@ publishing {
|
|||||||
licenses {
|
licenses {
|
||||||
license {
|
license {
|
||||||
name = 'ComputerCraft Public License, Version 1.0'
|
name = 'ComputerCraft Public License, Version 1.0'
|
||||||
url = 'https://github.com/cc-tweaked/CC-Tweaked/blob/mc-1.15.x/LICENSE'
|
url = 'https://github.com/cc-tweaked/CC-Tweaked/blob/mc-1.16.x/LICENSE'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
withXml { asNode().remove(asNode().get("dependencies")) }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -606,10 +574,11 @@ githubRelease {
|
|||||||
.join("\n").trim()
|
.join("\n").trim()
|
||||||
}))
|
}))
|
||||||
prerelease false
|
prerelease false
|
||||||
|
prerelease !isStable
|
||||||
}
|
}
|
||||||
|
|
||||||
def uploadTasks = ["publish", "curseforge", "publishModrinth", "githubRelease"]
|
def uploadTasks = ["publish", "curseforge", "modrinth", "githubRelease"]
|
||||||
uploadTasks.forEach { tasks.getByName(it).dependsOn checkRelease }
|
uploadTasks.forEach { tasks.named(it) { dependsOn checkRelease } }
|
||||||
|
|
||||||
task uploadAll(dependsOn: uploadTasks) {
|
task uploadAll(dependsOn: uploadTasks) {
|
||||||
group "upload"
|
group "upload"
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
org.gradle.jvmargs=-Xmx3G
|
||||||
|
kotlin.stdlib.default.dependency=false
|
||||||
|
|
||||||
# Mod properties
|
# Mod properties
|
||||||
mod_version=1.100.6
|
mod_version=1.100.6
|
||||||
|
|
||||||
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,5 +1,5 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
@ -1 +0,0 @@
|
|||||||
rootProject.name = "cc-tweaked-${mc_version}"
|
|
17
settings.gradle.kts
Normal file
17
settings.gradle.kts
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
pluginManagement {
|
||||||
|
repositories {
|
||||||
|
gradlePluginPortal()
|
||||||
|
maven("https://maven.minecraftforge.net")
|
||||||
|
maven("https://maven.parchmentmc.org")
|
||||||
|
}
|
||||||
|
resolutionStrategy {
|
||||||
|
eachPlugin {
|
||||||
|
if (requested.id.id == "org.spongepowered.mixin") {
|
||||||
|
useModule("org.spongepowered:mixingradle:${requested.version}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val mc_version: String by settings
|
||||||
|
rootProject.name = "cc-tweaked-${mc_version}"
|
Loading…
x
Reference in New Issue
Block a user