@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; }
/** * 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; }
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(); }
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); }
@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; }
@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; }
@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; }
public AppliedPlugin findPlugin(final String id) { DomainObjectSet<PluginWithId> pluginWithIds = pluginsForId(id); if (!pluginWithIds.isEmpty()) { return pluginWithIds.iterator().next().asAppliedPlugin(); } return null; }
/** * 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."); } }
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); }); }
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(); }
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; }
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); }
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; }
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(); }
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); }
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(); }
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(); }
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(); }
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)); }
@Override public DomainObjectSet<LanguageSourceSet> getInputs() { return inputSourceSets; }
private InstallExecutable getInstallTask() { final DomainObjectSet<InstallExecutable> installTasks = getBinary().getTasks().withType(InstallExecutable.class); return installTasks.isEmpty() ? null : installTasks.iterator().next(); }
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; }
public NativeLibraryBinary resolveLibrary(DomainObjectSet<NativeLibraryBinary> allBinaries) { Class<? extends NativeLibraryBinary> type = getTypeForLinkage(requirement.getLinkage()); DomainObjectSet<? extends NativeLibraryBinary> candidateBinaries = allBinaries.withType(type); return resolve(candidateBinaries); }
@Override public DomainObjectSet<NativeLibraryBinary> getBinaries() { return binaries; }
public DelegatingDomainObjectSet(DomainObjectSet<T> backingSet) { this.backingSet = backingSet; }
public DomainObjectSet<T> matching(Closure spec) { return matching(Specs.convertClosureToSpec(spec)); }
public DomainObjectSet<T> matching(Spec<? super T> spec) { return backingSet.matching(spec); }
public <S extends T> DomainObjectSet<S> withType(Class<S> type) { return backingSet.withType(type); }
@Override public <S extends T> DomainObjectSet<S> withType(Class<S> type) { return filtered(createFilter(type)); }
@Override public DomainObjectSet<T> matching(Spec<? super T> spec) { return filtered(createFilter(spec)); }
@Override public DomainObjectSet<T> matching(Closure spec) { return matching(Specs.<T>convertClosureToSpec(spec)); }
public DefaultDependencySet(String displayName, Configuration clientConfiguration, DomainObjectSet<Dependency> backingSet) { super(backingSet); this.displayName = displayName; this.clientConfiguration = clientConfiguration; }
public DefaultPublishArtifactSet(String displayName, DomainObjectSet<PublishArtifact> backingSet, FileCollectionFactory fileCollectionFactory) { super(backingSet); this.displayName = displayName; this.files = fileCollectionFactory.create(builtBy, new ArtifactsFileCollection()); }
/** * 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)); }
/** * The signatures generated by this task. */ @Internal public DomainObjectSet<Signature> getSignatures() { return signatures; }
@Override public DomainObjectSet<LanguageSourceSet> getInputs() { return sourceSets; }
/** * 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; }
/** * 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; }
public DomainObjectSet<LanguageSourceSet> getSource() { return sourceSets; }