org.gradle.language.base.plugins.ComponentModelBasePlugin Java Examples

The following examples show how to use org.gradle.language.base.plugins.ComponentModelBasePlugin. 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: JvmComponentPlugin.java    License: BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void apply(final Project project) {
    project.getPlugins().apply(ComponentModelBasePlugin.class);

    ComponentSpecContainer componentSpecs = project.getExtensions().getByType(ComponentSpecContainer.class);

    final ProjectSourceSet sources = project.getExtensions().getByType(ProjectSourceSet.class);
    componentSpecs.registerFactory(JvmLibrarySpec.class, new NamedDomainObjectFactory<JvmLibrarySpec>() {
        public JvmLibrarySpec create(String name) {
            ComponentSpecIdentifier id = new DefaultComponentSpecIdentifier(project.getPath(), name);
            return new DefaultJvmLibrarySpec(id, sources.maybeCreate(name));
        }
    });

    final NamedDomainObjectContainer<JvmLibrarySpec> jvmLibraries = componentSpecs.containerWithType(JvmLibrarySpec.class);
    project.getExtensions().create("jvm", DefaultJvmComponentExtension.class, jvmLibraries);
}
 
Example #2
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 #3
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 #4
Source Project: pushfish-android   Author: PushFish   File: NativeComponentModelPlugin.java    License: BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void apply(final ProjectInternal project) {
    project.getPlugins().apply(ComponentModelBasePlugin.class);

    ProjectSourceSet sources = project.getExtensions().getByType(ProjectSourceSet.class);
    ComponentSpecContainer components = project.getExtensions().getByType(ComponentSpecContainer.class);
    components.registerFactory(NativeExecutableSpec.class, new NativeExecutableSpecFactory(instantiator, sources, project));
    NamedDomainObjectContainer<NativeExecutableSpec> nativeExecutables = components.containerWithType(NativeExecutableSpec.class);

    components.registerFactory(NativeLibrarySpec.class, new NativeLibrarySpecFactory(instantiator, sources, project));
    NamedDomainObjectContainer<NativeLibrarySpec> nativeLibraries = components.containerWithType(NativeLibrarySpec.class);

    project.getExtensions().create("nativeRuntime", DefaultNativeComponentExtension.class, nativeExecutables, nativeLibraries);

    // TODO:DAZ Remove these: should not pollute the global namespace
    project.getExtensions().add("nativeComponents", components.withType(NativeComponentSpec.class));
    project.getExtensions().add("executables", nativeExecutables);
    project.getExtensions().add("libraries", nativeLibraries);
}
 
Example #5
Source Project: Pushjet-Android   Author: Pushjet   File: JvmComponentPlugin.java    License: BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void apply(final Project project) {
    project.getPlugins().apply(ComponentModelBasePlugin.class);

    ComponentSpecContainer componentSpecs = project.getExtensions().getByType(ComponentSpecContainer.class);

    final ProjectSourceSet sources = project.getExtensions().getByType(ProjectSourceSet.class);
    componentSpecs.registerFactory(JvmLibrarySpec.class, new NamedDomainObjectFactory<JvmLibrarySpec>() {
        public JvmLibrarySpec create(String name) {
            ComponentSpecIdentifier id = new DefaultComponentSpecIdentifier(project.getPath(), name);
            return new DefaultJvmLibrarySpec(id, sources.maybeCreate(name));
        }
    });

    final NamedDomainObjectContainer<JvmLibrarySpec> jvmLibraries = componentSpecs.containerWithType(JvmLibrarySpec.class);
    project.getExtensions().create("jvm", DefaultJvmComponentExtension.class, jvmLibraries);
}
 
