Gradle 7 Support and Kotlin DSL Rewrite

pull/10/head
SmushyTaco 3 years ago
parent c2f7d5991b
commit 9c0fe3af68

11
.gitignore vendored

@ -1,7 +1,12 @@
#Gradle
.gradle
build
.gradle/
build/
out/
# Idea
.idea/
*.iml
*.ipr
*.iws
#Eclipse
.settings
.project

@ -1,91 +0,0 @@
buildscript {
repositories {
mavenCentral()
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
maven {
name = 'Jitpack'
url 'https://jitpack.io/'
}
maven {
name = 'HalfOf2'
url = 'https://storage.googleapis.com/devan-maven/'
}
}
dependencies {
classpath 'com.github.Chocohead:Fabric-Loom:d823377'
}
}
apply plugin: 'fabric-loom'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group
repositories {
maven {
name = 'Jitpack'
url 'https://jitpack.io/'
}
maven {
name = 'HalfOf2'
url = 'https://storage.googleapis.com/devan-maven/'
}
}
minecraft {
//Skip old versions of libraries which Mojang use but we don't need
addLibraryFilter {library ->
return !(library.startsWith('net.minecraft:launchwrapper:') ||
library.startsWith('net.sf.jopt-simple:jopt-simple:') ||
library.startsWith('org.ow2.asm:asm-all:'))
}
}
dependencies {
//to change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "io.github.minecraft-cursed-legacy:plasma:b1.7.3-build.${project.plasma_build}"
modImplementation("io.github.minecraft-cursed-legacy:cursed-fabric-loader:${project.loader_version}") {
transitive false
}
// API. You technically don't need it, but it's extremely useful for not having to write the same code in every mod.
modImplementation "io.github.minecraft-cursed-legacy:cursed-legacy-api:${project.api_version}"
}
processResources {
inputs.property 'version', project.version
from(sourceSets.main.resources.srcDirs) {
include 'fabric.mod.json'
expand 'version': project.version
}
from(sourceSets.main.resources.srcDirs) {
exclude 'fabric.mod.json'
}
}
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this task, sources will not be generated.
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}

@ -0,0 +1,59 @@
buildscript {
repositories {
mavenCentral()
maven("https://maven.fabricmc.net/") { name = "Fabric" }
maven("https://jitpack.io/") { name = "Jitpack" }
maven("https://storage.googleapis.com/devan-maven/") { name = "HalfOf2" }
}
dependencies {
classpath("com.github.Chocohead:Fabric-Loom:d823377")
}
}
plugins { java }
apply { plugin("fabric-loom") }
base {
val archivesBaseNameTwo: String by project
archivesBaseName = archivesBaseNameTwo
}
val modVersion: String by project
version = modVersion
val mavenGroup: String by project
group = mavenGroup
repositories {
maven("https://jitpack.io/") { name = "Jitpack" }
maven("https://storage.googleapis.com/devan-maven/") { name = "HalfOf2" }
}
dependencies {
val minecraftVersion: String by project
"minecraft"("com.mojang:minecraft:$minecraftVersion")
val plasmaBuild: String by project
"mappings"("io.github.minecraft-cursed-legacy:plasma:b1.7.3-build.$plasmaBuild")
val loaderVersion: String by project
"modImplementation"("io.github.minecraft-cursed-legacy:cursed-fabric-loader:$loaderVersion") {
isTransitive = false
}
val apiVersion: String by project
"modImplementation"("io.github.minecraft-cursed-legacy:cursed-legacy-api:$apiVersion")
}
tasks {
val javaVersion = JavaVersion.VERSION_1_8.toString()
withType<JavaCompile> {
options.encoding = "UTF-8"
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
}
processResources {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
inputs.property("version", project.version)
from(sourceSets["main"].resources.srcDirs) {
include("fabric.mod.json")
expand(mutableMapOf("version" to project.version))
}
from(sourceSets["main"].resources.srcDirs) { exclude("fabric.mod.json") }
}
val sourcesJar by creating(Jar::class) {
archiveClassifier.set("sources")
from(sourceSets.main.get().allSource)
}
artifacts { archives(sourcesJar) }
}

@ -1,13 +1,10 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx1G
# Fabric Properties
minecraft_version=b1.7.3
loader_version=1.0.0
plasma_build=18
api_version=1.1.0
minecraftVersion=b1.7.3
loaderVersion=1.0.0
plasmaBuild=18
apiVersion=1.1.0
# Mod Properties
mod_version = 1.0.0
maven_group = io.github.minecraftcursedlegacy.example
archives_base_name = cursed-legacy-example-mod
modVersion = 1.0.0
mavenGroup = io.github.minecraftcursedlegacy.example
archivesBaseNameTwo = cursed-legacy-example-mod

@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip

@ -1,34 +1,23 @@
package io.github.minecraftcursedlegacy.example;
import java.io.IOException;
import io.github.minecraftcursedlegacy.api.config.Configs;
import io.github.minecraftcursedlegacy.api.registry.Id;
import net.fabricmc.api.ModInitializer;
import tk.valoeghese.zoesteriaconfig.api.container.WritableConfig;
import tk.valoeghese.zoesteriaconfig.api.template.ConfigTemplate;
import java.io.IOException;
public class ExampleMod implements ModInitializer {
@Override
public void onInitialize() {
// This code runs as soon as Minecraft is in a mod-load-ready state.
// However, some things (like resources) may still be uninitialized.
// Proceed with mild caution.
System.out.println("Hello Fabric world!");
// example config
try {
config = Configs.loadOrCreate(new Id("modid", "example"),
ConfigTemplate.builder()
.addContainer("exampleContainer", container -> container.addDataEntry("someData", "0.5"))
.build());
.addContainer("exampleContainer", container -> container.addDataEntry("someData", "0.5"))
.build());
} catch (IOException e) {
throw new RuntimeException(e);
}
System.out.println(config.getDoubleValue("exampleContainer.someData"));
}
private static WritableConfig config;
}

@ -1,16 +1,13 @@
package io.github.minecraftcursedlegacy.example.mixin;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import net.minecraft.client.gui.screen.TitleScreen;
@Mixin(TitleScreen.class)
public class ExampleMixin {
@Inject(at = @At("HEAD"), method = "init()V")
private void init(CallbackInfo info) {
System.out.println("This line is printed by an example mod mixin!");
}
}
}
Loading…
Cancel
Save