当前位置: 首页>>代码示例>>Java>>正文


Java ModelRegistry类代码示例

本文整理汇总了Java中org.gradle.model.internal.registry.ModelRegistry的典型用法代码示例。如果您正苦于以下问题:Java ModelRegistry类的具体用法?Java ModelRegistry怎么用?Java ModelRegistry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ModelRegistry类属于org.gradle.model.internal.registry包,在下文中一共展示了ModelRegistry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getBinaries

import org.gradle.model.internal.registry.ModelRegistry; //导入依赖的package包/类
@Nullable
@Override
public DomainObjectSet<NativeLibraryBinary> getBinaries(LibraryIdentifier libraryIdentifier) {
    ModelRegistry projectModel = projectModelResolver.resolveProjectModel(libraryIdentifier.getProjectPath());
    ComponentSpecContainer components = projectModel.find("components", ComponentSpecContainer.class);
    if (components == null) {
        return null;
    }
    String libraryName = libraryIdentifier.getLibraryName();
    NativeLibrarySpec library = components.withType(NativeLibrarySpec.class).get(libraryName);
    if (library == null) {
        return null;
    }
    ModelMap<NativeBinarySpec> projectBinaries = library.getBinaries().withType(NativeBinarySpec.class);
    DomainObjectSet<NativeLibraryBinary> binaries = new DefaultDomainObjectSet<NativeLibraryBinary>(NativeLibraryBinary.class);
    for (NativeBinarySpec nativeBinarySpec : projectBinaries.values()) {
        binaries.add((NativeLibraryBinary) nativeBinarySpec);
    }
    return binaries;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:21,代码来源:ProjectLibraryBinaryLocator.java

示例2: report

import org.gradle.model.internal.registry.ModelRegistry; //导入依赖的package包/类
@TaskAction
public void report() {
    Project project = getProject();
    StyledTextOutput textOutput = getTextOutputFactory().create(ModelReport.class);
    ModelNodeRenderer renderer = new ModelNodeRenderer(isShowHidden(), getFormat());

    TextModelReportRenderer textModelReportRenderer = new TextModelReportRenderer(renderer);

    textModelReportRenderer.setOutput(textOutput);
    textModelReportRenderer.startProject(project);

    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(project);
    textModelReportRenderer.complete();
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:21,代码来源:ModelReport.java

示例3: report

import org.gradle.model.internal.registry.ModelRegistry; //导入依赖的package包/类
@TaskAction
public void report() {
     // Output reports per execution, not mixed.
     // Cross-project ModelRegistry operations do not happen concurrently.
    synchronized (DependentComponentsReport.class) {
        Project project = getProject();
        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);
        reportRenderer.startProject(project);

        Set<ComponentSpec> allComponents = getAllComponents(modelRegistry);
        if (showTestSuites) {
            allComponents.addAll(getAllTestSuites(modelRegistry));
        }
        reportRenderer.renderComponents(getReportedComponents(allComponents));
        reportRenderer.renderLegend();

        reportRenderer.completeProject(project);
        reportRenderer.complete();
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:27,代码来源:DependentComponentsReport.java

示例4: doRegister

import org.gradle.model.internal.registry.ModelRegistry; //导入依赖的package包/类
private <R, S extends BinarySpec> void doRegister(MethodRuleDefinition<R> ruleDefinition, ModelRegistry modelRegistry, RuleSourceDependencies dependencies) {
    try {
        RuleMethodDataCollector dataCollector = new RuleMethodDataCollector();
        visitAndVerifyMethodSignature(dataCollector, ruleDefinition);

        final Class<S> binaryType = dataCollector.getParameterType(BinarySpec.class);
        final Class<? extends ComponentSpec> componentType = dataCollector.getParameterType(ComponentSpec.class);
        dependencies.add(ComponentModelBasePlugin.class);
        final ModelReference<BinaryContainer> subject = ModelReference.of(ModelPath.path("binaries"), new ModelType<BinaryContainer>() {
        });

        configureMutationRule(modelRegistry, subject, componentType, binaryType, ruleDefinition);
    } catch (InvalidComponentModelException e) {
        invalidModelRule(ruleDefinition, e);
    }
}
 
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:17,代码来源:ComponentBinariesRuleDefinitionHandler.java

示例5: doRegister

import org.gradle.model.internal.registry.ModelRegistry; //导入依赖的package包/类
private <R, S extends BinarySpec> void doRegister(MethodRuleDefinition<R> ruleDefinition, ModelRegistry modelRegistry, RuleSourceDependencies dependencies) {
    try {
        RuleMethodDataCollector dataCollector = new RuleMethodDataCollector();
        verifyMethodSignature(dataCollector, ruleDefinition);

        Class<S> binaryType =  dataCollector.getParameterType(BinarySpec.class);
        dependencies.add(ComponentModelBasePlugin.class);

        final ModelReference<TaskContainer> tasks = ModelReference.of(ModelPath.path("tasks"), new ModelType<TaskContainer>() {
        });

        modelRegistry.mutate(new BinaryTaskRule<R, S>(tasks, binaryType, ruleDefinition, modelRegistry));

    } catch (InvalidComponentModelException e) {
        invalidModelRule(ruleDefinition, e);
    }
}
 
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:18,代码来源:BinaryTasksRuleDefinitionHandler.java

示例6: inspect

import org.gradle.model.internal.registry.ModelRegistry; //导入依赖的package包/类
public <T> void inspect(Class<T> source, ModelRegistry modelRegistry, RuleSourceDependencies dependencies) {
    validate(source);
    final Method[] methods = source.getDeclaredMethods();

    // sort for determinism
    Arrays.sort(methods, new Comparator<Method>() {
        public int compare(Method o1, Method o2) {
            return o1.toString().compareTo(o2.toString());
        }
    });

    for (Method method : methods) {
        validate(method);
        MethodRuleDefinition<?> ruleDefinition = DefaultMethodRuleDefinition.create(source, method);
        MethodRuleDefinitionHandler handler = getMethodHandler(ruleDefinition);
        if (handler != null) {
            // TODO catch “strange” exceptions thrown here and wrap with some context on the rule being registered
            // If the thrown exception doesn't provide any “model rule” context, it will be more or less impossible for a user
            // to work out what happened because the stack trace won't reveal any info about which rule was being registered.
            // However, a “wrap everything” strategy doesn't quite work because the thrown exception may already have enough context
            // and do a better job of explaining what went wrong than what we can do at this level.
            handler.register(ruleDefinition, modelRegistry, dependencies);
        }
    }
}
 
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:26,代码来源:ModelRuleInspector.java

示例7: register

import org.gradle.model.internal.registry.ModelRegistry; //导入依赖的package包/类
public <T> void register(MethodRuleDefinition<T> ruleDefinition, ModelRegistry modelRegistry, RuleSourceDependencies dependencies) {

        // TODO validate model name
        String modelName = determineModelName(ruleDefinition);

        try {
            ModelPath.validatePath(modelName);
        } catch (Exception e) {
            throw new InvalidModelRuleDeclarationException(String.format("Path of declared model element created by rule %s is invalid.", ruleDefinition.getDescriptor()), e);
        }

        // TODO validate the return type (generics?)
        ModelType<T> returnType = ruleDefinition.getReturnType();
        ModelPath path = ModelPath.path(modelName);
        List<ModelReference<?>> references = ruleDefinition.getReferences();
        ModelRuleDescriptor descriptor = ruleDefinition.getDescriptor();

        Transformer<T, Inputs> transformer = new ModelRuleInvokerBackedTransformer<T>(ruleDefinition.getRuleInvoker(), descriptor, references);
        modelRegistry.create(
                ModelCreators.of(ModelReference.of(path, returnType), transformer)
                        .descriptor(descriptor)
                        .inputs(references)
                        .build()
        );
    }
 
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:26,代码来源:ModelCreationRuleDefinitionHandler.java

示例8: resolveProjectModel

import org.gradle.model.internal.registry.ModelRegistry; //导入依赖的package包/类
@Override
public ModelRegistry resolveProjectModel(String path) {
    ProjectInternal projectInternal = delegate.getProject(path);
    if (projectInternal == null) {
        throw new UnknownProjectException("Project with path '" + path + "' not found.");
    }

    // TODO This is a brain-dead way to ensure that the reference project's model is ready to access
    projectInternal.evaluate();
    projectInternal.getTasks().discoverTasks();
    return projectInternal.getModelRegistry();
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:13,代码来源:DefaultProjectModelResolver.java

示例9: doResolve

import org.gradle.model.internal.registry.ModelRegistry; //导入依赖的package包/类
@Nullable
private LibraryResolutionResult doResolve(String selectorProjectPath, String libraryName) {
    try {
        ModelRegistry projectModel = projectModelResolver.resolveProjectModel(selectorProjectPath);
        Collection<VariantComponent> candidates = libraryResolver.resolveCandidates(projectModel, libraryName);
        if (candidates.isEmpty()) {
            return LibraryResolutionResult.emptyResolutionResult(binaryType);
        }
        return LibraryResolutionResult.of(binaryType, candidates, libraryName, binaryPredicate);
    } catch (UnknownProjectException e) {
        return LibraryResolutionResult.projectNotFound(binaryType);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:14,代码来源:LocalLibraryDependencyResolver.java

示例10: resolveCandidates

import org.gradle.model.internal.registry.ModelRegistry; //导入依赖的package包/类
@Override
public Collection<VariantComponent> resolveCandidates(ModelRegistry projectModel, String libraryName) {
    List<VariantComponent> librarySpecs = Lists.newArrayList();
    collectLocalComponents(projectModel, "components", librarySpecs);
    collectLocalComponents(projectModel, "testSuites", librarySpecs);
    if (librarySpecs.isEmpty()) {
        return Collections.emptyList();
    }
    return librarySpecs;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:11,代码来源:DefaultLocalLibraryResolver.java

示例11: collectLocalComponents

import org.gradle.model.internal.registry.ModelRegistry; //导入依赖的package包/类
private void collectLocalComponents(ModelRegistry projectModel, String container, List<VariantComponent> librarySpecs) {
    ModelMap<ComponentSpec> components = projectModel.find(container, COMPONENT_MAP_TYPE);
    if (components != null) {
        ModelMap<? extends VariantComponentSpec> libraries = components.withType(VariantComponentSpec.class);
        librarySpecs.addAll(libraries.values());
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:8,代码来源:DefaultLocalLibraryResolver.java

示例12: apply

import org.gradle.model.internal.registry.ModelRegistry; //导入依赖的package包/类
@Override
public void apply(final ModelRegistry modelRegistry, MutableModelNode target) {
    final ModelPath targetPath = calculateTarget(target);
    for (final ExtractedRuleDetails details : rules) {
        details.rule.apply(new MethodModelRuleApplicationContext() {
            @Override
            public ModelRegistry getRegistry() {
                return modelRegistry;
            }

            @Override
            public ModelPath getScope() {
                return targetPath;
            }

            @Override
            public ModelAction contextualize(final MethodRuleAction action) {
                final List<ModelReference<?>> inputs = withImplicitInputs(action.getInputs());
                final ModelReference<?> mappedSubject = mapSubject(action.getSubject(), targetPath);
                mapInputs(inputs.subList(0, action.getInputs().size()), targetPath);
                final MethodRuleDefinition<?, ?> methodRuleDefinition = details.method;
                final Factory<? extends T> factory = getFactory();
                return new ContextualizedModelAction<T>(methodRuleDefinition, mappedSubject, inputs, action, factory);
            }
        }, target);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:28,代码来源:ModelRuleExtractor.java

示例13: configureRuleAction

import org.gradle.model.internal.registry.ModelRegistry; //导入依赖的package包/类
public static void configureRuleAction(MethodModelRuleApplicationContext context, RuleApplicationScope ruleApplicationScope, ModelActionRole role, MethodRuleAction ruleAction) {
    ModelAction action = context.contextualize(ruleAction);
    ModelRegistry registry = context.getRegistry();
    switch (ruleApplicationScope) {
        case SELF:
            registry.configure(role, action);
            break;
        case DESCENDANTS:
            registry.configureMatching(new NonReferenceDescendantsSpec(context.getScope()), role, action);
            break;
        default:
            throw new AssertionError();
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:15,代码来源:RuleExtractorUtils.java

示例14: getDependentTaskDependencies

import org.gradle.model.internal.registry.ModelRegistry; //导入依赖的package包/类
private static List<Task> getDependentTaskDependencies(String dependedOnBinaryTaskName, BinarySpecInternal binary, DependentBinariesResolver dependentsResolver, ProjectModelResolver projectModelResolver) {
    List<Task> dependencies = Lists.newArrayList();
    DependentBinariesResolvedResult result = dependentsResolver.resolve(binary).getRoot();
    for (DependentBinariesResolvedResult dependent : result.getChildren()) {
        if (dependent.isBuildable()) {
            ModelRegistry modelRegistry = projectModelResolver.resolveProjectModel(dependent.getId().getProjectPath());
            ModelMap<NativeBinarySpecInternal> projectBinaries = modelRegistry.realize("binaries", ModelTypes.modelMap(NativeBinarySpecInternal.class));
            ModelMap<Task> projectTasks = modelRegistry.realize("tasks", ModelTypes.modelMap(Task.class));
            NativeBinarySpecInternal dependentBinary = projectBinaries.get(dependent.getProjectScopedName());
            dependencies.add(projectTasks.get(dependentBinary.getNamingScheme().getTaskName(dependedOnBinaryTaskName)));
        }
    }
    return dependencies;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:15,代码来源:NativeComponents.java

示例15: getBinaries

import org.gradle.model.internal.registry.ModelRegistry; //导入依赖的package包/类
@Nullable
@Override
public DomainObjectSet<NativeLibraryBinary> getBinaries(LibraryIdentifier library) {
    ModelRegistry projectModel = projectModelResolver.resolveProjectModel(library.getProjectPath());
    Repositories repositories = projectModel.find("repositories", Repositories.class);
    if (repositories == null) {
        return null;
    }
    PrebuiltLibrary prebuiltLibrary = getPrebuiltLibrary(repositories.withType(PrebuiltLibraries.class), library.getLibraryName());
    return prebuiltLibrary != null ? prebuiltLibrary.getBinaries() : null;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:12,代码来源:PrebuiltLibraryBinaryLocator.java


注:本文中的org.gradle.model.internal.registry.ModelRegistry类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。