Java 类org.gradle.api.DomainObjectSet 实例源码

项目:Reer    文件:ProjectLibraryBinaryLocator.java   
@Nullable
@Override
public DomainObjectSet<NativeLibraryBinary> getBinaries(LibraryIdentifier libraryIdentifier) {
    ModelRegistry projectModel = projectModelResolver.resolveProjectModel(libraryIdentifier.getProjectPath());
    ComponentSpecContainer components = projectModel.find("components", ComponentSpecContainer.class);
    if (components == null) {
        return null;
    }
    String libraryName = libraryIdentifier.getLibraryName();
    NativeLibrarySpec library = components.withType(NativeLibrarySpec.class).get(libraryName);
    if (library == null) {
        return null;
    }
    ModelMap<NativeBinarySpec> projectBinaries = library.getBinaries().withType(NativeBinarySpec.class);
    DomainObjectSet<NativeLibraryBinary> binaries = new DefaultDomainObjectSet<NativeLibraryBinary>(NativeLibraryBinary.class);
    for (NativeBinarySpec nativeBinarySpec : projectBinaries.values()) {
        binaries.add((NativeLibraryBinary) nativeBinarySpec);
    }
    return binaries;
}
项目:nw-gradle    文件:DependenciesUtil.java   
/**
 * Helper to get project dependent, optionally recursively.
 */
private static Set<Project> getProjectTypeDependencies(final Project project, boolean recursive) {
  //System.out.println("--------getProjectDependencies--------");
  Set<Project> result = new HashSet<Project>();
  //Set<ProjectDependency> set = new HashSet<ProjectDependency>();
  DomainObjectSet<ProjectDependency> directProjectTypeDependent = getDirectProjectTypeDependencies(project);
  //System.out.println("--directDependentProjects.size(): " + directDependentProjects.size());
  for (ProjectDependency projectTypeDependency : directProjectTypeDependent) {
    Project dependentProject = projectTypeDependency.getDependencyProject();
    //System.out.println("------project: " + dependentProject);
    if (dependentProject!=null) {
      result.add(dependentProject);
      if (recursive) {
        result.addAll(getProjectTypeDependencies(dependentProject, recursive));
      }
    }
  }
  return result;
}
项目:Reer    文件:DefaultBinaryTasksCollection.java   
public <T extends Task> T findSingleTaskWithType(Class<T> type) {
    DomainObjectSet<T> tasks = withType(type);
    if (tasks.size() == 0) {
        return null;
    }
    if (tasks.size() > 1) {
        throw new UnknownDomainObjectException(String.format("Multiple tasks with type '%s' found.", type.getSimpleName()));
    }
    return tasks.iterator().next();
}
项目:Reer    文件:DefaultLibraryResolver.java   
public NativeLibraryBinary resolveLibraryBinary() {
    DomainObjectSet<NativeLibraryBinary> binaries = libraryBinaryLocator.getBinaries(new LibraryIdentifier(requirement.getProjectPath(), requirement.getLibraryName()));
    if (binaries == null) {
        throw new LibraryResolveException(getFailureMessage(requirement));
    }
    return new LibraryResolution()
        .withFlavor(context.getFlavor())
        .withPlatform(context.getTargetPlatform())
        .withBuildType(context.getBuildType())
        .resolveLibrary(binaries);
}
项目:Reer    文件:ChainedLibraryBinaryLocator.java   
@Nullable
@Override
public DomainObjectSet<NativeLibraryBinary> getBinaries(LibraryIdentifier library) {
    for (LibraryBinaryLocator locator : locators) {
        DomainObjectSet<NativeLibraryBinary> binaries = locator.getBinaries(library);
        if (binaries != null) {
            return binaries;
        }
    }
    return null;
}
项目:Reer    文件:CachingLibraryBinaryLocator.java   
@Nullable
@Override
public DomainObjectSet<NativeLibraryBinary> getBinaries(LibraryIdentifier library) {
    DomainObjectSet<NativeLibraryBinary> libraryBinaries = libraries.get(library);
    if (libraryBinaries == null) {
        libraryBinaries = delegate.getBinaries(library);
        if (libraryBinaries == null) {
            libraryBinaries = NULL_RESULT;
        }
        libraries.put(library, libraryBinaries);
    }
    return libraryBinaries == NULL_RESULT ? null : libraryBinaries;
}
项目:Reer    文件:PrebuiltLibraryBinaryLocator.java   
@Nullable
@Override
public DomainObjectSet<NativeLibraryBinary> getBinaries(LibraryIdentifier library) {
    ModelRegistry projectModel = projectModelResolver.resolveProjectModel(library.getProjectPath());
    Repositories repositories = projectModel.find("repositories", Repositories.class);
    if (repositories == null) {
        return null;
    }
    PrebuiltLibrary prebuiltLibrary = getPrebuiltLibrary(repositories.withType(PrebuiltLibraries.class), library.getLibraryName());
    return prebuiltLibrary != null ? prebuiltLibrary.getBinaries() : null;
}
项目:Reer    文件:DefaultPluginManager.java   
public AppliedPlugin findPlugin(final String id) {
    DomainObjectSet<PluginWithId> pluginWithIds = pluginsForId(id);
    if (!pluginWithIds.isEmpty()) {
        return pluginWithIds.iterator().next().asAppliedPlugin();
    }
    return null;
}
项目:Reer    文件:Sign.java   
/**
 * Returns the single signature generated by this task.
 *
 * @return The signature.
 * @throws IllegalStateException if there is not exactly one signature.
 */
