Java Code Examples for org.gradle.api.tasks.TaskContainer#register()

The following examples show how to use org.gradle.api.tasks.TaskContainer#register() . 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: CMakeApplicationPlugin.java    From native-samples with Apache License 2.0 5 votes vote down vote up
public void apply(final Project project) {
    project.getPluginManager().apply("org.gradle.samples.wrapped-native-application");

    /*
     * Create some tasks to drive the CMake build
     */
    TaskContainer tasks = project.getTasks();

    TaskProvider<CMake> cmakeDebug = tasks.register("cmakeDebug", CMake.class, task -> {
        task.setBuildType("Debug");
        task.getIncludeDirs().from(project.getConfigurations().getByName("cppCompile"));
        task.getLinkFiles().from(project.getConfigurations().getByName("linkDebug"));
        task.getVariantDirectory().set(project.getLayout().getBuildDirectory().dir("debug"));
        task.getProjectDirectory().set(project.getLayout().getProjectDirectory());
    });

    TaskProvider<CMake> cmakeRelease = tasks.register("cmakeRelease", CMake.class, task -> {
        task.setBuildType("RelWithDebInfo");
        task.getIncludeDirs().from(project.getConfigurations().getByName("cppCompile"));
        task.getLinkFiles().from(project.getConfigurations().getByName("linkRelease"));
        task.getVariantDirectory().set(project.getLayout().getBuildDirectory().dir("release"));
        task.getProjectDirectory().set(project.getLayout().getProjectDirectory());
    });

    TaskProvider<Make> assembleDebug = tasks.register("assembleDebug", Make.class, task -> {
        task.setGroup("Build");
        task.setDescription("Builds the debug binaries");
        task.generatedBy(cmakeDebug);
        task.binary(project.provider(() -> project.getName()));
    });

    TaskProvider<Make> assembleRelease = tasks.register("assembleRelease", Make.class, task -> {
        task.setGroup("Build");
        task.setDescription("Builds the release binaries");
        task.generatedBy(cmakeRelease);
        task.binary(project.provider(() -> project.getName()));
    });

    tasks.named("assemble", task -> task.dependsOn(assembleDebug));
}
 
Example 2
Source File: CMakeApplicationPlugin.java    From native-samples with Apache License 2.0 5 votes vote down vote up
public void apply(final Project project) {
    project.getPluginManager().apply("org.gradle.samples.wrapped-native-application");

    /*
     * Create some tasks to drive the CMake build
     */
    TaskContainer tasks = project.getTasks();

    TaskProvider<CMake> cmakeDebug = tasks.register("cmakeDebug", CMake.class, task -> {
        task.setBuildType("Debug");
        task.getIncludeDirs().from(project.getConfigurations().getByName("cppCompile"));
        task.getLinkFiles().from(project.getConfigurations().getByName("linkDebug"));
        task.getVariantDirectory().set(project.getLayout().getBuildDirectory().dir("debug"));
        task.getProjectDirectory().set(project.getLayout().getProjectDirectory());
    });

    TaskProvider<CMake> cmakeRelease = tasks.register("cmakeRelease", CMake.class, task -> {
        task.setBuildType("RelWithDebInfo");
        task.getIncludeDirs().from(project.getConfigurations().getByName("cppCompile"));
        task.getLinkFiles().from(project.getConfigurations().getByName("linkRelease"));
        task.getVariantDirectory().set(project.getLayout().getBuildDirectory().dir("release"));
        task.getProjectDirectory().set(project.getLayout().getProjectDirectory());
    });

    TaskProvider<Make> assembleDebug = tasks.register("assembleDebug", Make.class, task -> {
        task.setGroup("Build");
        task.setDescription("Builds the debug binaries");
        task.generatedBy(cmakeDebug);
        task.binary(project.provider(() -> project.getName()));
    });

    TaskProvider<Make> assembleRelease = tasks.register("assembleRelease", Make.class, task -> {
        task.setGroup("Build");
        task.setDescription("Builds the release binaries");
        task.generatedBy(cmakeRelease);
        task.binary(project.provider(() -> project.getName()));
    });

    tasks.named("assemble", task -> task.dependsOn(assembleDebug));
}
 
