本文整理汇总了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;
}
示例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();
}
示例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();
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
}
示例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()
);
}
示例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();
}
示例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);
}
}
示例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;
}
示例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());
}
}
示例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);
}
}
示例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();
}
}
示例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;
}
示例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;
}