我有你的mill Gradle web应用程序项目的基本运行,它工作正常,但我注意到Gradle的运行时类路径包含在jetty中,这可能会与web应用程序发生冲突。
请注意,下面的gradle使用的是一个稍微老一点的logback版本,并且SL4J警告说它在类路径中发现了多个绑定。
: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.在运行jettyRun任务时,有没有办法排除gradle运行时类路径?我使用的是Gradle的最新1.0里程碑5版本。
我正在寻找类似于Ant任务中的“includeAntRuntime”的东西。
http://ant.apache.org/manual/Tasks/javac.html
includeAntRuntime是否将Ant运行时库包含在类路径中;除非设置了build.sysclasspath,否则默认为yes。通常,最好将其设置为false,这样脚本的行为就不会对运行它的环境敏感。
精简build.gradle:
apply plugin: 'groovy'
apply plugin: 'war'
apply plugin: 'jetty'
jettyRun {
contextPath = ''
}发布于 2011-11-03 11:21:41
如manual for jettyRun任务中所述,它有一个classpath属性,该属性在缺省情况下设置为project.sourceSets.main.runtimeClasspath。您只需将此属性设置为您选择的类路径:
configurations{
myJettyRuntime
}
dependencies{
myJettyRuntime "group:name:version"
...
}
jettyRun{
classpath = configurations.myJettyRuntime
}或者,您可以分别使用-=和+=运算符在类路径中添加或减去不需要的或冲突的依赖项。
jettyRun{
classpath -= configurations.myExcludedConf
}发布于 2011-11-07 23:32:00
如果您只是担心这两个SLF4j绑定,看起来您可以使用ignore the warning in this case。这正是我正在做的。
https://stackoverflow.com/questions/7982507
复制相似问题