Example 3
Source File: CppPublicMacrosPlugin.java    From native-samples with Apache License 2.0 5 votes vote down vote up
private static TaskProvider<GeneratePublicMacrosManifest> createTask(TaskContainer tasks) {
    return tasks.register("generatePublicMacros", GeneratePublicMacrosManifest.class, new Action<GeneratePublicMacrosManifest>() {
        @Override
        public void execute(GeneratePublicMacrosManifest task) {
            task.getOutputFile().set(new File(task.getTemporaryDir(), "public-macros.txt"));
        }
    });
}
 
Example 4
Source File: CppHeaderLibraryPlugin.java    From native-samples with Apache License 2.0 5 votes vote down vote up
private static TaskProvider<GenerateDummyCppSource> createTask(TaskContainer tasks, Project project) {
    return tasks.register("generateCppHeaderSourceFile", GenerateDummyCppSource.class, (task) -> {
        Provider<RegularFile> sourceFile = project.getLayout().getBuildDirectory().file("dummy-source.cpp");
        task.getOutputFile().set(sourceFile);
        task.getSymbolName().set("__" + toSymbol(project.getPath()) + "_" + toSymbol(project.getName()) + "__");
    });
}
 
Example 5
Source File: CMakeApplicationPlugin.java    From native-samples with Apache License 2.0 5 votes vote down vote up
public void apply(final Project project) {
    project.getPluginManager().apply("org.gradle.samples.wrapped-native-application");

    /*
     * Create some tasks to drive the CMake build
     */
    TaskContainer tasks = project.getTasks();

    TaskProvider<CMake> cmakeDebug = tasks.register("cmakeDebug", CMake.class, task -> {
        task.setBuildType("Debug");
        task.getIncludeDirs().from(project.getConfigurations().getByName("cppCompile"));
        task.getLinkFiles().from(project.getConfigurations().getByName("linkDebug"));
        task.getVariantDirectory().set(project.getLayout().getBuildDirectory().dir("debug"));
        task.getProjectDirectory().set(project.getLayout().getProjectDirectory());
    });

    TaskProvider<CMake> cmakeRelease = tasks.register("cmakeRelease", CMake.class, task -> {
        task.setBuildType("RelWithDebInfo");
        task.getIncludeDirs().from(project.getConfigurations().getByName("cppCompile"));
        task.getLinkFiles().from(project.getConfigurations().getByName("linkRelease"));
        task.getVariantDirectory().set(project.getLayout().getBuildDirectory().dir("release"));
        task.getProjectDirectory().set(project.getLayout().getProjectDirectory());
    });

    TaskProvider<Make> assembleDebug = tasks.register("assembleDebug", Make.class, task -> {
        task.setGroup("Build");
        task.setDescription("Builds the debug binaries");
        task.generatedBy(cmakeDebug);
        task.binary(project.provider(() -> project.getName()));
    });

    TaskProvider<Make> assembleRelease = tasks.register("assembleRelease", Make.class, task -> {
        task.setGroup("Build");
        task.setDescription("Builds the release binaries");
        task.generatedBy(cmakeRelease);
        task.binary(project.provider(() -> project.getName()));
    });

    tasks.named("assemble", task -> task.dependsOn(assembleDebug));
}
 
