Issue
I'm using LibGDX to make a videogame and I updated Android Studio to version 3 and Gradle to version 4 without noticing that some of the plugins that LibGDX uses on the Gradle files are now deprecated.
I have no experience using Gradle and I know a little bit about how the tasks work and the plugins but not in much depth.
My question is about the Jetty plugin that is now deprecated and Gradle recommends me to use the Gretty plugin instead.
I already put it in my code but, of course, now I need to change the Jetty tasks for the Gretty ones and that is now my problem.
This is my build.gradle file right now:
apply plugin: "java"
//apply plugin: "jetty"
apply plugin: 'war'
apply from: 'https://raw.github.com/akhikhl/gretty/master/pluginScripts/gretty.plugin'
//TODO: Arreglar jetty por gretty
gwt {
gwtVersion='2.6.0' // Should match the gwt version used for building the gwt backend
maxHeapSize="1G" // Default 256m is not enough for gwt compiler. GWT is HUNGRY
minHeapSize="1G"
src = files(file("src/")) // Needs to be in front of "modules" below.
modules 'com.projectcastle.game.GdxDefinition'
devModules 'com.projectcastle.game.GdxDefinitionSuperdev'
project.webAppDirName = 'webapp'
compiler {
strict = true;
enableClosureCompiler = true;
disableCastChecking = true;
}
}
task draftRun(type: JettyRunWar) {
dependsOn draftWar
dependsOn.remove('war')
webApp=draftWar.archivePath
daemon=true
}
task superDev(type: de.richsource.gradle.plugins.gwt.GwtSuperDev) {
dependsOn draftRun
doFirst {
gwt.modules = gwt.devModules
}
}
task dist(dependsOn: [clean, compileGwt]) {
doLast {
file("build/dist").mkdirs()
copy {
from "build/gwt/out"
into "build/dist"
}
copy {
from "webapp"
into "build/dist"
}
copy {
from "war"
into "build/dist"
}
}
}
draftWar {
from "war"
}
task addSource << {
sourceSets.main.compileClasspath += files(project(':core').sourceSets.main.allJava.srcDirs)
}
tasks.compileGwt.dependsOn(addSource)
tasks.draftCompileGwt.dependsOn(addSource)
sourceCompatibility = 1.6
sourceSets.main.java.srcDirs = [ "src/" ]
eclipse.project {
name = appName + "-html"
}
And this is the error is giving me:
* What went wrong:
A problem occurred evaluating project ':html'.
> Could not get unknown property 'JettyRunWar' for project ':html' of type org.gradle.api.Project.
So the JettyRunWar
type and the draftRun
task are the ones that I don't know how to change to make them compatible for Gretty.
Thanks in advance!!
Solution
Using this build file gets rid of jetty completely (you just have to edit some lines so it fits your project): https://github.com/libgdx/libgdx/blob/master/tests/gdx-tests-gwt/build.gradle
But there is another huge problem with gradle 4.+ as seen in this issue: https://github.com/libgdx/libgdx/issues/4698
They say they will fix it and as long as they are working on it, we have to use old gradle and had to wait.
Answered By - Kromzem
Answer Checked By - Gilberto Lyons (JavaFixing Admin)