-
Notifications
You must be signed in to change notification settings - Fork 823
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework the Gradle build scripts for multi-loader
* Shared logic is moved into a build plugin where possible * Build time is significantly improved when the Gradle daemon is warmed * Mixins are remapped in-place now, eliminating the need for refmaps at runtime. This also gets rid of some warning messages at startup. * Module relationships are now correctly represented in IDEA for other source sets (fixes a lot of code analysis features) * Split Java source and resources into different configurations * Run configurations are now consistent between NeoForge/Fabric * The common project is no longer remapped unnecessarily * Updated Gradle and build plugins
- Loading branch information
1 parent
65068c5
commit dc7dc4c
Showing
20 changed files
with
337 additions
and
336 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,5 @@ jobs: | |
- name: Upload assets to GitHub | ||
uses: AButler/[email protected] | ||
with: | ||
# Filter built files to disregard -sources and -dev, and leave only the minecraft-compatible jars. | ||
files: 'build/libs/*[0-9].jar;LICENSE' | ||
files: 'build/mods/*.jar' | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,84 +0,0 @@ | ||
plugins { | ||
id("java") | ||
id("fabric-loom") version ("1.7.3") apply (false) | ||
} | ||
|
||
val MINECRAFT_VERSION by extra { "1.21.1" } | ||
val NEOFORGE_VERSION by extra { "21.1.46" } | ||
val FABRIC_LOADER_VERSION by extra { "0.16.4" } | ||
val FABRIC_API_VERSION by extra { "0.103.0+1.21.1" } | ||
|
||
// This value can be set to null to disable Parchment. | ||
// TODO: Re-add Parchment | ||
val PARCHMENT_VERSION by extra { null } | ||
|
||
// https://semver.org/ | ||
val MOD_VERSION by extra { "0.6.0-beta.2" } | ||
|
||
allprojects { | ||
apply(plugin = "java") | ||
apply(plugin = "maven-publish") | ||
} | ||
|
||
tasks.withType<JavaCompile> { | ||
options.encoding = "UTF-8" | ||
} | ||
|
||
// Disable the default publish task if it exists | ||
tasks.replace("publish").dependsOn(":fabric:publish", ":neoforge:publish") | ||
tasks.replace("publishToMavenLocal").dependsOn(":fabric:publishToMavenLocal", ":neoforge:publishToMavenLocal") | ||
|
||
tasks.jar { | ||
enabled = false | ||
} | ||
|
||
subprojects { | ||
apply(plugin = "maven-publish") | ||
|
||
java.toolchain.languageVersion = JavaLanguageVersion.of(21) | ||
|
||
|
||
fun createVersionString(): String { | ||
val builder = StringBuilder() | ||
|
||
val isReleaseBuild = project.hasProperty("build.release") | ||
val buildId = System.getenv("GITHUB_RUN_NUMBER") | ||
|
||
if (isReleaseBuild) { | ||
builder.append(MOD_VERSION) | ||
} else { | ||
builder.append(MOD_VERSION.substringBefore('-')) | ||
builder.append("-snapshot") | ||
} | ||
|
||
builder.append("+mc").append(MINECRAFT_VERSION) | ||
|
||
if (!isReleaseBuild) { | ||
if (buildId != null) { | ||
builder.append("-build.${buildId}") | ||
} else { | ||
builder.append("-local") | ||
} | ||
} | ||
|
||
return builder.toString() | ||
} | ||
|
||
tasks.processResources { | ||
filesMatching("META-INF/neoforge.mods.toml") { | ||
expand(mapOf("version" to createVersionString())) | ||
} | ||
} | ||
|
||
version = createVersionString() | ||
group = "net.caffeinemc.mods" | ||
|
||
tasks.withType<JavaCompile> { | ||
options.encoding = "UTF-8" | ||
options.release.set(21) | ||
} | ||
|
||
tasks.withType<GenerateModuleMetadata>().configureEach { | ||
enabled = false | ||
} | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
plugins { | ||
`kotlin-dsl` | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
gradlePluginPortal() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
object BuildConfig { | ||
val MINECRAFT_VERSION: String = "1.21.1" | ||
val NEOFORGE_VERSION: String = "21.1.46" | ||
val FABRIC_LOADER_VERSION: String = "0.16.4" | ||
val FABRIC_API_VERSION: String = "0.103.0+1.21.1" | ||
|
||
// This value can be set to null to disable Parchment. | ||
// TODO: Re-add Parchment | ||
val PARCHMENT_VERSION: String? = null | ||
|
||
// https://semver.org/ | ||
val MOD_VERSION: String = "0.6.0-beta.2" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
plugins { | ||
id("java-library") | ||
id("idea") | ||
} | ||
|
||
group = "net.caffeinemc" | ||
version = BuildConfig.MOD_VERSION | ||
|
||
java.toolchain.languageVersion = JavaLanguageVersion.of(21) | ||
|
||
tasks.withType<JavaCompile> { | ||
options.encoding = "UTF-8" | ||
options.release.set(21) | ||
} | ||
|
||
tasks.withType<GenerateModuleMetadata>().configureEach { | ||
enabled = false | ||
} | ||
|
||
repositories { | ||
exclusiveContent { | ||
forRepository { | ||
maven { | ||
name = "Modrinth" | ||
url = uri("https://api.modrinth.com/maven") | ||
} | ||
} | ||
filter { | ||
includeGroup("maven.modrinth") | ||
} | ||
} | ||
|
||
exclusiveContent { | ||
forRepository { | ||
maven { | ||
name = "Parchment" | ||
url = uri("https://maven.parchmentmc.org") | ||
} | ||
} | ||
filter { | ||
includeGroup("org.parchmentmc.data") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
plugins { | ||
id("multiloader-base") | ||
id("maven-publish") | ||
} | ||
|
||
val configurationDesktopIntegrationJava: Configuration = configurations.create("commonDesktopIntegration") { | ||
isCanBeResolved = true | ||
} | ||
|
||
dependencies { | ||
configurationDesktopIntegrationJava(project(path = ":common", configuration = "commonDesktopJava")) | ||
} | ||
|
||
tasks { | ||
processResources { | ||
inputs.property("version", BuildConfig.MOD_VERSION) | ||
|
||
filesMatching(listOf("fabric.mod.json", "META-INF/neoforge.mods.toml")) { | ||
expand(mapOf("version" to BuildConfig.MOD_VERSION)) | ||
} | ||
} | ||
|
||
jar { | ||
duplicatesStrategy = DuplicatesStrategy.FAIL | ||
from(rootDir.resolve("LICENSE.md")) | ||
|
||
// Entry-point for desktop integration when the file is executed directly | ||
from(configurationDesktopIntegrationJava) | ||
manifest.attributes["Main-Class"] = "net.caffeinemc.mods.sodium.desktop.LaunchWarn" | ||
} | ||
} | ||
|
||
publishing { | ||
publications { | ||
create<MavenPublication>("maven") { | ||
groupId = project.group as String | ||
artifactId = project.name as String | ||
version = BuildConfig.MOD_VERSION | ||
|
||
from(components["java"]) | ||
} | ||
} | ||
} |
Oops, something went wrong.