Property duplicatesStrategy in Task 'Jar don't work~~~


(Zhaoyun Liu) #1

I has a JarTask as:

task merge_a_b(type: Jar){

classifier = ‘a_b’

duplicatesStrategy = ‘exclude’

from zipTree(‘a.jar’)

from zipTree(‘b.jar’)

}

since a.jar and b.jar has same file as ‘com/xxx/common/util.class’ , the default jar task will copy two files (util.class) into my new jar file. As I read the gradle DSL Reference , I found jar has a property duplicatesStrategy which can be used to exclude duplicated files.

quote: http://www.gradle.org/docs/current/dsl/org.gradle.api.tasks.bundling.Jar.html#org.gradle.api.tasks.bundling.Jar

DuplicatesStrategy duplicatesStrategy The strategy to use when trying to copy more than one file to the same destination. The value can be set with a case insensitive string of the enum value (e.g. ‘exclude’ for DuplicatesStrategy.EXCLUDE). This strategy can be overridden for individual files by using CopySpec.eachFile() or CopySpec.filesMatching().

but when the property is set, gradle will warning me that "Deprecated dynamic property: “duplicatesStrategy” on “task '” which means the property does not exits!

my gradle version is 1.6.


(Peter Niederwieser) #2

If you go to the DSL reference for Gradle 1.6 (replace ‘current’ with ‘1.6’ in the URL), you’ll see that 1.6 doesn’t have such a property. It was only introduced in 1.7.


(Zhaoyun Liu) #3

That’s right. Thax for your reply