Search in sources :

Example 11 with ModelRegistry

use of org.gradle.model.internal.registry.ModelRegistry in project gradle by gradle.

the class DependentComponentsReport method report.

@TaskAction
public void report() {
    // Once we are here, the project lock is held. If we synchronize to avoid cross-project operations, we will have a dead lock.
    getWorkerLeaseService().runAsIsolatedTask(() -> {
        // Cross-project ModelRegistry operations do not happen concurrently.
        synchronized (DependentComponentsReport.class) {
            ((ProjectInternal) getProject()).getOwner().applyToMutableState(project -> {
                ModelRegistry modelRegistry = getModelRegistry();
                DependentBinariesResolver dependentBinariesResolver = modelRegistry.find("dependentBinariesResolver", DependentBinariesResolver.class);
                StyledTextOutput textOutput = getTextOutputFactory().create(DependentComponentsReport.class);
                TextDependentComponentsReportRenderer reportRenderer = new TextDependentComponentsReportRenderer(dependentBinariesResolver, showNonBuildable, showTestSuites);
                reportRenderer.setOutput(textOutput);
                ProjectDetails projectDetails = ProjectDetails.of(project);
                reportRenderer.startProject(projectDetails);
                Set<ComponentSpec> allComponents = getAllComponents(modelRegistry);
                if (showTestSuites) {
                    allComponents.addAll(getAllTestSuites(modelRegistry));
                }
                reportRenderer.renderComponents(getReportedComponents(allComponents));
                reportRenderer.renderLegend();
                reportRenderer.completeProject(projectDetails);
                reportRenderer.complete();
            });
        }
    });
}
Also used : ModelRegistry(org.gradle.model.internal.registry.ModelRegistry) ProjectDetails(org.gradle.api.tasks.diagnostics.internal.ProjectDetails) DependentBinariesResolver(org.gradle.platform.base.internal.dependents.DependentBinariesResolver) TextDependentComponentsReportRenderer(org.gradle.api.reporting.dependents.internal.TextDependentComponentsReportRenderer) StyledTextOutput(org.gradle.internal.logging.text.StyledTextOutput) ComponentSpec(org.gradle.platform.base.ComponentSpec) TaskAction(org.gradle.api.tasks.TaskAction)

Example 12 with ModelRegistry

use of org.gradle.model.internal.registry.ModelRegistry in project gradle by gradle.

the class ModelReport method report.

@TaskAction
public void report() {
    ProjectInternal project = (ProjectInternal) getProject();
    project.prepareForRuleBasedPlugins();
    StyledTextOutput textOutput = getTextOutputFactory().create(ModelReport.class);
    ModelNodeRenderer renderer = new ModelNodeRenderer(isShowHidden(), getFormat());
    TextModelReportRenderer textModelReportRenderer = new TextModelReportRenderer(renderer);
    textModelReportRenderer.setOutput(textOutput);
    ProjectDetails projectDetails = ProjectDetails.of(project);
    textModelReportRenderer.startProject(projectDetails);
    ModelRegistry modelRegistry = getModelRegistry();
    ModelNode rootNode = modelRegistry.realizeNode(ModelPath.ROOT);
    // Ensure binding validation has been done. This should happen elsewhere
    modelRegistry.bindAllReferences();
    textModelReportRenderer.render(rootNode);
    textModelReportRenderer.completeProject(projectDetails);
    textModelReportRenderer.complete();
}
Also used : ProjectDetails(org.gradle.api.tasks.diagnostics.internal.ProjectDetails) ModelRegistry(org.gradle.model.internal.registry.ModelRegistry) ProjectInternal(org.gradle.api.internal.project.ProjectInternal) ModelNodeRenderer(org.gradle.api.reporting.model.internal.ModelNodeRenderer) TextModelReportRenderer(org.gradle.api.reporting.model.internal.TextModelReportRenderer) StyledTextOutput(org.gradle.internal.logging.text.StyledTextOutput) ModelNode(org.gradle.model.internal.core.ModelNode) TaskAction(org.gradle.api.tasks.TaskAction)

Example 13 with ModelRegistry

use of org.gradle.model.internal.registry.ModelRegistry in project gradle by gradle.

the class RuleBasedPluginTarget method applyRules.

@Override
public void applyRules(@Nullable String pluginId, Class<?> clazz) {
    target.prepareForRuleBasedPlugins();
    ModelRegistry modelRegistry = target.getModelRegistry();
    Iterable<Class<? extends RuleSource>> declaredSources = ruleDetector.getDeclaredSources(clazz);
    for (Class<? extends RuleSource> ruleSource : declaredSources) {
        ExtractedRuleSource<?> rules = ruleInspector.extract(ruleSource);
        for (Class<?> dependency : rules.getRequiredPlugins()) {
            target.getPluginManager().apply(dependency);
        }
        modelRegistry.getRoot().applyToSelf(rules);
    }
}
Also used : RuleSource(org.gradle.model.RuleSource) ExtractedRuleSource(org.gradle.model.internal.inspect.ExtractedRuleSource) ModelRegistry(org.gradle.model.internal.registry.ModelRegistry)

Aggregations

ModelRegistry (org.gradle.model.internal.registry.ModelRegistry)13 ProjectInternal (org.gradle.api.internal.project.ProjectInternal)3 File (java.io.File)2 Nullable (javax.annotation.Nullable)2 RegularFile (org.gradle.api.file.RegularFile)2 TaskAction (org.gradle.api.tasks.TaskAction)2 TaskContainer (org.gradle.api.tasks.TaskContainer)2 ProjectDetails (org.gradle.api.tasks.diagnostics.internal.ProjectDetails)2 StyledTextOutput (org.gradle.internal.logging.text.StyledTextOutput)2 Names (org.gradle.language.nativeplatform.internal.Names)2 SwiftCompile (org.gradle.language.swift.tasks.SwiftCompile)2 DefaultNativePlatform (org.gradle.nativeplatform.platform.internal.DefaultNativePlatform)2 LinkMachOBundle (org.gradle.nativeplatform.tasks.LinkMachOBundle)2 SwiftXCTestBundle (org.gradle.nativeplatform.test.xctest.SwiftXCTestBundle)2 DefaultSwiftXCTestBundle (org.gradle.nativeplatform.test.xctest.internal.DefaultSwiftXCTestBundle)2 DefaultSwiftXCTestExecutable (org.gradle.nativeplatform.test.xctest.internal.DefaultSwiftXCTestExecutable)2 InstallXCTestBundle (org.gradle.nativeplatform.test.xctest.tasks.InstallXCTestBundle)2 NativeToolChain (org.gradle.nativeplatform.toolchain.NativeToolChain)2 NativeToolChainInternal (org.gradle.nativeplatform.toolchain.internal.NativeToolChainInternal)2 NativeToolChainRegistryInternal (org.gradle.nativeplatform.toolchain.internal.NativeToolChainRegistryInternal)2