Example 6
Source File: CMakeApplicationPlugin.java    From native-samples with Apache License 2.0 5 votes vote down vote up
public void apply(final Project project) {
    project.getPluginManager().apply("org.gradle.samples.wrapped-native-application");

    /*
     * Create some tasks to drive the CMake build
     */
    TaskContainer tasks = project.getTasks();

    TaskProvider<CMake> cmakeDebug = tasks.register("cmakeDebug", CMake.class, task -> {
        task.setBuildType("Debug");
        task.getIncludeDirs().from(project.getConfigurations().getByName("cppCompile"));
        task.getLinkFiles().from(project.getConfigurations().getByName("linkDebug"));
        task.getVariantDirectory().set(project.getLayout().getBuildDirectory().dir("debug"));
        task.getProjectDirectory().set(project.getLayout().getProjectDirectory());
    });

    TaskProvider<CMake> cmakeRelease = tasks.register("cmakeRelease", CMake.class, task -> {
        task.setBuildType("RelWithDebInfo");
        task.getIncludeDirs().from(project.getConfigurations().getByName("cppCompile"));
        task.getLinkFiles().from(project.getConfigurations().getByName("linkRelease"));
        task.getVariantDirectory().set(project.getLayout().getBuildDirectory().dir("release"));
        task.getProjectDirectory().set(project.getLayout().getProjectDirectory());
    });

    TaskProvider<Make> assembleDebug = tasks.register("assembleDebug", Make.class, task -> {
        task.setGroup("Build");
        task.setDescription("Builds the debug binaries");
        task.generatedBy(cmakeDebug);
        task.binary(project.provider(() -> project.getName()));
    });

    TaskProvider<Make> assembleRelease = tasks.register("assembleRelease", Make.class, task -> {
        task.setGroup("Build");
        task.setDescription("Builds the release binaries");
        task.generatedBy(cmakeRelease);
        task.binary(project.provider(() -> project.getName()));
    });

    tasks.named("assemble", task -> task.dependsOn(assembleDebug));
}
 
Example 7
Source File: CMakeLibraryPlugin.java    From native-samples with Apache License 2.0 4 votes vote down vote up
public void apply(final Project project) {
    project.getPluginManager().apply("org.gradle.samples.wrapped-native-library");

    // Add a CMake extension to the Gradle model
    final CMakeExtension extension = project.getExtensions().create("cmake", CMakeExtension.class, project.getLayout(), project.getObjects());

    /*
     * Create some tasks to drive the CMake build
     */
    TaskContainer tasks = project.getTasks();

    final TaskProvider<CMake> cmakeDebug = tasks.register("cmakeDebug", CMake.class, task -> {
            task.setBuildType("Debug");
            task.getIncludeDirs().from(project.getConfigurations().getByName("cppCompile"));
            task.getLinkFiles().from(project.getConfigurations().getByName("cppLinkDebug"));
            task.getVariantDirectory().set(project.getLayout().getBuildDirectory().dir("debug"));
            task.getProjectDirectory().set(extension.getProjectDirectory());
    });

    final TaskProvider<CMake> cmakeRelease = tasks.register("cmakeRelease", CMake.class, task -> {
        task.setBuildType("RelWithDebInfo");
        task.getIncludeDirs().from(project.getConfigurations().getByName("cppCompile"));
        task.getLinkFiles().from(project.getConfigurations().getByName("cppLinkRelease"));
        task.getVariantDirectory().set(project.getLayout().getBuildDirectory().dir("release"));
        task.getProjectDirectory().set(extension.getProjectDirectory());
    });

    final TaskProvider<Make> assembleDebug = tasks.register("assembleDebug", Make.class, task -> {
        task.setGroup("Build");
        task.setDescription("Builds the debug binaries");
        task.generatedBy(cmakeDebug);
        task.binary(extension.getBinary());
    });

    TaskProvider<Make> assembleRelease = tasks.register("assembleRelease", Make.class, task -> {
        task.setGroup("Build");
        task.setDescription("Builds the release binaries");
        task.generatedBy(cmakeRelease);
        task.binary(extension.getBinary());
    });

    tasks.named("assemble", task -> task.dependsOn(assembleDebug));

    /*
     * Configure the artifacts which should be exposed by this build
     * to other Gradle projects. (Note that this build does not currently
     * expose any runtime (shared library) artifacts)
     */
    ConfigurationContainer configurations = project.getConfigurations();
    configurations.getByName("headers").getOutgoing().artifact(extension.getIncludeDirectory());
    configurations.getByName("linkDebug").getOutgoing().artifact(assembleDebug.flatMap(it -> it.getBinary()));
    configurations.getByName("linkRelease").getOutgoing().artifact(assembleRelease.flatMap(it -> it.getBinary()));
}
 
