2

Presently having an annoying time getting a jar added to the external library for the project, then in turn not disappear when syncing and the imports working. Adding I figured out and answered in another question. The issue is to keep persistent and accessible to a jar I create within the project for import.

I am not sure if I am missing a step or forgot to set something. I am using a modified gradle (forgegradle) to create the project. Have not found a solution with the documentation, or any for IntelliJ yet. I am generally new with IntelliJ, choosing to use it instead eclipse which I have previously used.

The goal is a to create an add-on for a mod to another jar. The main jar already in the external library from the start, now attempting to add the mod to it. I could modify the mod, but it is not my code, so rather not simply modify it directly and repackage it.

Siddharth Das
  • 1,057
  • 1
  • 15
  • 33

1 Answers1

0

a jar added to the external library for the project, then in turn not disappear when syncing and the imports working

If you are using an external build tool / system that syncs with IntelliJ it is recommended to use that build tool / system to add dependencies.

IntelliJ will always take a backseat, and treat the build tooling / system as the source of truth for the project model as best it can.

You mention you are using gradle, I would recommend adding the dependency as a managed dependency that is, let gradle download it from a repository, and resolve the dependency/library itself.

If you can not do this, and you can't host a repository yourself, The next best recommendation I have, is creating a 'libs' folder inside the project, that contains jars that can't be found in repositories (They may be mods or plugins that were never published)

You can read up on how to add a library folder to gradle here: How to add local .jar file dependency to build.gradle file?

Ryan Leach
  • 4,262
  • 5
  • 34
  • 71
  • I followed these suggestions regarding adding the .jar file dependency. Intellij still does not resolve the imports. As in, the imports are grayed out with tip saying unused, and with the name of the mod of the intended jar in red with the tip saying cannot resolve symbol. But if I right click on the jar to 'Add to Library', now it is just the referenced classes goes red and rest grayed out. Meanwhile, imports leading to jar already included in the external library by the build.gradle resolved and links. – Melanie of Ottawa Jun 04 '18 at 16:45
  • I am going to scream with one huge facepalm. Manage to find the answer in some random post on the internet that clued me in. Due to misunderstanding something I previously read somewhere, I was putting the libs folder under /src/ in the project dir. I moved the libs into project dir and then intellij able to sync it with the improts recognizing. I knew it was something silly that I was missing. – Melanie of Ottawa Jun 04 '18 at 18:16