#Jar in Jar

9 messages · Page 1 of 1 (latest)

sick pendant
#

Hello, fellow coders!
I've been programming a library, and need to add it as a dependency in my Gradle project. I simply built the library jar, then drag-and-dropped it into a directory in my project called 'lib'. Then, in my build.gradle dependencies, I added :

implementation fileTree('dir': 'lib', include: '*.jar')

This work in IntelliJ before compilation, however when I run the resulting jar, it cannot find any of the classes in the library. The problem is obviously that the library is not being packaged in the jar, but I can't seem to be able to fix that. I've tried adding this to the 'jar' task :

from {
        configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it)
            exclude("module-info.class") }
    }

But that just gives me this error :

Circular dependency between the following tasks:
:jar
\--- :jar (*)

Please note : the Gradle project is a Fabric mod, but I don't think that should affect anything.

Any help would be very much appreciated, thanks!

daring isleBOT
#

This post has been reserved for your question.

Hey @sick pendant! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

final solstice
#

the library isn’t in the actual jarfile when distributed

#

i have a nice snippet for including dependencies like that somewhere, give me a second

sick pendant
#

OK thx

final solstice
#

Completely forgot about this post, use this:

configurations {
  jarInJar
}
dependencies {
  // ...
  jarInJar implementation("what:ever:1.2.3")
}

jar {
  // ...

  from {
    configurations.jarInJar.collect { it.isDirectory() ? it : zipTree(it) }
  }
  duplicatesStrategy(DuplicatesStrategy.EXCLUDE)
}
sick pendant
#

Thanks! And don't worry, that's fine.

daring isleBOT
# sick pendant Thanks! And don't worry, that's fine.

If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.