Java 类org.gradle.api.specs.Spec 实例源码

项目:Reer    文件:NativeCompiler.java   
protected List<String> maybeGetPCHArgs(final T spec, File sourceFile) {
    if (spec.getPreCompiledHeader() == null) {
        return Lists.newArrayList();
    }

    final IncludeDirectives includes = spec.getSourceFileIncludeDirectives().get(sourceFile);
    final String header = spec.getPreCompiledHeader();

    List<Include> headers = includes.getIncludesAndImports();
    boolean usePCH = !headers.isEmpty() && header.equals(headers.get(0).getValue());

    if (usePCH) {
        return getPCHArgs(spec);
    } else {
        boolean containsHeader = CollectionUtils.any(headers, new Spec<Include>() {
            @Override
            public boolean isSatisfiedBy(Include include) {
                return include.getValue().equals(header);
            }
        });
        if (containsHeader) {
            logger.log(LogLevel.WARN, getCantUsePCHMessage(spec.getPreCompiledHeader(), sourceFile));
        }
        return Lists.newArrayList();
    }
}
项目:Reer    文件:AvailableJavaHomes.java   
public List<JvmInstallation> findJvms() {
    List<JvmInstallation> jvms = new ArrayList<JvmInstallation>();
    if (OperatingSystem.current().isLinux()) {
        jvms = addJvm(jvms, JavaVersion.VERSION_1_5, "1.5.0", new File("/opt/jdk/sun-jdk-5"), true, JvmInstallation.Arch.i386);
        jvms = addJvm(jvms, JavaVersion.VERSION_1_6, "1.6.0", new File("/opt/jdk/sun-jdk-6"), true, JvmInstallation.Arch.x86_64);
        jvms = addJvm(jvms, JavaVersion.VERSION_1_6, "1.6.0", new File("/opt/jdk/ibm-jdk-6"), true, JvmInstallation.Arch.x86_64);
        jvms = addJvm(jvms, JavaVersion.VERSION_1_7, "1.7.0", new File("/opt/jdk/oracle-jdk-7"), true, JvmInstallation.Arch.x86_64);
        jvms = addJvm(jvms, JavaVersion.VERSION_1_8, "1.8.0", new File("/opt/jdk/oracle-jdk-8"), true, JvmInstallation.Arch.x86_64);
        jvms = addJvm(jvms, JavaVersion.VERSION_1_9, "1.9.0", new File("/opt/jdk/oracle-jdk-9"), true, JvmInstallation.Arch.x86_64);
    }
    return CollectionUtils.filter(jvms, new Spec<JvmInstallation>() {
        public boolean isSatisfiedBy(JvmInstallation element) {
            return element.getJavaHome().isDirectory();
        }
    });
}
项目:Reer    文件:GarbageCollectionMonitor.java   
private static GarbageCollectorMonitoringStrategy determineGcStrategy() {
    JVMStrategy jvmStrategy = JVMStrategy.current();

    final List<String> garbageCollectors = CollectionUtils.collect(ManagementFactory.getGarbageCollectorMXBeans(), new Transformer<String, GarbageCollectorMXBean>() {
        @Override
        public String transform(GarbageCollectorMXBean garbageCollectorMXBean) {
            return garbageCollectorMXBean.getName();
        }
    });
    GarbageCollectorMonitoringStrategy gcStrategy = CollectionUtils.findFirst(jvmStrategy.getGcStrategies(), new Spec<GarbageCollectorMonitoringStrategy>() {
        @Override
        public boolean isSatisfiedBy(GarbageCollectorMonitoringStrategy strategy) {
            return garbageCollectors.contains(strategy.getGarbageCollectorName());
        }
    });

    if (gcStrategy == null) {
        LOGGER.info("Unable to determine a garbage collection monitoring strategy for " + jvmStrategy.toString());
        return GarbageCollectorMonitoringStrategy.UNKNOWN;
    } else {
        return gcStrategy;
    }
}
项目:Reer    文件:DaemonMemoryStatus.java   
private boolean exceedsThreshold(String pool, GarbageCollectionStats gcStats, Spec<GarbageCollectionStats> spec) {
    if (isEnabled()
        && strategy != GarbageCollectorMonitoringStrategy.UNKNOWN
        && spec.isSatisfiedBy(gcStats)) {

        if (gcStats.getUsage() > 0) {
            LOGGER.debug(String.format("GC rate: %.2f/s %s usage: %s%%", gcStats.getRate(), pool, gcStats.getUsage()));
        } else {
            LOGGER.debug("GC rate: 0.0/s");
        }

        return true;
    }

    return false;
}
项目:Reer    文件:CompatibleDaemonExpirationStrategy.java   
@Override
public DaemonExpirationResult checkExpiration() {
    Spec<DaemonInfo> spec = new Spec<DaemonInfo>() {
        @Override
        public boolean isSatisfiedBy(DaemonInfo daemonInfo) {
            return compatibilitySpec.isSatisfiedBy(daemonInfo.getContext());
        }
    };
    Collection<DaemonInfo> compatibleIdleDaemons = CollectionUtils.filter(daemon.getDaemonRegistry().getIdle(), spec);

    if (compatibleIdleDaemons.size() > 1) {
        return new DaemonExpirationResult(DaemonExpirationStatus.GRACEFUL_EXPIRE, EXPIRATION_REASON);
    } else {
        return DaemonExpirationResult.NOT_TRIGGERED;
    }
}
项目:Reer    文件:PersistentCachingPluginResolutionServiceClient.java   
public Response<ClientStatus> queryClientStatus(final String portalUrl, final boolean shouldValidate, final String checksum) {
    ClientStatusKey key = new ClientStatusKey(portalUrl);
    Factory<Response<ClientStatus>> factory = new Factory<Response<ClientStatus>>() {
        public Response<ClientStatus> create() {
            return delegate.queryClientStatus(portalUrl, shouldValidate, checksum);
        }
    };

    if (shouldValidate) {
        return fetch(CLIENT_STATUS_OP_NAME, clientStatusCache, key, factory);
    } else {
        return maybeFetch(CLIENT_STATUS_OP_NAME, clientStatusCache, key, factory, new Spec<Response<ClientStatus>>() {
            public boolean isSatisfiedBy(Response<ClientStatus> element) {
                return !element.getClientStatusChecksum().equals(checksum);
            }
        });
    }
}
项目:Reer    文件:BuildScriptTransformer.java   
public BuildScriptTransformer(ScriptSource scriptSource, ScriptTarget scriptTarget) {
    final List<String> blocksToIgnore = Arrays.asList(scriptTarget.getClasspathBlockName(), InitialPassStatementTransformer.PLUGINS, InitialPassStatementTransformer.PLUGIN_REPOS);
    this.filter = new Spec<Statement>() {
        @Override
        public boolean isSatisfiedBy(Statement statement) {
            return AstUtils.detectScriptBlock(statement, blocksToIgnore) != null;
        }
    };
    this.scriptSource = scriptSource;
}
项目:Reer    文件:DefaultPlatformResolvers.java   
private <T extends Platform> T resolveFromContainer(Class<T> type, PlatformRequirement platformRequirement) {
    final String target = platformRequirement.getPlatformName();

    NamedDomainObjectSet<T> allWithType = platforms.withType(type);
    T matching = CollectionUtils.findFirst(allWithType, new Spec<T>() {
        public boolean isSatisfiedBy(T element) {
            return element.getName().equals(target);
        }
    });

    if (matching == null) {
        throw new InvalidUserDataException(String.format("Invalid %s: %s", type.getSimpleName(), target));
    }
    return matching;
}
项目:Reer    文件:DomainObjectCollectionBackedModelMap.java   
@Override
public void named(final String name, Action<? super T> configAction) {
    collection.matching(new Spec<T>() {
        @Override
        public boolean isSatisfiedBy(T element) {
            return get(name) == element;
        }
    }).all(configAction);
}
项目:Reer    文件:FactoryBasedStructNodeInitializerExtractionStrategy.java   
private String formatKnownTypes(Spec<ModelType<?>> constraints, Set<? extends ModelType<?>> supportedTypes) {
    StringBuilder builder = new StringBuilder();
    for (ModelType<?> supportedType : supportedTypes) {
        if (constraints.isSatisfiedBy(supportedType)) {
            if (builder.length() > 0) {
                builder.append(", ");
            }
            builder.append(supportedType);
        }
    }
    if (builder.length() == 0) {
        return "(none)";
    }
    return builder.toString();
}
项目:Reer    文件:EclipseModelBuilder.java   
private DefaultEclipseProject findEclipseProjectByName(final String eclipseProjectName) {
    return CollectionUtils.findFirst(eclipseProjects, new Spec<DefaultEclipseProject>() {
        @Override
        public boolean isSatisfiedBy(DefaultEclipseProject element) {
            return element.getName().equals(eclipseProjectName);
        }
    });
}
项目:Reer    文件:SingleIncludePatternFileTree.java   
public SingleIncludePatternFileTree(File baseDir, String includePattern, Spec<FileTreeElement> excludeSpec) {
    this.baseDir = baseDir;
    if (includePattern.endsWith("/") || includePattern.endsWith("\\")) {
        includePattern += "**";
    }
    this.includePattern = includePattern;
    this.patternSegments = Arrays.asList(includePattern.split("[/\\\\]"));
    this.excludeSpec = excludeSpec;
}
项目:Reer    文件:AbstractTask.java   
public void setOnlyIf(final Spec<? super Task> spec) {
    taskMutator.mutate("Task.setOnlyIf(Spec)", new Runnable() {
        public void run() {
            onlyIfSpec = createNewOnlyIfSpec().and(spec);
        }
    });
}
项目:Reer    文件:EclipseModelBuilder.java   
private DefaultEclipseProject findEclipseProject(final Project project) {
    return CollectionUtils.findFirst(eclipseProjects, new Spec<DefaultEclipseProject>() {
        @Override
        public boolean isSatisfiedBy(DefaultEclipseProject element) {
            return element.getGradleProject().getPath().equals(project.getPath());
        }
    });
}
项目:Reer    文件:NativeBinaryResolveResult.java   
public List<NativeBinaryRequirementResolveResult> getPendingResolutions() {
    return CollectionUtils.filter(resolutions, new Spec<NativeBinaryRequirementResolveResult>() {
        public boolean isSatisfiedBy(NativeBinaryRequirementResolveResult element) {
            return !element.isComplete();
        }
    });
}
项目:Reer    文件:PatternSpecFactory.java   
protected Spec<FileTreeElement> createSpec(Collection<String> patterns, boolean include, boolean caseSensitive) {
    if (patterns.isEmpty()) {
        return include ? Specs.<FileTreeElement>satisfyAll() : Specs.<FileTreeElement>satisfyNone();
    }

    List<Spec<RelativePath>> matchers = new ArrayList<Spec<RelativePath>>(patterns.size());
    for (String pattern : patterns) {
        Spec<RelativePath> patternMatcher = PatternMatcherFactory.getPatternMatcher(include, caseSensitive, pattern);
        matchers.add(patternMatcher);
    }

    return new RelativePathSpec(Specs.union(matchers));
}
项目:Reer    文件:CollectionUtils.java   
public static <T> T findFirst(Iterable<? extends T> source, Spec<? super T> filter) {
    for (T item : source) {
        if (filter.isSatisfiedBy(item)) {
            return item;
        }
    }

    return null;
}
项目:Reer    文件:CollectionUtils.java   
public static <T> T findFirst(T[] source, Spec<? super T> filter) {
    for (T thing : source) {
        if (filter.isSatisfiedBy(thing)) {
            return thing;
        }
    }

    return null;
}
项目:Reer    文件:CachingPatternSpecFactory.java   
@Override
protected Spec<FileTreeElement> createSpec(final Collection<String> patterns, final boolean include, final boolean caseSensitive) {
    final SpecKey key = new SpecKey(ImmutableList.copyOf(patterns), include, caseSensitive);
    try {
        return Cast.uncheckedCast(specInstanceCache.get(key, new Callable<Spec<FileTreeElement>>() {
            @Override
            public Spec<FileTreeElement> call() throws Exception {
                Spec<FileTreeElement> spec = CachingPatternSpecFactory.super.createSpec(patterns, include, caseSensitive);
                return new CachingSpec(key, spec);
            }
        }));
    } catch (ExecutionException e) {
        throw UncheckedException.throwAsUncheckedException(e);
    }
}
项目:Reer    文件:AvailableJavaHomes.java   
/**
 * Returns a JDK for each of the given java versions, if available.
 */
