简体   繁体   English

有什么简单的方法可以从gradle中运行码头8(与jettyRun一样)?

[英]Is there any easy way to run jetty 8 from gradle (like with jettyRun)?

Unlucky I need jetty 8 to work properly with spray/akka (it's scala project). 不幸的是,我需要码头8才能与spray / akka一起正常工作(这是scala项目)。
With older version used by jettyRun I'm getting error like: 使用jettyRun使用的旧版本时,出现如下错误:
java.lang.NoClassDefFoundError: org/eclipse/jetty/continuation/ContinuationListener java.lang.NoClassDefFoundError:org / eclipse / jetty / continuation / ContinuationListener
Is it possible to create some simple task to do the job which jettyRun is doing but with jetty 8? 是否可以创建一些简单的任务来完成jettyRun所做的工作,但要使用jetty 8?

In worst case I can use embedded version of jetty with war which I'm building, but I would be happy to see some simpler solution if there is any... 在最坏的情况下,我可以在正在建造的战争中使用嵌入式版本的码头,但如果有的话,我很高兴看到一些更简单的解决方案...

Pitor, why didn't you end up adding your excellent answer from here ? 先生,您为什么不从这里开始添加出色的答案呢?

I've adapted it below, to use Jetty version 9 , to depend on the war task, and to use the same task name as the jetty plugin (ie jettyRun ). 我在下面对其进行了修改,以使用Jetty版本9来依赖war任务,并使用与jetty插件相同的任务名称(即jettyRun )。

configurations {
    jetty
}

dependencies {
    jetty "org.eclipse.jetty:jetty-runner:9.2.11.v20150529"
}

task jettyRun(type: JavaExec, dependsOn: war) {
    main = "org.eclipse.jetty.runner.Runner"
    args = [war.archivePath]
    classpath configurations.jetty
}

Usage: 用法:

gradle jettyRun

I think it's a little late for an answer :) But I'll post it for others who would google around for the same thing. 我认为答案来晚了:)但是,我会将其发布给其他会搜索同一内容的人。

I stumbled upon the same issue while trying to run a scalatra app with gradle. 在尝试使用gradle运行scalatra应用程序时,我偶然发现了同一问题。 I found this plugin and it just works - https://github.com/martins1930/jettyMulti 我找到了这个插件,它可以正常工作-https://github.com/martins1930/jettyMulti

Since I wasn't able to find good solution at the gradle build level I decided to use embedded jetty. 由于无法在gradle构建级别上找到好的解决方案,因此决定使用嵌入式码头。 Here is scala class: 这是scala类:

import org.eclipse.jetty.server.Server
import org.eclipse.jetty.webapp.WebAppContext
import org.eclipse.jetty.server.bio.SocketConnector

object JettyServer {

  def main(args: Array[String]) {
    val server = new Server
    val context = new WebAppContext
    val connector = new SocketConnector

    connector.setMaxIdleTime(1000 * 60 * 60)
    connector.setPort(8080)

    context.setServer(server)
    context.setWar(args(0))

    server.setConnectors(Array(connector))
    server.setHandler(context)

    try {
      server.start();
      server.join();
    } catch {
      case e: Exception => e.printStackTrace();
    }
  }
}

And then in build.gradle: 然后在build.gradle中:

apply plugin: "application"

mainClassName = "com.mycompany.myproject"
run.args = [war.archivePath]
task jettyRun(dependsOn: run)

And everything works :) 一切正常:)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从模型生成1.sql的简单方法? - Easy way to generate 1.sql from model? 有没有办法在不运行的情况下将内容从IO提升到其他容器? - Is there any way to lift content from IO to other container without run? 是否有任何自动化的方法来使用Gradle更新和管理Java / Scala依赖关系? - Is there any automated way to update and manage Java/Scala dependencies with Gradle? 从scala中的长(时间戳)获取可读日期的简单方法 - Easy way to get a readable date from a long (timestamp) in scala sbt web 插件:无效密钥:jetty-run(类似:jetty-port、jetty-context、run) - sbt web plugin: Not a valid key: jetty-run (similar: jetty-port, jetty-context, run) 有一种简单的方法可以将布尔值转换为整数吗? - Is There an Easy Way to Convert a Boolean to an Integer? 如何在没有 maven 和 gradle 的情况下从 java 代码运行加特林模拟? - How to run a Gatling simulation from java code without maven and gradle? Scala中是否有任何简便的方法可以迭代Map [String,Set [String]],并且Key的值具有大于'n'个字符串 - Is there any easy way in Scala to Iterate over a Map[String, Set[String]] and if a Value for Key has more than 'n' number of Strings 有没有办法使用 Gradle 的 Scala 3 编译器(Dotty)? - Is there a way to use the Scala 3 compiler (Dotty) from Gradle yet? 如何使用SBT 0.7.7与https一起运行码头 - How to run jetty with https using sbt 0.7.7
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM