Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

How to create fat jar after reobfJar?


Recommended Posts

Hi,

I am trying to get HikariCP bundled with my mod as a one fat jar. But there is a problem where HikariCP causes reobfJar to fail with InvalidArgumentException, and I'm not sure why.

Here is my gradle code right now (I left out a lot of stuff which I don't think matters):
 

configurations {
    embed
}

dependencies {
    minecraft 'net.minecraftforge:forge:1.16.5-36.1.0'
	embed group: 'com.zaxxer', name: 'HikariCP', version: '4.0.3'
    compileOnly group: 'com.ea.async', name: 'ea-async', version: '1.2.3'
}

jar {
    from configurations.embed.collect{ it.isDirectory() ? it : zipTree(it) }
    manifest {
        attributes([
                "Specification-Title": "examplemod",
                "Specification-Vendor": "examplemodsareus",
                "Specification-Version": "1", // We are version 1 of ourselves
                "Implementation-Title": project.name,
                "Implementation-Version": "${version}",
                "Implementation-Vendor" :"examplemodsareus",
                "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
        ])
    }
}

jar.finalizedBy('reobfJar')

 

As I understand, this is the current order of events:

  1. `jar` task to run, which will bundle all the dependencies marked with `embed`, which will create the fat jar
  2. `reobfJar` will run on that fat jar.


Would I would like to do instead is this order of events:

  1. `jar` task to run, but no fat jar is created at this time.
  2. `reobfJar` will run on the output of `jar`.
  3. A new task runs, which will take the output of `reobfJar` and combine it with the dependencies marked with `embed` to create the one fat jar

 

I think the code would look something like this:
 

jar {
    manifest {
        attributes([
            "Specification-Title": "examplemod",
            "Specification-Vendor": "examplemodsareus",
            "Specification-Version": "1", // We are version 1 of ourselves
            "Implementation-Title": project.name,
            "Implementation-Version": "${version}",
            "Implementation-Vendor" :"examplemodsareus",
            "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
        ])
    }
}

jar.finalizedBy('reobfJar')

task bundle(type: Jar) {
    manifest {
        attributes 'Main-Class': 'com.gluecode.fpvdrone.server.Main'
    }
    from "build/libs/modid-1.0.jar"
    from configurations.embed.collect{ it.isDirectory() ? it : zipTree(it) }
}


The problems I have with the above is:

  1. I have to run `./gradlew bundle` after running `./gradlew buildNeeded`. And I'd like to just run 1 command.
  2. It doesn't work because it results in an invalid mod jar.

I'm am still learning gradle. Can anyone help me?

Link to post
Share on other sites

shadowJar creates a new jar task.

You need to use reobf { shadowJar } and then shadowJar.finalizedBy('reobfShadowJar') like the default buildscript already does for the normal Jar task.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • I think I've found the cause of the problem.  A recently updated Java installation installed just the JRE instead of the JDK, and was causing gradle to be unable to find tools.jar.  Installing the updated version of the JDK seems to have fixed the problem.  Thank you, and I apologize for wasting your time.
    • Send me examples with entities if u have ^^
    • Minecraft 1.16.5 Forge latest  This is my /data/forge/loot_modifiers/global_loot_modifiers.json  { "replace": false, "entries": [ "multimod:blaze_loot" ] }   This my /data/multimod/loot_modifiers/blaze_loot.json (serialized json) { "conditions": [ { "condition": "minecraft:killed_by_player" }, { "condition": "minecraft:entity_properties", "predicate": { "type": "minecraft:blaze" }, "entity": "this" } ] }   and now I want that the Entity Blaze can drop my custom item (custom_item) in this GlobalLotModifiers.java package com.squidxtv.multimod.core.init; import com.google.gson.JsonObject; import net.minecraft.item.ItemStack; import net.minecraft.loot.LootContext; import net.minecraft.loot.conditions.ILootCondition; import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.loot.GlobalLootModifierSerializer; import net.minecraftforge.common.loot.LootModifier; import javax.annotation.Nonnull; import java.util.List; public class GlobalLootModifiers extends LootModifier { /** * Constructs a LootModifier. * * @param conditionsIn the ILootConditions that need to be matched before the loot is modified. */ protected GlobalLootModifiers(ILootCondition[] conditionsIn) { super(conditionsIn); } @Nonnull @Override public List<ItemStack> doApply(List<ItemStack> generatedLoot, LootContext context) { return null; } private static class Serializer extends GlobalLootModifierSerializer<GlobalLootModifiers> { @Override public GlobalLootModifiers read(ResourceLocation location, JsonObject object, ILootCondition[] ailootcondition) { return null; } @Override public JsonObject write(GlobalLootModifiers instance) { return null; } } } but how can I do this?
    • I tried to found debug.log, but I can't found that, would you tell me about the location of the debug.log?
    • 1.12 is no longer supported on this forum. Please update to a modern version of Minecraft to receive support.
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.