On 26/11/2010, at 4:12 AM, richardm wrote:
>
> Why don't the includes/exludes in WAR files work when using these list
> formats:
>
> exclude '**/FileViewerControllerServlet.class, **/StreamingContent.class,
> **/iPlanet/**'
You need to put each pattern in a separate string. Above, you've combined all 3
patterns in a single string, which doesn't work - Gradle will treat this as a
single pattern.
Here's an example:
exclude '**/Something.class', '**/AnotherThing.class'
Note that each pattern is in its own string.
>
> OR
>
> excludes ['**/FileViewerControllerServlet.class',
> '**/StreamingContent.class', '**/iPlanet/**']
exclude() takes a collection as well:
def someExcludes = ['**/Something.class', '**/OtherThing.class']
war1 {
exclude someExcludes
}
war2 {
exclude someExcludes
}
Note that the example uses the singular 'exclude', not the plural 'excludes'.
This is a common pattern in Gradle. The singular form is a method which adds
things to a collection - in this case exclude() adds exclude patterns. The
plural form is a property containing the set of things - in this case
'excludes' is a property containing the set of exclude patterns. So, you can do
things like:
// add exclude patterns
exclude 'somePattern'
exclude 'otherPattern', 'moreExcludes'
exclude someCollectionOfStrings
// set the excludes directly using the property
excludes = ['pattern1', 'pattern2']
// use the excludes property from another war
exclude otherWar.excludes
You can see how this looks in the API documentation at
http://gradle.org/0.9-rc-3/docs/javadoc/org/gradle/api/tasks/util/PatternFilterable.html
--
Adam Murdoch
Gradle Developer
http://www.gradle.org
CTO, Gradle Inc. - Gradle Training, Support, Consulting
http://www.gradle.biz