Search in sources :

Example 1 with SimpleModelRuleDescriptor

use of org.gradle.model.internal.core.rule.describe.SimpleModelRuleDescriptor in project gradle by gradle.

the class DefaultTaskContainer method addPlaceholderAction.

public <T extends TaskInternal> void addPlaceholderAction(final String placeholderName, final Class<T> taskType, final Action<? super T> configure) {
    if (!modelNode.hasLink(placeholderName)) {
        final ModelType<T> taskModelType = ModelType.of(taskType);
        ModelPath path = MODEL_PATH.child(placeholderName);
        modelNode.addLink(ModelRegistrations.of(path).action(ModelActionRole.Create, new TaskCreator<T>(placeholderName, taskType, configure, taskModelType)).withProjection(new UnmanagedModelProjection<T>(taskModelType)).descriptor(new SimpleModelRuleDescriptor("tasks.addPlaceholderAction(" + placeholderName + ")")).build());
    }
    if (findByNameWithoutRules(placeholderName) == null) {
        placeholders.add(placeholderName);
    }
}
Also used : ModelPath(org.gradle.model.internal.core.ModelPath) UnmanagedModelProjection(org.gradle.model.internal.core.UnmanagedModelProjection) SimpleModelRuleDescriptor(org.gradle.model.internal.core.rule.describe.SimpleModelRuleDescriptor)

Example 2 with SimpleModelRuleDescriptor

use of org.gradle.model.internal.core.rule.describe.SimpleModelRuleDescriptor in project gradle by gradle.

the class TestNativeBinariesFactory method create.

public static <T extends NativeBinarySpec, I extends AbstractNativeBinarySpec> T create(Class<T> publicType, Class<I> implType, String name, ITaskFactory taskFactory, MutableModelNode componentNode, BinaryNamingScheme namingScheme, NativeDependencyResolver resolver, NativePlatform platform, BuildType buildType, Flavor flavor) {
    T binary = BaseBinaryFixtures.create(publicType, implType, name, componentNode, taskFactory);
    NativeBinaries.initialize(binary, namingScheme, resolver, TestFiles.fileCollectionFactory(), platform, buildType, flavor);
    SourceComponentSpec component = componentNode.asImmutable(ModelType.of(SourceComponentSpec.class), new SimpleModelRuleDescriptor("get component of " + name)).getInstance();
    binary.getInputs().addAll(component.getSources().values());
    return binary;
}
Also used : SimpleModelRuleDescriptor(org.gradle.model.internal.core.rule.describe.SimpleModelRuleDescriptor) SourceComponentSpec(org.gradle.platform.base.SourceComponentSpec)

Example 3 with SimpleModelRuleDescriptor

use of org.gradle.model.internal.core.rule.describe.SimpleModelRuleDescriptor in project gradle by gradle.

the class NonTransformedModelDslBacking method register.

private <T> void register(Class<T> type, Action<? super T> action) {
    ModelRuleDescriptor descriptor = new SimpleModelRuleDescriptor("model." + modelPath);
    NodeInitializerRegistry nodeInitializerRegistry = modelRegistry.realize(DEFAULT_REFERENCE.getPath(), DEFAULT_REFERENCE.getType());
    ModelType<T> modelType = ModelType.of(type);
    NodeInitializer nodeInitializer = nodeInitializerRegistry.getNodeInitializer(forType(modelType));
    modelRegistry.register(ModelRegistrations.of(modelPath, nodeInitializer).descriptor(descriptor).action(ModelActionRole.Initialize, NoInputsModelAction.of(ModelReference.of(modelPath, modelType), descriptor, action)).build());
}
Also used : NodeInitializer(org.gradle.model.internal.core.NodeInitializer) NodeInitializerRegistry(org.gradle.model.internal.core.NodeInitializerRegistry) SimpleModelRuleDescriptor(org.gradle.model.internal.core.rule.describe.SimpleModelRuleDescriptor) ModelRuleDescriptor(org.gradle.model.internal.core.rule.describe.ModelRuleDescriptor) SimpleModelRuleDescriptor(org.gradle.model.internal.core.rule.describe.SimpleModelRuleDescriptor)

Aggregations

SimpleModelRuleDescriptor (org.gradle.model.internal.core.rule.describe.SimpleModelRuleDescriptor)3 ModelPath (org.gradle.model.internal.core.ModelPath)1 NodeInitializer (org.gradle.model.internal.core.NodeInitializer)1 NodeInitializerRegistry (org.gradle.model.internal.core.NodeInitializerRegistry)1 UnmanagedModelProjection (org.gradle.model.internal.core.UnmanagedModelProjection)1 ModelRuleDescriptor (org.gradle.model.internal.core.rule.describe.ModelRuleDescriptor)1 SourceComponentSpec (org.gradle.platform.base.SourceComponentSpec)1