我已经创建了一个gradle构建并添加了java,scala,war,jetty代码,并且它的工作正常。
apply plugin: 'java'
apply plugin: 'scala'
apply plugin: 'war'
apply plugin: 'jetty'
List compileTime = [
"javax.servlet:servlet-api:2.4@jar",
"org.scalatra:scalatra_2.8.0:2.0.0.M2@jar",
"org.mortbay.jetty:jetty:6.1.22@jar",
"com.mongodb.casbah:casbah_2.8.0:2.0.2@jar",
"org.scala-lang:scala-library:2.8.1@jar"
]
List runTime = [
"org.scalatra:scalatra_2.8.0:2.0.0.M2@jar",
"com.mongodb.casbah:casbah_2.8.0:2.0.2@jar",
"org.scala-lang:scala-library:2.8.1@jar"
]
// "org.mortbay.jetty:servlet-api:2.5-20081211@jar",
repositories {
mavenCentral()
mavenRepo urls: ["http://scala-tools.org/repo-releases","http://mirrors.ibiblio.org/pub/mirrors/maven2","http://repo1.maven.org/maven2","https://oss.sonatype.org/content/repositories/snapshots","https://oss.sonatype.org/content/repositories/releases"]
}
dependencies {
scalaTools 'org.scala-lang:scala-compiler:2.8.1'
scalaTools 'org.scala-lang:scala-library:2.8.1'
compile compileTime
runtime runTime
testCompile "junit:junit:3.8.2"
}
task myTask (type: War) {
println configurations.runtime.collect
println classpath()
}
war {
// from 'main/webapp'
webInf { from 'src/main/webapp/WEB-INF' }
// classpath classpath() /
classpath configurations.runtime
webXml = file('src/main/webapp/WEB-INF/web.xml')
}
我喜欢 1)只添加必要的罐子。在战争中,在上面的代码中,我在战争中获得了Jetty和servlet jar。 !
答案 0 :(得分:11)
对于不应进入战争的依赖项,请使用“providedCompile”或“providedRuntime”范围。
对构建脚本的一些评论: