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

Hello,

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
GQuark
 
Posts: 6
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
obigu
 
Posts: 135
Joined: Fri Aug 02, 2013 4:47 pm

Re: Updating LibGdx project to Gradle 5.x

Postby shatterblast » Sat Apr 20, 2019 3:28 pm

Thank you for this! I confirm that this directly works with Gradle 5.1.1.

I had to pay extra attention to adding the 's' on 'classesDir' so that it became:

Code: Select all
from files(sourceSets.main.output.classesDirs)
shatterblast
 
Posts: 404
Joined: Sun Jul 06, 2014 1:14 pm

Re: Updating LibGdx project to Gradle 5.x

Postby TomGrill » Sun Apr 21, 2019 1:22 pm

Thanks!
Acorn Tilewalker iOS & Android: tomgrillgames.com
@TomGrillGames
TomGrill
 
Posts: 532
Joined: Tue May 06, 2014 8:05 pm

Re: Updating LibGdx project to Gradle 5.x

Postby Guich » Mon Apr 22, 2019 1:13 pm

Hi,

Is there a sample online with working scripts?

thanks

guich
Guich
 
Posts: 82
Joined: Sun Dec 11, 2016 9:36 am

Re: Updating LibGdx project to Gradle 5.x

Postby drorasta » Mon Apr 22, 2019 3:52 pm

Thanks GQuark,
I applied the changes you mentioned (there was no compile -> api to change) and I'm getting an error of:
ERROR: No value has been specified for property 'manifestOutputDirectory'
I can't find anything about it online.
Any idea? (:
Thanks
Numblies Speed Math. A free fun challenging math game
drorasta
 
Posts: 30
Joined: Mon Jan 09, 2012 12:00 pm

Re: Updating LibGdx project to Gradle 5.x

Postby evilentity » Mon Apr 22, 2019 6:41 pm

Dont update stuff for no reason. Perfect way to break stuff :P
Looking for a freelancer? PM me!
Check out libgdx discord server!
evilentity
 
Posts: 4849
Joined: Wed Aug 24, 2011 11:37 am

Re: Updating LibGdx project to Gradle 5.x

Postby drorasta » Mon Apr 22, 2019 11:17 pm

There is a reason to update as I use the android studio for other developments as well ;)
Numblies Speed Math. A free fun challenging math game
drorasta
 
Posts: 30
Joined: Mon Jan 09, 2012 12:00 pm

Re: Updating LibGdx project to Gradle 5.x

Postby evilentity » Tue Apr 23, 2019 8:51 am

Installing idea and android studio together is not illegal last ive checked. I have 3 idea versions and 2 as version installed on this machine. And like 5 version of unity and few of unreal engine 4. I think i have a problem.
Looking for a freelancer? PM me!
Check out libgdx discord server!
evilentity
 
Posts: 4849
Joined: Wed Aug 24, 2011 11:37 am

Re: Updating LibGdx project to Gradle 5.x

Postby drorasta » Tue Apr 23, 2019 3:12 pm

Sounds like you do have a problem :D :D (just kidding)
In my eyes it's not a very organized way of working but everyone can have his own way that fits him best.
Numblies Speed Math. A free fun challenging math game
drorasta
 
Posts: 30
Joined: Mon Jan 09, 2012 12:00 pm

Next

Return to Libgdx

Who is online

Users browsing this forum: Bing [Bot] and 1 guest