Example #6
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 #7
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 #8
Source Project: Pushjet-Android   Author: Pushjet   File: NativeComponentModelPlugin.java    License: BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void apply(final ProjectInternal project) {
    project.getPlugins().apply(ComponentModelBasePlugin.class);

    ProjectSourceSet sources = project.getExtensions().getByType(ProjectSourceSet.class);
    ComponentSpecContainer components = project.getExtensions().getByType(ComponentSpecContainer.class);
    components.registerFactory(NativeExecutableSpec.class, new NativeExecutableSpecFactory(instantiator, sources, project));
    NamedDomainObjectContainer<NativeExecutableSpec> nativeExecutables = components.containerWithType(NativeExecutableSpec.class);

    components.registerFactory(NativeLibrarySpec.class, new NativeLibrarySpecFactory(instantiator, sources, project));
    NamedDomainObjectContainer<NativeLibrarySpec> nativeLibraries = components.containerWithType(NativeLibrarySpec.class);

    project.getExtensions().create("nativeRuntime", DefaultNativeComponentExtension.class, nativeExecutables, nativeLibraries);

    // TODO:DAZ Remove these: should not pollute the global namespace
    project.getExtensions().add("nativeComponents", components.withType(NativeComponentSpec.class));
    project.getExtensions().add("executables", nativeExecutables);
    project.getExtensions().add("libraries", nativeLibraries);
}
 
Example #9
public <R> void register(MethodRuleDefinition<R> ruleDefinition, ModelRegistry modelRegistry, RuleSourceDependencies dependencies) {
    try {
        ModelType<? extends T> type = readType(ruleDefinition);
        ModelType<? extends U> implementation = determineImplementationType(ruleDefinition, type);

        dependencies.add(ComponentModelBasePlugin.class);
        if (implementation != null) {
            ModelMutator<?> mutator = new RegisterTypeRule<T, U>(type, implementation, ruleDefinition.getDescriptor(), registerer);
            modelRegistry.mutate(mutator);
        }
    } catch (InvalidComponentModelException e) {
        invalidModelRule(ruleDefinition, e);
    }
}
 
Example #10
public <R> void register(MethodRuleDefinition<R> ruleDefinition, ModelRegistry modelRegistry, RuleSourceDependencies dependencies) {
    try {
        ModelType<? extends T> type = readType(ruleDefinition);
        ModelType<? extends U> implementation = determineImplementationType(ruleDefinition, type);

        dependencies.add(ComponentModelBasePlugin.class);
        if (implementation != null) {
            ModelMutator<?> mutator = new RegisterTypeRule<T, U>(type, implementation, ruleDefinition.getDescriptor(), registerer);
            modelRegistry.mutate(mutator);
        }
    } catch (InvalidComponentModelException e) {
        invalidModelRule(ruleDefinition, e);
    }
}
 
Example #11
Source Project: pushfish-android   Author: PushFish   File: JvmResourcesPlugin.java    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void apply(final Project project) {
    project.getPlugins().apply(ComponentModelBasePlugin.class);
    project.getExtensions().getByType(LanguageRegistry.class).add(new JvmResources());
}
 
Example #12
Source Project: pushfish-android   Author: PushFish   File: JavaLanguagePlugin.java    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void apply(ProjectInternal project) {
    project.getPlugins().apply(ComponentModelBasePlugin.class);
    project.getPlugins().apply(JvmResourcesPlugin.class);
    project.getExtensions().getByType(LanguageRegistry.class).add(new Java());
}
 
Example #13
Source Project: pushfish-android   Author: PushFish   File: ObjectiveCLangPlugin.java    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void apply(final ProjectInternal project) {

        project.getPlugins().apply(ComponentModelBasePlugin.class);
        project.getExtensions().getByType(LanguageRegistry.class).add(new ObjectiveC());
    }
 
Example #14
Source Project: pushfish-android   Author: PushFish   File: WindowsResourceScriptPlugin.java    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void apply(final ProjectInternal project) {
    project.getPlugins().apply(ComponentModelBasePlugin.class);
    project.getExtensions().getByType(LanguageRegistry.class).add(new WindowsResources());
}
 
Example #15
Source Project: pushfish-android   Author: PushFish   File: CppLangPlugin.java    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void apply(final ProjectInternal project) {

        project.getPlugins().apply(ComponentModelBasePlugin.class);
        project.getExtensions().getByType(LanguageRegistry.class).add(new Cpp());
   }
 
