I am trying to build a gradle project, where we have several dependent jars. One of this jar is a FAT jar which consist of hundreds of jar. All dependent jars are uploaded to artifactory.
build.gradle is able to compile all other jars however it is not able to get this fat jar compile due to transitive dependency
compile(group:"com.xyz.test", name:"joda-time",Version:"1.6") --works for normal jar
compile(group:"com.xyz.test", name:"FAT_JAR", Version:"1.0") --does not works for FAT jar
Getting following Error
Could not find org.objectweb.asm.Type ( class present in the asm.jar which is present in the FAT JAR)
Searched in following locations
.....
.....Artifactory repository locations
.....
For Required
project: Test> com.xyz.test.FAT_JAR.Test
I also tried other options like api/implementation instead of compile but it did not help.
I looked into many places, many pages have answer to build a FAT Jar, but what I am looking for compile build with dependent FAT jar.
Please advise.
Related
I have a maven project that should be obfuscated by proguard plugin.
This works fine when my dependency jar is not obfuscated.
But the result is that the dependency jar (also owned by me) is included in my obfuscated app not obfuscated. The opposite when i include the already obfuscated jar in my project i get compile errors for not finding packages and classes.
How can i obfuscate both my app and my dependency jar?
If I add a JAR file to a gradle project's depenencies, the code compiles just fine, but after publishing to maven (publishToMavenLocal), the classes from the JAR are not found.
Obviously, this is because the jar is added as a "dependency" and not part of the project itself. Is there a way to get the contents of the JAR file to merge into the library? Do I need to make a separate maven repo for each JAR?
You can always try to create a fat jar which includes dependencies. You can follow the instructions provided here https://www.baeldung.com/gradle-fat-jar
I was learning maven scope and I encountered a doubt.
If scope of all the dependencies in a project , say A , is compile , then they will be present in its jar too. So, it is said, for any other project , say B, that depends on this project A , will get transitive dependencies too of A. But they are already present in the jar of project A ? Why download them again ?
They are not "present in the jar". Transitive dependencies of a jar are not bundled into the jar, unless you explicitly build a fat jar, e.g. with the assembly plugin or shade plugin.
Fat jars, though, are not meant to be dependencies of other artifacts, they are only meant to be run standalone.
For ears and wars, the situation is different (standard is to bundle everything), but wars and ears do not serve as libraries that you depend on.
How to write a gradle script so that the application jar should be packed without dependency classes similar to maven jar package
The application JAR is always without dependencies, except you use special plugins to create a "fat" JAR where the dependencies are included. If you ask how to set up a Gradle build at all, you should start reading the Users Guide.
If you are trying to package a jar from your Android app or library:
I ran into this question because gradle would include 3rd party libraries into my jar when running gradle assembleRelease.
The contents of the jar then looked like this:
com/android/...
/myCompany/...
For some reason this did not happen when building for debug. Finally I found that changing:
compile 'com.android.support:recyclerview-v7:23.0.0'
to
provided 'com.android.support:recyclerview-v7:23.0.0'
would not include the 3rd party libs ...
We are building one jar and that jar depending on many jars. Currently we are adding dependency jars explicitly like below.
compile files('libraries/amqp-client-3.1.3.jar')
compile files('libraries/antisamy-1.5.1.jar')
compile files('libraries/antlr-2.7.7.jar')
compile files('libraries/aopalliance-1.0.jar')
So, instead of adding all the dependency jars explicitly, we need to take required classes from dependency jars and those should be included as part of jar preparation. Can any one tell me how to achieve? thanks.
Depending on your build system, you want the shade plugin (maven): http://maven.apache.org/plugins/maven-shade-plugin/ or the shadow plugin (gradle): https://github.com/johnrengelman/shadow
If you are using ant, I would try to leverage the maven plugin: http://maven.apache.org/ant-tasks/index.html
However, see the warnings in my answer here: Gradle shadow jar with conflicting dependencies