Gradle .war another web.xml

It’s possible to copy another web.xml to my WEB-INF directory when i run gradle war?

I have to web.xml one for developnment and another to production and when i run gradle war i need to copy the web.xml from dir myApp\files\web.xml to my WEB-INF dir in .war file

tks

Someone might be able to tell you how to do this, but in general, this is a bad idea. As much as possible, you should deploy the same artifact to all of your environments. Obviously, there are details that are different in each environment, and you handle that with properties files stored outside of the deployable artifact,but in the classpath of the runtime container.

David,
But every time i need to deploy my add (gradle war) i need to open my Web.xml and change my environment from Develop to Production :confused:

tks

No. Not if you do this correctly. There are numerous techniques involved with this.

For instance, you could configure the “java” command in each environment to specify a “env” system property on the command line, with values like “dev”, “test”, and “production”.

Your web container startup can have additional directories in the classpath, from which you can load specifically named properties files, or you can do something like load “${env}-conf.properties”.

If you’re running a JEE or JEE-like container, you could specify JNDI references in your web.xml that are set in your container environment configuration.

you can do something like this in your build file:

war {
    into("WEB-INF") {
        from("myApp/files/web.xml")
    }
}