gradle-tomcat-plugin icon indicating copy to clipboard operation
gradle-tomcat-plugin copied to clipboard

customizing WEB-INF and META-INF for exploded WAR with tomcatRun

Open chronodm opened this issue 10 years ago • 3 comments

I'm trying to port a webapp with a heavily customized ant build to gradle, and among other things it requires

  1. that certain resource files be copied/moved to the WEB-INF directory
  2. that certain files from the WEB-INF directory be copied to the META-INF directory, with filtering

With the war plugin, I'm able to do something along the lines of:

war {
  webInf {
    from fileTree('src/main/java').files
    include "${mypattern}"
  }
  metaInf {
    from("src/main/webapp/WEB-INF")
    include "${otherpattern}"
    filter { ... }
  }
}

For the tomcatRun task, I can more or less duplicate this behavior by creating copy tasks that put the resources into src/main/webapp/WEB-INF/ and the filtered file into src/main/webapp/META-INF -- but note the src. Basically I have to pollute my source tree to get this to work.

Is there any way to add files at runtime to the exploded WAR's WEB-INF and META-INF without putting them in the source directory?

chronodm avatar Jun 03 '14 23:06 chronodm

Alternatively, is there a way to point the embedded Tomcat at an exploded WAR explicitly produced e.g. by the task below?

task explodedWar(type: Copy) {
  into "${buildDir}/exploded/${war.archiveName}"
  with war
}

chronodm avatar Jun 04 '14 00:06 chronodm

At the moment you cannot set arbitrary directories to the runtime classpath. Please see #41 for more information. Would love to see a contribution.

You should be able to create your own task of type TomcatRun and point to a webapp directory. You will find some information to do so in the FAQ or generally the Gradle user guide.

bmuschko avatar Jun 06 '14 02:06 bmuschko

+1 on this

tommyschnabel avatar Feb 05 '15 18:02 tommyschnabel

Closing as issue got no traction.

bmuschko avatar Sep 24 '23 02:09 bmuschko