public static List<Jvm> getJdks(JavaVersion... versions) {
    final Set<JavaVersion> remaining = Sets.newHashSet(versions);
    return getAvailableJdks(new Spec<JvmInstallation>() {
        @Override
        public boolean isSatisfiedBy(JvmInstallation element) {
            return remaining.remove(element.getJavaVersion());
        }
    });
}
项目:Reer    文件:AvailableJavaHomes.java   
/**
 * Returns all JDKs for the given java version.
 */
public static List<Jvm> getAvailableJdks(final JavaVersion version) {
    return getAvailableJdks(new Spec<JvmInstallation>() {
        @Override
        public boolean isSatisfiedBy(JvmInstallation element) {
            return version.equals(element.getJavaVersion());
        }
    });
}
项目:Reer    文件:DefaultTaskOutputs.java   
@Override
public void upToDateWhen(final Spec<? super Task> spec) {
    taskMutator.mutate("TaskOutputs.upToDateWhen(Spec)", new Runnable() {
        public void run() {
            upToDateSpec = upToDateSpec.and(spec);
        }
    });
}
项目:Reer    文件:DefaultCopySpec.java   
public List<Spec<FileTreeElement>> getAllExcludeSpecs() {
    List<Spec<FileTreeElement>> result = new ArrayList<Spec<FileTreeElement>>();
    if (parentResolver != null) {
        result.addAll(parentResolver.getAllExcludeSpecs());
    }
    result.addAll(patternSet.getExcludeSpecs());
    return result;
}
项目:Reer    文件:DaemonStopEvents.java   
public static List<DaemonStopEvent> oldStopEvents(final List<DaemonStopEvent> stopEvents) {
    return CollectionUtils.filter(stopEvents, new Spec<DaemonStopEvent>() {
        @Override
        public boolean isSatisfiedBy(DaemonStopEvent event) {
            return !event.occurredInLastHours(RECENTLY);
        }
    });
}
项目:Reer    文件:WorkerProcessClassPathProvider.java   
public void execute(PersistentCache cache) {
    try {
        File jarFile = jarFile(cache);
        LOGGER.debug("Generating worker process classes to {}.", jarFile);

        // TODO - calculate this list of classes dynamically
        List<Class<?>> classes = Arrays.asList(
                GradleWorkerMain.class,
                BootstrapSecurityManager.class,
                EncodedStream.EncodedInput.class,
                ClassLoaderUtils.class,
                FilteringClassLoader.class,
                FilteringClassLoader.Spec.class,
                ClassLoaderHierarchy.class,
                ClassLoaderVisitor.class,
                ClassLoaderSpec.class,
                SystemClassLoaderSpec.class,
                JavaReflectionUtil.class,
                JavaMethod.class,
                GradleException.class,
                NoSuchPropertyException.class,
                NoSuchMethodException.class,
                UncheckedException.class,
                PropertyAccessor.class,
                PropertyMutator.class,
                Factory.class,
                Spec.class);
        ZipOutputStream outputStream = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(jarFile)));
        try {
            for (Class<?> classToMap : classes) {
                remapClass(classToMap, outputStream);
            }
        } finally {
            outputStream.close();
        }
    } catch (Exception e) {
        throw new GradleException("Could not generate worker process bootstrap classes.", e);
    }
}
项目:Reer    文件:JacocoAgentJar.java   
/**
 * Unzips the resolved {@code org.jacoco.agent.jar} to retrieve the {@code jacocoagent.jar}.
 *
 * @return a file pointing to the {@code jacocoagent.jar}
 */
