org.gradle.api.DomainObjectSet Java Examples

The following examples show how to use org.gradle.api.DomainObjectSet. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PrebuiltLibraryBinaryLocator.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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();
}
 
Example #2
Source File: AssembleNeededPlugin.java    From gradle-plugins with Apache License 2.0 5 votes vote down vote up
@Override
public void apply(Project project) {
	project.getPlugins().apply("base");

	Task assembleNeeded = project.getTasks().create("assembleNeeded");
	assembleNeeded.dependsOn("assemble");
	project.afterEvaluate(project1 -> {
		DomainObjectSet<ProjectDependency> projectDependencies = project1.getConfigurations().getByName("runtime").getAllDependencies().withType(ProjectDependency.class);
		for (ProjectDependency neededProjectDependency : projectDependencies) {
			assembleNeeded.dependsOn(neededProjectDependency.getDependencyProject().getPath() + ":assembleNeeded");
		}
	});
}
 
Example #3
Source File: AndServerPlugin.java    From AndServer with Apache License 2.0 5 votes vote down vote up
private void configGenerator(Project project, DomainObjectSet<? extends BaseVariant> variants) {
    variants.all(it -> {
        File outputDir = new File(project.getBuildDir(), "generated/source/andServer/" + it.getDirName());
        String taskName = String.format("generate%sAppInfo", capitalize(it.getName()));
        Task generate = project.getTasks().create(taskName, AppInfoGenerator.class, generator -> {
            generator.setOutputDir(outputDir);
            String appId = it.getApplicationId();
            generator.setAppId(appId);
            String packageName = String.format("%s.andserver.plugin.generator", appId);
            generator.setPackageName(packageName);
        });
        it.registerJavaGeneratingTask(generate, outputDir);
    });
}
 
Example #4
Source File: PrebuiltLibraryBinaryLocator.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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();
}
 
Example #5
Source File: ProjectLibraryBinaryLocator.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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();
}
 
Example #6
Source File: ChainedLibraryBinaryLocator.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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);
}
 
Example #7
Source File: DefaultBinaryTasksCollection.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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();
}
 
Example #8
Source File: ChainedLibraryBinaryLocator.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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);
}
 
Example #9
Source File: ProjectLibraryBinaryLocator.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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();
}
 
Example #10
Source File: PrebuiltLibraryBinaryLocator.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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();
}
 
Example #11
Source File: ChainedLibraryBinaryLocator.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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);
}
 
Example #12
Source File: DefaultBinaryTasksCollection.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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();
}
 
Example #13
Source File: ProjectLibraryBinaryLocator.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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;
}
 
Example #14
Source File: AndroidPublishTask.java    From gradle-android-publisher with Apache License 2.0 5 votes vote down vote up
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));
}
 
Example #15
Source File: DefaultNativeBinaryTasks.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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();
}
 
Example #16
Source File: PrebuiltLibraryBinaryLocator.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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();
}
 
Example #17
Source File: AbstractNativeComponentSpec.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DomainObjectSet<NativeBinarySpec> getNativeBinaries() {
    return nativeBinaries;
}
 
Example #18
Source File: DelegatingDomainObjectSet.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DomainObjectSet<T> matching(Spec<? super T> spec) {
    return backingSet.matching(spec);
}
 
Example #19
Source File: AbstractNativeComponentSpec.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DomainObjectSet<BinarySpec> getBinaries() {
    return binaries;
}
 
Example #20
Source File: DefaultLibraryResolver.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public LibraryBinaryInternal resolveLibrary(DomainObjectSet<NativeBinary> allBinaries) {
    Class<? extends LibraryBinary> type = getTypeForLinkage(requirement.getLinkage());
    DomainObjectSet<? extends LibraryBinary> candidateBinaries = allBinaries.withType(type);
    return resolve(candidateBinaries);
}
 
Example #21
Source File: DefaultDependencySet.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DefaultDependencySet(String displayName, DomainObjectSet<Dependency> backingSet) {
    super(backingSet);
    this.displayName = displayName;
}
 
Example #22
Source File: DefaultDomainObjectSet.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public DomainObjectSet<T> matching(Closure spec) {
    return matching(Specs.<T>convertClosureToSpec(spec));
}
 
Example #23
Source File: DefaultJvmLibrarySpec.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DomainObjectSet<LanguageSourceSet> getSource() {
    return sourceSets;
}
 
Example #24
Source File: DelegatingDomainObjectSet.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DelegatingDomainObjectSet(DomainObjectSet<T> backingSet) {
    this.backingSet = backingSet;
}
 
Example #25
Source File: DefaultDomainObjectSet.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public <S extends T> DomainObjectSet<S> withType(Class<S> type) {
    return filtered(createFilter(type));
}
 
Example #26
Source File: DelegatingDomainObjectSet.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public <S extends T> DomainObjectSet<S> withType(Class<S> type) {
    return backingSet.withType(type);
}
 
Example #27
Source File: DelegatingDomainObjectSet.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DomainObjectSet<T> matching(Spec<? super T> spec) {
    return backingSet.matching(spec);
}
 
Example #28
Source File: DelegatingDomainObjectSet.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DomainObjectSet<T> matching(Closure spec) {
    return backingSet.matching(spec);
}
 
Example #29
Source File: DelegatingDomainObjectSet.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public <S extends T> DomainObjectSet<S> withType(Class<S> type) {
    return backingSet.withType(type);
}
 
Example #30
Source File: DelegatingDomainObjectSet.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DomainObjectSet<T> matching(Closure spec) {
    return backingSet.matching(spec);
}