Generate war with custom folder

Hi,

When calling gradle war, instead of taking content of src/main/webapp I would like to take the content of another folder. Ideally I would like also to call a command to generate this folder. How can I do that ? So basically here is what I want :

  1. gradle war is called 2) tool is called to generate my web files 3) a war is generated with the content of src/main/webapp/Build/Deployment instead of the default src/main/webapp.

Thanks

Hello, to get started, you can do the following:

//reconfigure the path to your web files
webAppDirName = "build/generatedWebinf"
  //a task that generates the content in your webapp folder
task generatedWebContent(){
 doLast{
  //create your webcontent
   // into the 'webAppDirName'
  }
   }
  // configure war task to depend on the task
 // that generates the content
war.dependsOn generatedWebContent

In general, I suggest to put generated sources in a subfolder of your build directory. This way, you don’t mix up generated sources and ordinary committed sources. furthermore it makes it often easier for your version control system to cleanup your working directory.

regards, René

I tried this :

task jakeDeploy(type:Exec) {

workingDir ‘src/main/webapp’

commandLine ‘jake deploy’ }

war.dependsOn jakeDeploy

and when I try to run it : ./gradlew --stacktrace war I have the following stacktrace : …

at org.gradle.messaging.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:66) Caused by: java.io.IOException: Cannot run program “jake deploy” (in directory “/Users/Vincent/Projects/kairos/src/main/webapp”): error=2, No such file or directory

at org.gradle.process.internal.ExecHandleRunner.run(ExecHandleRunner.java:69)

… 1 more Caused by: java.io.IOException: error=2, No such file or directory

… 2 more

However if I try in a terminal it works : $> cd /Users/Vincent/Projects/kairos/src/main/webapp $> jake deploy

Can you retry with the following task implementation:

task jakeDeploy(type:Exec) {
     workingDir 'src/main/webapp'
     commandLine 'jake'
     args 'deploy'
  }

regards, René

Ok it works except that now even when I run gradlew build jakedeploy is called.