Improved utility spec
@@ -4,6 +4,10 @@ import org.gradle.api.Task;
import org.gradle.api.specs.Spec;
import java.io.File;
+import java.util.HashSet;
+import java.util.Set;
+
+import static edu.emory.mathcs.backport.java.util.Arrays.asList;
/**
* Helper methods for Gradle Spec objects
@@ -11,13 +15,14 @@ import java.io.File;
public class Specs {
/**
- * Spec satisfied by task that matches provided name
+ * Task that matches any of the provided names
*/
- public static Spec<Task> withName(final String name) {
+ public static Spec<Task> withName(final String ... names) {
+ Set<String> namesSet = new HashSet<>(asList(names));
return new Spec<Task>() {
@Override
public boolean isSatisfiedBy(Task t) {
- return t.getName().equals(name);
+ return namesSet.contains(t.getName());
}
};
}