@Internal
public Signature getSingleSignature() {
    final DomainObjectSet<Signature> signatureSet = getSignatures();
    if (signatureSet.size() == 0) {
        throw new IllegalStateException("Expected %s to contain exactly one signature, however, it contains no signatures.");
    } else if (signatureSet.size() == 1) {
        return signatureSet.iterator().next();
    } else {
        throw new IllegalStateException("Expected %s to contain exactly one signature, however, it contains no " + String.valueOf(signatureSet.size()) + " signatures.");
    }

}
项目:android-gradle-plugins    文件:VariantBasedCodeQualityPlugin.java   
private void configureForVariants(DomainObjectSet<? extends BaseVariant> variants) {
    variants.all(sourceSet -> {
        Task task = project.getTasks().create(getTaskName(sourceSet, getTaskBaseName(), null), getCastedTaskType());
        task.setGroup(JavaBasePlugin.VERIFICATION_GROUP);
        configureForVariant(sourceSet, (T)task);
    });
}
项目:Pushjet-Android    文件:DefaultBinaryTasksCollection.java   
protected <T extends Task> T findSingleTaskWithType(Class<T> type) {
    DomainObjectSet<T> tasks = withType(type);
    if (tasks.size() == 0) {
        return null;
    }
    if (tasks.size() > 1) {
        throw new UnknownDomainObjectException(String.format("Multiple tasks with type '%s' found.", type.getSimpleName()));
    }
    return tasks.iterator().next();
}
项目:Pushjet-Android    文件:DefaultConfiguration.java   
private DefaultConfiguration createCopy(Set<Dependency> dependencies, boolean recursive) {
    DetachedConfigurationsProvider configurationsProvider = new DetachedConfigurationsProvider();
    DefaultConfiguration copiedConfiguration = new DefaultConfiguration(path + "Copy", name + "Copy",
            configurationsProvider, resolver, listenerManager, metaDataProvider, resolutionStrategy.copy());
    configurationsProvider.setTheOnlyConfiguration(copiedConfiguration);
    // state, cachedResolvedConfiguration, and extendsFrom intentionally not copied - must re-resolve copy
    // copying extendsFrom could mess up dependencies when copy was re-resolved

    copiedConfiguration.visibility = visibility;
    copiedConfiguration.transitive = transitive;
    copiedConfiguration.description = description;

    copiedConfiguration.getArtifacts().addAll(getAllArtifacts());

    // todo An ExcludeRule is a value object but we don't enforce immutability for DefaultExcludeRule as strong as we
    // should (we expose the Map). We should provide a better API for ExcludeRule (I don't want to use unmodifiable Map).
    // As soon as DefaultExcludeRule is truly immutable, we don't need to create a new instance of DefaultExcludeRule.
    Set<Configuration> excludeRuleSources = new LinkedHashSet<Configuration>();
    excludeRuleSources.add(this);
    if (recursive) {
        excludeRuleSources.addAll(getHierarchy());
    }

    for (Configuration excludeRuleSource : excludeRuleSources) {
        for (ExcludeRule excludeRule : excludeRuleSource.getExcludeRules()) {
            copiedConfiguration.excludeRules.add(new DefaultExcludeRule(excludeRule.getGroup(), excludeRule.getModule()));
        }
    }

    DomainObjectSet<Dependency> copiedDependencies = copiedConfiguration.getDependencies();
    for (Dependency dependency : dependencies) {
        copiedDependencies.add(dependency.copy());
    }
    return copiedConfiguration;
}
项目:Pushjet-Android    文件:ChainedLibraryBinaryLocator.java   
public DomainObjectSet<NativeLibraryBinary> getBinaries(NativeLibraryRequirement requirement) {
    List<Exception> failures = new ArrayList<Exception>();
    for (LibraryBinaryLocator locator : locators) {
        try {
            return locator.getBinaries(requirement);
        } catch (Exception e) {
            failures.add(e);
        }
    }
    throw new LibraryResolveException(getFailureMessage(requirement), failures);
}
项目:Pushjet-Android    文件:ProjectLibraryBinaryLocator.java   
public DomainObjectSet<NativeLibraryBinary> getBinaries(NativeLibraryRequirement requirement) {
    Project project = findProject(requirement);
    ComponentSpecContainer componentSpecContainer = project.getExtensions().findByType(ComponentSpecContainer.class);
    if (componentSpecContainer == null) {
        throw new LibraryResolveException(String.format("Project does not have a libraries container: '%s'", project.getPath()));
    }
    DomainObjectSet<NativeBinarySpec> projectBinaries = componentSpecContainer.withType(NativeLibrarySpec.class).getByName(requirement.getLibraryName()).getNativeBinaries();
    DomainObjectSet<NativeLibraryBinary> binaries = new DefaultDomainObjectSet<NativeLibraryBinary>(NativeLibraryBinary.class);
    // TODO:DAZ Convert, don't cast
    for (NativeBinarySpec nativeBinarySpec : projectBinaries) {
        binaries.add((NativeLibraryBinary) nativeBinarySpec);
    }
    return binaries;
}
项目:Pushjet-Android    文件:PrebuiltLibraryBinaryLocator.java   
public DomainObjectSet<NativeLibraryBinary> getBinaries(NativeLibraryRequirement requirement) {
    ProjectInternal project = projectLocator.locateProject(requirement.getProjectPath());
    NamedDomainObjectSet<PrebuiltLibraries> repositories = project.getModelRegistry().get(ModelPath.path("repositories"), ModelType.of(Repositories.class)).withType(PrebuiltLibraries.class);
    if (repositories.isEmpty()) {
        throw new PrebuiltLibraryResolveException("Project does not have any prebuilt library repositories.");
    }
    PrebuiltLibrary prebuiltLibrary = getPrebuiltLibrary(repositories, requirement.getLibraryName());
    return prebuiltLibrary.getBinaries();
}
项目:Pushjet-Android    文件:ChainedLibraryBinaryLocator.java   
public DomainObjectSet<NativeBinary> getBinaries(NativeLibraryRequirement requirement) {
    List<Exception> failures = new ArrayList<Exception>();
    for (LibraryBinaryLocator locator : locators) {
        try {
            return locator.getBinaries(requirement);
        } catch (Exception e) {
            failures.add(e);
        }
    }
    throw new LibraryResolveException(getFailureMessage(requirement), failures);
}
项目:Pushjet-Android    文件:ProjectLibraryBinaryLocator.java   
public DomainObjectSet<NativeBinary> getBinaries(NativeLibraryRequirement requirement) {
    Project project = findProject(requirement);
    LibraryContainer libraryContainer = (LibraryContainer) project.getExtensions().findByName("libraries");
    if (libraryContainer == null) {
        throw new LibraryResolveException(String.format("Project does not have a libraries container: '%s'", project.getPath()));
    }
    return libraryContainer.getByName(requirement.getLibraryName()).getBinaries();
}
项目:Pushjet-Android    文件:PrebuiltLibraryBinaryLocator.java   
public DomainObjectSet<NativeBinary> getBinaries(NativeLibraryRequirement requirement) {
    ProjectInternal project = projectLocator.locateProject(requirement.getProjectPath());
    NamedDomainObjectSet<PrebuiltLibraries> repositories = project.getModelRegistry().get("repositories", Repositories.class).withType(PrebuiltLibraries.class);
    if (repositories.isEmpty()) {
        throw new PrebuiltLibraryResolveException("Project does not have any prebuilt library repositories.");
    }
    PrebuiltLibrary prebuiltLibrary = getPrebuiltLibrary(repositories, requirement.getLibraryName());
    return prebuiltLibrary.getBinaries();
}
项目:Pushjet-Android    文件:DefaultNativeBinaryTasks.java   
private <T extends Task> T findOnlyWithType(Class<T> type) {
    DomainObjectSet<T> tasks = withType(type);
    if (tasks.size() == 0) {
        return null;
    }
    if (tasks.size() > 1) {
        throw new UnknownDomainObjectException(String.format("Multiple task with type '%s' found", type.getSimpleName()));
    }
    return tasks.iterator().next();
}
项目:gradle-android-publisher    文件:AndroidPublishTask.java   
private File getApkFile(AndroidPublisherExtension publisherExtension) {
    String variantName = publisherExtension.getVariantName();
    DomainObjectSet<ApplicationVariant> variants = getProject().getExtensions().getByType(AppExtension.class).getApplicationVariants();
    ApplicationVariant variant = null;
    getLogger().info(String.format("Looking for %s variant in outputs", variantName));
    for (ApplicationVariant v : variants) {
        getLogger().debug(String.format("Found variant %s", v.getName()));
        if (v.getName().equals(variantName)) {
            getLogger().debug(String.format("Variant %s will be used", variantName));
            variant = v;
            break;
        }
    }
    if (variant == null) {
        throw new InvalidUserDataException(String.format(
                "Cannot find %s variant for android configuration", variantName));
    }

    for(BaseVariantOutput output : variant.getOutputs()) {
        getLogger().debug(String.format("Found output %s (%s)", output.getName(), output.getBaseName()));
        if (output!=null) {
            getLogger().debug(String.format("Output %s will be used", output.getName()));
            return output.getOutputFile();
        }
    }
    throw new InvalidUserDataException(String.format(
            "Cannot find APK output file for %s variant", variantName));
}
项目:Reer    文件:BaseBinarySpec.java   
@Override
public DomainObjectSet<LanguageSourceSet> getInputs() {
    return inputSourceSets;
}
项目:Reer    文件:ExecutableVisualStudioProjectConfiguration.java   
private InstallExecutable getInstallTask() {
    final DomainObjectSet<InstallExecutable> installTasks = getBinary().getTasks().withType(InstallExecutable.class);
    return installTasks.isEmpty() ? null : installTasks.iterator().next();
}
项目:Reer    文件:DefaultConfiguration.java   
private DefaultConfiguration createCopy(Set<Dependency> dependencies, boolean recursive) {
    DetachedConfigurationsProvider configurationsProvider = new DetachedConfigurationsProvider();
    String newName = name + "Copy";
    Path newIdentityPath = identityPath.getParent().child(newName);
    Path newPath = path.getParent().child(newName);
    DefaultConfiguration copiedConfiguration = instantiator.newInstance(DefaultConfiguration.class, newIdentityPath, newPath, newName,
        configurationsProvider, resolver, listenerManager, metaDataProvider, resolutionStrategy.copy(), projectAccessListener, projectFinder, configurationComponentMetaDataBuilder, fileCollectionFactory, componentIdentifierFactory, buildOperationExecutor, instantiator, artifactNotationParser);
    configurationsProvider.setTheOnlyConfiguration(copiedConfiguration);
    // state, cachedResolvedConfiguration, and extendsFrom intentionally not copied - must re-resolve copy
    // copying extendsFrom could mess up dependencies when copy was re-resolved

    copiedConfiguration.visible = visible;
    copiedConfiguration.transitive = transitive;
    copiedConfiguration.description = description;

    copiedConfiguration.defaultDependencyActions.addAll(defaultDependencyActions);

    copiedConfiguration.canBeConsumed = canBeConsumed;
    copiedConfiguration.canBeResolved = canBeResolved;

    copiedConfiguration.getArtifacts().addAll(getAllArtifacts());

    if (hasAttributes()) {
        for (Attribute<?> attribute : configurationAttributes.keySet()) {
            Object value = configurationAttributes.getAttribute(attribute);
            copiedConfiguration.attribute(Cast.<Attribute<Object>>uncheckedCast(attribute), value);
        }
    }

    // todo An ExcludeRule is a value object but we don't enforce immutability for DefaultExcludeRule as strong as we
    // should (we expose the Map). We should provide a better API for ExcludeRule (I don't want to use unmodifiable Map).
    // As soon as DefaultExcludeRule is truly immutable, we don't need to create a new instance of DefaultExcludeRule.
    Set<Configuration> excludeRuleSources = new LinkedHashSet<Configuration>();
    excludeRuleSources.add(this);
    if (recursive) {
        excludeRuleSources.addAll(getHierarchy());
    }

    for (Configuration excludeRuleSource : excludeRuleSources) {
        for (ExcludeRule excludeRule : excludeRuleSource.getExcludeRules()) {
            copiedConfiguration.excludeRules.add(new DefaultExcludeRule(excludeRule.getGroup(), excludeRule.getModule()));
        }
    }

    DomainObjectSet<Dependency> copiedDependencies = copiedConfiguration.getDependencies();
    for (Dependency dependency : dependencies) {
        copiedDependencies.add(dependency.copy());
    }
    return copiedConfiguration;
}
项目:Reer    文件:DefaultLibraryResolver.java   
public NativeLibraryBinary resolveLibrary(DomainObjectSet<NativeLibraryBinary> allBinaries) {
    Class<? extends NativeLibraryBinary> type = getTypeForLinkage(requirement.getLinkage());
    DomainObjectSet<? extends NativeLibraryBinary> candidateBinaries = allBinaries.withType(type);
    return resolve(candidateBinaries);
}
项目:Reer    文件:DefaultPrebuiltLibrary.java   
@Override
public DomainObjectSet<NativeLibraryBinary> getBinaries() {
    return binaries;
}
项目:Reer    文件:DelegatingDomainObjectSet.java   
public DelegatingDomainObjectSet(DomainObjectSet<T> backingSet) {
    this.backingSet = backingSet;
}
项目:Reer    文件:DelegatingDomainObjectSet.java   
public DomainObjectSet<T> matching(Closure spec) {
    return matching(Specs.convertClosureToSpec(spec));
}
项目:Reer    文件:DelegatingDomainObjectSet.java   
public DomainObjectSet<T> matching(Spec<? super T> spec) {
    return backingSet.matching(spec);
}
项目:Reer    文件:DelegatingDomainObjectSet.java   
public <S extends T> DomainObjectSet<S> withType(Class<S> type) {
    return backingSet.withType(type);
}
项目:Reer    文件:DefaultDomainObjectSet.java   
@Override
public <S extends T> DomainObjectSet<S> withType(Class<S> type) {
    return filtered(createFilter(type));
}
项目:Reer    文件:DefaultDomainObjectSet.java   
@Override
public DomainObjectSet<T> matching(Spec<? super T> spec) {
    return filtered(createFilter(spec));
}
项目:Reer    文件:DefaultDomainObjectSet.java   
@Override
public DomainObjectSet<T> matching(Closure spec) {
    return matching(Specs.<T>convertClosureToSpec(spec));
}
项目:Reer    文件:DefaultDependencySet.java   
public DefaultDependencySet(String displayName, Configuration clientConfiguration, DomainObjectSet<Dependency> backingSet) {
    super(backingSet);
    this.displayName = displayName;
    this.clientConfiguration = clientConfiguration;
}
项目:Reer    文件:DefaultPublishArtifactSet.java   
public DefaultPublishArtifactSet(String displayName, DomainObjectSet<PublishArtifact> backingSet, FileCollectionFactory fileCollectionFactory) {
    super(backingSet);
    this.displayName = displayName;
    this.files = fileCollectionFactory.create(builtBy, new ArtifactsFileCollection());
}
项目:Reer    文件:WrapUtil.java   
/**
 * Wraps the given items in a mutable domain object set.
 */
