Updating LibGdx project to Gradle 5.x

Anything libgdx related goes here!

Re: Updating LibGdx project to Gradle 5.x

Postby shatterblast » Wed Apr 24, 2019 2:06 pm

As requested, here is a link for a basic LibGDX setup with Gradle 5.1.1 added:

https://github.com/shatterblast/my-gdx-game-with-gradle5-as-a-reference-only

Despite the warnings for "compileOnly" for the build.gradle files, it seems to work fine on my end.
shatterblast
 
Posts: 306
Joined: Sun Jul 06, 2014 1:14 pm

Re: Updating LibGdx project to Gradle 5.x

Postby Guich » Wed Apr 24, 2019 3:55 pm

Awesome, thanks!
Guich
 
Posts: 82
Joined: Sun Dec 11, 2016 9:36 am

Re: Updating LibGdx project to Gradle 5.x

Postby t_jenesaisquoi » Tue May 07, 2019 10:23 am

Thanks, GQuark, you're a life saver.

And, Drorasta:
Like you, I also got this error at first:
ERROR: No value has been specified for property 'manifestOutputDirectory'

But then, I went back to the gradle.build file for the android module and change the COMPILER on line 127 to API. I'd initially left it unchanged because it was in capitals. After I changed it, the project compiled successfully.
t_jenesaisquoi
 
Posts: 1
Joined: Mon May 06, 2019 7:43 pm

Re: Updating LibGdx project to Gradle 5.x

Postby Guich » Wed May 08, 2019 12:30 pm

Hi,

The project works fine for Android and desktop, but is failing in MacOS/MOE.

The error is:
Unable to find method 'org.gradle.api.tasks.compile.CompileOptions.setBootClasspath(Ljava/lang/String;)V'

I already UNCHECKED Android Studio / Preferences / Experimental / Only sync the active variant <<<--- this makes it work for Android and Desktop on Windows

The solution from the Gradle forum is to replace it with: CompileOptions.setBootstrapClasspath

However, i can't find WHERE to replace this!
Guich
 
Posts: 82
Joined: Sun Dec 11, 2016 9:36 am

Re: Updating LibGdx project to Gradle 5.x

Postby shatterblast » Wed May 08, 2019 6:45 pm

Guich wrote:The project works fine for Android and desktop, but is failing in MacOS/MOE.

I might be wrong, but I think Gradle 5 has better support with MobiVM / RoboVM. I do not have any builds for it myself, though, since I can not immediately test it.
shatterblast
 
Posts: 306
Joined: Sun Jul 06, 2014 1:14 pm

Re: Updating LibGdx project to Gradle 5.x

Postby Guich » Thu May 09, 2019 12:49 am

I'm posting the patches that made it work - it is easier than having to check which files has been changed. It is based on the project posted on Github.

