本文整理汇总了Java中org.gradle.model.internal.core.ModelReference类的典型用法代码示例。如果您正苦于以下问题:Java ModelReference类的具体用法?Java ModelReference怎么用?Java ModelReference使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ModelReference类属于org.gradle.model.internal.core包,在下文中一共展示了ModelReference类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toInputBuilder
import org.gradle.model.internal.core.ModelReference; //导入依赖的package包/类
private UnboundRuleInput.Builder toInputBuilder(ModelBinding binding) {
ModelReference<?> reference = binding.getPredicate().getReference();
UnboundRuleInput.Builder builder = UnboundRuleInput.type(reference.getType());
ModelPath path;
if (binding.isBound()) {
builder.bound();
path = binding.getNode().getPath();
} else {
path = reference.getPath();
if (path != null) {
builder.suggestions(CollectionUtils.stringize(suggestionsProvider.transform(path)));
}
ModelPath scope = reference.getScope();
if (scope != null && !scope.equals(ModelPath.ROOT)) {
builder.scope(scope.toString());
}
}
if (path != null) {
builder.path(path);
}
builder.description(reference.getDescription());
return builder;
}
示例2: apply
import org.gradle.model.internal.core.ModelReference; //导入依赖的package包/类
public void apply(ProjectInternal project) {
project.getPluginManager().apply(BasePlugin.class);
project.getPluginManager().apply(ReportingBasePlugin.class);
project.getPluginManager().apply(LanguageBasePlugin.class);
project.getPluginManager().apply(BinaryBasePlugin.class);
JavaPluginConvention javaConvention = new JavaPluginConvention(project, instantiator);
project.getConvention().getPlugins().put("java", javaConvention);
configureCompileDefaults(project, javaConvention);
BridgedBinaries binaries = configureSourceSetDefaults(javaConvention);
modelRegistry.register(ModelRegistrations.bridgedInstance(ModelReference.of("bridgedBinaries", BridgedBinaries.class), binaries)
.descriptor("JavaBasePlugin.apply()")
.hidden(true)
.build());
configureJavaDoc(project, javaConvention);
configureTest(project, javaConvention);
configureBuildNeeded(project);
configureBuildDependents(project);
}
示例3: doRegister
import org.gradle.model.internal.core.ModelReference; //导入依赖的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);
}
}
示例4: doRegister
import org.gradle.model.internal.core.ModelReference; //导入依赖的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);
}
}
示例5: visitDependency
import org.gradle.model.internal.core.ModelReference; //导入依赖的package包/类
protected <R, S> void visitDependency(RuleMethodDataCollector dataCollector, MethodRuleDefinition<R> ruleDefinition, ModelType<S> expectedDependency) {
// TODO:DAZ Use ModelType.toString instead of getSimpleName()
List<ModelReference<?>> references = ruleDefinition.getReferences();
ModelType<? extends S> dependency = null;
for (ModelReference<?> reference : references) {
ModelType<? extends S> newDependency = expectedDependency.asSubclass(reference.getType());
if (newDependency != null) {
if (dependency != null) {
throw new InvalidComponentModelException(String.format("%s method must have one parameter extending %s. Found multiple parameter extending %s.", annotationType.getSimpleName(),
expectedDependency.getConcreteClass().getSimpleName(),
expectedDependency.getConcreteClass().getSimpleName()));
}
dependency = newDependency;
}
}
if (dependency == null) {
throw new InvalidComponentModelException(String.format("%s method must have one parameter extending %s. Found no parameter extending %s.", annotationType.getSimpleName(),
expectedDependency.getConcreteClass().getSimpleName(),
expectedDependency.getConcreteClass().getSimpleName()));
}
dataCollector.put(expectedDependency.getConcreteClass(), dependency.getConcreteClass());
}
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:25,代码来源:AbstractAnnotationDrivenMethodComponentRuleDefinitionHandler.java
示例6: apply
import org.gradle.model.internal.core.ModelReference; //导入依赖的package包/类
public void apply(final ProjectInternal project) {
project.getPlugins().apply(LanguageBasePlugin.class);
LanguageRegistry languageRegistry = project.getExtensions().create("languages", DefaultLanguageRegistry.class);
ProjectSourceSet sources = project.getExtensions().getByType(ProjectSourceSet.class);
DefaultComponentSpecContainer components = project.getExtensions().create("componentSpecs", DefaultComponentSpecContainer.class, instantiator);
modelRegistry.create(
ModelCreators.of(ModelReference.of("componentSpecs", DefaultComponentSpecContainer.class), components)
.simpleDescriptor("Project.<init>.componentSpecs()")
.withProjection(new PolymorphicDomainObjectContainerModelProjection<DefaultComponentSpecContainer, ComponentSpec>(components, ComponentSpec.class))
.build()
);
// TODO:DAZ Convert to model rules
createLanguageSourceSets(sources, components, languageRegistry, project.getFileResolver());
}
示例7: toInputBuilder
import org.gradle.model.internal.core.ModelReference; //导入依赖的package包/类
private UnboundRuleInput.Builder toInputBuilder(ModelBinding<?> binding, ModelReference<?> reference) {
UnboundRuleInput.Builder builder = UnboundRuleInput.type(reference.getType());
ModelPath path;
if (binding != null) {
builder.bound();
path = binding.getPath();
} else {
path = reference.getPath();
if (path != null) {
builder.suggestions(CollectionUtils.stringize(suggestionsProvider.transform(path)));
}
}
if (path != null) {
builder.path(path);
}
builder.description(reference.getDescription());
return builder;
}
示例8: registerConfigurationAction
import org.gradle.model.internal.core.ModelReference; //导入依赖的package包/类
private void registerConfigurationAction(final Closure<?> action) {
modelRegistry.mutate(new ModelMutator<Object>() {
public ModelReference<Object> getSubject() {
return ModelReference.untyped(modelPath);
}
public void mutate(Object object, Inputs inputs) {
new ClosureBackedAction<Object>(action).execute(object);
}
public ModelRuleDescriptor getDescriptor() {
return new SimpleModelRuleDescriptor("model." + modelPath);
}
public List<ModelReference<?>> getInputs() {
return Collections.emptyList();
}
});
}
示例9: registration
import org.gradle.model.internal.core.ModelReference; //导入依赖的package包/类
@Nullable
@Override
public <R, S> ExtractedModelRule registration(MethodRuleDefinition<R, S> ruleDefinition, MethodModelRuleExtractionContext context) {
validateIsVoidMethod(ruleDefinition, context);
if (ruleDefinition.getReferences().size() != 1) {
context.add(ruleDefinition, String.format("A method %s must have a single parameter of type %s.", getDescription(), TypeBuilder.class.getName()));
return null;
}
ModelReference<?> subjectReference = ruleDefinition.getSubjectReference();
ModelType<?> subjectType = subjectReference.getType();
Class<?> rawSubjectType = subjectType.getRawClass();
if (!rawSubjectType.equals(TypeBuilder.class)) {
context.add(ruleDefinition, String.format("A method %s must have a single parameter of type %s.", getDescription(), TypeBuilder.class.getName()));
return null;
}
List<ModelType<?>> typeVariables = subjectType.getTypeVariables();
if (typeVariables.size() != 1) {
context.add(ruleDefinition, String.format("Parameter of type %s must declare a type parameter.", rawSubjectType.getName()));
return null;
}
ModelType<?> builtType = typeVariables.get(0);
if (builtType.isWildcard()) {
context.add(ruleDefinition, String.format("Type '%s' cannot be a wildcard type (i.e. cannot use ? super, ? extends etc.).", builtType.toString()));
return null;
}
ComponentTypeRegistrationInfo info = componentTypeRegistrationInfoFor(builtType);
if (info == null) {
context.add(ruleDefinition, String.format("Type '%s' is not a subtype of '%s'.", builtType.toString(), COMPONENT_SPEC_MODEL_TYPE.toString()));
return null;
}
return new ExtractedTypeRule(ruleDefinition, info, builtType.asSubtype(info.baseInterface));
}
示例10: visitDependency
import org.gradle.model.internal.core.ModelReference; //导入依赖的package包/类
protected <S> void visitDependency(RuleMethodDataCollector dataCollector, MethodRuleDefinition<?, ?> ruleDefinition, ModelType<S> expectedDependency, RuleSourceValidationProblemCollector problems) {
if (ruleDefinition.getReferences().isEmpty() && problems.hasProblems()) {
return;
}
List<ModelReference<?>> references = ruleDefinition.getReferences();
ModelType<? extends S> dependency = null;
for (ModelReference<?> reference : references) {
if (expectedDependency.isAssignableFrom(reference.getType())) {
if (dependency != null) {
problems.add(ruleDefinition, String.format("A method %s must have one parameter extending %s. Found multiple parameter extending %s.", getDescription(),
expectedDependency.getDisplayName(),
expectedDependency.getDisplayName()));
return;
}
dependency = reference.getType().asSubtype(expectedDependency);
}
}
if (dependency == null) {
problems.add(ruleDefinition, String.format("A method %s must have one parameter extending %s. Found no parameter extending %s.", getDescription(),
expectedDependency.getDisplayName(),
expectedDependency.getDisplayName()));
return;
}
dataCollector.put(expectedDependency, dependency);
}
示例11: ModelMapBasedRule
import org.gradle.model.internal.core.ModelReference; //导入依赖的package包/类
public ModelMapBasedRule(ModelReference<C> subject, final ModelType<? extends T> baseType, MethodRuleDefinition<?, ?> ruleDefinition, ModelReference<?>... additionalInputs) {
super(subject, ruleDefinition.getDescriptor());
this.inputs = calculateInputs(
baseType,
ruleDefinition.getReferences().subList(1, ruleDefinition.getReferences().size()),
Arrays.asList(additionalInputs)
);
this.baseTypeParameterIndex = 1 + Iterables.indexOf(ruleDefinition.getReferences().subList(1, ruleDefinition.getReferences().size()), new Predicate<ModelReference<?>>() {
@Override
public boolean apply(ModelReference<?> element) {
return element.getType().equals(baseType);
}
});
}
示例12: calculateInputs
import org.gradle.model.internal.core.ModelReference; //导入依赖的package包/类
private static ImmutableList<ModelReference<?>> calculateInputs(final ModelType<?> baseType, final List<ModelReference<?>> references, List<ModelReference<?>> modelReferences) {
Iterable<ModelReference<?>> filteredReferences = Iterables.filter(references, new Predicate<ModelReference<?>>() {
@Override
public boolean apply(ModelReference<?> element) {
return !element.getType().equals(baseType);
}
});
ImmutableList.Builder<ModelReference<?>> allInputs = ImmutableList.builder();
allInputs.addAll(modelReferences);
allInputs.addAll(filteredReferences);
return allInputs.build();
}
示例13: apply
import org.gradle.model.internal.core.ModelReference; //导入依赖的package包/类
@Override
public void apply(final MethodModelRuleApplicationContext context, MutableModelNode target) {
MethodRuleDefinition<?, ?> ruleDefinition = getRuleDefinition();
ModelReference<?> targetReference = ruleDefinition.getReferences().get(1);
List<ModelReference<?>> inputs = ruleDefinition.getReferences().subList(2, ruleDefinition.getReferences().size());
RuleSourceApplicationAction ruleAction = new RuleSourceApplicationAction(targetReference, ruleDefinition.getDescriptor(), inputs, ruleSourceType, ruleExtractor);
RuleExtractorUtils.configureRuleAction(context, ruleApplicationScope, ModelActionRole.Defaults, ruleAction);
}
示例14: RuleSourceApplicationAction
import org.gradle.model.internal.core.ModelReference; //导入依赖的package包/类
public RuleSourceApplicationAction(ModelReference<?> targetReference, ModelRuleDescriptor descriptor, List<ModelReference<?>> inputs, ModelType<? extends RuleSource> ruleSourceType, ModelRuleExtractor ruleExtractor) {
this.targetReference = targetReference;
this.descriptor = descriptor;
this.inputs = inputs;
this.ruleSourceType = ruleSourceType;
this.ruleExtractor = ruleExtractor;
}
示例15: validateRuleMethod
import org.gradle.model.internal.core.ModelReference; //导入依赖的package包/类
private void validateRuleMethod(MethodRuleDefinition<?, ?> ruleDefinition, Method ruleMethod, RuleSourceValidationProblemCollector problems) {
if (Modifier.isPrivate(ruleMethod.getModifiers())) {
problems.add(ruleMethod, "A rule method cannot be private");
}
if (Modifier.isAbstract(ruleMethod.getModifiers())) {
problems.add(ruleMethod, "A rule method cannot be abstract");
}
if (ruleMethod.getTypeParameters().length > 0) {
problems.add(ruleMethod, "Cannot have type variables (i.e. cannot be a generic method)");
}
// TODO validations on method: synthetic, bridge methods, varargs, abstract, native
ModelType<?> returnType = ModelType.returnType(ruleMethod);
if (returnType.isRawClassOfParameterizedType()) {
problems.add(ruleMethod, "Raw type " + returnType + " used for return type (all type parameters must be specified of parameterized type)");
}
for (int i = 0; i < ruleDefinition.getReferences().size(); i++) {
ModelReference<?> reference = ruleDefinition.getReferences().get(i);
if (reference.getType().isRawClassOfParameterizedType()) {
problems.add(ruleMethod, "Raw type " + reference.getType() + " used for parameter " + (i + 1) + " (all type parameters must be specified of parameterized type)");
}
if (reference.getPath() != null) {
try {
ModelPath.validatePath(reference.getPath().getPath());
} catch (Exception e) {
problems.add(ruleDefinition, "The declared model element path '" + reference.getPath().getPath() + "' used for parameter " + (i + 1) + " is not a valid path", e);
}
}
}
}