Gradle process resources and include in war

413 Views Asked by At

I am trying to use Gradle to build my APIMan plugin, it builds a war and should process resources in src/main/apiman and include those resources in META-INF/apiman in the built war.

I'm having some trouble getting the build.gradle right. This is what I have

processResources {
  from("${project.rootDir}/src/main/apiman") {
    include('**/*.json')
  }
  filter ReplaceTokens, tokens: [
    "project.version": '1.5.2-SNAPSHOT',
    "project.groupId": 'io.apiman.plugins',
    "project.artifactId": 'apiman-plugins',
    "project.packaging": 'war' 
  ]
}

war {
  from("${project.rootDir}/src/main") {
      include('apiman')
      into('META-INF')
  }
}
1

There are 1 best solutions below

2
PDStat On BEST ANSWER

For anyone interested, the following worked for me

war {
  with copySpec {
    from("src/main/apiman") {
      include('**/*')
      into('META-INF/apiman')
    }
    filter(ReplaceTokens, tokens: [
      "project.version": '1.5.2-SNAPSHOT',
      "project.groupId": 'io.apiman.plugins',
      "project.artifactId": 'apiman-plugins',
      "project.packaging": 'war' 
    ])
  }
}