public static <T> DomainObjectSet<T> toDomainObjectSet(Class<T> type, T... items) {
    return new DefaultDomainObjectSet<T>(type, toSet(items));
}
项目:Reer    文件:Sign.java   
/**
 * The signatures generated by this task.
 */
@Internal
public DomainObjectSet<Signature> getSignatures() {
    return signatures;
}
项目:Reer    文件:DefaultClassDirectoryBinarySpec.java   
@Override
public DomainObjectSet<LanguageSourceSet> getInputs() {
    return sourceSets;
}
项目:intellij-ce-playground    文件:TestedExtension.java   
/**
 * Returns the list of (Android) test variants. Since the collections is built after evaluation,
 * it should be used with Gradle's <code>all</code> iterator to process future items.
 */
@Override
@NonNull
public DomainObjectSet<TestVariant> getTestVariants() {
    return testVariantList;
}
项目:intellij-ce-playground    文件:TestedExtension.java   
/**
 * Returns the list of (Android) test variants. Since the collections is built after evaluation,
 * it should be used with Gradle's <code>all</code> iterator to process future items.
 */
@Override
@NonNull
public DomainObjectSet<UnitTestVariant> getUnitTestVariants() {
    return unitTestVariantList;
}
项目:Pushjet-Android    文件:DefaultJarBinarySpec.java   
public DomainObjectSet<LanguageSourceSet> getSource() {
    return sourceSets;
}