Java Code Examples for org.gradle.api.DomainObjectSet

The following examples show how to use org.gradle.api.DomainObjectSet. These examples are extracted from open source projects. 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 Project: pushfish-android   Author: PushFish   File: DefaultBinaryTasksCollection.java    License: 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 #2
Source Project: pushfish-android   Author: PushFish   File: ChainedLibraryBinaryLocator.java    License: 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 #3
Source Project: Pushjet-Android   Author: Pushjet   File: ProjectLibraryBinaryLocator.java    License: 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 #4
Source Project: pushfish-android   Author: PushFish   File: PrebuiltLibraryBinaryLocator.java    License: 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 Project: pushfish-android   Author: PushFish   File: ChainedLibraryBinaryLocator.java    License: 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 #6
Source Project: pushfish-android   Author: PushFish   File: ProjectLibraryBinaryLocator.java    License: 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 #7
Source Project: Pushjet-Android   Author: Pushjet   File: PrebuiltLibraryBinaryLocator.java    License: 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 #8
Source Project: pushfish-android   Author: PushFish   File: PrebuiltLibraryBinaryLocator.java    License: 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 #9
Source Project: gradle-android-publisher   Author: bluesliverx   File: AndroidPublishTask.java    License: 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 #10
Source Project: gradle-plugins   Author: rmee   File: AssembleNeededPlugin.java    License: 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 #11
Source Project: AndServer   Author: yanzhenjie   File: AndServerPlugin.java    License: 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 #12
Source Project: Pushjet-Android   Author: Pushjet   File: DefaultBinaryTasksCollection.java    License: 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 Project: Pushjet-Android   Author: Pushjet   File: ChainedLibraryBinaryLocator.java    License: 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 #14
Source Project: Pushjet-Android   Author: Pushjet   File: ProjectLibraryBinaryLocator.java    License: 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 #15
Source Project: Pushjet-Android   Author: Pushjet   File: DefaultNativeBinaryTasks.java    License: 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 Project: Pushjet-Android   Author: Pushjet   File: PrebuiltLibraryBinaryLocator.java    License: 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 Project: pushfish-android   Author: PushFish   File: DefaultJarBinarySpec.java    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DomainObjectSet<LanguageSourceSet> getSource() {
    return sourceSets;
}
 
Example #18
Source Project: Pushjet-Android   Author: Pushjet   File: DelegatingDomainObjectSet.java    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DelegatingDomainObjectSet(DomainObjectSet<T> backingSet) {
    this.backingSet = backingSet;
}
 
Example #19
Source Project: pushfish-android   Author: PushFish   File: DefaultJvmLibrarySpec.java    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DomainObjectSet<BinarySpec> getBinaries() {
    return binaries;
}
 
Example #20
Source Project: pushfish-android   Author: PushFish   File: BaseBinarySpec.java    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DomainObjectSet<LanguageSourceSet> getSource() {
    return sourceSets;
}
 
Example #21
Source Project: Pushjet-Android   Author: Pushjet   File: DefaultDomainObjectSet.java    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public DomainObjectSet<T> matching(Spec<? super T> spec) {
    return filtered(createFilter(spec));
}
 
Example #22
Source Project: pushfish-android   Author: PushFish   File: BaseComponentSpec.java    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DomainObjectSet<BinarySpec> getBinaries() {
    return binaries;
}
 
Example #23
Source Project: Pushjet-Android   Author: Pushjet   File: DefaultDomainObjectSet.java    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public DomainObjectSet<T> matching(Spec<? super T> spec) {
    return filtered(createFilter(spec));
}
 
Example #24
Source Project: pushfish-android   Author: PushFish   File: AbstractNativeComponentSpec.java    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DomainObjectSet<LanguageSourceSet> getSource() {
    return sourceSets;
}
 
Example #25
Source Project: Pushjet-Android   Author: Pushjet   File: DefaultPublishArtifactSet.java    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DefaultPublishArtifactSet(String displayName, DomainObjectSet<PublishArtifact> backingSet) {
    super(backingSet);
    this.displayName = displayName;
}
 
Example #26
Source Project: pushfish-android   Author: PushFish   File: AbstractNativeComponentSpec.java    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DomainObjectSet<NativeBinarySpec> getNativeBinaries() {
    return nativeBinaries;
}
 
Example #27
Source Project: pushfish-android   Author: PushFish   File: DefaultLibraryResolver.java    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
public NativeLibraryBinary resolveLibrary(DomainObjectSet<NativeLibraryBinary> allBinaries) {
    Class<? extends NativeLibraryBinary> type = getTypeForLinkage(requirement.getLinkage());
    DomainObjectSet<? extends NativeLibraryBinary> candidateBinaries = allBinaries.withType(type);
    return resolve(candidateBinaries);
}
 
Example #28
Source Project: pushfish-android   Author: PushFish   File: AbstractNativeBinarySpec.java    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DomainObjectSet<LanguageSourceSet> getSource() {
    return sourceSets;
}
 
Example #29
Source Project: pushfish-android   Author: PushFish   File: DefaultPrebuiltLibrary.java    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DomainObjectSet<NativeLibraryBinary> getBinaries() {
    return binaries;
}
 
Example #30
Source Project: Pushjet-Android   Author: Pushjet   File: DefaultDependencySet.java    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DefaultDependencySet(String displayName, DomainObjectSet<Dependency> backingSet) {
    super(backingSet);
    this.displayName = displayName;
}