org.gradle.model.internal.core.ModelReference Java Examples
The following examples show how to use
org.gradle.model.internal.core.ModelReference.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: pushfish-android Author: PushFish File: ComponentBinariesRuleDefinitionHandler.java License: BSD 2-Clause "Simplified" License | 6 votes |
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); } }
Example #2
Source Project: pushfish-android Author: PushFish File: BinaryTasksRuleDefinitionHandler.java License: BSD 2-Clause "Simplified" License | 6 votes |
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); } }
Example #3
Source Project: pushfish-android Author: PushFish File: AbstractAnnotationDrivenMethodComponentRuleDefinitionHandler.java License: BSD 2-Clause "Simplified" License | 6 votes |
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()); }
Example #4
Source Project: pushfish-android Author: PushFish File: ComponentModelBasePlugin.java License: BSD 2-Clause "Simplified" License | 6 votes |
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()); }
Example #5
Source Project: pushfish-android Author: PushFish File: UnboundRulesProcessor.java License: BSD 2-Clause "Simplified" License | 6 votes |
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; }
Example #6
Source Project: pushfish-android Author: PushFish File: NonTransformedModelDslBacking.java License: BSD 2-Clause "Simplified" License | 6 votes |
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(); } }); }
Example #7
Source Project: javaide Author: tranleduy2000 File: JavaBasePlugin.java License: GNU General Public License v3.0 | 6 votes |
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); }
Example #8
Source Project: Pushjet-Android Author: Pushjet File: ComponentBinariesRuleDefinitionHandler.java License: BSD 2-Clause "Simplified" License | 6 votes |
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); } }
Example #9
Source Project: Pushjet-Android Author: Pushjet File: BinaryTasksRuleDefinitionHandler.java License: BSD 2-Clause "Simplified" License | 6 votes |
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); } }
Example #10
Source Project: Pushjet-Android Author: Pushjet File: AbstractAnnotationDrivenMethodComponentRuleDefinitionHandler.java License: BSD 2-Clause "Simplified" License | 6 votes |
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()); }
Example #11
Source Project: Pushjet-Android Author: Pushjet File: ComponentModelBasePlugin.java License: BSD 2-Clause "Simplified" License | 6 votes |
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()); }
Example #12
Source Project: Pushjet-Android Author: Pushjet File: UnboundRulesProcessor.java License: BSD 2-Clause "Simplified" License | 6 votes |
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; }
Example #13
Source Project: Pushjet-Android Author: Pushjet File: NonTransformedModelDslBacking.java License: BSD 2-Clause "Simplified" License | 6 votes |
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(); } }); }
Example #14
Source Project: pushfish-android Author: PushFish File: ComponentModelRuleDefinitionHandler.java License: BSD 2-Clause "Simplified" License | 5 votes |
protected RegisterTypeRule(ModelType<? extends T> type, ModelType<? extends U> implementation, ModelRuleDescriptor descriptor, Action<? super RegistrationContext<T, U>> registerAction) { this.type = type; this.implementation = implementation; this.descriptor = descriptor; this.registerAction = registerAction; subject = ModelReference.of("extensions", ExtensionContainer.class); inputs = ImmutableList.<ModelReference<?>>of(ModelReference.of(ProjectIdentifier.class)); }
Example #15
Source Project: pushfish-android Author: PushFish File: LanguageBasePlugin.java License: BSD 2-Clause "Simplified" License | 5 votes |
public void apply(final Project target) { target.getPlugins().apply(LifecycleBasePlugin.class); target.getExtensions().create("sources", DefaultProjectSourceSet.class, instantiator); DefaultBinaryContainer binaries = target.getExtensions().create("binaries", DefaultBinaryContainer.class, instantiator); modelRegistry.create( ModelCreators.of(ModelReference.of("binaries", BinaryContainer.class), binaries) .simpleDescriptor("Project.<init>.binaries()") .withProjection(new PolymorphicDomainObjectContainerModelProjection<DefaultBinaryContainer, BinarySpec>(binaries, BinarySpec.class)) .build() ); }
Example #16
Source Project: pushfish-android Author: PushFish File: AbstractMutationRuleDefinitionHandler.java License: BSD 2-Clause "Simplified" License | 5 votes |
public <R> void register(MethodRuleDefinition<R> ruleDefinition, ModelRegistry modelRegistry, RuleSourceDependencies dependencies) { List<ModelReference<?>> bindings = ruleDefinition.getReferences(); ModelReference<?> subject = bindings.get(0); List<ModelReference<?>> inputs = bindings.subList(1, bindings.size()); MethodModelMutator<?> mutator = toMutator(ruleDefinition, subject, inputs); if (isFinalize()) { modelRegistry.finalize(mutator); } else { modelRegistry.mutate(mutator); } }
Example #17
Source Project: pushfish-android Author: PushFish File: DefaultMethodRuleDefinition.java License: BSD 2-Clause "Simplified" License | 5 votes |
public List<ModelReference<?>> getReferences() { Type[] types = method.getGenericParameterTypes(); ImmutableList.Builder<ModelReference<?>> inputBindingBuilder = ImmutableList.builder(); for (int i = 0; i < types.length; i++) { Type paramType = types[i]; Annotation[] paramAnnotations = method.getParameterAnnotations()[i]; inputBindingBuilder.add(reference(paramType, paramAnnotations, i)); } return inputBindingBuilder.build(); }
Example #18
Source Project: pushfish-android Author: PushFish File: DefaultMethodRuleDefinition.java License: BSD 2-Clause "Simplified" License | 5 votes |
private ModelReference<?> reference(Type type, Annotation[] annotations, int i) { Path pathAnnotation = (Path) findFirst(annotations, new Spec<Annotation>() { public boolean isSatisfiedBy(Annotation element) { return element.annotationType().equals(Path.class); } }); String path = pathAnnotation == null ? null : pathAnnotation.value(); ModelType<?> cast = ModelType.of(type); return ModelReference.of(path == null ? null : ModelPath.path(path), cast, String.format("parameter %s", i + 1)); }
Example #19
Source Project: pushfish-android Author: PushFish File: RuleBinder.java License: BSD 2-Clause "Simplified" License | 5 votes |
public RuleBinder(@Nullable ModelReference<T> subjectReference, List<ModelReference<?>> inputReferences, ModelRuleDescriptor descriptor, Action<? super RuleBinder<T>> onBind) { this.subjectReference = subjectReference; this.inputReferences = inputReferences; this.descriptor = descriptor; this.onBind = onBind; this.inputBindings = inputReferences.isEmpty() ? Collections.<ModelBinding<?>>emptyList() : Arrays.asList(new ModelBinding<?>[inputReferences.size()]); // fix size maybeFire(); }
Example #20
Source Project: pushfish-android Author: PushFish File: TransformedModelDslBacking.java License: BSD 2-Clause "Simplified" License | 5 votes |
public List<ModelReference<?>> transform(Closure<?> closure) { RuleMetadata ruleMetadata = getRuleMetadata(closure); String[] paths = ruleMetadata.inputPaths(); List<ModelReference<?>> references = Lists.newArrayListWithCapacity(paths.length); for (int i = 0; i < paths.length; i++) { String description = String.format("@ line %d", ruleMetadata.inputLineNumbers()[i]); references.add(ModelReference.untyped(ModelPath.path(paths[i]), description)); } return references; }
Example #21
Source Project: pushfish-android Author: PushFish File: TransformedModelDslBacking.java License: BSD 2-Clause "Simplified" License | 5 votes |
TransformedModelDslBacking(ModelRegistry modelRegistry, Object thisObject, Object owner, Transformer<? extends List<ModelReference<?>>, ? super Closure<?>> inputPathsExtractor, Transformer<SourceLocation, ? super Closure<?>> ruleLocationExtractor) { this.modelRegistry = modelRegistry; this.thisObject = thisObject; this.owner = owner; this.inputPathsExtractor = inputPathsExtractor; this.ruleLocationExtractor = ruleLocationExtractor; }
Example #22
Source Project: pushfish-android Author: PushFish File: TransformedModelDslBacking.java License: BSD 2-Clause "Simplified" License | 5 votes |
public void configure(String modelPathString, Closure<?> configuration) { List<ModelReference<?>> references = inputPathsExtractor.transform(configuration); SourceLocation sourceLocation = ruleLocationExtractor.transform(configuration); ModelPath modelPath = ModelPath.path(modelPathString); Closure<?> reownered = configuration.rehydrate(null, owner, thisObject); modelRegistry.mutate(new ClosureBackedModelMutator(reownered, references, modelPath, sourceLocation)); }
Example #23
Source Project: Pushjet-Android Author: Pushjet File: ComponentModelRuleDefinitionHandler.java License: BSD 2-Clause "Simplified" License | 5 votes |
protected RegisterTypeRule(ModelType<? extends T> type, ModelType<? extends U> implementation, ModelRuleDescriptor descriptor, Action<? super RegistrationContext<T, U>> registerAction) { this.type = type; this.implementation = implementation; this.descriptor = descriptor; this.registerAction = registerAction; subject = ModelReference.of("extensions", ExtensionContainer.class); inputs = ImmutableList.<ModelReference<?>>of(ModelReference.of(ProjectIdentifier.class)); }
Example #24
Source Project: Pushjet-Android Author: Pushjet File: LanguageBasePlugin.java License: BSD 2-Clause "Simplified" License | 5 votes |
public void apply(final Project target) { target.getPlugins().apply(LifecycleBasePlugin.class); target.getExtensions().create("sources", DefaultProjectSourceSet.class, instantiator); DefaultBinaryContainer binaries = target.getExtensions().create("binaries", DefaultBinaryContainer.class, instantiator); modelRegistry.create( ModelCreators.of(ModelReference.of("binaries", BinaryContainer.class), binaries) .simpleDescriptor("Project.<init>.binaries()") .withProjection(new PolymorphicDomainObjectContainerModelProjection<DefaultBinaryContainer, BinarySpec>(binaries, BinarySpec.class)) .build() ); }
Example #25
Source Project: Pushjet-Android Author: Pushjet File: AbstractMutationRuleDefinitionHandler.java License: BSD 2-Clause "Simplified" License | 5 votes |
public <R> void register(MethodRuleDefinition<R> ruleDefinition, ModelRegistry modelRegistry, RuleSourceDependencies dependencies) { List<ModelReference<?>> bindings = ruleDefinition.getReferences(); ModelReference<?> subject = bindings.get(0); List<ModelReference<?>> inputs = bindings.subList(1, bindings.size()); MethodModelMutator<?> mutator = toMutator(ruleDefinition, subject, inputs); if (isFinalize()) { modelRegistry.finalize(mutator); } else { modelRegistry.mutate(mutator); } }
Example #26
Source Project: Pushjet-Android Author: Pushjet File: DefaultMethodRuleDefinition.java License: BSD 2-Clause "Simplified" License | 5 votes |
public List<ModelReference<?>> getReferences() { Type[] types = method.getGenericParameterTypes(); ImmutableList.Builder<ModelReference<?>> inputBindingBuilder = ImmutableList.builder(); for (int i = 0; i < types.length; i++) { Type paramType = types[i]; Annotation[] paramAnnotations = method.getParameterAnnotations()[i]; inputBindingBuilder.add(reference(paramType, paramAnnotations, i)); } return inputBindingBuilder.build(); }
Example #27
Source Project: Pushjet-Android Author: Pushjet File: DefaultMethodRuleDefinition.java License: BSD 2-Clause "Simplified" License | 5 votes |
private ModelReference<?> reference(Type type, Annotation[] annotations, int i) { Path pathAnnotation = (Path) findFirst(annotations, new Spec<Annotation>() { public boolean isSatisfiedBy(Annotation element) { return element.annotationType().equals(Path.class); } }); String path = pathAnnotation == null ? null : pathAnnotation.value(); ModelType<?> cast = ModelType.of(type); return ModelReference.of(path == null ? null : ModelPath.path(path), cast, String.format("parameter %s", i + 1)); }
Example #28
Source Project: Pushjet-Android Author: Pushjet File: RuleBinder.java License: BSD 2-Clause "Simplified" License | 5 votes |
public RuleBinder(@Nullable ModelReference<T> subjectReference, List<ModelReference<?>> inputReferences, ModelRuleDescriptor descriptor, Action<? super RuleBinder<T>> onBind) { this.subjectReference = subjectReference; this.inputReferences = inputReferences; this.descriptor = descriptor; this.onBind = onBind; this.inputBindings = inputReferences.isEmpty() ? Collections.<ModelBinding<?>>emptyList() : Arrays.asList(new ModelBinding<?>[inputReferences.size()]); // fix size maybeFire(); }
Example #29
Source Project: Pushjet-Android Author: Pushjet File: TransformedModelDslBacking.java License: BSD 2-Clause "Simplified" License | 5 votes |
public List<ModelReference<?>> transform(Closure<?> closure) { RuleMetadata ruleMetadata = getRuleMetadata(closure); String[] paths = ruleMetadata.inputPaths(); List<ModelReference<?>> references = Lists.newArrayListWithCapacity(paths.length); for (int i = 0; i < paths.length; i++) { String description = String.format("@ line %d", ruleMetadata.inputLineNumbers()[i]); references.add(ModelReference.untyped(ModelPath.path(paths[i]), description)); } return references; }
Example #30
Source Project: Pushjet-Android Author: Pushjet File: TransformedModelDslBacking.java License: BSD 2-Clause "Simplified" License | 5 votes |
TransformedModelDslBacking(ModelRegistry modelRegistry, Object thisObject, Object owner, Transformer<? extends List<ModelReference<?>>, ? super Closure<?>> inputPathsExtractor, Transformer<SourceLocation, ? super Closure<?>> ruleLocationExtractor) { this.modelRegistry = modelRegistry; this.thisObject = thisObject; this.owner = owner; this.inputPathsExtractor = inputPathsExtractor; this.ruleLocationExtractor = ruleLocationExtractor; }