From d1d9aaa76e3d6adff70f38fbb4b6d0ca57cb9139 Mon Sep 17 00:00:00 2001 From: Jonas Herzig Date: Mon, 30 Mar 2020 00:46:52 +0200 Subject: [PATCH] Bundle and relocate all the things This is necessary because FG's patching approach is fairly brittle, so even a technically non-breaking upgrade to one of its deps (e.g. ASM 6.0 -> 6.1) can cause it to break. See https://github.com/ModCoderPack/MCInjector/pull/4 for an example. --- build.gradle | 113 ++++++++++----------------------------------------- 1 file changed, 21 insertions(+), 92 deletions(-) diff --git a/build.gradle b/build.gradle index bfdbfb184..0ca7f81ca 100644 --- a/build.gradle +++ b/build.gradle @@ -1,3 +1,5 @@ +import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation + buildscript { repositories { maven { @@ -10,10 +12,14 @@ buildscript { } } -apply plugin: 'java' +plugins { + id 'java' + id 'maven-publish' + id 'com.github.johnrengelman.shadow' version '5.2.0' +} + apply plugin: 'idea' apply plugin: 'eclipse' -apply plugin: 'maven' apply plugin: "com.gradle.plugin-publish" apply plugin: 'license' @@ -54,12 +60,10 @@ repositories { configurations { deployerJars - shade - compileOnly.extendsFrom shade } dependencies { - compile gradleApi() + shadow gradleApi() compile 'org.ow2.asm:asm:6.0' compile 'org.ow2.asm:asm-tree:6.0' @@ -80,7 +84,7 @@ dependencies { compile 'com.github.tony19:named-regexp:0.2.3' // 1.7 Named regexp features compile 'net.minecraftforge:forgeflower:1.0.342-SNAPSHOT' // Fernflower Forge edition - shade('net.md-5:SpecialSource:1.8.2'){ + compile('net.md-5:SpecialSource:1.8.2'){ exclude group: 'org.ow2.asm' } // deobf and reobf @@ -89,8 +93,8 @@ dependencies { compile 'org.apache.httpcomponents:httpmime:4.3.3' // mcp stuff - shade 'de.oceanlabs.mcp:RetroGuard:3.6.6' - shade('de.oceanlabs.mcp:mcinjector:3.4-SNAPSHOT'){ + compile 'de.oceanlabs.mcp:RetroGuard:3.6.6' + compile('de.oceanlabs.mcp:mcinjector:3.4-SNAPSHOT'){ exclude group: 'org.ow2.asm' } compile('net.minecraftforge.srg2source:Srg2Source:4.0-SNAPSHOT'){ @@ -112,13 +116,6 @@ wrapper { gradleVersion = '5.4.1' } -sourceSets { - main.compileClasspath += configurations.shade; - main.runtimeClasspath += configurations.shade; - test.compileClasspath += configurations.shade; - test.runtimeClasspath += configurations.shade; -} - compileJava { options.deprecation = true //options.compilerArgs += ["-Werror"] @@ -136,24 +133,6 @@ processResources { } jar { - - configurations.shade.each { dep -> - /* I can use this again to find where dupes come from, so.. gunna just keep it here. - logger.lifecycle(dep.toString()) - project.zipTree(dep).visit { - element -> - def path = element.relativePath.toString() - if (path.contains('org/eclipse/core') && path.endsWith('.class')) - println " $element.relativePath" - - } - */ - from(project.zipTree(dep)){ - exclude 'META-INF', 'META-INF/**', '.api_description', '.options', 'about.html', 'module-info.class', 'plugin.properties', 'plugin.xml', 'about_files/**' - duplicatesStrategy 'warn' - } - } - manifest { attributes 'version':project.version attributes 'javaCompliance': project.targetCompatibility @@ -238,66 +217,16 @@ pluginBundle { } } -uploadArchives { - repositories.mavenDeployer { - - dependsOn 'build' - - if (project.hasProperty('forgeMavenPass')) - { - repository(url: "https://files.minecraftforge.net/maven/manage/upload") { - authentication(userName: "forge", password: project.getProperty('forgeMavenPass')) - } - } - else - { - // local repo folder. Might wanna juset use gradle install if you wanans end it to maven-local - repository(url: 'file://localhost/' + project.file('repo').getAbsolutePath()) - } - +task relocateShadowJar(type: ConfigureShadowRelocation) { + target = tasks.shadowJar + prefix = "fg_2_3" +} +tasks.shadowJar.dependsOn tasks.relocateShadowJar - pom { - groupId = project.group - version = project.version - artifactId = project.archivesBaseName - project { - name project.archivesBaseName - packaging 'jar' - description 'Gradle plugin for Forge' - url 'https://github.com/MinecraftForge/ForgeGradle' - - scm { - url 'https://github.com/MinecraftForge/ForgeGradle' - connection 'scm:git:git://github.com/MinecraftForge/ForgeGradle.git' - developerConnection 'scm:git:git@github.com:MinecraftForge/ForgeGradle.git' - } - - issueManagement { - system 'github' - url 'https://github.com/MinecraftForge/ForgeGradle/issues' - } - - licenses { - license { - name 'Lesser GNU Public License, Version 2.1' - url 'https://www.gnu.org/licenses/lgpl-2.1.html' - distribution 'repo' - } - } - - developers { - developer { - id 'AbrarSyed' - name 'Abrar Syed' - roles { role 'developer' } - } - developer { - id 'LexManos' - name 'Lex Manos' - roles { role 'developer' } - } - } - } +publishing { + publications { + shadow(MavenPublication) { publication -> + project.shadow.component(publication) } } }