diff --git a/build.gradle b/build.gradle index 3c70ee0..4e69b60 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,4 @@ -import groovy.json.JsonSlurper -import groovy.json.JsonOutput +import java.nio.charset.StandardCharsets buildscript { repositories { @@ -14,28 +13,92 @@ buildscript { } plugins { - id 'fabric-loom' version '0.7-SNAPSHOT' - id 'maven-publish' + id "fabric-loom" version "0.6-SNAPSHOT" apply false + id "maven-publish" + id "java-library" } -sourceCompatibility = JavaVersion.VERSION_1_8 -targetCompatibility = JavaVersion.VERSION_1_8 - -archivesBaseName = project.archives_base_name -version = project.mod_version -group = project.maven_group +group = "draylar" +archivesBaseName = "omega-config" subprojects { apply plugin: 'fabric-loom' apply plugin: 'maven-publish' + apply plugin: 'java-library' archivesBaseName = project.name + group = "draylar.${project.group}" + + // import utility functions + apply from: "https://raw.githubusercontent.com/NerdHubMC/Gradle-Scripts/master/scripts/utilities.gradle" + + repositories { + mavenCentral() + } + + compileJava { + options.encoding = StandardCharsets.UTF_8.name() + } + + if (JavaVersion.current().isJava8Compatible()) { + allprojects { + tasks.withType(Javadoc) { + options.addStringOption("Xdoclint:none", "-quiet") + } + } + } + + jar { + from "LICENSE.md" + from "LICENSE" + manifest.mainAttributes( + "Implementation-Title": project.archivesBaseName, + "Implementation-Version": mod_version, + "Maven-Artifact": "${project.group}:${project.name}:${mod_version}".toLowerCase(Locale.ROOT), + "Built-On-Minecraft": "${project.minecraft_version}", + "Built-On-Java": "${System.getProperty("java.vm.version")} (${System.getProperty("java.vm.vendor")})" + ) + } + + task sourcesJar(type: Jar, dependsOn: classes) { + from sourceSets.main.allSource + classifier = "sources" + } + + task javadocJar(type: Jar, dependsOn: javadoc) { + from javadoc.destinationDir + classifier = "javadoc" + } + tasks.build.dependsOn javadocJar + + publishing { + publications { + mavenJava(MavenPublication) { + artifact(file("${project.buildDir}/libs/${archivesBaseName}-${project.mod_version}.jar")) { + builtBy(remapJar) + } + + pom.withXml { + def depsNode = asNode().appendNode("dependencies") + subprojects.each { + def depNode = depsNode.appendNode("dependency") + depNode.appendNode("groupId", it.group) + depNode.appendNode("artifactId", it.name) + depNode.appendNode("version", it.version) + depNode.appendNode("scope", "compile") + } + } + } + } + } + + tasks.publish.dependsOn build //stupid fix for maven/loom not publishing the main artifact task ('proguard', type: proguard.gradle.ProGuardTask) { - configuration '../proguard.conf' + configuration './proguard.conf' verbose - injars 'build/libs/' + archivesBaseName + "-" + project.mod_version + "-" + project.minecraft_version + ".jar" - outjars '/build/libs/' + archivesBaseName + "-min-" + project.mod_version + "-" + project.minecraft_version + ".jar" + injars project.buildDir.toString() + '/libs/' + archivesBaseName + "-" + project.mod_version + ".jar" + outjars project.buildDir.toString() + '/libs/' + archivesBaseName + "-" + project.mod_version + "-min.jar" printmapping 'out.map' keepparameternames renamesourcefileattribute 'SourceFile' @@ -55,19 +118,19 @@ subprojects { ;\ }' } - - // Task for building base jars in all modules - task buildJar(type: Jar) { - archivesBaseName += "-" + project.mod_version + "-" + project.minecraft_version - } - - buildJar.finalizedBy(proguard) } allprojects { - apply plugin: 'fabric-loom' + apply plugin: "fabric-loom" + sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8 + version = System.getenv("TRAVIS_TAG") ?: project.mod_version repositories { + maven { + name = "FabricMC" + url = "https://maven.fabricmc.net" + } + maven { url = "https://maven.terraformersmc.com/releases/"} } @@ -76,105 +139,98 @@ allprojects { minecraft "com.mojang:minecraft:${project.minecraft_version}" mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" - - // Fabric API. This is technically optional, but you probably want it anyway. modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" - modImplementation "com.terraformersmc:modmenu:1.16.8" - - afterEvaluate { - testmodImplementation sourceSets.main.output - } } processResources { - inputs.property "version", project.version + // this will ensure that this task is redone when there"s a change + inputs.property "version", mod_version + // replace stuff in fabric.mod.json, nothing else from(sourceSets.main.resources.srcDirs) { include "fabric.mod.json" - expand "version": project.version + + // add mod metadata + expand "version": mod_version } + // copy everything else, that"s not the fabric.mod.json from(sourceSets.main.resources.srcDirs) { exclude "fabric.mod.json" } - - doLast { - def jsonMinifyStart = System.currentTimeMillis() - def jsonMinified = 0 - def jsonBytesSaved = 0 - - fileTree(dir: outputs.files.asPath, include: '**/*.json').each { - - File file = it - jsonMinified++ - def oldLength = file.length() - file.text = JsonOutput.toJson(new JsonSlurper().parse(file)) - jsonBytesSaved += oldLength - file.length() - - println(it) - } - - println('Minified ' + jsonMinified + ' json files. Saved ' + jsonBytesSaved + ' bytes. Took ' + (System.currentTimeMillis() - jsonMinifyStart) + 'ms.') - } } - sourceSets { - testmod { - compileClasspath += main.compileClasspath - runtimeClasspath += main.runtimeClasspath + jar { + from(rootProject.file("LICENSE.md")) { + rename { "LICENSE_${project.archivesBaseName.replace('-', '_')}"} } } - - // 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 - } } -// base build task -task buildJar(type: Jar) { - archivesBaseName += "-" + project.mod_version + "-" + project.minecraft_version +sourceSets { + testmod { + compileClasspath += main.compileClasspath + runtimeClasspath += main.runtimeClasspath + } + test { + compileClasspath += main.compileClasspath + runtimeClasspath += main.runtimeClasspath + } +} + +task licenseFormatAll +subprojects { p -> licenseFormatAll.dependsOn("${p.path}:licenseFormat") } +subprojects.each { remapJar.dependsOn("${it.path}:remapJar") } + +repositories { + maven { + name = "JitPack" + url = "https://jitpack.io" + } } dependencies { - compile project(":omega-config-base") - compile project(":omega-config-gui") + minecraft "com.mojang:minecraft:${project.minecraft_version}" + mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" + modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" + + // Fabric API. This is technically optional, but you probably want it anyway. + modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" + + modImplementation "com.terraformersmc:modmenu:1.16.8" + + afterEvaluate { + testmodImplementation sourceSets.main.output + } + + afterEvaluate { + subprojects.each { + api it + include it + } + } } -// 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" -} - -// configure the maven publication publishing { publications { mavenJava(MavenPublication) { - // add all the jars that should be included when publishing to maven - artifact(remapJar) { - builtBy remapJar + artifact(file("${project.buildDir}/libs/${archivesBaseName}-${project.mod_version}.jar")) { + builtBy(remapJar) } - artifact(sourcesJar) { - builtBy remapSourcesJar + + pom.withXml { + def depsNode = asNode().appendNode("dependencies") + subprojects.each { + def depNode = depsNode.appendNode("dependency") + depNode.appendNode("groupId", it.group) + depNode.appendNode("artifactId", it.name) + depNode.appendNode("version", it.version) + depNode.appendNode("scope", "compile") + } } } } - - // select the repositories you want to publish to - repositories { - // uncomment to publish to the local maven - // mavenLocal() - } } -// technician what does this do -tasks.withType(net.fabricmc.loom.task.AbstractRunTask) { - classpath += sourceSets.testmod.runtimeClasspath - classpath += sourceSets.testmod.output -} \ No newline at end of file +tasks.publish.dependsOn build //stupid fix for maven/loom not publishing the main artifact \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 463091e..0a488c0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,14 +1,17 @@ # Done to increase the memory available to gradle. org.gradle.jvmargs=-Xmx1G + # Fabric Properties # check these on https://modmuss50.me/fabric.html minecraft_version=1.16.5 yarn_mappings=1.16.5+build.5 loader_version=0.11.2 + # Mod Properties mod_version=1.0.0 maven_group=draylar archives_base_name=omega-config + # Dependencies # check this on https://modmuss50.me/fabric.html fabric_version=0.32.0+1.16 diff --git a/omega-config-base/proguard.conf b/omega-config-base/proguard.conf new file mode 100644 index 0000000..7079fd3 --- /dev/null +++ b/omega-config-base/proguard.conf @@ -0,0 +1 @@ +-ignorewarnings \ No newline at end of file diff --git a/omega-config-gui/proguard.conf b/omega-config-gui/proguard.conf new file mode 100644 index 0000000..7079fd3 --- /dev/null +++ b/omega-config-gui/proguard.conf @@ -0,0 +1 @@ +-ignorewarnings \ No newline at end of file