# Gradle war copytask not executing

**URL:** <https://discuss.gradle.org/t/gradle-war-copytask-not-executing/24250>\
**Category:** Help/Discuss\
**Created:** [September 28, 2017, 8:16pm UTC](https://discuss.gradle.org/t/gradle-war-copytask-not-executing/24250 "2017-09-28T20:16:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![karthik](https://avatars.discourse-cdn.com/v4/letter/k/9fc348/32.png) [@karthik](https://discuss.gradle.org/u/karthik)\
**Post date:** [September 28, 2017, 8:16pm UTC](https://discuss.gradle.org/t/gradle-war-copytask-not-executing/24250/1 "2017-09-28T20:16:14Z")

</div>

![](https://global.discourse-cdn.com/gradle/original/2X/5/534a393e60a38c36d09923db5c8a9b8a92897e15.png)

\*\*I need \*\*\ ***.properties to be copied to the properties DIR and exclude Environment DIR based on the params passed from Jenkins. Below is the build.gradle file and it’s not copying the properties file.**

war {  
println (‘here is my variable …’ + System.getProperty(‘Env’))  
println (check: ‘properties/Environment/’ + System.getenv(‘Env’) + ‘/’)  
task Copy(type: Copy){  
from(‘properties/Environment/’ + System.getProperty(‘Env’) + ‘/’)  
include(’\*.properties’)  
into(‘properties’)   
}  
exclude “properties/Environment”  
manifest {  
from ‘WebContent/META-INF/MANIFEST.MF’  
}  
}

---

<div class="post-metadata">

**Author:** ![jjustinic](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/jjustinic/32/9005_2.png) [@jjustinic](https://discuss.gradle.org/u/jjustinic)\
**Post date:** [September 29, 2017, 8:22pm UTC](https://discuss.gradle.org/t/gradle-war-copytask-not-executing/24250/2 "2017-09-29T20:22:54Z")

</div>

There is no such thing as a war copy task. The code shown creates a new `Copy` task named `Copy` that would copy files between folders, not into the war. The `war` and `Copy` task are two different, unrelated tasks in the project. Even though you can’t create a task on the war task, this syntax doesn’t cause an error because it automatically delegates to the project and creates another task.

Your overall project structure isn’t clear, but you definitely have some inconsistencies on whether or not you’re including `WebContent` in your paths. You likely want to configure a `CopySpec` in the `war` task, and not a `Copy` task at all.

Although there are multiple ways to express this, using your provided code, file structure, and ignoring the other folders in `WebContent` that you don’t mention or show code to include, your `war` task configuration could look something like this:

```groovy
war {
    into('properties') {
        from('WebContent/properties') { exclude 'Environment' }
        from('WebContent/properties/Environment/' + System.getProperty('Env'))
    }

    manifest {
        from 'WebContent/META-INF/MANIFEST.MF'
    }
}

```