public File getJar() {
    if (agentJar == null) {
        agentJar = project.zipTree(getAgentConfConventionValue().getSingleFile()).filter(new Spec<File>() {
            @Override
            public boolean isSatisfiedBy(File file) {
                return file.getName().equals("jacocoagent.jar");
            }
        }).getSingleFile();
    }
    return agentJar;
}
项目:Reer    文件:DefaultProjectRegistry.java   
public Set<T> findAll(Spec<? super T> constraint) {
    Set<T> matches = new HashSet<T>();
    for (T project : projects.values()) {
        if (constraint.isSatisfiedBy(project)) {
            matches.add(project);
        }
    }
    return matches;
}
项目:Reer    文件:BuildEnvironmentReportTask.java   
public BuildEnvironmentReportTask() {
    getOutputs().upToDateWhen(new Spec<Task>() {
        public boolean isSatisfiedBy(Task element) {
            return false;
        }
    });
}
项目:Reer    文件:ScalaBasePlugin.java   
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);
        }

    });
}
项目:Reer    文件:CacheLockingArtifactDependencyResolver.java   
@Override
public void resolve(final ResolveContext resolveContext, final List<? extends ResolutionAwareRepository> repositories, final GlobalDependencyResolutionRules metadataHandler, final Spec<? super DependencyMetadata> edgeFilter, final DependencyGraphVisitor graphVisitor, final DependencyArtifactsVisitor artifactsVisitor, final AttributesSchema attributesSchema) {
    lockingManager.useCache("resolve " + resolveContext, new Runnable() {
        public void run() {
            resolver.resolve(resolveContext, repositories, metadataHandler, edgeFilter, graphVisitor, artifactsVisitor, attributesSchema);
        }
    });
}
项目:Reer    文件:DefaultLenientConfiguration.java   
private Set<DependencyGraphNodeResult> getFirstLevelNodes(Spec<? super Dependency> dependencySpec) {
    Set<DependencyGraphNodeResult> matches = new LinkedHashSet<DependencyGraphNodeResult>();
    TransientConfigurationResults graphResults = loadTransientGraphResults(selectedArtifacts);
    for (Map.Entry<ModuleDependency, DependencyGraphNodeResult> entry : graphResults.getFirstLevelDependencies().entrySet()) {
        if (dependencySpec.isSatisfiedBy(entry.getKey())) {
            matches.add(entry.getValue());
        }
    }
    return matches;
}
项目:Reer    文件:ExcludedTaskFilteringBuildConfigurationAction.java   
public void configure(BuildExecutionContext context) {
    GradleInternal gradle = context.getGradle();
    Set<String> excludedTaskNames = gradle.getStartParameter().getExcludedTaskNames();
    if (!excludedTaskNames.isEmpty()) {
        final Set<Spec<Task>> filters = new HashSet<Spec<Task>>();
        for (String taskName : excludedTaskNames) {
            filters.add(taskSelector.getFilter(taskName));
        }
        gradle.getTaskGraph().useFilter(Specs.intersect(filters));
    }

    context.proceed();
}
项目:Reer    文件:BuildComparisonResult.java   
public boolean isBuildsAreIdentical() {
    //noinspection SimplifiableIfStatement
    if (!getUncomparedSourceOutcomes().isEmpty() || !getUncomparedTargetOutcomes().isEmpty()) {
        return false;
    } else {
        return CollectionUtils.every(comparisons, new Spec<BuildOutcomeComparisonResult<?>>() {
            public boolean isSatisfiedBy(BuildOutcomeComparisonResult<?> comparisonResult) {
                return comparisonResult.isOutcomesAreIdentical();
            }
        });
    }
}
项目:Reer    文件:ErrorHandlingConfigurationResolver.java   
@Override
public Set<ResolvedDependency> getFirstLevelModuleDependencies(Spec<? super Dependency> dependencySpec) {
    try {
        return lenientConfiguration.getFirstLevelModuleDependencies(dependencySpec);
    } catch (Throwable e) {
        throw wrapException(e, resolveContext);
    }
}
项目:Reer    文件:ErrorHandlingConfigurationResolver.java   
@Override
public Set<File> getFiles(Spec<? super Dependency> dependencySpec) {
    try {
        return lenientConfiguration.getFiles(dependencySpec);
    } catch (Throwable e) {
        throw wrapException(e, resolveContext);
    }
}
项目:Reer    文件:PlayTwirlPlugin.java   
private static boolean hasTwirlSourceSetsWithJavaImports(PlayApplicationSpec playApplicationSpec) {
    return CollectionUtils.any(playApplicationSpec.getSources().withType(TwirlSourceSet.class).values(), new Spec<TwirlSourceSet>() {
        @Override
        public boolean isSatisfiedBy(TwirlSourceSet twirlSourceSet) {
            return twirlSourceSet.getDefaultImports() == TwirlImports.JAVA;
        }
    });
}
项目:Reer    文件:DefaultArtifactDependencyResolver.java   
@Override
public void resolve(ResolveContext resolveContext, List<? extends ResolutionAwareRepository> repositories, GlobalDependencyResolutionRules metadataHandler, Spec<? super DependencyMetadata> edgeFilter, DependencyGraphVisitor graphVisitor, DependencyArtifactsVisitor artifactsVisitor, AttributesSchema attributesSchema) {
    LOGGER.debug("Resolving {}", resolveContext);
    ComponentResolvers resolvers = createResolvers(resolveContext, repositories, metadataHandler);
    DependencyGraphBuilder builder = createDependencyGraphBuilder(resolvers, resolveContext.getResolutionStrategy(), metadataHandler, edgeFilter, attributesSchema);

    ArtifactResolver artifactResolver = new ErrorHandlingArtifactResolver(new CacheLockingArtifactResolver(cacheLockingManager, resolvers.getArtifactResolver()));
    DependencyGraphVisitor artifactsGraphVisitor = new ResolvedArtifactsGraphVisitor(artifactsVisitor, artifactResolver);

    // Resolve the dependency graph
    builder.resolve(resolveContext, new CompositeDependencyGraphVisitor(graphVisitor, artifactsGraphVisitor));
}
项目:Reer    文件:DependencyGraphBuilder.java   
public DependencyGraphBuilder(DependencyToComponentIdResolver componentIdResolver, ComponentMetaDataResolver componentMetaDataResolver,
                              ResolveContextToComponentResolver resolveContextToComponentResolver,
                              ConflictHandler conflictHandler, Spec<? super DependencyMetadata> edgeFilter, AttributesSchema attributesSchema) {
    this.idResolver = componentIdResolver;
    this.metaDataResolver = componentMetaDataResolver;
    this.moduleResolver = resolveContextToComponentResolver;
    this.conflictHandler = conflictHandler;
    this.edgeFilter = edgeFilter;
    this.attributesSchema = attributesSchema;
}
项目:Reer    文件:DependencyResultSpecNotationConverter.java   
public static NotationParser<Object, Spec<DependencyResult>> parser() {
    return NotationParserBuilder
            .toType(new TypeInfo<Spec<DependencyResult>>(Spec.class))
            .invalidNotationMessage("Please check the input for the DependencyInsight.dependency element.")
            .fromType(Closure.class, new ClosureToSpecNotationConverter<DependencyResult>(DependencyResult.class))
            .fromCharSequence(new DependencyResultSpecNotationConverter())
            .toComposite();
}
项目:Reer    文件:DefaultConfiguration.java   
private ConfigurationFileCollection(final Set<Dependency> dependencies) {
    this(new Spec<Dependency>() {
        public boolean isSatisfiedBy(Dependency element) {
            return dependencies.contains(element);
        }
    });
}