Example 8
Source File: CMakeLibraryPlugin.java    From native-samples with Apache License 2.0 4 votes vote down vote up
public void apply(final Project project) {
    project.getPluginManager().apply("org.gradle.samples.wrapped-native-library");

    // Add a CMake extension to the Gradle model
    final CMakeExtension extension = project.getExtensions().create("cmake", CMakeExtension.class, project.getLayout(), project.getObjects());

    /*
     * Create some tasks to drive the CMake build
     */
    TaskContainer tasks = project.getTasks();

    final TaskProvider<CMake> cmakeDebug = tasks.register("cmakeDebug", CMake.class, task -> {
            task.setBuildType("Debug");
            task.getIncludeDirs().from(project.getConfigurations().getByName("cppCompile"));
            task.getLinkFiles().from(project.getConfigurations().getByName("cppLinkDebug"));
            task.getVariantDirectory().set(project.getLayout().getBuildDirectory().dir("debug"));
            task.getProjectDirectory().set(extension.getProjectDirectory());
    });

    final TaskProvider<CMake> cmakeRelease = tasks.register("cmakeRelease", CMake.class, task -> {
        task.setBuildType("RelWithDebInfo");
        task.getIncludeDirs().from(project.getConfigurations().getByName("cppCompile"));
        task.getLinkFiles().from(project.getConfigurations().getByName("cppLinkRelease"));
        task.getVariantDirectory().set(project.getLayout().getBuildDirectory().dir("release"));
        task.getProjectDirectory().set(extension.getProjectDirectory());
    });

    final TaskProvider<Make> assembleDebug = tasks.register("assembleDebug", Make.class, task -> {
        task.setGroup("Build");
        task.setDescription("Builds the debug binaries");
        task.generatedBy(cmakeDebug);
        task.binary(extension.getBinary());
    });

    TaskProvider<Make> assembleRelease = tasks.register("assembleRelease", Make.class, task -> {
        task.setGroup("Build");
        task.setDescription("Builds the release binaries");
        task.generatedBy(cmakeRelease);
        task.binary(extension.getBinary());
    });

    tasks.named("assemble", task -> task.dependsOn(assembleDebug));

    /*
     * Configure the artifacts which should be exposed by this build
     * to other Gradle projects. (Note that this build does not currently
     * expose any runtime (shared library) artifacts)
     */
    ConfigurationContainer configurations = project.getConfigurations();
    configurations.getByName("headers").getOutgoing().artifact(extension.getIncludeDirectory());
    configurations.getByName("linkDebug").getOutgoing().artifact(assembleDebug.flatMap(it -> it.getBinary()));
    configurations.getByName("linkRelease").getOutgoing().artifact(assembleRelease.flatMap(it -> it.getBinary()));
}
 
Example 9
Source File: CMakeLibraryPlugin.java    From native-samples with Apache License 2.0 4 votes vote down vote up
public void apply(final Project project) {
    project.getPluginManager().apply("org.gradle.samples.wrapped-native-library");

    // Add a CMake extension to the Gradle model
    final CMakeExtension extension = project.getExtensions().create("cmake", CMakeExtension.class, project.getLayout(), project.getObjects());

    /*
     * Create some tasks to drive the CMake build
     */
    TaskContainer tasks = project.getTasks();

    final TaskProvider<CMake> cmakeDebug = tasks.register("cmakeDebug", CMake.class, task -> {
            task.setBuildType("Debug");
            task.getIncludeDirs().from(project.getConfigurations().getByName("cppCompile"));
            task.getLinkFiles().from(project.getConfigurations().getByName("cppLinkDebug"));
            task.getVariantDirectory().set(project.getLayout().getBuildDirectory().dir("debug"));
            task.getProjectDirectory().set(extension.getProjectDirectory());
    });

    final TaskProvider<CMake> cmakeRelease = tasks.register("cmakeRelease", CMake.class, task -> {
        task.setBuildType("RelWithDebInfo");
        task.getIncludeDirs().from(project.getConfigurations().getByName("cppCompile"));
        task.getLinkFiles().from(project.getConfigurations().getByName("cppLinkRelease"));
        task.getVariantDirectory().set(project.getLayout().getBuildDirectory().dir("release"));
        task.getProjectDirectory().set(extension.getProjectDirectory());
    });

    final TaskProvider<Make> assembleDebug = tasks.register("assembleDebug", Make.class, task -> {
        task.setGroup("Build");
        task.setDescription("Builds the debug binaries");
        task.generatedBy(cmakeDebug);
        task.binary(extension.getBinary());
    });

    TaskProvider<Make> assembleRelease = tasks.register("assembleRelease", Make.class, task -> {
        task.setGroup("Build");
        task.setDescription("Builds the release binaries");
        task.generatedBy(cmakeRelease);
        task.binary(extension.getBinary());
    });

    tasks.named("assemble", task -> task.dependsOn(assembleDebug));

    /*
     * Configure the artifacts which should be exposed by this build
     * to other Gradle projects. (Note that this build does not currently
     * expose any runtime (shared library) artifacts)
     */
    ConfigurationContainer configurations = project.getConfigurations();
    configurations.getByName("headers").getOutgoing().artifact(extension.getIncludeDirectory());
    configurations.getByName("linkDebug").getOutgoing().artifact(assembleDebug.flatMap(it -> it.getBinary()));
    configurations.getByName("linkRelease").getOutgoing().artifact(assembleRelease.flatMap(it -> it.getBinary()));
}
 
