Search in sources :

Example 36 with ProjectInternal

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);
}
Also used : ReportingExtension(org.gradle.api.reporting.ReportingExtension) ProjectInternal(org.gradle.api.internal.project.ProjectInternal) FileOperations(org.gradle.api.internal.file.FileOperations) JacocoAgentJar(org.gradle.internal.jacoco.JacocoAgentJar)

Example 37 with ProjectInternal

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())));
        });
    });
}
Also used : Names(org.gradle.language.nativeplatform.internal.Names) DefaultNativeComponent(org.gradle.language.nativeplatform.internal.DefaultNativeComponent) ProjectPublicationRegistry(org.gradle.api.internal.artifacts.ivyservice.projectmodule.ProjectPublicationRegistry) Project(org.gradle.api.Project) ProductionSwiftComponent(org.gradle.language.swift.ProductionSwiftComponent) SwiftCompile(org.gradle.language.swift.tasks.SwiftCompile) NativeBasePlugin(org.gradle.language.plugins.NativeBasePlugin) SwiftCompilerPlugin(org.gradle.nativeplatform.toolchain.plugins.SwiftCompilerPlugin) Inject(javax.inject.Inject) DefaultSwiftBinary(org.gradle.language.swift.internal.DefaultSwiftBinary) SwiftSharedLibrary(org.gradle.language.swift.SwiftSharedLibrary) SwiftStaticLibrary(org.gradle.language.swift.SwiftStaticLibrary) TaskContainer(org.gradle.api.tasks.TaskContainer) AttributeCompatibilityRule(org.gradle.api.attributes.AttributeCompatibilityRule) TaskProvider(org.gradle.api.tasks.TaskProvider) DirectoryProperty(org.gradle.api.file.DirectoryProperty) ProjectInternal(org.gradle.api.internal.project.ProjectInternal) CompatibilityCheckDetails(org.gradle.api.attributes.CompatibilityCheckDetails) NativeProjectPublication(org.gradle.swiftpm.internal.NativeProjectPublication) Names(org.gradle.language.nativeplatform.internal.Names) MacOSSdkPathLocator(org.gradle.nativeplatform.toolchain.internal.xcode.MacOSSdkPathLocator) Plugin(org.gradle.api.Plugin) SwiftPmTarget(org.gradle.swiftpm.internal.SwiftPmTarget) Usage(org.gradle.api.attributes.Usage) TaskContainer(org.gradle.api.tasks.TaskContainer) DirectoryProperty(org.gradle.api.file.DirectoryProperty) SwiftCompile(org.gradle.language.swift.tasks.SwiftCompile) SwiftSharedLibrary(org.gradle.language.swift.SwiftSharedLibrary) DefaultNativeComponent(org.gradle.language.nativeplatform.internal.DefaultNativeComponent) NativeProjectPublication(org.gradle.swiftpm.internal.NativeProjectPublication) SwiftStaticLibrary(org.gradle.language.swift.SwiftStaticLibrary) SwiftPmTarget(org.gradle.swiftpm.internal.SwiftPmTarget)

Example 38 with ProjectInternal

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()));
}
Also used : Delete(org.gradle.api.tasks.Delete) BuildOutputCleanupRegistry(org.gradle.internal.execution.BuildOutputCleanupRegistry) Provider(org.gradle.api.provider.Provider) Delete(org.gradle.api.tasks.Delete) CleanRule(org.gradle.language.base.internal.plugins.CleanRule) Project(org.gradle.api.Project) ProjectInternal(org.gradle.api.internal.project.ProjectInternal) Directory(org.gradle.api.file.Directory) Plugin(org.gradle.api.Plugin) BuildOutputCleanupRegistry(org.gradle.internal.execution.BuildOutputCleanupRegistry) Directory(org.gradle.api.file.Directory)

Example 39 with ProjectInternal

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);
}
Also used : ProjectInternal(org.gradle.api.internal.project.ProjectInternal)

Example 40 with ProjectInternal

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;
}
Also used : NativeLibraryBinary(org.gradle.nativeplatform.NativeLibraryBinary) ModelRegistry(org.gradle.model.internal.registry.ModelRegistry) VariantComponentSpec(org.gradle.platform.base.VariantComponentSpec) NativeComponentSpec(org.gradle.nativeplatform.NativeComponentSpec) ProjectInternal(org.gradle.api.internal.project.ProjectInternal)

Aggregations

ProjectInternal (org.gradle.api.internal.project.ProjectInternal)58 File (java.io.File)13 Project (org.gradle.api.Project)11 Task (org.gradle.api.Task)6 ServiceRegistry (org.gradle.internal.service.ServiceRegistry)6 Inject (javax.inject.Inject)5 Plugin (org.gradle.api.Plugin)5 ProjectStateRegistry (org.gradle.api.internal.project.ProjectStateRegistry)5 Map (java.util.Map)4 Configuration (org.gradle.api.artifacts.Configuration)4 FileResolver (org.gradle.api.internal.file.FileResolver)4 Lists (com.google.common.collect.Lists)3 ArrayList (java.util.ArrayList)3 Collections (java.util.Collections)3 HashSet (java.util.HashSet)3 List (java.util.List)3 Set (java.util.Set)3 Callable (java.util.concurrent.Callable)3 Collectors (java.util.stream.Collectors)3 FileCollectionFactory (org.gradle.api.internal.file.FileCollectionFactory)3