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?
Related
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.
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
Unlike external dependencies (from Maven, Ivy, etc.) local JAR files usually do not provide a list of transitive dependencies for Gradle. Unless they theoretically do in form of files pom.xml and pom.properties in directory META-INF/maven/<groupId>/<artifactId>. As far as I understand these are the same files Maven uses to provide transitive dependencies for an artifact.
So I wonder if Gradle is somehow able to read these transitive dependencies from a local JAR file as if the local JAR was an external dependency. Only adding the local JAR as dependency seems to ignore the embedded pom.xml.
Use case: I am writing an Plugin API JAR for an internal product which should be used by our developers to develop plugins. The API JAR has some external dependencies (Hibernate Annotations in domain classes, dom4j, stuff like that) and it would be great if the developer wouldn't have to define these dependencies by himself (they could change with newer API version). I also don't want to create a fat JAR containing all dependencies because a) the size! and b) it would not contain the sources of the external dependencies.
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 ...
Is there a simple way to have gradle automatically generated a pom file listing the jar dependencies (both to published jars of other sibling projects and external) and have it included in the jar and published to a maven repo?
There is a lot of documentation on this subject but I am either missing something or it is as complicated as it seems. Can this not be done automatically?