我想为许多项目重用某些过滤器,所以我想提取它并使用一个jar将其添加到任何Web App.
对于构建我正在使用Gradle 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()
}
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,我需要servlet api成功编译此过滤器,因此我想将其添加为maven提供的依赖项.
无论如何,运行后gradle build我得到以下错误:
无法在根项目'hibernate-conversation-context'上找到方法providedCompile()的参数[{group = javax.servlet,name = javax.servlet-api,version = 3. +}].
现在,我知道在没有WAR插件的情况下我不能使用providedCompile,但我需要将项目作为一个简单的JAR.还有另一种方法吗?
gradle ×1