Skip to content

Commit

Permalink
Switch to Kotlin for Gradle.
Browse files Browse the repository at this point in the history
  • Loading branch information
fnuecke committed Aug 18, 2023
1 parent 806c2ec commit f255eb3
Show file tree
Hide file tree
Showing 6 changed files with 147 additions and 148 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: ubuntu-latest-gradle-
- name: Build with Gradle
run: ./gradlew -Psemver='${{ steps.split_tag.outputs.mod_version }}' build
run: ./gradlew -PmodVersion='${{ steps.split_tag.outputs.mod_version }}' build

- name: Add Artifacts to Github Release
uses: alexellis/upload-assets@0.4.0
Expand Down
128 changes: 0 additions & 128 deletions build.gradle

This file was deleted.

128 changes: 128 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
plugins {
id("net.minecraftforge.gradle") version "[6.0,6.2)"
id("idea")
id("eclipse")
}

fun getGitRef(): String {
return providers.exec {
commandLine("git", "rev-parse", "--short", "HEAD")
isIgnoreExitValue = true
}.standardOutput.asText.get().trim()
}

val modId: String by extra
val minecraftVersion: String by extra
val forgeVersion: String by extra
val modVersion: String by extra
val mavenGroup: String by extra

version = "${modVersion}+${getGitRef()}"
group = mavenGroup
base {
archivesName.set("${modId}-MC${minecraftVersion}")
}

java.toolchain.languageVersion.set(JavaLanguageVersion.of(17))

tasks.withType<JavaCompile>().configureEach {
options.encoding = "utf-8"
}

repositories {
maven {
url = uri("https://cursemaven.com")
content { includeGroup("curse.maven") }
}
}

dependencies {
minecraft("net.minecraftforge:forge:${minecraftVersion}-${forgeVersion}")

// Just for in-dev convenience. Mod doesn't use any JEI APIs.
runtimeOnly(fg.deobf("curse.maven:jei-238222:4690097"))
}

minecraft {
mappings("official", minecraftVersion)

runs {
create("client") {
workingDirectory(file("run"))

property("forge.logging.markers", "REGISTRIES")
property("forge.logging.console.level", "info")

mods {
create(modId) {
source(sourceSets.main.get())
}
}
}

create("server") {
workingDirectory(file("run"))

property("forge.logging.markers", "REGISTRIES")
property("forge.logging.console.level", "info")

mods {
create(modId) {
source(sourceSets.main.get())
}
}
}

create("data") {
workingDirectory(file("run"))

property("forge.logging.markers", "REGISTRIES")
property("forge.logging.console.level", "info")

args("--mod", "bedrockores", "--all", "--output", file("src/generated/resources/"), "--existing", file("src/main/resources"))

mods {
create(modId) {
source(sourceSets.main.get())
}
}
}
}
}

tasks.register<Copy>("copyGeneratedResources") {
from("src/generated")
into("src/main")
exclude("resources/.cache")
}

tasks.withType<ProcessResources> {
inputs.property("version", modVersion)

filesMatching("META-INF/mods.toml") {
expand(mapOf("version" to modVersion))
}
}

tasks.withType<Jar> {
finalizedBy("reobfJar")

manifest {
attributes(mapOf(
"Specification-Title" to "bedrockores",
"Specification-Vendor" to "Sangar",
"Specification-Version" to "1",
"Implementation-Title" to project.name,
"Implementation-Version" to version,
"Implementation-Vendor" to "Sangar",
))
}
}

idea {
module {
for (exclude in arrayOf("out", "logs")) {
excludeDirs.add(file(exclude))
}
}
}
12 changes: 5 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false

minecraft_version=1.20.1
minecraftVersion=1.20.1
forgeVersion=47.1.0

archives_base_name=bedrockores
maven_group=li.cil.bedrockores

forge_version=47.1.0
modId=bedrockores
mavenGroup=li.cil.bedrockores

# Set by build pipeline.
semver=0.0.0
modVersion=0.0.0
12 changes: 0 additions & 12 deletions settings.gradle

This file was deleted.

13 changes: 13 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
pluginManagement {
repositories {
gradlePluginPortal()
maven { url = uri("https://maven.minecraftforge.net/") }
}
}

plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version "0.5.0"
}

val modId: String by settings
rootProject.name = modId

0 comments on commit f255eb3

Please sign in to comment.