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

  • Home
  • SEARCH
  • 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 8763603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:49:01+00:00 2026-06-13T15:49:01+00:00

I am using the war plugin to generate a simple .WAR file for my

  • 0

I am using the war plugin to generate a simple .WAR file for my project in gradle. I’d like to know how to configure gradle so that I can create 4 different .WAR files with different dependencies.

I’ve configured the dependency compile configuration with the jars that are needed to go into the distribution. None of the code in the src depends on a couple of these jars but I would like to know how to configure the project to create

  • a standard.WAR file that contains all of the jars in the dependency graph (Even though they aren’t used – that is OK – I am testing something)
  • another standard-qas-only.WAR file that only contains the qas.jar
  • another standard-qas-log4j.WAR file that contains qas.jar and log4j

What tasks do i configure to have the artifact generated use a particular dependency configuration?

FYI: The only jar that is required for compilation is qas.jar in this case.

My example below creates a war file that only includes one jar but i’d like to have 5 different .war files generated with different jars.

build.gradle

apply plugin: 'java'
apply plugin: 'war'

dependencies {
    compile files('/lib/qas.jar','/lib/axis1-1.4.jar','/lib/axis2-kernel-1.3.jar','/lib/dom4j-1.6.1.jar','/lib/log4j-1.2.14.jar')
    providedCompile files('/lib/j2ee-1.4.03.jar')
}

war {
    classpath = ['/lib/qas.jar']
}

task dist(dependsOn: 'war') << {
    copy {
        from war.archivePath
        into "dist/"
    }
}
  • 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-13T15:49:02+00:00Added an answer on June 13, 2026 at 3:49 pm

    I got a bit confused on how many WAR distributions you are actually trying to build. You can easily modify it to create additional WAR files. Here’s one approach to make this happen:

    task createStandardWar(type: War, dependsOn: classes) {
        baseName = 'standard'
        destinationDir = file("$buildDir/dist")
    }
    
    task createStandardWarQasOnly(type: War, dependsOn: classes) {
        baseName = 'standard-qas-only'
        destinationDir = file("$buildDir/dist")
        classpath = war.classpath.minus(files('/lib/axis1-1.4.jar','/lib/axis2-kernel-1.3.jar','/lib/dom4j-1.6.1.jar','/lib/log4j-1.2.14.jar'))
    }
    
    task createStandardWarQasAndLog4J(type: War, dependsOn: classes) {
        baseName = 'standard-qas-log4j'
        destinationDir = file("$buildDir/dist")
        classpath = war.classpath.minus(files('/lib/axis1-1.4.jar','/lib/axis2-kernel-1.3.jar','/lib/dom4j-1.6.1.jar'))
    }
    
    task createDists(dependsOn: [createStandardWar, createStandardWarQasOnly, createStandardWarQasAndLog4J])
    

    This build script excerpt creates three different WAR files by declaring enhanced tasks of type War. It assumes that you still want to have your compiled source files under WEB-INF/classes within the WAR files so I didn’t remove it from the classpath. The distributions end up in the directory build/dist. The task createDists creates all of them.

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

Sidebar

Related Questions

I have a simple project with maven using the maven war plugin. When I
I want to create war using grails, but by default it creates war file
My (simple) war project builds fine using mvn:package at the command line, but fails
I have a Maven project that generates a WAR file and tries to get
I need to create two WAR files with two different web.xml files using Maven.
Using Maven war plugin, I generate WAR which includes following directory: META-INF -- maven
I have been trying to convert a web project that produces a war file
I want to copy war file to tomcat web-app directory using NSIS setup. I
I am using maven to build applications. I have deployed a WAR file containing
I am generating xlsx file using Apache POI. On making the war and deploying

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.