【问题标题】:Use Gretty plugin instead of Jetty for Gradle 4.2.1Gradle 4.2.1 使用 Gretty 插件而不是 Jetty
【发布时间】:2023-03-02 22:20:01
【问题描述】:

我正在使用 LibGDX 制作视频游戏,我将 Android Studio 更新到第 3 版,将 Gradle 更新到第 4 版,却没有注意到 LibGDX 在 Gradle 文件上使用的一些插件现已弃用。

我没有使用 Gradle 的经验,我对任务的工作原理和插件了解一些,但并不深入。

我的问题是关于现已弃用的 Jetty 插件,Gradle 建议我改用 Gretty 插件。

我已经把它放在我的代码中,但是,当然,现在我需要为 Gretty 更改 Jetty 任务,这就是我现在的问题。

这是我现在的 build.gradle 文件:

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"
}

这是给我的错误:

* What went wrong:
A problem occurred evaluating project ':html'.
> Could not get unknown property 'JettyRunWar' for project ':html' of type org.gradle.api.Project.

所以 JettyRunWar 类型和 draftRun 任务是我不知道如何更改以使它们与 Gretty 兼容的。

提前致谢!!

【问题讨论】:

    标签: java maven android-studio gradle build.gradle


    【解决方案1】:

    使用此构建文件可以完全摆脱 jetty(您只需编辑一些行使其适合您的项目): https://github.com/libgdx/libgdx/blob/master/tests/gdx-tests-gwt/build.gradle

    但是 gradle 4.+ 还有另一个大问题,如本期所示: https://github.com/libgdx/libgdx/issues/4698

    他们说他们会修复它,只要他们在努力,我们就必须使用旧的 gradle 并且不得不等待。

    【讨论】:

    • 非常感谢。然后我将降级我的 AS 和 Gradle。另外,我将摆脱 Jetty 以后不会有这个问题
    猜你喜欢
    • 2018-10-11
    • 1970-01-01
    • 1970-01-01
    • 2019-11-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-17
    相关资源
    最近更新 更多