启动JettyRun时排除Gradle类路径运行时 [英] Exclude Gradle classpath runtime when launching JettyRun
问题描述
我有磨坊Gradle Web应用程序项目的基本运行,并且它工作正常,但我注意到Gradle的运行时类路径正在包含在可能与Web应用程序发生冲突的jetty中。
注意下面的信息,gradle使用的是稍旧版本的logback,SL4J警告它在类路径中找到多个绑定。
:jettyRun
SLF4J:类路径包含多个SLF4J绑定。
SLF4J:在[jar:file:/ C:/dev/java/tools/gradle-1.0-milestone-5/lib/logback-classic-0.9.29.jar!/ org / slf4j / impl中找到绑定/StaticLoggerBinder.class]
SLF4J:在[jar:file:/ C:/Users/kirk.rasmussen/.gradle/caches/artifacts-3/ch.qos.logback/logback-classic/fd9fe39e28f1bd54eee47f04ca040f2b/中找到绑定jars / logback-classic-0.9.30.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J:请参阅http://www.slf4j.org/codes.html#multiple_bindings以获取解释。
有没有办法在运行jettyRun任务时排除gradle运行时类路径被包含在内?我正在使用最新的1.0版里程碑5版Gradle。
我正在寻找类似于'includeAntRuntime'的Ant中的javac任务。 p>
http://ant.apache。 org / manual / Tasks / javac.html
includeAntRuntime是否将Ant运行时库包含在类路径中;默认为yes,除非设置了build.sysclasspath。通常最好将其设置为false,以便脚本的行为对其运行环境不敏感。
剥离build.gradle:
apply plugin:'groovy'
apply plugin:'war'
apply plugin:'jetty'
jettyRun {
contextPath =''
}
正如任务,它有一个 classpath
属性,默认情况下它被设置为项目。 sourceSets.main.runtimeClasspath
。您可以将此属性设置为您选择的类路径:
配置{
myJettyRuntime
}
依赖项{
myJettyRuntimegroup:name:version
...
}
jettyRun {
classpath = .myJettyRuntime
$ b 或者,您可以从该类路径中添加或减去不需要的或冲突的依赖项,分别使用 - =
和 + =
运算符。 $ p> jettyRun {
classpath - = configurations.myExcludedConf
}
I have your basic run of the mill Gradle web application project and it works ok but I noticed that Gradle's runtime classpath is being included in the jetty one which has the potential to conflict with the web applications.
Notice below that gradle is using a slightly older version of logback and that SL4J is warning that it found multiple bindings in the classpath.
:jettyRun
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/dev/java/tools/gradle-1.0-milestone-5/lib/logback-classic-0.9.29.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/kirk.rasmussen/.gradle/caches/artifacts-3/ch.qos.logback/logback-classic/fd9fe39e28f1bd54eee47f04ca040f2b/jars/logback-classic-0.9.30.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
Is there a way to exclude the gradle runtime classpath from being included when running jettyRun task? I'm using the latest 1.0 milestone 5 version of Gradle.
I'm looking for something along the lines of 'includeAntRuntime' in the javac task in Ant.
http://ant.apache.org/manual/Tasks/javac.html
includeAntRuntime Whether to include the Ant run-time libraries in the classpath; defaults to yes, unless build.sysclasspath is set. It is usually best to set this to false so the script's behavior is not sensitive to the environment in which it is run.
Stripped down build.gradle:
apply plugin: 'groovy'
apply plugin: 'war'
apply plugin: 'jetty'
jettyRun {
contextPath = ''
}
As described in the manual for jettyRun task, it has a classpath
property which is by default set to project.sourceSets.main.runtimeClasspath
. You can just set this property to the classpath of your choice:
configurations{
myJettyRuntime
}
dependencies{
myJettyRuntime "group:name:version"
...
}
jettyRun{
classpath = configurations.myJettyRuntime
}
alternatively you can add or subtract unneeded or conflicting dependencies from this classpath, using -=
and +=
operators respectively.
jettyRun{
classpath -= configurations.myExcludedConf
}
这篇关于启动JettyRun时排除Gradle类路径运行时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!