Search in sources :

Example 1 with ComponentWithOutputs

use of org.gradle.language.ComponentWithOutputs in project gradle by gradle.

the class NativeBasePlugin method addLifecycleTasks.

private void addLifecycleTasks(final TaskContainer tasks, final SoftwareComponentContainer components) {
    components.withType(ComponentWithBinaries.class, new Action<ComponentWithBinaries>() {

        @Override
        public void execute(final ComponentWithBinaries component) {
            // Register each child of each component
            component.getBinaries().whenElementKnown(new Action<SoftwareComponent>() {

                @Override
                public void execute(SoftwareComponent binary) {
                    components.add(binary);
                }
            });
            if (component instanceof ProductionComponent) {
                // Add an assemble task for each binary and also wire the development binary in to the `assemble` task
                component.getBinaries().whenElementFinalized(ComponentWithOutputs.class, new Action<ComponentWithOutputs>() {

                    @Override
                    public void execute(ComponentWithOutputs binary) {
                        // Determine which output to produce at development time.
                        FileCollection outputs = binary.getOutputs();
                        Names names = ((ComponentWithNames) binary).getNames();
                        Task lifecycleTask = tasks.create(names.getTaskName("assemble"));
                        lifecycleTask.dependsOn(outputs);
                        if (binary == ((ProductionComponent) component).getDevelopmentBinary().get()) {
                            tasks.getByName(LifecycleBasePlugin.ASSEMBLE_TASK_NAME).dependsOn(outputs);
                        }
                    }
                });
            }
        }
    });
}
Also used : ComponentWithNames(org.gradle.language.nativeplatform.internal.ComponentWithNames) Names(org.gradle.language.nativeplatform.internal.Names) Action(org.gradle.api.Action) Task(org.gradle.api.Task) AbstractLinkTask(org.gradle.nativeplatform.tasks.AbstractLinkTask) ComponentWithBinaries(org.gradle.language.ComponentWithBinaries) ComponentWithOutputs(org.gradle.language.ComponentWithOutputs) ProductionComponent(org.gradle.language.ProductionComponent) FileCollection(org.gradle.api.file.FileCollection) ComponentWithNames(org.gradle.language.nativeplatform.internal.ComponentWithNames) SoftwareComponent(org.gradle.api.component.SoftwareComponent)

Aggregations

Action (org.gradle.api.Action)1 Task (org.gradle.api.Task)1 SoftwareComponent (org.gradle.api.component.SoftwareComponent)1 FileCollection (org.gradle.api.file.FileCollection)1 ComponentWithBinaries (org.gradle.language.ComponentWithBinaries)1 ComponentWithOutputs (org.gradle.language.ComponentWithOutputs)1 ProductionComponent (org.gradle.language.ProductionComponent)1 ComponentWithNames (org.gradle.language.nativeplatform.internal.ComponentWithNames)1 Names (org.gradle.language.nativeplatform.internal.Names)1 AbstractLinkTask (org.gradle.nativeplatform.tasks.AbstractLinkTask)1