use of org.gradle.api.specs.Spec in project gradle by gradle.
the class DefaultNamedDomainObjectSetTest method filteredCollectionExecutesClosureWhenMatchingObjectAdded.
@Test
public void filteredCollectionExecutesClosureWhenMatchingObjectAdded() {
final TestClosure closure = context.mock(TestClosure.class);
final Bean bean = new Bean();
context.checking(new Expectations() {
{
one(closure).call(bean);
}
});
Spec<Bean> spec = new Spec<Bean>() {
public boolean isSatisfiedBy(Bean element) {
return element == bean;
}
};
container.matching(spec).whenObjectAdded(TestUtil.toClosure(closure));
container.add(bean);
container.add(new Bean());
}
use of org.gradle.api.specs.Spec in project gradle by gradle.
the class DefaultNamedDomainObjectSetTest method filteredCollectionExecutesActionWhenMatchingObjectAdded.
@Test
public void filteredCollectionExecutesActionWhenMatchingObjectAdded() {
final Action<Bean> action = context.mock(Action.class);
final Bean bean = new Bean();
context.checking(new Expectations() {
{
one(action).execute(bean);
}
});
Spec<Bean> spec = new Spec<Bean>() {
public boolean isSatisfiedBy(Bean element) {
return element == bean;
}
};
container.matching(spec).whenObjectAdded(action);
container.add(bean);
container.add(new Bean());
}
use of org.gradle.api.specs.Spec in project gradle by gradle.
the class JacocoReport method generate.
@TaskAction
public void generate() {
final Spec<File> fileExistsSpec = new Spec<File>() {
@Override
public boolean isSatisfiedBy(File file) {
return file.exists();
}
};
new AntJacocoReport(getAntBuilder()).execute(getJacocoClasspath(), getProject().getName(), getAllClassDirs().filter(fileExistsSpec), getAllSourceDirs().filter(fileExistsSpec), getExecutionData(), getReports());
}
use of org.gradle.api.specs.Spec in project gradle by gradle.
the class JacocoCoverageVerification method check.
@TaskAction
public void check() {
final Spec<File> fileExistsSpec = new Spec<File>() {
@Override
public boolean isSatisfiedBy(File file) {
return file.exists();
}
};
JacocoCheckResult checkResult = new AntJacocoCheck(getAntBuilder()).execute(getJacocoClasspath(), getProject().getName(), getAllClassDirs().filter(fileExistsSpec), getAllSourceDirs().filter(fileExistsSpec), getExecutionData(), getViolationRules());
if (!checkResult.isSuccess()) {
throw new GradleException(checkResult.getFailureMessage());
}
}
use of org.gradle.api.specs.Spec in project gradle by gradle.
the class ScalaBasePlugin method configureSourceSetDefaults.
private static void configureSourceSetDefaults(final Project project, final SourceDirectorySetFactory sourceDirectorySetFactory) {
final JavaBasePlugin javaPlugin = project.getPlugins().getPlugin(JavaBasePlugin.class);
project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().all(new Action<SourceSet>() {
@Override
public void execute(final SourceSet sourceSet) {
String displayName = (String) InvokerHelper.invokeMethod(sourceSet, "getDisplayName", null);
Convention sourceSetConvention = (Convention) InvokerHelper.getProperty(sourceSet, "convention");
DefaultScalaSourceSet scalaSourceSet = new DefaultScalaSourceSet(displayName, sourceDirectorySetFactory);
sourceSetConvention.getPlugins().put("scala", scalaSourceSet);
final SourceDirectorySet scalaDirectorySet = scalaSourceSet.getScala();
scalaDirectorySet.srcDir(new Callable<File>() {
@Override
public File call() throws Exception {
return project.file("src/" + sourceSet.getName() + "/scala");
}
});
sourceSet.getAllJava().source(scalaDirectorySet);
sourceSet.getAllSource().source(scalaDirectorySet);
sourceSet.getResources().getFilter().exclude(new Spec<FileTreeElement>() {
@Override
public boolean isSatisfiedBy(FileTreeElement element) {
return scalaDirectorySet.contains(element.getFile());
}
});
configureScalaCompile(project, javaPlugin, sourceSet);
}
});
}
Aggregations