Java Code Examples for org.gradle.platform.base.BinaryContainer#withType()

The following examples show how to use org.gradle.platform.base.BinaryContainer#withType() . 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: LanguageBasePlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Mutate
void createLifecycleTaskForBinary(TaskContainer tasks, BinaryContainer binaries) {
    Task assembleTask = tasks.getByName(LifecycleBasePlugin.ASSEMBLE_TASK_NAME);
    for (BinarySpecInternal binary : binaries.withType(BinarySpecInternal.class)) {
        if (!binary.isLegacyBinary()) {
            Task binaryLifecycleTask = tasks.create(binary.getNamingScheme().getLifecycleTaskName());
            binaryLifecycleTask.setGroup(LifecycleBasePlugin.BUILD_GROUP);
            binaryLifecycleTask.setDescription(String.format("Assembles %s.", binary));
            binary.setBuildTask(binaryLifecycleTask);

            if (binary.isBuildable()) {
                assembleTask.dependsOn(binary);
            }
        }
    }
}
 
Example 2
Source File: NativeBinariesTestPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Finalize
public void createTestTasks(final TaskContainer tasks, BinaryContainer binaries) {
    for (NativeTestSuiteBinarySpec testBinary : binaries.withType(NativeTestSuiteBinarySpec.class)) {
        NativeBinarySpecInternal binary = (NativeBinarySpecInternal) testBinary;
        final BinaryNamingScheme namingScheme = binary.getNamingScheme();

        RunTestExecutable runTask = tasks.create(namingScheme.getTaskName("run"), RunTestExecutable.class);
        final Project project = runTask.getProject();
        runTask.setDescription(String.format("Runs the %s", binary.getNamingScheme().getDescription()));

        final InstallExecutable installTask = binary.getTasks().withType(InstallExecutable.class).iterator().next();
        runTask.getInputs().files(installTask.getOutputs().getFiles());
        runTask.setExecutable(installTask.getRunScript().getPath());
        runTask.setOutputDir(new File(project.getBuildDir(), "/test-results/" + namingScheme.getOutputDirectoryBase()));
    }
}
 
Example 3
Source File: BaseComponentModelPlugin.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
public void createBinaryTasks(
        final ModelMap<Task> tasks,
        BinaryContainer binaries,
        ModelMap<AndroidComponentSpec> specs,
        TaskManager taskManager) {
    final VariantManager variantManager =
            ((DefaultAndroidComponentSpec) specs.get(COMPONENT_NAME)).getVariantManager();
    binaries.withType(AndroidBinary.class, new Action<AndroidBinary>() {
        @Override
        public void execute(AndroidBinary androidBinary) {
            DefaultAndroidBinary binary = (DefaultAndroidBinary) androidBinary;
            variantManager.createTasksForVariantData(
                    new TaskModelMapAdaptor(tasks),
                    binary.getVariantData());
        }
    });
}
 
Example 4
Source File: LanguageBasePlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Mutate
void createLifecycleTaskForBinary(TaskContainer tasks, BinaryContainer binaries) {
    Task assembleTask = tasks.getByName(LifecycleBasePlugin.ASSEMBLE_TASK_NAME);
    for (BinarySpecInternal binary : binaries.withType(BinarySpecInternal.class)) {
        if (!binary.isLegacyBinary()) {
            Task binaryLifecycleTask = tasks.create(binary.getNamingScheme().getLifecycleTaskName());
            binaryLifecycleTask.setGroup(LifecycleBasePlugin.BUILD_GROUP);
            binaryLifecycleTask.setDescription(String.format("Assembles %s.", binary));
            binary.setBuildTask(binaryLifecycleTask);

            if (binary.isBuildable()) {
                assembleTask.dependsOn(binary);
            }
        }
    }
}
 
Example 5
Source File: NativeBinariesTestPlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Finalize
public void createTestTasks(final TaskContainer tasks, BinaryContainer binaries) {
    for (NativeTestSuiteBinarySpec testBinary : binaries.withType(NativeTestSuiteBinarySpec.class)) {
        NativeBinarySpecInternal binary = (NativeBinarySpecInternal) testBinary;
        final BinaryNamingScheme namingScheme = binary.getNamingScheme();

        RunTestExecutable runTask = tasks.create(namingScheme.getTaskName("run"), RunTestExecutable.class);
        final Project project = runTask.getProject();
        runTask.setDescription(String.format("Runs the %s", binary.getNamingScheme().getDescription()));

        final InstallExecutable installTask = binary.getTasks().withType(InstallExecutable.class).iterator().next();
        runTask.getInputs().files(installTask.getOutputs().getFiles());
        runTask.setExecutable(installTask.getRunScript().getPath());
        runTask.setOutputDir(new File(project.getBuildDir(), "/test-results/" + namingScheme.getOutputDirectoryBase()));
    }
}
 
