5

使用 Gradle 帮助运行 Jetty 9

我已经看到在how-to-run-jetty-7-with-specified-war-with-groovy-gradlesetting_up_embedded_jetty_8_and_spring_mvc_with_maven上运行 Jetty 的参考资料

但我想在 Gradle 中运行新的 Eclipse Jetty 9。

我试过这个:

task jetty8Run(type: JavaExec, dependsOn: assemble) {
    main = "org.eclipse.jetty.server.Server"
    args = ["--port", 8080, "--stop-port", 9876, "--stop-key", 'shutterdown', war.archivePath]
    classpath configurations.jetty8
}

我将其用作依赖项:

jettyEclipse "org.eclipse.jetty:jetty-server:$jetty9Version"
jettyEclipse "org.eclipse.jetty:jetty-servlet:$jetty9Version"
jettyEclipse "org.eclipse.jetty:jetty-webapp:$jetty9Version"
jettyEclipse "org.eclipse.jetty:jetty-servlets:$jetty9Version"
jettyEclipse "org.eclipse.jetty:jetty-jsp:$jetty9Version"
jettyEclipse "javax.servlet:jstl:1.2"

在我的 gradle.properties 中:

jetty9Version: 9.0.0.M0

但是当我运行时,我收到以下消息

An attempt to initialize for well behaving parent process finished.

