Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9013897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:22:53+00:00 2026-06-16T03:22:53+00:00

I want to reuse certain filter for many projects so I want to extract

  • 0

I want to reuse certain filter for many projects so I want to extract it and use a single jar to just add it to any Web App.

For building I am using Gradle 1.3 and the following build.gradle file:

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()

}

As you can see, I need the servlet api to compile this filter succesfully so I want to add it like a maven provided dependency.

Anyways, after running gradle build I get the following error:

Could not find method providedCompile() for arguments
[{group=javax.servlet, name=javax.servlet-api, version=3.+}] on root
project ‘hibernate-conversation-context’.

Now, I know that I cannot use providedCompile without the WAR plugin but I need the project to be a simple JAR. Is there another way to do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T03:22:54+00:00Added an answer on June 16, 2026 at 3:22 am

    There is no such configuration out of the box for the java plugin. However you can build it yourself as follows:

    configurations { providedCompile }
    
    dependencies {
        providedCompile "javax.servlet:javax.servlet-api:3.+"
    }
    
    sourceSets.main.compileClasspath += configurations.providedCompile
    sourceSets.test.compileClasspath += configurations.providedCompile
    sourceSets.test.runtimeClasspath += configurations.providedCompile
    

    This adds the configuration, and puts all the dependencies in there on the compile classpaths of both your main classes and test classes. You also need to add it to the runtimeClasspath, as that doesn’t include the compile classpath according to the gradle DSL documentation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to reuse some code I wrote to add some functionality to a
I have some shared code I want to reuse in my Xcode projects. The
I have a whole bunch of projects which I want to reuse between the
I want to use/reuse C++ object with Objective-C. I have a hello.h that has
How can we re-use the deleted id from any MySQL-DB table? If I want
I am currently learning to use the Propel ORM, and I want to reuse
When should I use one versus the other? I want to cache a certain
I want DRY/reuse as much editor code (View and Model) as possible. Some of
I want to reuse a WebRequest object so that cookies and session would be
I want to define the data.store that store companyList, because I want to reuse

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.