Skip to content

Commit

Permalink
Mixinexit (#9)
Browse files Browse the repository at this point in the history
* update buildscript

* exit if a mixin fails

* exit code -99 for missing mixins

* fix error
  • Loading branch information
bombcar authored Dec 23, 2021
1 parent 551a6b1 commit 971a68b
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 29 deletions.
113 changes: 86 additions & 27 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//version: 928ecf7feb33a1149538b0e2cd17e3bc5f281428
//version: 8fa7883b6196c1765266f4e6ddf3118d5043aafb
/*
DO NOT CHANGE THIS FILE!
Expand Down Expand Up @@ -42,6 +42,7 @@ plugins {
id("org.ajoberstar.grgit") version("3.1.1")
id("com.github.johnrengelman.shadow") version("4.0.4")
id("com.palantir.git-version") version("0.12.3")
id("maven-publish")
}

apply plugin: 'forge'
Expand Down Expand Up @@ -194,7 +195,9 @@ if(file("addon.gradle").exists()) {
apply from: 'repositories.gradle'

configurations {
implementation.extendsFrom(shadowImplementation)
implementation.extendsFrom(shadowImplementation) // TODO: remove after all uses are refactored
implementation.extendsFrom(shadowCompile)
implementation.extendsFrom(shadeCompile)
}

repositories {
Expand Down Expand Up @@ -260,16 +263,28 @@ task relocateShadowJar(type: ConfigureShadowRelocation) {
}

shadowJar {
project.configurations.shadeCompile.each { dep ->
from(project.zipTree(dep)) {
exclude 'META-INF', 'META-INF/**'
}
}

manifest {
attributes(getManifestAttributes())
}

minimize() // This will only allow shading for actually used classes
configurations = [project.configurations.shadowImplementation]
configurations = [project.configurations.shadowImplementation, project.configurations.shadowCompile]
dependsOn(relocateShadowJar)
}

jar {
project.configurations.shadeCompile.each { dep ->
from(project.zipTree(dep)) {
exclude 'META-INF', 'META-INF/**'
}
}

manifest {
attributes(getManifestAttributes())
}
Expand Down Expand Up @@ -343,31 +358,31 @@ tasks.withType(JavaExec).configureEach {
}

processResources
{
// this will ensure that this task is redone when the versions change.
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version

// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'

// replace version and mcversion
expand "minecraftVersion": project.minecraft.version,
"modVersion": versionDetails().lastTag,
"modId": modId,
"modName": modName
}
{
// this will ensure that this task is redone when the versions change.
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version

if(usesMixins.toBoolean()) {
from refMap
}
// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'

// copy everything else, thats not the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
}
// replace version and mcversion
expand "minecraftVersion": project.minecraft.version,
"modVersion": versionDetails().lastTag,
"modId": modId,
"modName": modName
}

if(usesMixins.toBoolean()) {
from refMap
}

// copy everything else, thats not the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
}

def getManifestAttributes() {
def manifestAttributes = [:]
Expand Down Expand Up @@ -400,6 +415,12 @@ task sourcesJar(type: Jar) {
}

task shadowDevJar(type: ShadowJar) {
project.configurations.shadeCompile.each { dep ->
from(project.zipTree(dep)) {
exclude 'META-INF', 'META-INF/**'
}
}

from sourceSets.main.output
getArchiveClassifier().set("dev")

Expand All @@ -408,7 +429,7 @@ task shadowDevJar(type: ShadowJar) {
}

minimize() // This will only allow shading for actually used classes
configurations = [project.configurations.shadowImplementation]
configurations = [project.configurations.shadowImplementation, project.configurations.shadowCompile]
}

task relocateShadowDevJar(type: ConfigureShadowRelocation) {
Expand All @@ -423,6 +444,12 @@ task circularResolverJar(type: Jar) {
}

task devJar(type: Jar) {
project.configurations.shadeCompile.each { dep ->
from(project.zipTree(dep)) {
exclude 'META-INF', 'META-INF/**'
}
}

from sourceSets.main.output
getArchiveClassifier().set("dev")

Expand Down Expand Up @@ -460,6 +487,38 @@ artifacts {
}
}

// publishing
publishing {
publications {
maven(MavenPublication) {
artifact source: jar
artifact source: sourcesJar, classifier: "src"
artifact source: devJar, classifier: "dev"
if (apiPackage) {
artifact source: apiJar, classifier: "api"
}

groupId = System.getenv("ARTIFACT_GROUP_ID") ?: group
artifactId = System.getenv("ARTIFACT_ID") ?: project.name
version = System.getenv("ARTIFACT_VERSION") ?: project.version
}
}

repositories {
maven {
String owner = System.getenv("REPOSITORY_OWNER") ?: "Unknown"
String repositoryName = System.getenv("REPOSITORY_NAME") ?: "Unknown"
String githubRepositoryUrl = "https://maven.pkg.github.com/$owner/$repositoryName"
name = "GitHubPackages"
url = githubRepositoryUrl
credentials {
username = System.getenv("GITHUB_ACTOR") ?: "NONE"
password = System.getenv("GITHUB_TOKEN") ?: "NONE"
}
}
}
}

// Updating
task updateBuildScript {
doLast {
Expand Down
1 change: 1 addition & 0 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ dependencies {
}

// Do not set to compile instead of compileOnly! It will not run in dev!
// NOTE! This is for a mixin and is using Curse's version - not GTNH's
compileOnly("curse.maven:pams-harvestcraft-221857:2270206") {
transitive = false
}
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/squeek/applecore/mixinplugin/MixinPlugin.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package squeek.applecore.mixinplugin;

import cpw.mods.fml.common.FMLCommonHandler;
import net.minecraft.launchwrapper.Launch;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand Down Expand Up @@ -63,7 +64,8 @@ public List<String> getMixins() {
LOG.info("Found " + mod.modName + "! Integrating now...");
}
else {
LOG.info("Could not find " + mod.modName + "! Skipping integration....");
LOG.error("Could not find " + mod.modName + "! Going to crash now");

This comment has been minimized.

Copy link
@SinTh0r4s

SinTh0r4s Dec 24, 2021

Member

As below. Mixins into mods are optional and a missing mod is perfectly fine!

FMLCommonHandler.instance().exitJava(-99, false);
}
}

Expand All @@ -81,7 +83,7 @@ private boolean loadJarOf(final TargetedMod mod) {
try {
File jar = findJarOf(mod);
if(jar == null) {
LOG.info("Jar not found for " + mod);
LOG.warn("Jar not found for " + mod);

This comment has been minimized.

Copy link
@SinTh0r4s

SinTh0r4s Dec 24, 2021

Member

Jar not found is a perfectly normal occurrence! No need for a warning.

This comment has been minimized.

Copy link
@mitchej123

mitchej123 Dec 24, 2021

Not in the GTNH modpack. If Applecore is loading in the full pack, we want all of the mixins (pam's etc) to have been applied.

return false;
}

Expand Down

0 comments on commit 971a68b

Please sign in to comment.