use of org.gradle.api.internal.project.ProjectInternal in project gradle by gradle.
the class JacocoPlugin method apply.
@Override
public void apply(Project project) {
project.getPluginManager().apply(ReportingBasePlugin.class);
this.project = project;
addJacocoConfigurations();
ProjectInternal projectInternal = (ProjectInternal) project;
JacocoAgentJar agent = instantiator.newInstance(JacocoAgentJar.class, projectInternal.getServices().get(FileOperations.class));
JacocoPluginExtension extension = project.getExtensions().create(PLUGIN_EXTENSION_NAME, JacocoPluginExtension.class, project, agent);
extension.setToolVersion(DEFAULT_JACOCO_VERSION);
final ReportingExtension reportingExtension = (ReportingExtension) project.getExtensions().getByName(ReportingExtension.NAME);
extension.getReportsDirectory().convention(project.getLayout().dir(project.provider(() -> reportingExtension.file("jacoco"))));
configureAgentDependencies(agent, extension);
configureTaskClasspathDefaults(extension);
applyToDefaultTasks(extension);
configureDefaultOutputPathForJacocoMerge();
configureJacocoReportsDefaults(extension);
addDefaultReportAndCoverageVerificationTasks(extension);
configureCoverageDataElementsVariants(project);
}
use of org.gradle.api.internal.project.ProjectInternal in project gradle by gradle.
the class SwiftBasePlugin method apply.
@Override
public void apply(final Project project) {
project.getPluginManager().apply(NativeBasePlugin.class);
project.getPluginManager().apply(SwiftCompilerPlugin.class);
final TaskContainer tasks = project.getTasks();
final DirectoryProperty buildDirectory = project.getLayout().getBuildDirectory();
project.getDependencies().getAttributesSchema().attribute(Usage.USAGE_ATTRIBUTE).getCompatibilityRules().add(SwiftCppUsageCompatibilityRule.class);
project.getComponents().withType(DefaultSwiftBinary.class, binary -> {
final Names names = binary.getNames();
TaskProvider<SwiftCompile> compile = tasks.register(names.getCompileTaskName("swift"), SwiftCompile.class, task -> {
task.getModules().from(binary.getCompileModules());
task.getSource().from(binary.getSwiftSource());
task.getDebuggable().set(binary.isDebuggable());
task.getOptimized().set(binary.isOptimized());
if (binary.isTestable()) {
task.getCompilerArgs().add("-enable-testing");
}
if (binary.getTargetMachine().getOperatingSystemFamily().isMacOs()) {
task.getCompilerArgs().add("-sdk");
task.getCompilerArgs().add(locator.find().getAbsolutePath());
}
task.getModuleName().set(binary.getModule());
task.getObjectFileDir().set(buildDirectory.dir("obj/" + names.getDirName()));
task.getModuleFile().set(buildDirectory.file(binary.getModule().map(moduleName -> "modules/" + names.getDirName() + moduleName + ".swiftmodule")));
task.getSourceCompatibility().set(binary.getTargetPlatform().getSourceCompatibility());
task.getTargetPlatform().set(binary.getNativePlatform());
// TODO - make this lazy
task.getToolChain().set(binary.getToolChain());
if (binary instanceof SwiftSharedLibrary || binary instanceof SwiftStaticLibrary) {
task.getCompilerArgs().add("-parse-as-library");
}
});
binary.getModuleFile().set(compile.flatMap(task -> task.getModuleFile()));
binary.getCompileTask().set(compile);
binary.getObjectsDir().set(compile.flatMap(task -> task.getObjectFileDir()));
});
project.getComponents().withType(ProductionSwiftComponent.class, component -> {
project.afterEvaluate(p -> {
DefaultNativeComponent componentInternal = (DefaultNativeComponent) component;
publicationRegistry.registerPublication((ProjectInternal) project, new NativeProjectPublication(componentInternal.getDisplayName(), new SwiftPmTarget(component.getModule().get())));
});
});
}
use of org.gradle.api.internal.project.ProjectInternal in project gradle by gradle.
the class LifecycleBasePlugin method addClean.
private void addClean(final ProjectInternal project) {
Provider<Directory> buildDir = project.getLayout().getBuildDirectory();
// Register at least the project buildDir as a directory to be deleted.
final BuildOutputCleanupRegistry buildOutputCleanupRegistry = project.getServices().get(BuildOutputCleanupRegistry.class);
buildOutputCleanupRegistry.registerOutputs(buildDir);
final Provider<Delete> clean = project.getTasks().register(CLEAN_TASK_NAME, Delete.class, cleanTask -> {
cleanTask.setDescription("Deletes the build directory.");
cleanTask.setGroup(BUILD_GROUP);
cleanTask.delete(buildDir);
});
buildOutputCleanupRegistry.registerOutputs(clean.map(cl -> cl.getTargetFiles()));
}
use of org.gradle.api.internal.project.ProjectInternal in project gradle by gradle.
the class LifecycleBasePlugin method apply.
@Override
public void apply(final Project project) {
final ProjectInternal projectInternal = (ProjectInternal) project;
addClean(projectInternal);
addCleanRule(project);
addAssemble(project);
addCheck(project);
addBuild(project);
}
use of org.gradle.api.internal.project.ProjectInternal in project gradle by gradle.
the class NativeDependentBinariesResolutionStrategy method buildState.
private State buildState() {
State state = new State();
List<ProjectInternal> orderedProjects = Ordering.usingToString().sortedCopy(projectRegistry.getAllProjects());
for (ProjectInternal project : orderedProjects) {
if (project.getPlugins().hasPlugin(ComponentModelBasePlugin.class)) {
ModelRegistry modelRegistry = projectModelResolver.resolveProjectModel(project.getPath());
ModelMap<NativeComponentSpec> components = modelRegistry.realize("components", ModelTypes.modelMap(NativeComponentSpec.class));
for (NativeBinarySpecInternal binary : allBinariesOf(components.withType(VariantComponentSpec.class))) {
state.registerBinary(binary);
}
ModelMap<Object> testSuites = modelRegistry.find("testSuites", ModelTypes.modelMap(Object.class));
if (testSuites != null) {
for (NativeBinarySpecInternal binary : allBinariesOf(testSuites.withType(NativeComponentSpec.class).withType(VariantComponentSpec.class))) {
state.registerBinary(binary);
}
}
}
}
for (NativeBinarySpecInternal nativeBinary : state.dependencies.keySet()) {
for (NativeLibraryBinary libraryBinary : nativeBinary.getDependentBinaries()) {
// Skip prebuilt libraries
if (libraryBinary instanceof NativeBinarySpecInternal) {
// Unfortunate cast! see LibraryBinaryLocator
state.dependencies.get(nativeBinary).add((NativeBinarySpecInternal) libraryBinary);
}
}
if (testSupport != null) {
state.dependencies.get(nativeBinary).addAll(testSupport.getTestDependencies(nativeBinary));
}
}
return state;
}
Aggregations