Skip to content

Commit

Permalink
Ported to 1.18 (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheOnlyTails authored Dec 9, 2021
1 parent 0cd6ecf commit 58e399c
Show file tree
Hide file tree
Showing 20 changed files with 273 additions and 484 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,5 @@ run/
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar

/logs
logs
docs
15 changes: 3 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Maven metadata URL](https://img.shields.io/maven-metadata/v?color=blue&label=maven%20central&logo=gradle&metadataUrl=https%3A%2F%2Fs01.oss.sonatype.org%2Fservice%2Flocal%2Frepositories%2Freleases%2Fcontent%2Fcom%2Ftheonlytails%2lootgoblin%2Fmaven-metadata.xml&style=for-the-badge)](https://search.maven.org/artifact/com.theonlytails/lootgoblin)
[![Maven metadata URL](https://img.shields.io/maven-central/v/com.theonlytails/lootgoblin?color=blue&style=for-the-badge)](https://search.maven.org/artifact/com.theonlytails/lootgoblin)
![GitHub Workflow Status](https://img.shields.io/github/workflow/status/TheOnlyTails/LootGoblin/Java%20CI%20with%20Gradle?label=gradle%20build&logo=github&style=for-the-badge)
![Kotlin](https://img.shields.io/badge/kotlin-%238052ff.svg?style=for-the-badge&logo=kotlin&logoColor=white)
![Gradle](https://img.shields.io/badge/gradle-%2302303A.svg?style=for-the-badge&logo=gradle&logoColor=white)
Expand Down Expand Up @@ -30,11 +30,7 @@ repositories {
}
dependencies {
def lootGoblin = fg.deobf(project.dependencies.create(group: "com.theonlytails", name: "lootgoblin", version: VERSION) {
transitive = false
})
implementation fg.deobf(lootGoblin)
implementation fg.deobf("com.theonlytails:lootgoblin:VERSION")
}
```

Expand All @@ -45,15 +41,10 @@ repositories {
}

dependencies {
val lootGoblin = project.dependencies.create(group = "com.theonlytails", name = "lootgoblin", version = VERSION)
.apply { isTransitive = false }

implementation(fg.deobf(lootGoblin))
implementation(fg.deobf(group = "com.theonlytails", name = "lootgoblin", version = "VERSION"))
}
```

The `isTransitive` property is added to make sure the library is imported correctly.

---

Want to generate block models with a DSL like this? Check
Expand Down
121 changes: 63 additions & 58 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,29 +1,23 @@
import com.vanniktech.maven.publish.MavenPublishPluginExtension
import com.vanniktech.maven.publish.SonatypeHost
import org.gradle.jvm.toolchain.JvmVendorSpec.ADOPTOPENJDK
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.time.Instant.now
import java.time.format.DateTimeFormatter.ISO_INSTANT

plugins {
idea
`java-library`
kotlin("jvm") version "1.5.31"
id("net.minecraftforge.gradle")
id("com.vanniktech.maven.publish")
kotlin("jvm") version "1.6.0"
id("net.minecraftforge.gradle") version "5.+"
id("com.vanniktech.maven.publish.base")
id("org.jetbrains.dokka") version "latest.release" // dokka
}

// Config -> Minecraft
val forgeVersion = findProperty("forge_version") as String
val minecraftVersion = findProperty("minecraft_version") as String
val projectVersion = findProperty("VERSION_NAME") as String
val projectGroup = findProperty("GROUP") as String
val modId = findProperty("POM_ARTIFACT_ID") as String
val projectName = findProperty("POM_NAME") as String
val projectAuthor = findProperty("POM_DEVELOPER_NAME") as String

val testModId = "lootgoblin_test"
val projectVersion = findProperty("version") as String
val groupId = findProperty("groupId") as String
val modId = findProperty("modId") as String

// JVM Info
println("""
Expand All @@ -40,36 +34,6 @@ minecraft {
// accessTransformer(file("src/main/resources/META-INF/accesstransformer.cfg"))

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

taskName = "datagen"

// Recommended logging data for a userdev environment
property("forge.logging.markers", "SCAN,REGISTRIES,REGISTRYDUMP")

// Recommended logging level for the console
property("forge.logging.console.level", "debug")

// Specify the mod ID for data generation, where to output the resulting resource, and where to look for existing resources.
args("--mod",
testModId,
"--all",
"--output",
file("src/generated/resources/"),
"--existing",
file("src/main/resources/"))

mods {
create("lootgoblin") {
source(sourceSets["main"])
}
create(testModId) {
source(sourceSets["test"])
}
}
}

all {
lazyToken("minecraft_classpath") {
library.copyRecursive().resolve().joinToString(File.pathSeparator) { it.absolutePath }
Expand All @@ -83,47 +47,50 @@ val library: Configuration by configurations.creating
configurations.implementation.get().extendsFrom(library)

repositories {
maven {
name = "kotlinforforge"
url = uri("https://thedarkcolour.github.io/KotlinForForge/")
}
mavenCentral()
mavenLocal()
}

dependencies {
"minecraft"(group = "net.minecraftforge", name = "forge", version = "$minecraftVersion-$forgeVersion")
library(group = "org.jetbrains.kotlin", name = "kotlin-stdlib-jdk8", version = kotlin.coreLibrariesVersion)
library(group = "org.jetbrains.kotlin", name = "kotlin-stdlib", version = kotlin.coreLibrariesVersion) {
exclude("org.jetbrains", "annotations")
}
}

// Setup
project.group = projectGroup
project.group = groupId
project.version = projectVersion
base.archivesName.set(modId)

// Sets the toolchain to compile against OpenJDK 16
val javaVersion = 17

// Sets the toolchain to compile against Java 17
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(16))
vendor.set(ADOPTOPENJDK)
languageVersion.set(JavaLanguageVersion.of(javaVersion))
}
}
kotlin {
jvmToolchain {
(this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(javaVersion))
}
}

tasks.withType<KotlinCompile>().configureEach {
kotlinOptions.jvmTarget = "16"
kotlinOptions.jvmTarget = "$javaVersion"
}

// Finalize the jar by re-obfuscating
tasks.named<Jar>("jar") {
// Manifest
manifest {
attributes(
"Specification-Title" to projectName,
"Specification-Vendor" to projectAuthor,
"Specification-Title" to "LootGoblin",
"Specification-Vendor" to "TheOnlyTails",
"Specification-Version" to "1",
"Implementation-Title" to projectName,
"Implementation-Title" to "LootGoblin",
"Implementation-Version" to project.version,
"Implementation-Vendor" to projectName,
"Implementation-Vendor" to "LootGoblin",
"Implementation-Timestamp" to ISO_INSTANT.format(now()),
"FMLModType" to "GAMELIBRARY",
)
Expand All @@ -138,4 +105,42 @@ tasks.dokkaHtml.configure {
}

// Publishing to maven central
extensions.getByType<MavenPublishPluginExtension>().sonatypeHost = SonatypeHost.S01
plugins.withId("com.vanniktech.maven.publish.base") {
mavenPublishing {
publishToMavenCentral(SonatypeHost.S01)
signAllPublications()

pom {
name.set("LootGoblin")
description.set("A Kotlin DSL for creating loot tables in Minecraft Forge mods.")
url.set("https://github.com/theonlytails/lootgoblin")
inceptionYear.set("2021")

licenses {
license {
name.set("MIT License")
url.set("https://www.opensource.org/licenses/mit-license.php")
distribution.set("repo")
}
}

scm {
connection.set("scm:git:git://github.com/theonlytails/lootgoblin.git")
developerConnection.set("scm:git:ssh://[email protected]/theonlytails/lootgoblin.git")
url.set("https://github.com/theonlytails/lootgoblin/")
}

developers {
developer {
name.set("TheOnlyTails")
id.set("theonlytails")
url.set("https://github.com/theonlytails/")
}
}
}
}
}

publishing.publications.create<MavenPublication>("mavenLocal") {
artifactId = modId
}
24 changes: 5 additions & 19 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,9 @@ kotlin.stdlib.default.dependency=false
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false
# Versions
minecraft_version=1.17.1
forge_version=37.0.95
forge_gradle_version=5.+
minecraft_version=1.18
forge_version=38.0.15
# Maven publishing
GROUP=com.theonlytails
POM_ARTIFACT_ID=lootgoblin
VERSION_NAME=0.2.15
POM_NAME=LootGoblin
POM_DESCRIPTION=A Kotlin DSL for creating loot tables in Minecraft Forge mods.
POM_INCEPTION_YEAR=2021
POM_URL=https://github.com/theonlytails/lootgoblin
POM_LICENCE_NAME=MIT License
POM_LICENCE_URL=https://www.opensource.org/licenses/mit-license.php
POM_LICENCE_DIST=repo
POM_SCM_URL=https://github.com/theonlytails/lootgoblin/
POM_SCM_CONNECTION=scm:git:git://github.com/theonlytails/lootgoblin.git
POM_SCM_DEV_CONNECTION=scm:git:ssh://[email protected]/theonlytails/lootgoblin.git
POM_DEVELOPER_ID=theonlytails
POM_DEVELOPER_NAME=TheOnlyTails
POM_DEVELOPER_URL=https://github.com/theonlytails/
groupId=com.theonlytails
modId=lootgoblin
version=0.3.0
15 changes: 10 additions & 5 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@ pluginManagement {
mavenCentral()
gradlePluginPortal()
}
plugins {
id("net.minecraftforge.gradle")
}
resolutionStrategy {
eachPlugin {
if (requested.id.id == "net.minecraftforge.gradle") useModule("net.minecraftforge.gradle:ForgeGradle:${extra["forge_gradle_version"]}")
else if (requested.id.id == "com.vanniktech.maven.publish") useModule("com.vanniktech:gradle-maven-publish-plugin:latest.release")
if (requested.id.toString() == "net.minecraftforge.gradle")
useModule("${requested.id}:ForgeGradle:${requested.version}")
}
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath(group = "com.vanniktech", name = "gradle-maven-publish-plugin", version = "latest.release")
}
}
}
Empty file.

This file was deleted.

Loading

1 comment on commit 58e399c

@vercel
Copy link

@vercel vercel bot commented on 58e399c Dec 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.