这是完整的调试堆栈跟踪:

    14:22:16.699 [INFO] [org.gradle.process.internal.DefaultExecHandle] Starting process 'command 'C:\usr\bin\Java\jdk1.7\bin\java.exe''. Working directory: C:\usr\git_workspaces\oxygen\code_wash Command: C:\usr\bin\Java\jdk1.7\bin\java.exe -Dfile.encoding=windows-1252 -cp C:\Users\mknuts6173c\.gradle\caches\artifacts-14\filestore\org.mortbay.jetty\jetty-runner\8.1.5.v20120716\jar\2f8a590e1dcdf75e40cabfc0803c3712b7f04360\jetty-runner-8.1.5.v20120716.jar;C:\Users\mknuts6173c\.gradle\caches\artifacts-14\filestore\org.eclipse.jetty\jetty-server\9.0.0.M0\jar\7c6ea0dc0230fba0fe0e2a37490558477b9833c6\jetty-server-9.0.0.M0.jar;C:\Users\mknuts6173c\.gradle\caches\artifacts-14\filestore\org.eclipse.jetty\jetty-servlet\9.0.0.M0\jar\5bfecce207651c0f7861255061df32204e1f4ba0\jetty-servlet-9.0.0.M0.jar;C:\Users\mknuts6173c\.gradle\caches\artifacts-14\filestore\org.eclipse.jetty\jetty-webapp\9.0.0.M0\jar\b67fc43d6949e1bf66eb479fba3a9b335fa9dd0e\jetty-webapp-9.0.0.M0.jar;C:\Users\mknuts6173c\.gradle\caches\artifacts-14\filestore\org.eclipse.jetty\jetty-servlets\9.0.0.M0\jar\1cb5a7222ebec54e5c5b089d5c757ec6ac6506a0\jetty-servlets-9.0.0.M0.jar;C:\Users\mknuts6173c\.gradle\caches\artifacts-14\filestore\org.eclipse.jetty\jetty-jsp\9.0.0.M0\jar\5120a9a20405a286d158825257d50812d63493d4\jetty-jsp-9.0.0.M0.jar;C:\Users\mknuts6173c\.m2\repository\javax\servlet\jstl\1.2\jstl-1.2.jar;C:\Users\mknuts6173c\.gradle\caches\artifacts-14\filestore\org.mortbay.jetty\servlet-api\3.0.pre4\jar\d5611e63cefe84a858bb46a4cb1249dcb7ddb830\servlet-api-3.0.pre4.jar;C:\Users\mknuts6173c\.gradle\caches\artifacts-14\filestore\org.eclipse.jetty.orbit\javax.servlet\3.0.0.v201112011016\orbit\aaaa85845fb5c59da00193f06b8e5278d8bf3f8\javax.servlet-3.0.0.v201112011016.jar;C:\Users\mknuts6173c\.gradle\caches\artifacts-14\filestore\org.eclipse.jetty.orbit\javax.servlet.jsp\2.2.0.v201112011158\orbit\80b4ffe7c26ee97313bea2ddda5835fd38812ee4\javax.servlet.jsp-2.2.0.v201112011158.jar;C:\Users\mknuts6173c\.gradle\caches\artifacts-14\filestore\org.eclipse.jetty.orbit\org.apache.jasper.glassfish\2.2.2.v201112011158\orbit\3945afe6a042228a92da320aec3fa1bc1308183b\org.apache.jasper.glassfish-2.2.2.v201112011158.jar;C:\Users\mknuts6173c\.gradle\caches\artifacts-14\filestore\org.eclipse.jetty.orbit\javax.servlet.jsp.jstl\1.2.0.v201105211821\orbit\db594f1c8fc00d536f6d135bd7f8a9a99a6b8eea\javax.servlet.jsp.jstl-1.2.0.v201105211821.jar;C:\Users\mknuts6173c\.gradle\caches\artifacts-14\filestore\org.eclipse.jetty.orbit\javax.el\2.2.0.v201108011116\orbit\ec8944c11833d84b0283a5afbad0fafb264f86a9\javax.el-2.2.0.v201108011116.jar;C:\Users\mknuts6173c\.gradle\caches\artifacts-14\filestore\org.eclipse.jetty.orbit\com.sun.el\2.2.0.v201108011116\orbit\15f7774c3fa514835a371f47c152317704ea411a\com.sun.el-2.2.0.v201108011116.jar;C:\Users\mknuts6173c\.gradle\caches\artifacts-14\filestore\org.eclipse.jetty.orbit\org.eclipse.jdt.core\3.7.1\orbit\5b79bfee0852ca685e33cab74496fa3400271b5b\org.eclipse.jdt.core-3.7.1.jar;C:\Users\mknuts6173c\.gradle\caches\artifacts-14\filestore\org.eclipse.jetty\jetty-continuation\9.0.0.M0\jar\3031a06840cee834b640ae3d145044fb07aebdc4\jetty-continuation-9.0.0.M0.jar;C:\Users\mknuts6173c\.gradle\caches\artifacts-14\filestore\org.eclipse.jetty\jetty-util\9.0.0.M0\jar\7149f92459b45f91b5a0487a5edc300764392ee7\jetty-util-9.0.0.M0.jar;C:\Users\mknuts6173c\.gradle\caches\artifacts-14\filestore\org.eclipse.jetty\jetty-io\9.0.0.M0\jar\8dcc24862d1832e0035f893e227d38b656ecef49\jetty-io-9.0.0.M0.jar;C:\Users\mknuts6173c\.gradle\caches\artifacts-14\filestore\org.eclipse.jetty\jetty-http\9.0.0.M0\jar\c0a5dc125b94ebc049f60f66b5ce8b17a0d9d917\jetty-http-9.0.0.M0.jar;C:\Users\mknuts6173c\.gradle\caches\artifacts-14\filestore\org.eclipse.jetty\jetty-security\9.0.0.M0\jar\b18d3938499c88109283007657e4d89ffcc8aff3\jetty-security-9.0.0.M0.jar;C:\Users\mknuts6173c\.gradle\caches\artifacts-14\filestore\org.eclipse.jetty\jetty-xml\9.0.0.M0\jar\5421375311559e23bc77d1e65624f13406018467\jetty-xml-9.0.0.M0.jar;C:\Users\mknuts6173c\.gradle\caches\artifacts-14\filestore\org.eclipse.jetty.orbit\javax.activation\1.1.0.v201105071233\orbit\b394a9fbf664ca835452b3ced452710bcf79fd81\javax.activation-1.1.0.v201105071233.jar;C:\Users\mknuts6173c\.gradle\caches\artifacts-14\filestore\org.eclipse.jetty.orbit\javax.mail.glassfish\1.4.1.v201005082020\orbit\b707c39fc080529c4a9ffc1df4eac58421133aaf\javax.mail.glassfish-1.4.1.v201005082020.jar;C:\Users\mknuts6173c\.gradle\caches\artifacts-14\filestore\org.eclipse.jetty\jetty-jndi\8.1.5.v20120716\jar\f0c40a2e62bf4b78a8c3a34cd8c0a8250b8321c0\jetty-jndi-8.1.5.v20120716.jar;C:\Users\mknuts6173c\.gradle\caches\artifacts-14\filestore\org.eclipse.jetty.orbit\javax.transaction\1.1.1.v201105210645\orbit\68e61aa115bbff4e1e2ae4b16feb27d9f805eb6\javax.transaction-1.1.1.v201105210645.jar;C:\Users\mknuts6173c\.gradle\caches\artifacts-14\filestore\org.eclipse.jetty\jetty-plus\8.1.5.v20120716\jar\d901ed553709d53b2fa72ade6a06f8bef82f29f5\jetty-plus-8.1.5.v20120716.jar;C:\Users\mknuts6173c\.gradle\caches\artifacts-14\filestore\org.eclipse.jetty.orbit\javax.annotation\1.1.0.v201108011116\orbit\964b4bd5e4f40d6497fd302e2e66c4a4257138b3\javax.annotation-1.1.0.v201108011116.jar;C:\Users\mknuts6173c\.gradle\caches\artifacts-14\filestore\org.eclipse.jetty.orbit\org.objectweb.asm\3.1.0.v200803061910\orbit\bf952ae43613f460f11ce5f8727cc9e4a7f8d33d\org.objectweb.asm-3.1.0.v200803061910.jar;C:\Users\mknuts6173c\.gradle\caches\artifacts-14\filestore\org.eclipse.jetty\jetty-annotations\8.1.5.v20120716\jar\aee87dde17b6d6fe18a3bab3f3fc4ae40356ae94\jetty-annotations-8.1.5.v20120716.jar;C:\Users\mknuts6173c\.gradle\caches\artifacts-14\filestore\org.eclipse.jetty.orbit\org.apache.taglibs.standard.glassfish\1.2.0.v201112081803\orbit\2c4baa72af1d3aae3a1e029d4f8ca07498dabbe0\org.apache.taglibs.standard.glassfish-1.2.0.v201112081803.jar org.eclipse.jetty.server.Server --port 8080 --stop-port 9876 --stop-key shutterdown C:\usr\git_workspaces\oxygen\code_wash\target\libs\code_wash.war
    14:22:16.706 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Environment for process 'command 'C:\usr\bin\Java\jdk1.7\bin\java.exe'': {TERM=cygwin, USERPROFILE=C:\Users\mknuts6173c, HISTFILE=C:\usr\configs\scripts/.bash_history, LS_OPTS=--color=auto, JAVA_HOME=C:\usr\bin\Java\jdk1.7, HSTART_HOME=C:\usr\bin\utils\Hstart_4.1-bin, PROGRAMDATA=C:\ProgramData, PROGRAMPATH=C:\usr\bin\CONSOLES\Git, JAVA7_HOME=C:\usr\bin\Java\jdk1.7, GNUPGHOME=c:/Users/mknuts6173c/.gnupg, COMMONPROGRAMFILES=C:\Program Files\Common Files, USR_HOME=C:\usr, PWD=c:/usr/git_workspaces/oxygen/code_wash, JRUBY_HOME=C:\usr\bin\SDK\jruby\jruby-1.6.8, PROCESSOR_REVISION=2a07, LS_OPTIONS=--color=auto, USERDOMAIN=CABLE, GREP_COLOR=7, ALLUSERSPROFILE=C:\ProgramData, PROGRAMW6432=C:\Program Files, JAVA6_HOME=C:\usr\bin\Java\jdk1.6, !::=::\, CONFIGS_HOME=C:\usr\configs, INPUTRC=C:/usr/bin/CONSOLES/Git/etc/inputrc, SESSIONNAME=Console, M2_REPO=C:\usr\repository, PLINK_PROTOCOL=ssh, IDEA_JDK=C:\usr\bin\Java\jdk1.7, HISTSIZE=100, EDITOR=~/AppData/Roaming/GitPad/GitPad.exe, TMP=C:/Users/MKNUTS~1/AppData/Local/Temp, SCALA_HOME=C:\usr\bin\SDK\scala, PSMODULEPATH=C:\Windows\system32\WindowsPowerShell\v1.0\Modules\, LOGONSERVER=\\PAOAKADDCCB02, PATH=/c/Users/mknuts6173c/bin:.:/usr/local/bin:/mingw/bin:/bin:/usr/bin:/c/usr/bin/Java/jdk1.7/bin:/c/usr/bin/SDK/jruby/jruby-1.6.8/bin:/c/usr/bin/SDK/jruby/jruby-1.6.8/lib/ruby/gems/1.8/gems:/c/usr/bin/SDK/gradle/bin:/c/usr/bin/groovy-1.8.6/bin:/c/usr/bin/SDK/maven/bin:/c/usr/bin/SDK/ant/bin:/c/usr/bin/SDK/scala/bin:/c/usr/bin/mobile/android-sdk-windows/platform-tools/:/c/usr/bin/mobile/android-sdk-windows/tools/:/c/usr/bin/CONSOLES/ansicon/x86:/c/usr/bin/utils/Hstart_4.1-bin:/c/usr/configs/scripts:/c/usr/configs/scripts/shell:/c/usr/configs/scripts/cmd:/c/Program Files/Dell/DW WLAN Card:/c/Program Files (x86)/RSA SecurID Token Common:/c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Program Files/TortoiseSVN/bin:.:/c/Program Files/TortoiseSVN/bin:/c/Program Files (x86)/Graphviz 2.28/bin
    :/usr/bin/MOBILE/android-sdk-windows/platform-tools, SHELL_HOME=C:\usr\configs\scripts\shell, GRADLE_HOME=C:\usr\bin\SDK\gradle, PROMPT=$P$G, COMMONPROGRAMW6432=C:\Program Files\Common Files, PROCESSOR_LEVEL=6, LESS=-FRSX, LOCALAPPDATA=C:\Users\mknuts6173c\AppData\Local, SCRIPTS_HOME=C:\usr\configs\scripts, COMPUTERNAME=PAGWKL-D5CDBS1, ANSICON_HOME=C:\usr\bin\CONSOLES\ansicon\x86, CORP_PATH=C:\Program Files\Dell\DW WLAN Card;C:\Program Files (x86)\RSA SecurID Token Common;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files\TortoiseSVN\bin;, LSCOLORS=gxBxhxDxfxhxhxhxhxcxcx, USERNAME=MKnuts6173c, HISTFILESIZE=100, WINDIR=C:\Windows, APPDATA=C:\Users\mknuts6173c\AppData\Roaming, USERDNSDOMAIN=CABLE.COMCAST.COM, PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC, SHLVL=1, MAVEN_HOME=C:\usr\bin\SDK\maven, PROGRAMFILES(X86)=C:\Program Files (x86), CMD_HOME=C:\usr\configs\scripts\cmd, JREBEL_HOME=C:\usr\bin\SERVERS\jrebel, GROOVY_HOME=C:\usr\bin\groovy-1.8.6, DELLCLIENTSYSTEMUPDATEPATH=C:\Program Files (x86)\Dell\ClientSystemUpdate\, TEMP=C:/Users/MKNUTS~1/AppData/Local/Temp, PROMPT_COMMAND=history -n; history -w; history -c; history -r; lastcmd; , HOMEDRIVE=C:, JAVA_OPTS=-ea -Xmx512m -XX:MaxPermSize=512m -Dd2.config.location=file:///C:/xivr/d2/override.properties, TERM_DRIVE=c:/, SYSTEMDRIVE=C:, LOGNAME=MKnuts6173c, =C:=C:\usr\git_workspaces\xivr, JRUBY_GEMS=C:\usr\bin\SDK\jruby\jruby-1.6.8\lib\ruby\gems\1.8\gems, COMMONPROGRAMFILES(X86)=C:\Program Files (x86)\Common Files, PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 42 Stepping 7, GenuineIntel, OLDPWD=c:/usr/bin/SDK/gradle, SHELL=C:/usr/bin/CONSOLES/Git/bin/bash, MAKE_MODE=unix, GLASSFISH_HOME=C:\usr\bin\SERVERS\glassfish3, PROCESSOR_ARCHITECTURE=AMD64, JMETER_HOME=C:\usr\bin\TESTING\apache-jmeter-2.7, OS=MINGW, FP_NO_HOST_CHECK=NO, HOMEPATH=\Users\mknuts6173c, COMSPEC=C:\Windows\system32\cmd.exe, MSYSTEM=MINGW32, ANT_HOME=C:\usr\bin\SDK\ant, GRADLE_OPTS=-Xmx1024M -XX:MaxPermSize=512m, PROGRAMFILES=C:\Program Files, HISTCONTROL=ignoredups:erasedups, HOME=c:/Users/mknuts6173c, CYGWIN_HOME=C:\usr\bin\CONSOLES\cygwin, NUMBER_OF_PROCESSORS=4, SYSTEMROOT=C:\Windows, PUBLIC=C:\Users\Public, ANDROID_HOME=C:\usr\bin\mobile\android-sdk-windows, LESSCHARSET=utf-8}
    14:22:16.722 [DEBUG] [org.gradle.internal.nativeplatform.jna.WindowsHandlesManipulator] Invalid parameter attempting to uninherit stream - child process may remain attached.
    14:22:16.732 [DEBUG] [org.gradle.internal.nativeplatform.jna.WindowsHandlesManipulator] Invalid parameter attempting to uninherit stream - child process may remain attached.
    14:22:16.737 [DEBUG] [org.gradle.internal.nativeplatform.jna.WindowsHandlesManipulator] Invalid parameter attempting to uninherit stream - child process may remain attached.
    14:22:16.744 [INFO] [org.gradle.process.internal.ProcessParentingInitializer] An attempt to initialize for well behaving parent process finished.
    14:22:16.750 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Changing state to: STARTING
    14:22:16.758 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Waiting until process started: command 'C:\usr\bin\Java\jdk1.7\bin\java.exe'.
    14:22:16.768 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Changing state to: STARTED
    14:22:16.778 [INFO] [org.gradle.process.internal.DefaultExecHandle] Successfully started process 'command 'C:\usr\bin\Java\jdk1.7\bin\java.exe''
    14:22:16.778 [DEBUG] [org.gradle.process.internal.ExecHandleRunner] waiting until streams are handled...
    14:22:16.987 [ERROR] [system.err] 8.y.z-SNAPSHOT
    14:22:16.999 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Changing state to: SUCCEEDED
    14:22:17.008 [INFO] [org.gradle.process.internal.DefaultExecHandle] Process 'command 'C:\usr\bin\Java\jdk1.7\bin\java.exe'' finished with exit value 0 (state: SUCCEEDED)
    14:22:17.016 [DEBUG] [org.gradle.logging.internal.DefaultLoggingConfigurer] Finished configuring with level: DEBUG, configurers: [org.gradle.logging.internal.OutputEventRenderer@1398c0b5, org.gradle.logging.internal.logback.LogbackLoggingConfigurer@1193b520, org.gradle.logging.internal.JavaUtilLoggingConfigurer@785850e3]
    14:22:17.023 [DEBUG] [org.gradle.logging.internal.DefaultLoggingConfigurer] Finished configuring with level: DEBUG, configurers: [org.gradle.logging.internal.OutputEventRenderer@1398c0b5, org.gradle.logging.internal.logback.LogbackLoggingConfigurer@1193b520, org.gradle.logging.internal.JavaUtilLoggingConfigurer@785850e3]
    14:22:17.031 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':jetty8Run'
    14:22:17.036 [DEBUG] [org.gradle.execution.taskgraph.DefaultTaskGraphExecuter] Timing: Executing the DAG took 1 mins 17.814 secs
    14:22:17.044 [LIFECYCLE] [org.gradle.BuildResultLogger]
    14:22:17.051 [LIFECYCLE] [org.gradle.BuildResultLogger] BUILD SUCCESSFUL
    14:22:17.062 [LIFECYCLE] [org.gradle.BuildResultLogger]
    14:22:17.069 [LIFECYCLE] [org.gradle.BuildResultLogger] Total time: 1 mins 22.869 secs
    14:22:17.083 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on no_buildscript class cache for build file 'C:\usr\git_workspaces\oxygen\code_wash\build.gradle' (C:\Users\mknuts6173c\.gradle\caches\1.2\scripts\build_6pds00nsngb1qkefk395em9gdo\ProjectScript\no_buildscript).
    14:22:17.102 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on buildscript class cache for build file 'C:\usr\git_workspaces\oxygen\code_wash\build.gradle' (C:\Users\mknuts6173c\.gradle\caches\1.2\scripts\build_6pds00nsngb1qkefk395em9gdo\ProjectScript\buildscript).
    14:22:17.118 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on no_buildscript class cache for settings file 'C:\usr\git_workspaces\oxygen\code_wash\settings.gradle' (C:\Users\mknuts6173c\.gradle\caches\1.2\scripts\settings_6mc489vb6gkj8h6rl06dj51vmb\SettingsScript\no_buildscript).
    14:22:17.131 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on buildscript class cache for settings file 'C:\usr\git_workspaces\oxygen\code_wash\settings.gradle' (C:\Users\mknuts6173c\.gradle\caches\1.2\scripts\settings_6mc489vb6gkj8h6rl06dj51vmb\SettingsScript\buildscript).
    14:22:17.153 [DEBUG] [org.gradle.logging.internal.DefaultLoggingConfigurer] Finished configuring with level: DEBUG, configurers: [org.gradle.logging.internal.OutputEventRenderer@1398c0b5, org.gradle.logging.internal.logback.LogbackLoggingConfigurer@1193b520, org.gradle.logging.internal.JavaUtilLoggingConfigurer@785850e3]

任何人都可以帮助解决这个问题吗?

4

3 回答 3

7

Gretty gradle 插件解决问题:https ://github.com/akhikhl

它支持开箱即用的 jetty 版本 7、8 和 9。

披露:我是 Gretty 插件的作者。

于 2014-05-28T19:28:37.023 回答
0

你可以试试这个
https://github.com/Khoulaiz/gradle-jetty-eclipse-plugin
它对我有用。

于 2014-01-06T14:42:32.400 回答
0

我对 Gradle JavaExec 任务没有任何建议,但如果您遇到困难并想尝试替代方案 - 您可以尝试使用 Ant 任务启动,并为 fork/spawn 设置适当的设置。

于 2012-11-04T22:32:23.550 回答