0

I am working in an old project which was using Gradle Wrapper v3.2.1, but I want to update it to the latest version (currently v5.4.1).

I have tried updating it to v4.10.2 first but it fails too, so I guess it is something that was not backwards compatible between v3->v4.

The code we have in our build.gradle is:

task buildZip(type: Zip) {
    group 'Build'
    description 'Assembles a zip archive containing the main classes.'

    baseName = "someName"
    from compileJava
    from processResources
    into('lib') {
        from configurations.runtime
    }
}

Using gradle v3 it included all the libraries (as .jar files) in the .zip file under "lib/" folder, but if I use v4 or later, it does not fail, but it does not include the libraries neither. I have achieved to get the .class files of the dependencies, but that does not work for what I need (AWS Lambda function).

Any idea on how to get the .jar dependencies into the .zip file?

Cheers! Francisco Robles Martin

froblesmartin
  • 1,527
  • 18
  • 25
  • 1
    Maybe this is because the `runtime` configurations was deprecated. Please have a look here: https://docs.gradle.org/current/userguide/java_library_plugin.html#sec:java_library_configurations_graph. – Opal May 22 '19 at 08:26

1 Answers1

1

So, thanks to Opal comment, I kept looking for a bit more and got a solution, but it seems to not be very correct as I am forcing implementation to allow be resolved:

configurations.implementation.setCanBeResolved(true)

task buildZip(type: Zip) {
    group 'Build'
    description 'Assembles a zip archive containing the main classes.'

    baseName = "someName"
    from compileJava
    from processResources
    into('lib') {
        from configurations.implementation
    }
}

It works, but I guess there should be a better way to do it without the first line.

froblesmartin
  • 1,527
  • 18
  • 25