Skip to content

Commit

Permalink
Bundle and relocate all the things
Browse files Browse the repository at this point in the history
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 ModCoderPack/MCInjector#4 for an example.
  • Loading branch information
Johni0702 committed Mar 29, 2020
1 parent 2e95b7f commit d1d9aaa
Showing 1 changed file with 21 additions and 92 deletions.
113 changes: 21 additions & 92 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation

buildscript {
repositories {
maven {
Expand All @@ -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'

Expand Down Expand Up @@ -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'
Expand All @@ -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

Expand All @@ -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'){
Expand All @@ -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"]
Expand All @@ -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
Expand Down Expand Up @@ -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:[email protected]: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)
}
}
}
Expand Down

0 comments on commit d1d9aaa

Please sign in to comment.