Updating LibGdx project to Gradle 5.x

Anything libgdx related goes here!

Updating LibGdx project to Gradle 5.x

Postby GQuark » Sun Jan 13, 2019 5:55 pm


After some trials & errors, I describe here the simple fix to make your LibGdx project compatible with Gradle 5 and last releases of IntelliJ & Android Studio

1. In every gradle.build files (the main & the module ones), change each occurence of

- apply plugin: "java" by apply plugin: "java-library"
- compile by api (to get rid of the deprecation warnings)

Note that some "api" may be replaced by "implementation" but not all, in function of your configuration. So it is wise to start with api everywhere.

2. In the gradle.build from the desktop module, make these supplementary modifications :
in dist task, replace two lines of code as below :

Code: Select all
task dist(dependsOn: classes,type: Jar) {

    // comment these two lines :
    // from files(sourceSets.main.output.classesDir)
    // from {configurations.compile.collect {zipTree(it)}}

    // replace with theses ones for Gradle 5 compatibility
    from files(sourceSets.main.output.classesDirs)
    from {configurations.compileClasspath.collect { it.isDirectory() ? it : zipTree(it) }}
    // let the remaining code unchanged

Happy coding,
L. Crenier
Posts: 3
Joined: Mon Nov 19, 2018 7:21 pm

Re: Updating LibGdx project to Gradle 5.x

Postby obigu » Mon Jan 14, 2019 1:49 am

Thanks, I'm sure this will be useful at some point
Posts: 117
Joined: Fri Aug 02, 2013 4:47 pm

Return to Libgdx

Who is online

Users browsing this forum: Exabot [Bot], Google Feedfetcher and 1 guest