Java Code Examples for org.gradle.model.internal.core.ModelReference#of()

The following examples show how to use org.gradle.model.internal.core.ModelReference#of() . 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 File: ComponentBinariesRuleDefinitionHandler.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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 File: BinaryTasksRuleDefinitionHandler.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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 File: ComponentBinariesRuleDefinitionHandler.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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 4
Source File: BinaryTasksRuleDefinitionHandler.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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 5
Source File: ComponentModelRuleDefinitionHandler.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 6
Source File: DefaultMethodRuleDefinition.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 7
Source File: ComponentModelRuleDefinitionHandler.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 8
Source File: DefaultMethodRuleDefinition.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 9
Source File: ComponentBinariesRuleDefinitionHandler.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public ComponentBinariesRule(ModelReference<BinaryContainer> subject, final Class<? extends ComponentSpec> componentType, final Class<S> binaryType, MethodRuleDefinition<R> ruleDefinition, ModelRegistry modelRegistry) {
    super(subject, componentType, ruleDefinition, ModelReference.of("componentSpecs", ComponentSpecContainer.class));
    this.componentType = componentType;
    this.binaryType = binaryType;
    this.modelRegistry = modelRegistry;
}
 
Example 10
Source File: BinaryTasksRuleDefinitionHandler.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public BinaryTaskRule(ModelReference<TaskContainer> subject, final Class<T> binaryType, MethodRuleDefinition<R> ruleDefinition, ModelRegistry modelRegistry) {
    super(subject, binaryType, ruleDefinition, ModelReference.of("binaries", BinaryContainer.class));
    this.binaryType = binaryType;
    this.modelRegistry = modelRegistry;
}
 
Example 11
Source File: ComponentBinariesRuleDefinitionHandler.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public ComponentBinariesRule(ModelReference<BinaryContainer> subject, final Class<? extends ComponentSpec> componentType, final Class<S> binaryType, MethodRuleDefinition<R> ruleDefinition, ModelRegistry modelRegistry) {
    super(subject, componentType, ruleDefinition, ModelReference.of("componentSpecs", ComponentSpecContainer.class));
    this.componentType = componentType;
    this.binaryType = binaryType;
    this.modelRegistry = modelRegistry;
}
 
Example 12
Source File: BinaryTasksRuleDefinitionHandler.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public BinaryTaskRule(ModelReference<TaskContainer> subject, final Class<T> binaryType, MethodRuleDefinition<R> ruleDefinition, ModelRegistry modelRegistry) {
    super(subject, binaryType, ruleDefinition, ModelReference.of("binaries", BinaryContainer.class));
    this.binaryType = binaryType;
    this.modelRegistry = modelRegistry;
}