My current jar
in build.gradle
is like below:
jar {
manifest {
attributes "Main-Class": "hoge.Main"
}
from configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
}
and working well.
However, I have a message from Gradle (maybe since 6+?)
This is the actual message:
The compile configuration has been deprecated for dependency declaration. This will fail with an error in Gradle 7.0. Please use the implementation configuration instead.
The part configurations.compile
is deprecated.
How can I update it?
If I changed
jar {
manifest {
attributes "Main-Class": "hoge.Main"
}
from configurations.implementation.collect { it.isDirectory() ? it : zipTree(it) }
}
Gradle says > Resolving configuration 'implementation' directly is not allowed
In its simplest form, creating an executable JAR with Gradle is just a matter of adding the appropriate entries to the manifest. However, it's much more common to have dependencies that need to be included on the classpath, making this approach tricky in practice.
Gradle declares dependencies on JAR files inside your project's module_name /libs/ directory (because Gradle reads paths relative to the build.gradle file). This declares a dependency on version 12.3 of the "app-magic" library, inside the "com.example.android" namespace group.
For others wanting to upgrade their Gradle configuration to the 7.0+ format, note that simply replacing compile
with implementation
or api
will likely bug out if you use the java
plugin. You need to be using the java-library
plugin. Documentation.
Make sure that in your gradle.config
you replace:
apply plugin: 'java'
with:
apply plugin: 'java-library'
You use implementation
for non-transitive dependencies, and api
for transitive ones (if the dependencies are consumed directly by dependents of your project).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With