Gradle build assembly error: javax.servlet package does not exist

I am new to gradle and building systems, I am trying to build a project using gradle, but it cannot find the Tomcat server packages that I use in several classes of my project.

My build configuration:

apply plugin: 'java' apply plugin: 'war' repositories { flatDir { dirs "WebContent/WEB-INF/lib" } mavenCentral() } dependencies { compile group: 'com.orientechnologies', name: 'orient-commons', version: '1.3.0' compile group: 'com.orientechnologies', name: 'orientdb-client', version: '1.3.0' compile group: 'com.orientechnologies', name: 'orientdb-core', version: '1.3.0' compile group: 'com.orientechnologies', name: 'orientdb-graphdb', version: '1.3.0' compile group: 'com.orientechnologies', name: 'orientdb-enterprise', version: '1.3.0' compile group: 'com.tinkerpop.blueprints', name: 'blueprints-core', version: '2.3.0' compile group: 'com.tinkerpop.blueprints', name: 'blueprints-orient-graph', version: '2.3.0' compile group: 'com.tinkerpop', name: 'pipes', version: '2.3.0' compile group: 'com.tinkerpop.gremlin', name: 'gremlin-java', version: '2.3.0' compile group: 'com.tinkerpop.gremlin', name: 'gremlin-groovy', version: '2.3.0' testCompile group: 'junit', name: 'junit', version: '4.+' testCompile group: 'org.mockito', name: 'mockito-all', version: '1.9.5' } sourceSets { main { java { srcDir 'src' } } test { java { srcDir 'test' } } } task wrapper(type: Wrapper) { gradleVersion = '1.3' } war { from 'WebContent' } 

Errors occur when starting gradle Task - Build:

 OrientDBFilter.java:6: error: package javax.servlet does not exist import javax.servlet.FilterChain; OrientDBFilter.java:5: error: package javax.servlet does not exist import javax.servlet.Filter; 

....

+6
source share
1 answer

Usually you use the providedCompile . Sort of:

 providedCompile group: 'javax.servlet', name: 'javax.servlet-api', version: '3.0.1' 

Then your application will compile, but gradle will not include the api servlet in the final war file.

+9
source

All Articles