use of org.gradle.api.specs.Spec in project gradle by gradle.
the class PCHCompileTaskConfig method configureCompileTask.
@Override
protected void configureCompileTask(AbstractNativeCompileTask task, final NativeBinarySpecInternal binary, final LanguageSourceSetInternal languageSourceSet) {
// Note that the sourceSet is the sourceSet this pre-compiled header will be used with - it's not an
// input sourceSet to the compile task.
final DependentSourceSetInternal sourceSet = (DependentSourceSetInternal) languageSourceSet;
task.setDescription("Compiles a pre-compiled header for the " + sourceSet + " of " + binary);
// Add the source of the source set to the include paths to resolve any headers that may be in source directories
task.includes(sourceSet.getSource().getSourceDirectories());
final Project project = task.getProject();
task.source(sourceSet.getPrefixHeaderFile());
task.getObjectFileDir().set(new File(binary.getNamingScheme().getOutputDirectory(project.getBuildDir(), "objs"), languageSourceSet.getProjectScopedName() + "PCH"));
task.dependsOn(project.getTasks().withType(PrefixHeaderFileGenerateTask.class).matching(new Spec<PrefixHeaderFileGenerateTask>() {
@Override
public boolean isSatisfiedBy(PrefixHeaderFileGenerateTask prefixHeaderFileGenerateTask) {
return prefixHeaderFileGenerateTask.getPrefixHeaderFile().equals(sourceSet.getPrefixHeaderFile());
}
}));
// This is so that VisualCpp has the object file of the generated source file available at link time
binary.binaryInputs(task.getOutputs().getFiles().getAsFileTree().matching(new PatternSet().include("**/*.obj", "**/*.o")));
PreCompiledHeader pch = binary.getPrefixFileToPCH().get(sourceSet.getPrefixHeaderFile());
pch.setPchObjects(task.getOutputs().getFiles().getAsFileTree().matching(new PatternSet().include("**/*.pch", "**/*.gch")));
pch.builtBy(task);
}
use of org.gradle.api.specs.Spec in project gradle by gradle.
the class DefaultMethodRuleDefinition method reference.
private ModelReference<?> reference(List<Annotation> annotations, int i) {
Path pathAnnotation = (Path) findFirst(annotations, new Spec<Annotation>() {
@Override
public boolean isSatisfiedBy(Annotation element) {
return element.annotationType().equals(Path.class);
}
});
ModelPath path = pathAnnotation == null ? null : ModelPath.path(pathAnnotation.value());
ModelType<?> cast = method.getGenericParameterTypes().get(i);
return ModelReference.of(path, cast, PARAMETER_DESC[i]);
}
use of org.gradle.api.specs.Spec in project gradle by gradle.
the class AvailableToolChains method findSwiftcs.
static List<ToolChainCandidate> findSwiftcs() {
List<ToolChainCandidate> toolChains = Lists.newArrayList();
SwiftcMetadataProvider versionDeterminer = new SwiftcMetadataProvider(TestFiles.execActionFactory());
// On Linux, we assume swift is installed into /opt/swift
File rootSwiftInstall = new File("/opt/swift");
File[] swiftCandidates = GUtil.getOrDefault(rootSwiftInstall.listFiles(swiftInstall -> swiftInstall.isDirectory() && !swiftInstall.getName().equals("latest")), () -> new File[0]);
for (File swiftInstall : swiftCandidates) {
File swiftc = new File(swiftInstall, "/usr/bin/swiftc");
SearchResult<SwiftcMetadata> version = versionDeterminer.getCompilerMetaData(Collections.emptyList(), spec -> spec.executable(swiftc));
if (version.isAvailable()) {
File binDir = swiftc.getParentFile();
toolChains.add(new InstalledSwiftc(binDir, version.getComponent().getVersion()).inPath(binDir, new File("/usr/bin")));
}
}
// On macOS, we assume co-located Xcode is installed into /opt/xcode and default location at /Applications/Xcode.app
toolChains.addAll(findXcodes().stream().map(InstalledXcode::getSwiftc).filter(Optional::isPresent).map(Optional::get).collect(Collectors.toList()));
List<File> swiftcCandidates = OperatingSystem.current().findAllInPath("swiftc");
for (File candidate : swiftcCandidates) {
SearchResult<SwiftcMetadata> version = versionDeterminer.getCompilerMetaData(Collections.emptyList(), spec -> spec.executable(candidate));
if (version.isAvailable()) {
File binDir = candidate.getParentFile();
InstalledSwiftc swiftc = new InstalledSwiftc(binDir, version.getComponent().getVersion());
swiftc.inPath(binDir, new File("/usr/bin"));
toolChains.add(swiftc);
}
}
if (toolChains.isEmpty()) {
toolChains.add(new UnavailableToolChain(ToolFamily.SWIFTC));
} else {
toolChains.sort(LATEST_RELEASED_FIRST);
}
return toolChains;
}
use of org.gradle.api.specs.Spec in project gradle by gradle.
the class DefaultCopySpec method filesNotMatching.
public CopySpec filesNotMatching(Iterable<String> patterns, Action<? super FileCopyDetails> action) {
if (!patterns.iterator().hasNext()) {
throw new InvalidUserDataException("must provide at least one pattern to not match");
}
List<Spec> matchers = new ArrayList<Spec>();
for (String pattern : patterns) {
matchers.add(PatternMatcherFactory.getPatternMatcher(true, isCaseSensitive(), pattern));
}
Spec unionMatcher = Specs.union(matchers.toArray(new Spec[matchers.size()]));
return eachFile(new MatchingCopyAction(Specs.<RelativePath>negate(unionMatcher), action));
}
use of org.gradle.api.specs.Spec in project gradle by gradle.
the class DefaultDomainObjectCollectionTest method filteredCollectionExecutesClosureWhenMatchingObjectAdded.
@Test
public void filteredCollectionExecutesClosureWhenMatchingObjectAdded() {
final TestClosure closure = context.mock(TestClosure.class);
context.checking(new Expectations() {
{
oneOf(closure).call("a");
}
});
Spec<CharSequence> spec = new Spec<CharSequence>() {
public boolean isSatisfiedBy(CharSequence element) {
return !element.equals("b");
}
};
container.matching(spec).whenObjectAdded(TestUtil.toClosure(closure));
container.add("a");
container.add("b");
}
Aggregations