Code: Select all
Index: android/build.gradle
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- android/build.gradle   (date 1557362757000)
+++ android/build.gradle   (date 1557316400333)
@@ -1,5 +1,8 @@
+// IMPORTANT: Android Studio: File > Settings > Experimental > Gradle -> uncheck "Only sync the active variant" checkbox.
+
 android {
-    compileSdkVersion 27
+    buildToolsVersion "28.0.3"
+    compileSdkVersion 28
     sourceSets {
         main {
             manifest.srcFile 'AndroidManifest.xml'
@@ -17,6 +20,7 @@
         exclude 'META-INF/DEPENDENCIES'
         exclude 'META-INF/robovm/ios/robovm.xml'
     }
+    // not libgdx - version control update
     def versionPropsFile = file('assets/version.app')
     if (versionPropsFile.canRead()) {
         Properties versionProps = new Properties()
@@ -90,6 +94,12 @@
     }
 }
 
+tasks.whenTaskAdded { packageTask ->
+    if (packageTask.name.contains("package")) {
+        packageTask.dependsOn 'copyAndroidNatives'
+    }
+}
+
 task run(type: Exec) {
     def path
     def localProperties = project.file("../local.properties")
@@ -148,7 +158,7 @@
 idea {
     module {
         sourceDirs += file("src");
-        scopes = [ COMPILE: [plus:[project.configurations.compile]]]       
+        scopes = [ API: [plus:[project.configurations.compile]]]
 
         iml {
             withXml {
@@ -169,6 +179,6 @@
 
 dependencies {
 //    https://developer.android.com/topic/libraries/support-library/packages
-    implementation 'com.android.support:support-compat:27.1.1'
+    implementation 'com.android.support:support-compat:28.0.0'
 //    implementation fileTree(include: ['*.jar'], dir: '../libs')
 }
\ No newline at end of file
Index: build.gradle
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- build.gradle   (date 1557362757000)
+++ build.gradle   (date 1557362740842)
@@ -14,7 +14,7 @@
     }
     dependencies {
         classpath 'org.wisepersist:gwt-gradle-plugin:1.0.8'
-        classpath 'com.android.tools.build:gradle:3.1.3'
+        classpath 'com.android.tools.build:gradle:3.4.0'
         classpath 'org.multi-os-engine:moe-gradle:1.4.2'
     }
 }
@@ -26,7 +26,7 @@
     version = '1.0'
     ext {
         appName = "UeezeHelloWorld"
-        ueezeVersion = '0.1.50'
+        ueezeVersion = '0.1.57'
     }
 
     repositories {
Index: desktop/build.gradle
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- desktop/build.gradle   (date 1557362757000)
+++ desktop/build.gradle   (date 1557311599806)
@@ -1,4 +1,4 @@
-apply plugin: "java"
+apply plugin: "java-library"
 
 sourceCompatibility = 1.6
 sourceSets.main.java.srcDirs = [ "src/" ]
@@ -24,11 +24,11 @@
 }
 
 task dist(type: Jar) {
-    from files(sourceSets.main.output.classesDir)
+    from files(sourceSets.main.output.classesDirs)
     from files(sourceSets.main.output.resourcesDir)
-    from {configurations.compile.collect {zipTree(it)}}
+    from {configurations.compileClasspath.collect { it.isDirectory() ? it : zipTree(it) }}
     from files(project.assetsDir);
-
+
     manifest {
         attributes 'Main-Class': project.mainClassName
     }
@@ -44,12 +44,12 @@
 }
 
 task afterEclipseImport(description: "Post processing after project generation", group: "IDE") {
-  doLast {
-    def classpath = new XmlParser().parse(file(".classpath"))
-    new Node(classpath, "classpathentry", [ kind: 'src', path: 'assets' ]);
-    def writer = new FileWriter(file(".classpath"))
-    def printer = new XmlNodePrinter(new PrintWriter(writer))
-    printer.setPreserveWhitespace(true)
-    printer.print(classpath)
-  }
+    doLast {
+        def classpath = new XmlParser().parse(file(".classpath"))
+        new Node(classpath, "classpathentry", [ kind: 'src', path: 'assets' ]);
+        def writer = new FileWriter(file(".classpath"))
+        def printer = new XmlNodePrinter(new PrintWriter(writer))
+        printer.setPreserveWhitespace(true)
+        printer.print(classpath)
+    }
 }
Index: gradle/wrapper/gradle-wrapper.properties
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>windows-1252
===================================================================
--- gradle/wrapper/gradle-wrapper.properties   (date 1557362757000)
+++ gradle/wrapper/gradle-wrapper.properties   (date 1557362740832)
@@ -3,4 +3,5 @@
 distributionPath=wrapper/dists
 zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
+# must be used in MAC OS - distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
Guich
 
Posts: 82
Joined: Sun Dec 11, 2016 9:36 am

Re: Updating LibGdx project to Gradle 5.x

Postby shatterblast » Thu May 09, 2019 2:00 am

Guich wrote:I'm posting the patches that made it work - it is easier than having to check which files has been changed. It is based on the project posted on Github.

While I would not mind adding it to my stuff on GitHub, I can not test iOS content right now. If you wanted, you could probably just "fork" my repository and put your own code into it. In that way, you would have something to reference later for some reason.
shatterblast
 
Posts: 306
Joined: Sun Jul 06, 2014 1:14 pm

Re: Updating LibGdx project to Gradle 5.x

Postby Guich » Thu May 09, 2019 8:45 am

Yes, i just realized that my patches may be different, i'll do a fork.
Guich
 
Posts: 82
Joined: Sun Dec 11, 2016 9:36 am

Previous

Return to Libgdx

Who is online

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