Example #16
Source Project: pushfish-android   Author: PushFish   File: CLangPlugin.java    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void apply(final ProjectInternal project) {

        project.getPlugins().apply(ComponentModelBasePlugin.class);
        project.getExtensions().getByType(LanguageRegistry.class).add(new C());
    }
 
Example #17
Source Project: pushfish-android   Author: PushFish   File: AssemblerLangPlugin.java    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void apply(ProjectInternal project) {
    project.getPlugins().apply(ComponentModelBasePlugin.class);
    project.getExtensions().getByType(LanguageRegistry.class).add(new Assembler());
}
 
Example #18
Source Project: pushfish-android   Author: PushFish   File: ObjectiveCppLangPlugin.java    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void apply(final ProjectInternal project) {

        project.getPlugins().apply(ComponentModelBasePlugin.class);
        project.getExtensions().getByType(LanguageRegistry.class).add(new ObjectiveCpp());
    }
 
Example #19
Source Project: javaide   Author: tranleduy2000   File: AndroidComponentModelPlugin.java    License: GNU General Public License v3.0 4 votes vote down vote up
@Override
public void apply(Project project) {
    checkGradleVersion(project);
    project.getPlugins().apply(ComponentModelBasePlugin.class);
}
 
Example #20
Source Project: Pushjet-Android   Author: Pushjet   File: JvmResourcesPlugin.java    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void apply(final Project project) {
    project.getPlugins().apply(ComponentModelBasePlugin.class);
    project.getExtensions().getByType(LanguageRegistry.class).add(new JvmResources());
}
 
Example #21
Source Project: Pushjet-Android   Author: Pushjet   File: JavaLanguagePlugin.java    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void apply(ProjectInternal project) {
    project.getPlugins().apply(ComponentModelBasePlugin.class);
    project.getPlugins().apply(JvmResourcesPlugin.class);
    project.getExtensions().getByType(LanguageRegistry.class).add(new Java());
}
 
Example #22
Source Project: Pushjet-Android   Author: Pushjet   File: ObjectiveCLangPlugin.java    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void apply(final ProjectInternal project) {

        project.getPlugins().apply(ComponentModelBasePlugin.class);
        project.getExtensions().getByType(LanguageRegistry.class).add(new ObjectiveC());
    }
 
Example #23
Source Project: Pushjet-Android   Author: Pushjet   File: WindowsResourceScriptPlugin.java    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void apply(final ProjectInternal project) {
    project.getPlugins().apply(ComponentModelBasePlugin.class);
    project.getExtensions().getByType(LanguageRegistry.class).add(new WindowsResources());
}
 
Example #24
Source Project: Pushjet-Android   Author: Pushjet   File: CppLangPlugin.java    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void apply(final ProjectInternal project) {

        project.getPlugins().apply(ComponentModelBasePlugin.class);
        project.getExtensions().getByType(LanguageRegistry.class).add(new Cpp());
   }
 
Example #25
Source Project: Pushjet-Android   Author: Pushjet   File: CLangPlugin.java    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void apply(final ProjectInternal project) {

        project.getPlugins().apply(ComponentModelBasePlugin.class);
        project.getExtensions().getByType(LanguageRegistry.class).add(new C());
    }
 
Example #26
Source Project: Pushjet-Android   Author: Pushjet   File: AssemblerLangPlugin.java    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void apply(ProjectInternal project) {
    project.getPlugins().apply(ComponentModelBasePlugin.class);
    project.getExtensions().getByType(LanguageRegistry.class).add(new Assembler());
}
 
Example #27
Source Project: Pushjet-Android   Author: Pushjet   File: ObjectiveCppLangPlugin.java    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void apply(final ProjectInternal project) {

        project.getPlugins().apply(ComponentModelBasePlugin.class);
        project.getExtensions().getByType(LanguageRegistry.class).add(new ObjectiveCpp());
    }