Example 10
Source File: CMakeLibraryPlugin.java    From native-samples with Apache License 2.0 4 votes vote down vote up
public void apply(final Project project) {
    project.getPluginManager().apply("org.gradle.samples.wrapped-native-library");

    // Add a CMake extension to the Gradle model
    final CMakeExtension extension = project.getExtensions().create("cmake", CMakeExtension.class, project.getLayout(), project.getObjects());

    /*
     * Create some tasks to drive the CMake build
     */
    TaskContainer tasks = project.getTasks();

    final TaskProvider<CMake> cmakeDebug = tasks.register("cmakeDebug", CMake.class, task -> {
            task.setBuildType("Debug");
            task.getIncludeDirs().from(project.getConfigurations().getByName("cppCompile"));
            task.getLinkFiles().from(project.getConfigurations().getByName("cppLinkDebug"));
            task.getVariantDirectory().set(project.getLayout().getBuildDirectory().dir("debug"));
            task.getProjectDirectory().set(extension.getProjectDirectory());
    });

    final TaskProvider<CMake> cmakeRelease = tasks.register("cmakeRelease", CMake.class, task -> {
        task.setBuildType("RelWithDebInfo");
        task.getIncludeDirs().from(project.getConfigurations().getByName("cppCompile"));
        task.getLinkFiles().from(project.getConfigurations().getByName("cppLinkRelease"));
        task.getVariantDirectory().set(project.getLayout().getBuildDirectory().dir("release"));
        task.getProjectDirectory().set(extension.getProjectDirectory());
    });

    final TaskProvider<Make> assembleDebug = tasks.register("assembleDebug", Make.class, task -> {
        task.setGroup("Build");
        task.setDescription("Builds the debug binaries");
        task.generatedBy(cmakeDebug);
        task.binary(extension.getBinary());
    });

    TaskProvider<Make> assembleRelease = tasks.register("assembleRelease", Make.class, task -> {
        task.setGroup("Build");
        task.setDescription("Builds the release binaries");
        task.generatedBy(cmakeRelease);
        task.binary(extension.getBinary());
    });

    tasks.named("assemble", task -> task.dependsOn(assembleDebug));

    /*
     * Configure the artifacts which should be exposed by this build
     * to other Gradle projects. (Note that this build does not currently
     * expose any runtime (shared library) artifacts)
     */
    ConfigurationContainer configurations = project.getConfigurations();
    configurations.getByName("headers").getOutgoing().artifact(extension.getIncludeDirectory());
    configurations.getByName("linkDebug").getOutgoing().artifact(assembleDebug.flatMap(it -> it.getBinary()));
    configurations.getByName("linkRelease").getOutgoing().artifact(assembleRelease.flatMap(it -> it.getBinary()));
}