File isn't located in war file


#1

I’m using this task in order to add twho single files in my war file:

task createDemoWar(type: War, dependsOn: classes) {
    archiveName "webapi-demo-${versioning.info.display}.war"
    destinationDir = file("$buildDir/dist")
    from('scopes') {
        include 'demo.persistence.xml'
        rename('demo.persistence.xml', 'persistence.xml')
        into('src/main/resources/META-INF/')
    }
    from('scopes') {
        include 'configuration.demo.properties'
        rename('configuration.demo.properties', 'scope.properties')
        into('src/main/resources/')
    }
}

After having executed the task, the war doesn’t contain anyone of both ones.

Any ideas?


(Janito Vaqueiro Ferreira Filho) #2

Quick question: are you sure you want those files in the src/main/resources path inside the war file? I may be mistaken, but I think what is usually done is something like this:

task createDemoWar(type: War, dependsOn: classes) {
    archiveName "webapi-demo-${versioning.info.display}.war"
    destinationDir = file("$buildDir/dist")
    from('scopes') {
        include 'demo.persistence.xml'
        rename('demo.persistence.xml', 'persistence.xml')
        into('META-INF/')
    }
    from('scopes') {
        include 'configuration.demo.properties'
        rename('configuration.demo.properties', 'scope.properties')
    }
}