Jump to content

[1.15.2] Eclipse and gradle, how to use jar from another project and import? [solved]


Recommended Posts

Posted (edited)

Hello,

 

I am having trouble to understand what is required to use a jar from another project(source) I created as a dependency for my current project(target).

 

1. Which jar should be used in build.grade from the source project, do I have to run the gradle jar task or the gradle build task?

2. I tried both methods, and I am listing them as a dependency using: compile fileTree(dir: 'libs', includes: ['*.jar'])  in the target project this results in the following errors:

[m[1;31m[04:09:23] [Render thread/ERROR] [ne.mi.fm.ja.FMLModContainer/LOADING]: Caught exception during event RegistryEvent.Register<minecraft:item> dispatch for modid budgit
java.lang.NoSuchMethodError: net.minecraft.item.Item$Properties.func_200916_a(Lnet/minecraft/item/ItemGroup;)Lnet/minecraft/item/Item$Properties;
	at com.kow.budgit.init.ModItems.lambda$static$0(ModItems.java:18) ~[budgit-1.15.2-0.1.jar:1.15.2-0.1] {re:classloading}
	at net.minecraftforge.registries.DeferredRegister.lambda$register$0(DeferredRegister.java:84) ~[forge-1.15.2-31.1.16_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading}
-- cut here as the rest doesn't seem relevant

 

The code in question is:

public final class ModItems {

	public static final DeferredRegister<Item> ITEMS = new DeferredRegister<>(
			ForgeRegistries.ITEMS, Budgit.modId);

	public static final RegistryObject<VesaCardItem> vesa_card = ITEMS
			.register("vesa_card", () -> new VesaCardItem(
					new Item.Properties().group(ModItemGroups.MOD_ITEM_GROUP).maxStackSize(1)));
}

This code of the (source) is build, loading and working as a mod just fine on it's own. Just when attempted to add this to the target project to use some of it's methods, it produces this error.

 

It appears there is an issue finding the default Minecraft method, is this some issue with obfuscation?

 

Thanks for any hints!

Edited by KindOfWay
Posted

You'll want to look up a Gradle FlatDir repository, then wrap maven coordinates in fg.deobf()

This is my Forum Signature, I am currently attempting to transform it into a small guide for fixing easier issues using spoiler blocks to keep things tidy.

 

As the most common issue I feel I should put this outside the main bulk:

The only official source for Forge is https://files.minecraftforge.net, and the only site I trust for getting mods is CurseForge.

If you use any site other than these, please take a look at the StopModReposts project and install their browser extension, I would also advise running a virus scan.

 

For players asking for assistance with Forge please expand the spoiler below and read the appropriate section(s) in its/their entirety.

  Reveal hidden contents

 

Posted (edited)

Maybe it's my lack of build system knowledge.

 

Edit: I should also mentioned that it's building just fine now, just the runClient task is showing this issue

 

I changed the following to build.gradle:

 

I added

repositories {
  flatDir name: 'libs', dirs: 'libs'
}

And in dependencies I added

compile fg.deobf(name: 'budgit-1.15.2-0.1') 

 

Full build gradle of the target:

build.gradleFetching info...

 

Edit: Solved, if you find this:

Ensure that in the source project, jar.finalizedBy is commented out, delay that step as seen below.

// Example configuration to allow publishing using the maven-publish task
// This is the preferred method to reobfuscate your jar file
//jar.finalizedBy('reobfJar') 
// However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing
publish.dependsOn('reobfJar')

Then build via the jar task, not the build task.

Copy your jar into the repository, in my case the libs folder of the targets root directory.

Follow the rest of the configuration and it will work fine.

Edited by KindOfWay

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.