我想爲許多項目重用某些過濾器,所以我想提取它並使用一個jar將它添加到任何Web App。providedCompile without war插件
建築我使用的搖籃1.3及以下build.gradle
文件:
apply plugin: 'java'
dependencies {
compile group:'org.slf4j', name:'slf4j-api', version:'1.7.+'
testCompile group:'junit', name:'junit', version:'4.+'
compile group:'org.springframework', name:'spring-web', version:'3.+'
compile group:'org.slf4j', name:'slf4j-log4j12', version:'1.6.+'
compile group:'log4j', name:'log4j', version:'1.2.+'
providedCompile group: 'javax.servlet', name: 'javax.servlet-api', version:'3.+'
}
repositories {
mavenCentral()
}
正如你所看到的,我需要在Servlet API來編譯這個過濾器成功地讓我想添加它像一個行家提供的依賴。
不管怎麼說,運行gradle build
後,我收到以下錯誤:
Could not find method providedCompile() for arguments [{group=javax.servlet, name=javax.servlet-api, version=3.+}] on root project 'hibernate-conversation-context'.
現在,我知道我不能沒有WAR插件使用providedCompile但我需要這個項目是一個簡單的JAR。有沒有另一種方法來做到這一點?
的可能的複製[如何定義編譯-time \ * only \ * Gradle中的classpath?](http://stackoverflow.com/questions/10405970/how-do-i-define-a-compile-time-only-classpath-in-gradle) –