You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In this example there are several interesting parts of the gradle build configuration:
There are two project: a Java app and a library for this java application
The library is using aws core sdk as a transitive dependency for the application
But we use one version of the aws core sdk to compile (in the library project) and another version of aws core sdk in the application itself. Everything works fine even if we will include the aws core sdk dependency with our library distro, as Gradle can handle version conflict when working with transitive dependencies.
The library project has configuration to publish the lib distro to local maven.
The application configured to take the lib from the local maven repository.
There is a Gradle task to create a "fat jar" in the /application/build/readyJar directory
We use another lib (cloudfront sdk) in your library project to compile some code. But we do NOT provide this dependency to the consumer. So we have two sdks used in the same class of our library, but if we do not use the code from the absent library in the application code (see the parameter in the ... function) then there will be no errors, even we are using the class which contains dependency, which is NOT provided at the runtime. Try to use this compiled code - and there will be Class Not Found exception as we did not provide the cloudfront sdk to the runtime of the consumer of our library project.
To run the app:
run the build task of the library project
run the publishToMavenLocal task of the library project
run the build task of the root project
execute the java -jar application/build/readyJar/application-1.0-SNAPSHOT-all.jar command
About
A really awesome and precise code that can make you understand difference between "api" and "compileOnly" scopes in one glance and more!