Example 6
Source File: JvmComponentPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Mutate
public void createTasks(TaskContainer tasks, BinaryContainer binaries) {
    for (JarBinarySpecInternal projectJarBinary : binaries.withType(JarBinarySpecInternal.class)) {
        Task jarTask = createJarTask(tasks, projectJarBinary);
        projectJarBinary.builtBy(jarTask);
        projectJarBinary.getTasks().add(jarTask);
    }
}
 
Example 7
Source File: BinaryTasksRuleDefinitionHandler.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void mutate(TaskContainer container, Inputs inputs) {
    BinaryContainer binaries = inputs.get(0, ModelType.of(BinaryContainer.class)).getInstance();
    for (T binary : binaries.withType(binaryType)) {
        NamedEntityInstantiator<Task> instantiator = new Instantiator<Task>(binary, container);
        DefaultCollectionBuilder<Task> collectionBuilder = new DefaultCollectionBuilder<Task>(
                getSubject().getPath(),
                instantiator,
                new SimpleModelRuleDescriptor("Project.<init>.tasks()"),
                inputs,
                modelRegistry);

        invoke(inputs, collectionBuilder, binary, binaries);
    }
}
 
Example 8
Source File: VisualStudioPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Mutate
@SuppressWarnings("GroovyUnusedDeclaration")
public static void createVisualStudioModelForBinaries(VisualStudioExtensionInternal visualStudioExtension, BinaryContainer binaryContainer) {
    for (NativeBinarySpec binary : binaryContainer.withType(NativeBinarySpec.class)) {
        VisualStudioProjectConfiguration configuration = visualStudioExtension.getProjectRegistry().addProjectConfiguration(binary);

        // Only create a solution if one of the binaries is buildable
        if (binary.isBuildable()) {
            DefaultVisualStudioProject visualStudioProject = configuration.getProject();
            visualStudioExtension.getSolutionRegistry().addSolution(visualStudioProject);
        }
    }
}
 
Example 9
Source File: NativeBinariesTestPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Finalize // Must run after test binaries have been created (currently in CUnit plugin)
void attachTestedBinarySourcesToTestBinaries(BinaryContainer binaries) {
    for (NativeTestSuiteBinarySpec testSuiteBinary : binaries.withType(NativeTestSuiteBinarySpec.class)) {
        NativeBinarySpec testedBinary = testSuiteBinary.getTestedBinary();
        testSuiteBinary.source(testedBinary.getSource());

        for (DependentSourceSet testSource : testSuiteBinary.getSource().withType(DependentSourceSet.class)) {
            testSource.lib(testedBinary.getSource());
        }
    }
}
 
Example 10
Source File: JvmComponentPlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Mutate
public void createTasks(TaskContainer tasks, BinaryContainer binaries) {
    for (JarBinarySpecInternal projectJarBinary : binaries.withType(JarBinarySpecInternal.class)) {
        Task jarTask = createJarTask(tasks, projectJarBinary);
        projectJarBinary.builtBy(jarTask);
        projectJarBinary.getTasks().add(jarTask);
    }
}
 
Example 11
Source File: BinaryTasksRuleDefinitionHandler.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void mutate(TaskContainer container, Inputs inputs) {
    BinaryContainer binaries = inputs.get(0, ModelType.of(BinaryContainer.class)).getInstance();
    for (T binary : binaries.withType(binaryType)) {
        NamedEntityInstantiator<Task> instantiator = new Instantiator<Task>(binary, container);
        DefaultCollectionBuilder<Task> collectionBuilder = new DefaultCollectionBuilder<Task>(
                getSubject().getPath(),
                instantiator,
                new SimpleModelRuleDescriptor("Project.<init>.tasks()"),
                inputs,
                modelRegistry);

        invoke(inputs, collectionBuilder, binary, binaries);
    }
}
 
Example 12
Source File: VisualStudioPlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Mutate
@SuppressWarnings("GroovyUnusedDeclaration")
public static void createVisualStudioModelForBinaries(VisualStudioExtensionInternal visualStudioExtension, BinaryContainer binaryContainer) {
    for (NativeBinarySpec binary : binaryContainer.withType(NativeBinarySpec.class)) {
        VisualStudioProjectConfiguration configuration = visualStudioExtension.getProjectRegistry().addProjectConfiguration(binary);

        // Only create a solution if one of the binaries is buildable
        if (binary.isBuildable()) {
            DefaultVisualStudioProject visualStudioProject = configuration.getProject();
            visualStudioExtension.getSolutionRegistry().addSolution(visualStudioProject);
        }
    }
}
 
Example 13
Source File: NativeBinariesTestPlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Finalize // Must run after test binaries have been created (currently in CUnit plugin)
void attachTestedBinarySourcesToTestBinaries(BinaryContainer binaries) {
    for (NativeTestSuiteBinarySpec testSuiteBinary : binaries.withType(NativeTestSuiteBinarySpec.class)) {
        NativeBinarySpec testedBinary = testSuiteBinary.getTestedBinary();
        testSuiteBinary.source(testedBinary.getSource());

        for (DependentSourceSet testSource : testSuiteBinary.getSource().withType(DependentSourceSet.class)) {
            testSource.lib(testedBinary.getSource());
        }
    }
}