如何将 jetty 或 gretty 导入我的 gradle 脚本
how to import jetty or gretty into my gradle script
我正在尝试 gradle "todo-webapp-jetty" 一书中的示例 Gradle In Action .这可以找到 here。经过几次搜索,我才知道不再支持码头。相反,我们需要使用 gretty 插件(最好是 org.gretty 提供的插件)。但仍然没有运气。我的构建脚本与示例的相同,只是调整为使用 gretty 插件。
使用插件块,这工作正常,但只有在我执行 jettyRun 任务之前。执行jettyRun任务后,控制台卡在87%:
plugins{
id 'java'
id 'war'
id 'org.gretty' version '2.2.0'
}
............
t<===========--> 87% EXECUTING [13s]a:509)
> :jettyRun=--> 87% EXECUTING [12s]artifacts.configurations.DefaultConfiguration.access00> :jettyRun=--> 87% EXECUTING [12s]
> :jettyRunorg.gradle.api.internal.artifacts.configurations.DefaultConfiguration$Configurati<===========--> 87% EXECUTING [12s]ts(DefaultConfiguration.java:1037)
> :jettyRunorg.gradle.api.internal.artifacts.configurations.DefaultConfiguration$Configurati<===========--> 87% EXECUTING [12s]nfiguration.java:1025)
> :jettyRun 81 more
<===========--> 87% EXECUTING [12s]
> :jettyRun
> IDLE
编辑 1 开始:发布完整的堆栈跟踪
D:\Practice\Gradle\GradleInAction\todo-webapp-jetty>gradle jettyRun -is
Initialized native services in: C:\Users\am064763\.gradle\native
The client will now receive all logging from the daemon (pid: 48064). The daemon log file: C:\Users\am064763\.gradle\daemon.10.2\daemon-48064.out.log
Starting 2nd build in daemon [uptime: 10.343 secs, performance: 97%, GC rate: 0.50/s, tenured heap usage: 2% of 716.2 MB]
Using 8 worker leases.
Starting Build
another.gradle -->> This is executed during the initialization phase ---- timestamp @ 2018-11-16T13:30:45
init.gradle -->> This is executed during the initialization phase ---- timestamp @ 2018-11-16T13:30:45
zingAnother.gradle -->> This is executed during the initialization phase ---- timestamp @ 2018-11-16T13:30:45
Settings evaluated using settings file 'D:\Practice\Gradle\GradleInAction\todo-webapp-jetty\settings.gradle'.
Projects loaded. Root project using build file 'D:\Practice\Gradle\GradleInAction\todo-webapp-jetty\build.gradle'.
Included projects: [root project 'todo-webapp-jetty']
> Configure project :
Evaluating root project 'todo-webapp-jetty' using build file 'D:\Practice\Gradle\GradleInAction\todo-webapp-jetty\build.gradle'.
All projects evaluated.
Selected primary task 'jettyRun' from project :
Tasks to be executed: [task ':prepareInplaceWebAppFolder', task ':createInplaceWebAppFolder', task ':compileJava', task ':processResources', task ':classes', task ':prepareInplaceWebAppClasses', task ':prepareInplaceWebApp', task ':jettyRun']
:prepareInplaceWebAppFolder (Thread[Task worker for ':' Thread 5,5,main]) started.
> Task :prepareInplaceWebAppFolder UP-TO-DATE
Skipping task ':prepareInplaceWebAppFolder' as it is up-to-date.
:prepareInplaceWebAppFolder (Thread[Task worker for ':' Thread 5,5,main]) completed. Took 0.111 secs.
:createInplaceWebAppFolder (Thread[Task worker for ':' Thread 5,5,main]) started.
> Task :createInplaceWebAppFolder UP-TO-DATE
Skipping task ':createInplaceWebAppFolder' as it is up-to-date.
:createInplaceWebAppFolder (Thread[Task worker for ':' Thread 5,5,main]) completed. Took 0.001 secs.
:compileJava (Thread[Task worker for ':' Thread 5,5,main]) started.
> Task :compileJava UP-TO-DATE
Skipping task ':compileJava' as it is up-to-date.
:compileJava (Thread[Task worker for ':' Thread 5,5,main]) completed. Took 0.048 secs.
:processResources (Thread[Task worker for ':' Thread 5,5,main]) started.
> Task :processResources NO-SOURCE
file or directory 'D:\Practice\Gradle\GradleInAction\todo-webapp-jetty\src\main\resources', not found
Skipping task ':processResources' as it has no source files and no previous output files.
:processResources (Thread[Task worker for ':' Thread 5,5,main]) completed. Took 0.001 secs.
:classes (Thread[Task worker for ':' Thread 5,5,main]) started.
> Task :classes UP-TO-DATE
Skipping task ':classes' as it has no actions.
:classes (Thread[Task worker for ':' Thread 5,5,main]) completed. Took 0.0 secs.
:prepareInplaceWebAppClasses (Thread[Task worker for ':' Thread 5,5,main]) started.
> Task :prepareInplaceWebAppClasses UP-TO-DATE
Skipping task ':prepareInplaceWebAppClasses' as it has no actions.
:prepareInplaceWebAppClasses (Thread[Task worker for ':' Thread 5,5,main]) completed. Took 0.0 secs.
:prepareInplaceWebApp (Thread[Task worker for ':' Thread 5,5,main]) started.
> Task :prepareInplaceWebApp UP-TO-DATE
Skipping task ':prepareInplaceWebApp' as it has no actions.
:prepareInplaceWebApp (Thread[Task worker for ':' Thread 5,5,main]) completed. Took 0.0 secs.
:jettyRun (Thread[Task worker for ':' Thread 5,5,main]) started.
> Task :jettyRun
Task ':jettyRun' is not up-to-date because:
Task.upToDateWhen is false.
scanDir: D:\Practice\Gradle\GradleInAction\todo-webapp-jetty\src\main\webapp
scanDir: D:\Practice\Gradle\GradleInAction\todo-webapp-jetty\src\main\resources
scanDir: D:\Practice\Gradle\GradleInAction\todo-webapp-jetty\src\main\java
scanDir: D:\Practice\Gradle\GradleInAction\todo-webapp-jetty\build\classes\java\main
scanDir: D:\Practice\Gradle\GradleInAction\todo-webapp-jetty\build\resources\main
scanDir: C:\Users\am064763\.gradle\caches\modules-2\files-2.1\javax.servlet\javax.servlet-api.1.0cd63d075497751784b2fa84be59432f4905bf7c\javax.servlet-api-3.1.0.jar
scanDir: C:\Users\am064763\.gradle\caches\modules-2\files-2.1\javax.websocket\javax.websocket-api.0\fc843b649d4a1dcb0497669d262befa3918c7ba8\javax.websocket-api-1.0.jar
scanDir: C:\Users\am064763\.gradle\caches\modules-2\files-2.1\javax.servlet\servlet-api.559582d97d8b61f4d154ca9e495aafd16726e34\servlet-api-2.5.jar
scanDir: C:\Users\am064763\.gradle\caches\modules-2\files-2.1\javax.servlet\jstl.1.275e43c620df4f1114959400ff9bb90d12a2feb\jstl-1.1.2.jar
fastReloadMap={:=[org.akhikhl.gretty.FileReloadSpec(D:\Practice\Gradle\GradleInAction\todo-webapp-jetty\src\main\webapp, null, null)]}
Enabling hot deployment with interval of 1 second(s)
Resource missing. [HTTP GET: https://repo.maven.apache.org/maven2/org/gretty/gretty-runner-jetty9/2.2.0/gretty-runner-jetty9-2.2.0.pom]
Resource missing. [HTTP HEAD: https://repo.maven.apache.org/maven2/org/gretty/gretty-runner-jetty9/2.2.0/gretty-runner-jetty9-2.2.0.jar]
Stopping scanner
Exception in thread "Thread-52" org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files for configuration ':grettyRunnerJetty9'.
at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.rethrowFailure(DefaultConfiguration.java:1054)
at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.access00(DefaultConfiguration.java:123)
at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration$ConfigurationFileCollection.getFiles(DefaultConfiguration.java:1028)
at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.getFiles(DefaultConfiguration.java:444) at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration_Decorated.getFiles(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
at groovy.lang.MetaBeanProperty.getProperty(MetaBeanProperty.java:59)
at org.gradle.internal.metaobject.BeanDynamicObject$MetaClassAdapter.getProperty(BeanDynamicObject.java:228)
at org.gradle.internal.metaobject.BeanDynamicObject.tryGetProperty(BeanDynamicObject.java:171)
at org.gradle.internal.metaobject.CompositeDynamicObject.tryGetProperty(CompositeDynamicObject.java:55)
at org.gradle.internal.metaobject.AbstractDynamicObject.getProperty(AbstractDynamicObject.java:59)
at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration_Decorated.getProperty(Unknown Source)
at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:49)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty(AbstractCallSite.java:299)
at org.akhikhl.gretty.DefaultLauncher.getRunnerClassPath(DefaultLauncher.groovy:30)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at org.gradle.internal.metaobject.BeanDynamicObject$MetaClassAdapter.invokeMethod(BeanDynamicObject.java:479)
at org.gradle.internal.metaobject.BeanDynamicObject.tryInvokeMethod(BeanDynamicObject.java:191)
at org.gradle.internal.metaobject.ConfigureDelegate.invokeMethod(ConfigureDelegate.java:78)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeOnDelegationObjects(ClosureMetaClass.java:398)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:338)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:68)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:51)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:157)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:177)
at org.akhikhl.gretty.DefaultLauncher$_javaExec_closure7.doCall(DefaultLauncher.groovy:90)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:264)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034)
at groovy.lang.Closure.call(Closure.java:418)
at groovy.lang.Closure.call(Closure.java:434)
at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:71)
at org.gradle.util.ConfigureUtil.configureTarget(ConfigureUtil.java:155)
at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:106)
at org.gradle.util.ConfigureUtil$WrappedConfigureAction.execute(ConfigureUtil.java:167)
at org.gradle.api.internal.file.DefaultFileOperations.javaexec(DefaultFileOperations.java:224)
at org.gradle.api.internal.project.DefaultProject.javaexec(DefaultProject.java:1102)
at org.gradle.api.internal.project.DefaultProject.javaexec(DefaultProject.java:1097)
at org.gradle.api.Project$javaexec.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:128)
at org.akhikhl.gretty.DefaultLauncher.javaExec(DefaultLauncher.groovy:89)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:352)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:68)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:51)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:157)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:169)
at org.akhikhl.gretty.LauncherBase$_launchThread_closure4.doCall(LauncherBase.groovy:256)
at org.akhikhl.gretty.LauncherBase$_launchThread_closure4.doCall(LauncherBase.groovy)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:264)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034)
at groovy.lang.Closure.call(Closure.java:418)
at groovy.lang.Closure.call(Closure.java:412)
at groovy.lang.Closure.run(Closure.java:499)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.gradle.internal.resolve.ModuleVersionNotFoundException: Could not find org.gretty:gretty-runner-jetty9:2.2.0.
Searched in the following locations:
- https://repo.maven.apache.org/maven2/org/gretty/gretty-runner-jetty9/2.2.0/gretty-runner-jetty9-2.2.0.pom
- https://repo.maven.apache.org/maven2/org/gretty/gretty-runner-jetty9/2.2.0/gretty-runner-jetty9-2.2.0.jar
Required by:
project :
at org.gradle.internal.resolve.result.DefaultBuildableComponentResolveResult.notFound(DefaultBuildableComponentResolveResult.java:49)
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainComponentMetaDataResolver.resolveModule(RepositoryChainComponentMetaDataResolver.java:108)
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainComponentMetaDataResolver.resolve(RepositoryChainComponentMetaDataResolver.java:63)
at org.gradle.api.internal.artifacts.ivyservice.resolveengine.ComponentResolversChain$ComponentMetaDataResolverChain.resolve(ComponentResolversChain.java:94)
at org.gradle.api.internal.artifacts.ivyservice.clientmodule.ClientModuleResolver.resolve(ClientModuleResolver.java:62)
<===========--> 87% EXECUTING [37s]artifacts.ivyservice.resolveengine.graph.builder.ComponentState.resolve(ComponentState.java:208)
> :jettyRunorg.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.builder.ComponentState.resolve(ComponentState.java:196)
at org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.builder.ComponentState.getMetadata(ComponentState.java:152)
> :jettyRun=--> 87% EXECUTING [34s]artifacts.ivyservice.resolveengine.graph.builder.EdgeState.calculateTargetConfigurations(EdgeState.java:156)
<===========--> 87% EXECUTING [34s]artifacts.ivyservice.resolveengine.graph.builder.EdgeState.attachToTargetConfigurations(EdgeState.java:112)
> :jettyRunorg.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.builder.DependencyGraphBuilder.attachToTargetRevisionsSerially(DependencyGraphBuilder.java:315)
at org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.builder.DependencyGraphBuilder.resolveEdges(DependencyGraphBuilder.java:202)
> :jettyRun=--> 87% EXECUTING [33s]artifacts.ivyservice.resolveengine.graph.builder.DependencyGraphBuilder.traverseGraph(DependencyGraphBuilder.java:155)
at org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.builder.DependencyGraphBuilder.resolve(DependencyGraphBuilder.java:126)
at org.gradle.api.internal.artifacts.ivyservice.resolveengine.DefaultArtifactDependencyResolver.resolve(DefaultArtifactDependencyResolver.java:123)
> :jettyRun=--> 87% EXECUTING [33s]artifacts.ivyservice.DefaultConfigurationResolver.resolveGraph(DefaultConfigurationResolver.java:167)
<===========--> 87% EXECUTING [33s]artifacts.ivyservice.ShortCircuitEmptyConfigurationResolver.resolveGraph(ShortCircuitEmptyConfigurationResolver.java:89)
> :jettyRun=--> 87% EXECUTING [33s]artifacts.ivyservice.ErrorHandlingConfigurationResolver.resolveGraph(ErrorHandlingConfigurationResolver.java:73)
> :jettyRun=--> 87% EXECUTING [33s]artifacts.configurations.DefaultConfiguration.run(DefaultConfiguration.java:533)
> :jettyRun=--> 87% EXECUTING [33s]ations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:300)
> :jettyRunorg.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:292)
<===========--> 87% EXECUTING [32s]ations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:174)
> :jettyRunorg.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31) at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.resolveGraphIfRequired(DefaultConfig> :jettyRun=--> 87% EXECUTING [32s]
at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.resolveToStateOrLater(DefaultConfiguration.java:509)
at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.access00(DefaultConfiguration.java:123)
> :jettyRun=--> 87% EXECUTING [32s]artifacts.configurations.DefaultConfiguration$ConfigurationFileCollection.getSelectedArtifacts(DefaultConfiguration.java:1037)
> :jettyRunorg.gradle.api.internal.artifacts.configurations.DefaultConfiguration$ConfigurationFileCollection.getFiles(DefaultConfiguration.java:1025)
... 81 more
> :jettyRun=--> 87% EXECUTING [10s]
> :jettyRun
> IDLE
编辑 1 结束
但是如果没有插件阻止它,它就不起作用,每当我 运行 构建时,我都会收到以下错误消息:
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'org.gretty'
********
FAILURE: Build failed with an exception.
* Where:
Build file 'D:\Practice\Gradle\GradleInAction\todo-webapp-jetty\build.gradle' line: 3
* What went wrong:
A problem occurred evaluating root project 'todo-webapp-jetty'.
> Plugin with id 'org.gretty' not found.
编辑 2 开始 我的 build.gradle :
plugins{
id 'java'
id 'war'
id 'org.gretty' version '2.2.0'
}
repositories {
mavenCentral()
jcenter()
}
dependencies {
providedCompile 'javax.servlet:servlet-api:2.5'
runtime 'javax.servlet:jstl:1.1.2'
}
编辑 2 结束
非常感谢任何指导。
这是 Gradle 在执行正在启动的任务和 运行 应用程序(如 jettyRun 或 bootRun)时的 "normal" 行为:您将看到 <===---> XY% EXECUTING [...]
应用程序执行时的消息..
例如,使用 Spring 引导 bootRun
任务,您将拥有:
$ ./gradlew bootRun
> Task :bootRun
. ____ _ __ _ _
/\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.0.6.RELEASE)
<=========----> 75% EXECUTING [1m 58s]
> :bootRun
您应该在您的应用程序中配置日志记录,以便在 STDOUT 中提供一些日志跟踪,您通常会看到该应用程序已正确启动。
EDIT1
来自您的堆栈跟踪:
Enabling hot deployment with interval of 1 second(s)
Resource missing. [HTTP GET: https://repo.maven.apache.org/maven2/org/gretty/gretty-runner-jetty9/2.2.0/gretty-runner-jetty9-2.2.0.pom]
Resource missing. [HTTP HEAD: https://repo.maven.apache.org/maven2/org/gretty/gretty-runner-jetty9/2.2.0/gretty-runner-jetty9-2.2.0.jar]
Stopping scanner
Exception in thread "Thread-52" org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files for configuration ':grettyRunnerJetty9'.
==> 您需要在您的存储库块中添加 jcenter()
,因为 gretty-runner-jetty9-2.2.0.jar
所需的依赖项在 maven 中央存储库中不可用。
repositories {
jcenter()
// your other repositories ...
}
我正在尝试 gradle "todo-webapp-jetty" 一书中的示例 Gradle In Action .这可以找到 here。经过几次搜索,我才知道不再支持码头。相反,我们需要使用 gretty 插件(最好是 org.gretty 提供的插件)。但仍然没有运气。我的构建脚本与示例的相同,只是调整为使用 gretty 插件。
使用插件块,这工作正常,但只有在我执行 jettyRun 任务之前。执行jettyRun任务后,控制台卡在87%:
plugins{
id 'java'
id 'war'
id 'org.gretty' version '2.2.0'
}
............
t<===========--> 87% EXECUTING [13s]a:509)
> :jettyRun=--> 87% EXECUTING [12s]artifacts.configurations.DefaultConfiguration.access00> :jettyRun=--> 87% EXECUTING [12s]
> :jettyRunorg.gradle.api.internal.artifacts.configurations.DefaultConfiguration$Configurati<===========--> 87% EXECUTING [12s]ts(DefaultConfiguration.java:1037)
> :jettyRunorg.gradle.api.internal.artifacts.configurations.DefaultConfiguration$Configurati<===========--> 87% EXECUTING [12s]nfiguration.java:1025)
> :jettyRun 81 more
<===========--> 87% EXECUTING [12s]
> :jettyRun
> IDLE
编辑 1 开始:发布完整的堆栈跟踪
D:\Practice\Gradle\GradleInAction\todo-webapp-jetty>gradle jettyRun -is
Initialized native services in: C:\Users\am064763\.gradle\native
The client will now receive all logging from the daemon (pid: 48064). The daemon log file: C:\Users\am064763\.gradle\daemon.10.2\daemon-48064.out.log
Starting 2nd build in daemon [uptime: 10.343 secs, performance: 97%, GC rate: 0.50/s, tenured heap usage: 2% of 716.2 MB]
Using 8 worker leases.
Starting Build
another.gradle -->> This is executed during the initialization phase ---- timestamp @ 2018-11-16T13:30:45
init.gradle -->> This is executed during the initialization phase ---- timestamp @ 2018-11-16T13:30:45
zingAnother.gradle -->> This is executed during the initialization phase ---- timestamp @ 2018-11-16T13:30:45
Settings evaluated using settings file 'D:\Practice\Gradle\GradleInAction\todo-webapp-jetty\settings.gradle'.
Projects loaded. Root project using build file 'D:\Practice\Gradle\GradleInAction\todo-webapp-jetty\build.gradle'.
Included projects: [root project 'todo-webapp-jetty']
> Configure project :
Evaluating root project 'todo-webapp-jetty' using build file 'D:\Practice\Gradle\GradleInAction\todo-webapp-jetty\build.gradle'.
All projects evaluated.
Selected primary task 'jettyRun' from project :
Tasks to be executed: [task ':prepareInplaceWebAppFolder', task ':createInplaceWebAppFolder', task ':compileJava', task ':processResources', task ':classes', task ':prepareInplaceWebAppClasses', task ':prepareInplaceWebApp', task ':jettyRun']
:prepareInplaceWebAppFolder (Thread[Task worker for ':' Thread 5,5,main]) started.
> Task :prepareInplaceWebAppFolder UP-TO-DATE
Skipping task ':prepareInplaceWebAppFolder' as it is up-to-date.
:prepareInplaceWebAppFolder (Thread[Task worker for ':' Thread 5,5,main]) completed. Took 0.111 secs.
:createInplaceWebAppFolder (Thread[Task worker for ':' Thread 5,5,main]) started.
> Task :createInplaceWebAppFolder UP-TO-DATE
Skipping task ':createInplaceWebAppFolder' as it is up-to-date.
:createInplaceWebAppFolder (Thread[Task worker for ':' Thread 5,5,main]) completed. Took 0.001 secs.
:compileJava (Thread[Task worker for ':' Thread 5,5,main]) started.
> Task :compileJava UP-TO-DATE
Skipping task ':compileJava' as it is up-to-date.
:compileJava (Thread[Task worker for ':' Thread 5,5,main]) completed. Took 0.048 secs.
:processResources (Thread[Task worker for ':' Thread 5,5,main]) started.
> Task :processResources NO-SOURCE
file or directory 'D:\Practice\Gradle\GradleInAction\todo-webapp-jetty\src\main\resources', not found
Skipping task ':processResources' as it has no source files and no previous output files.
:processResources (Thread[Task worker for ':' Thread 5,5,main]) completed. Took 0.001 secs.
:classes (Thread[Task worker for ':' Thread 5,5,main]) started.
> Task :classes UP-TO-DATE
Skipping task ':classes' as it has no actions.
:classes (Thread[Task worker for ':' Thread 5,5,main]) completed. Took 0.0 secs.
:prepareInplaceWebAppClasses (Thread[Task worker for ':' Thread 5,5,main]) started.
> Task :prepareInplaceWebAppClasses UP-TO-DATE
Skipping task ':prepareInplaceWebAppClasses' as it has no actions.
:prepareInplaceWebAppClasses (Thread[Task worker for ':' Thread 5,5,main]) completed. Took 0.0 secs.
:prepareInplaceWebApp (Thread[Task worker for ':' Thread 5,5,main]) started.
> Task :prepareInplaceWebApp UP-TO-DATE
Skipping task ':prepareInplaceWebApp' as it has no actions.
:prepareInplaceWebApp (Thread[Task worker for ':' Thread 5,5,main]) completed. Took 0.0 secs.
:jettyRun (Thread[Task worker for ':' Thread 5,5,main]) started.
> Task :jettyRun
Task ':jettyRun' is not up-to-date because:
Task.upToDateWhen is false.
scanDir: D:\Practice\Gradle\GradleInAction\todo-webapp-jetty\src\main\webapp
scanDir: D:\Practice\Gradle\GradleInAction\todo-webapp-jetty\src\main\resources
scanDir: D:\Practice\Gradle\GradleInAction\todo-webapp-jetty\src\main\java
scanDir: D:\Practice\Gradle\GradleInAction\todo-webapp-jetty\build\classes\java\main
scanDir: D:\Practice\Gradle\GradleInAction\todo-webapp-jetty\build\resources\main
scanDir: C:\Users\am064763\.gradle\caches\modules-2\files-2.1\javax.servlet\javax.servlet-api.1.0cd63d075497751784b2fa84be59432f4905bf7c\javax.servlet-api-3.1.0.jar
scanDir: C:\Users\am064763\.gradle\caches\modules-2\files-2.1\javax.websocket\javax.websocket-api.0\fc843b649d4a1dcb0497669d262befa3918c7ba8\javax.websocket-api-1.0.jar
scanDir: C:\Users\am064763\.gradle\caches\modules-2\files-2.1\javax.servlet\servlet-api.559582d97d8b61f4d154ca9e495aafd16726e34\servlet-api-2.5.jar
scanDir: C:\Users\am064763\.gradle\caches\modules-2\files-2.1\javax.servlet\jstl.1.275e43c620df4f1114959400ff9bb90d12a2feb\jstl-1.1.2.jar
fastReloadMap={:=[org.akhikhl.gretty.FileReloadSpec(D:\Practice\Gradle\GradleInAction\todo-webapp-jetty\src\main\webapp, null, null)]}
Enabling hot deployment with interval of 1 second(s)
Resource missing. [HTTP GET: https://repo.maven.apache.org/maven2/org/gretty/gretty-runner-jetty9/2.2.0/gretty-runner-jetty9-2.2.0.pom]
Resource missing. [HTTP HEAD: https://repo.maven.apache.org/maven2/org/gretty/gretty-runner-jetty9/2.2.0/gretty-runner-jetty9-2.2.0.jar]
Stopping scanner
Exception in thread "Thread-52" org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files for configuration ':grettyRunnerJetty9'.
at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.rethrowFailure(DefaultConfiguration.java:1054)
at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.access00(DefaultConfiguration.java:123)
at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration$ConfigurationFileCollection.getFiles(DefaultConfiguration.java:1028)
at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.getFiles(DefaultConfiguration.java:444) at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration_Decorated.getFiles(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
at groovy.lang.MetaBeanProperty.getProperty(MetaBeanProperty.java:59)
at org.gradle.internal.metaobject.BeanDynamicObject$MetaClassAdapter.getProperty(BeanDynamicObject.java:228)
at org.gradle.internal.metaobject.BeanDynamicObject.tryGetProperty(BeanDynamicObject.java:171)
at org.gradle.internal.metaobject.CompositeDynamicObject.tryGetProperty(CompositeDynamicObject.java:55)
at org.gradle.internal.metaobject.AbstractDynamicObject.getProperty(AbstractDynamicObject.java:59)
at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration_Decorated.getProperty(Unknown Source)
at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:49)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty(AbstractCallSite.java:299)
at org.akhikhl.gretty.DefaultLauncher.getRunnerClassPath(DefaultLauncher.groovy:30)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at org.gradle.internal.metaobject.BeanDynamicObject$MetaClassAdapter.invokeMethod(BeanDynamicObject.java:479)
at org.gradle.internal.metaobject.BeanDynamicObject.tryInvokeMethod(BeanDynamicObject.java:191)
at org.gradle.internal.metaobject.ConfigureDelegate.invokeMethod(ConfigureDelegate.java:78)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeOnDelegationObjects(ClosureMetaClass.java:398)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:338)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:68)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:51)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:157)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:177)
at org.akhikhl.gretty.DefaultLauncher$_javaExec_closure7.doCall(DefaultLauncher.groovy:90)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:264)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034)
at groovy.lang.Closure.call(Closure.java:418)
at groovy.lang.Closure.call(Closure.java:434)
at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:71)
at org.gradle.util.ConfigureUtil.configureTarget(ConfigureUtil.java:155)
at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:106)
at org.gradle.util.ConfigureUtil$WrappedConfigureAction.execute(ConfigureUtil.java:167)
at org.gradle.api.internal.file.DefaultFileOperations.javaexec(DefaultFileOperations.java:224)
at org.gradle.api.internal.project.DefaultProject.javaexec(DefaultProject.java:1102)
at org.gradle.api.internal.project.DefaultProject.javaexec(DefaultProject.java:1097)
at org.gradle.api.Project$javaexec.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:128)
at org.akhikhl.gretty.DefaultLauncher.javaExec(DefaultLauncher.groovy:89)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:352)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:68)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:51)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:157)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:169)
at org.akhikhl.gretty.LauncherBase$_launchThread_closure4.doCall(LauncherBase.groovy:256)
at org.akhikhl.gretty.LauncherBase$_launchThread_closure4.doCall(LauncherBase.groovy)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:264)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034)
at groovy.lang.Closure.call(Closure.java:418)
at groovy.lang.Closure.call(Closure.java:412)
at groovy.lang.Closure.run(Closure.java:499)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.gradle.internal.resolve.ModuleVersionNotFoundException: Could not find org.gretty:gretty-runner-jetty9:2.2.0.
Searched in the following locations:
- https://repo.maven.apache.org/maven2/org/gretty/gretty-runner-jetty9/2.2.0/gretty-runner-jetty9-2.2.0.pom
- https://repo.maven.apache.org/maven2/org/gretty/gretty-runner-jetty9/2.2.0/gretty-runner-jetty9-2.2.0.jar
Required by:
project :
at org.gradle.internal.resolve.result.DefaultBuildableComponentResolveResult.notFound(DefaultBuildableComponentResolveResult.java:49)
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainComponentMetaDataResolver.resolveModule(RepositoryChainComponentMetaDataResolver.java:108)
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainComponentMetaDataResolver.resolve(RepositoryChainComponentMetaDataResolver.java:63)
at org.gradle.api.internal.artifacts.ivyservice.resolveengine.ComponentResolversChain$ComponentMetaDataResolverChain.resolve(ComponentResolversChain.java:94)
at org.gradle.api.internal.artifacts.ivyservice.clientmodule.ClientModuleResolver.resolve(ClientModuleResolver.java:62)
<===========--> 87% EXECUTING [37s]artifacts.ivyservice.resolveengine.graph.builder.ComponentState.resolve(ComponentState.java:208)
> :jettyRunorg.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.builder.ComponentState.resolve(ComponentState.java:196)
at org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.builder.ComponentState.getMetadata(ComponentState.java:152)
> :jettyRun=--> 87% EXECUTING [34s]artifacts.ivyservice.resolveengine.graph.builder.EdgeState.calculateTargetConfigurations(EdgeState.java:156)
<===========--> 87% EXECUTING [34s]artifacts.ivyservice.resolveengine.graph.builder.EdgeState.attachToTargetConfigurations(EdgeState.java:112)
> :jettyRunorg.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.builder.DependencyGraphBuilder.attachToTargetRevisionsSerially(DependencyGraphBuilder.java:315)
at org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.builder.DependencyGraphBuilder.resolveEdges(DependencyGraphBuilder.java:202)
> :jettyRun=--> 87% EXECUTING [33s]artifacts.ivyservice.resolveengine.graph.builder.DependencyGraphBuilder.traverseGraph(DependencyGraphBuilder.java:155)
at org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.builder.DependencyGraphBuilder.resolve(DependencyGraphBuilder.java:126)
at org.gradle.api.internal.artifacts.ivyservice.resolveengine.DefaultArtifactDependencyResolver.resolve(DefaultArtifactDependencyResolver.java:123)
> :jettyRun=--> 87% EXECUTING [33s]artifacts.ivyservice.DefaultConfigurationResolver.resolveGraph(DefaultConfigurationResolver.java:167)
<===========--> 87% EXECUTING [33s]artifacts.ivyservice.ShortCircuitEmptyConfigurationResolver.resolveGraph(ShortCircuitEmptyConfigurationResolver.java:89)
> :jettyRun=--> 87% EXECUTING [33s]artifacts.ivyservice.ErrorHandlingConfigurationResolver.resolveGraph(ErrorHandlingConfigurationResolver.java:73)
> :jettyRun=--> 87% EXECUTING [33s]artifacts.configurations.DefaultConfiguration.run(DefaultConfiguration.java:533)
> :jettyRun=--> 87% EXECUTING [33s]ations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:300)
> :jettyRunorg.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:292)
<===========--> 87% EXECUTING [32s]ations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:174)
> :jettyRunorg.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31) at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.resolveGraphIfRequired(DefaultConfig> :jettyRun=--> 87% EXECUTING [32s]
at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.resolveToStateOrLater(DefaultConfiguration.java:509)
at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.access00(DefaultConfiguration.java:123)
> :jettyRun=--> 87% EXECUTING [32s]artifacts.configurations.DefaultConfiguration$ConfigurationFileCollection.getSelectedArtifacts(DefaultConfiguration.java:1037)
> :jettyRunorg.gradle.api.internal.artifacts.configurations.DefaultConfiguration$ConfigurationFileCollection.getFiles(DefaultConfiguration.java:1025)
... 81 more
> :jettyRun=--> 87% EXECUTING [10s]
> :jettyRun
> IDLE
编辑 1 结束
但是如果没有插件阻止它,它就不起作用,每当我 运行 构建时,我都会收到以下错误消息:
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'org.gretty'
********
FAILURE: Build failed with an exception.
* Where:
Build file 'D:\Practice\Gradle\GradleInAction\todo-webapp-jetty\build.gradle' line: 3
* What went wrong:
A problem occurred evaluating root project 'todo-webapp-jetty'.
> Plugin with id 'org.gretty' not found.
编辑 2 开始 我的 build.gradle :
plugins{
id 'java'
id 'war'
id 'org.gretty' version '2.2.0'
}
repositories {
mavenCentral()
jcenter()
}
dependencies {
providedCompile 'javax.servlet:servlet-api:2.5'
runtime 'javax.servlet:jstl:1.1.2'
}
编辑 2 结束
非常感谢任何指导。
这是 Gradle 在执行正在启动的任务和 运行 应用程序(如 jettyRun 或 bootRun)时的 "normal" 行为:您将看到 <===---> XY% EXECUTING [...]
应用程序执行时的消息..
例如,使用 Spring 引导 bootRun
任务,您将拥有:
$ ./gradlew bootRun
> Task :bootRun
. ____ _ __ _ _
/\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.0.6.RELEASE)
<=========----> 75% EXECUTING [1m 58s]
> :bootRun
您应该在您的应用程序中配置日志记录,以便在 STDOUT 中提供一些日志跟踪,您通常会看到该应用程序已正确启动。
EDIT1
来自您的堆栈跟踪:
Enabling hot deployment with interval of 1 second(s) Resource missing. [HTTP GET: https://repo.maven.apache.org/maven2/org/gretty/gretty-runner-jetty9/2.2.0/gretty-runner-jetty9-2.2.0.pom] Resource missing. [HTTP HEAD: https://repo.maven.apache.org/maven2/org/gretty/gretty-runner-jetty9/2.2.0/gretty-runner-jetty9-2.2.0.jar] Stopping scanner Exception in thread "Thread-52" org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files for configuration ':grettyRunnerJetty9'.
==> 您需要在您的存储库块中添加 jcenter()
,因为 gretty-runner-jetty9-2.2.0.jar
所需的依赖项在 maven 中央存储库中不可用。
repositories {
jcenter()
// your other repositories ...
}