当前位置: 首页 > 知识库问答 >
问题:

在Gradle 4.2.1中使用Gretty插件而不是Jetty

尚棋
2023-03-14

我没有使用Gradle的经验,我对任务和插件的工作方式略有了解,但不是很深入。

我的问题是关于Jetty插件的,它现在已经不推荐使用了,Gradle建议我使用Gretty插件。

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

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.

提前谢谢!!

共有1个答案

宋志学
2023-03-14

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

但是Gradle4.+还有一个很大的问题:https://github.com/libgdx/libgdx/issues/4698

他们说他们会修好它,只要他们还在工作,我们就必须使用旧的gradle和不得不等待。

 类似资料:
  • 我目前的目标是让gradle在我的机器上的Jetty实例中启动我的web应用程序,这样我就可以针对它编写Selenium测试。Gretty插件似乎正在加载,但我还没有找到任何关于如何创建和配置任务的实际说明。 部分问题是Gretty插件的不同版本和版本存在混淆。首先加载它是一个反复试验的过程。 我正在尝试使用Gradle 5.4.1和Gretty 2.3.1,我相信这是当前的版本(目前)。 我有三

  • persistence.xml文件 http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd“>org.hibernate.ejb.hibernatePersistence

  • BFA插件似乎仍然使用jackson2-api插件中的jackson类,而不是直接依赖maven。导致https://issues.jenkins-ci.org/browse/jenkins-62214在MongoJack内部的导入中使用了错误的jackson版本,导致缺少方法: Jenkins的类路径中Jackson2-api插件的依赖性是否更高?

  • 问题内容: 我有express / nodejs api。我要添加socket.io功能。目前,我所有的路线都在单独的文件夹中,我将它们包含在server.js文件中,并将其用作app.use()函数。 在server.js文件中,我还通过侦听特定端口(例如3000)来启动Express服务器,如下所示。 根据所有谷歌搜索,我发现我需要传递服务器变量来初始化socket.io,如下所示。 现在的问

  • 我尝试使用: Java11 RestEasy 4.1.0最终版 码头9.4.19. v20190610 gretty-gradle-plugin来自https://raw.github.com/gretty-gradle-plugin/gretty/master/pluginScripts/gretty.plugin 使用下面的子项目构建。格雷德尔: 但是,当我试图运行我的服务器使用:我得到以下异

  • 是否可以在Android Studio中为设备显示?我正在编写一个使用USB端口的应用程序,我无法将其用于。 目前,我正在使用以下指令查看命令提示符中的logcat,但如果将其集成到AS:http://developer.android.com/tools/help/adb.html#wireless