Java Code Examples for org.gradle.api.Project#getTasks()

The following examples show how to use org.gradle.api.Project#getTasks() . 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: MinikubePluginTest.java    From minikube-build-tools-for-java with Apache License 2.0 6 votes vote down vote up
@Test
public void testMinikubeExtensionSetProperties() {
  Project project = ProjectBuilder.builder().withProjectDir(tmp.getRoot()).build();
  project.getPluginManager().apply(MinikubePlugin.class);
  MinikubeExtension ex = (MinikubeExtension) project.getExtensions().getByName("minikube");
  ex.setMinikube("/custom/minikube/path");

  TaskContainer t = project.getTasks();
  TaskCollection<MinikubeTask> tc = t.withType(MinikubeTask.class);

  Assert.assertEquals(3, tc.size());

  tc.forEach(
      minikubeTask -> {
        Assert.assertEquals(minikubeTask.getMinikube(), "/custom/minikube/path");
      });
}
 
Example 2
Source File: GolangPluginSupport.java    From gradle-golang-plugin with Mozilla Public License 2.0 6 votes vote down vote up
@Override
public void apply(Project project) {
    final ConfigurationContainer configurations = project.getConfigurations();
    configurations.maybeCreate("test");
    configurations.maybeCreate("build");
    configurations.maybeCreate("tool");

    final ExtensionContainer extensions = project.getExtensions();
    final ExtensionAware golang = (ExtensionAware) extensions.create("golang", GolangSettings.class, true, project);
    golang.getExtensions().create("build", BuildSettings.class, true, project);
    golang.getExtensions().create("toolchain", ToolchainSettings.class, true, project);
    golang.getExtensions().create("dependencies", DependenciesSettings.class, true, project);
    golang.getExtensions().create("testing", TestingSettings.class, true, project);

    extensions.create(INSTANCE_PROPERTY_NAME, Reference.class, this);

    final TaskContainer tasks = project.getTasks();
    addTasks(tasks);
}
 
Example 3
Source File: QuarkusPluginTest.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldMakeQuarkusDevAndQuarkusBuildDependOnClassesTask() {
    Project project = ProjectBuilder.builder().build();
    project.getPluginManager().apply(QuarkusPlugin.ID);
    project.getPluginManager().apply("java");

    TaskContainer tasks = project.getTasks();

    assertThat(tasks.getByName(QuarkusPlugin.QUARKUS_BUILD_TASK_NAME).getDependsOn())
            .contains(tasks.getByName(JavaPlugin.CLASSES_TASK_NAME));
    assertThat(tasks.getByName(QuarkusPlugin.QUARKUS_DEV_TASK_NAME).getDependsOn())
            .contains(tasks.getByName(JavaPlugin.CLASSES_TASK_NAME));
}
 
Example 4
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 5
Source File: ProjectConverter.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Adds the tasks from the project to the GradleProject.
 *
 * @param project the source parent project. Where we get the sub projects from.
 * @param projectView the destination of the tasks from project.
 */
private void addTasks(Project project, ProjectView projectView) {
    List<String> defaultTasks = project.getDefaultTasks();
    for (Task task : project.getTasks()) {
        String taskName = task.getName();

        boolean isDefault = defaultTasks.contains(taskName);

        projectView.createTask(taskName, task.getDescription(), isDefault);
    }
}
 
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: PythonCliDistributionPlugin.java    From pygradle with Apache License 2.0 5 votes vote down vote up
@Override
public void applyTo(Project project) {
    project.getPlugins().apply(PythonContainerPlugin.class);
    ExtensionUtils.maybeCreateCliExtension(project);

    TaskContainer tasks = project.getTasks();

    GenerateCompletionsTask completionsTask = tasks.create(TASK_GENERATE_COMPLETIONS, GenerateCompletionsTask.class);
    completionsTask.dependsOn(tasks.getByName(StandardTextValues.TASK_INSTALL_PROJECT.getValue()));

    tasks.getByName(ApplicationContainer.TASK_ASSEMBLE_CONTAINERS)
        .dependsOn(project.getTasks().getByName(TASK_GENERATE_COMPLETIONS));
}
 
Example 8
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 9
Source File: AtlasBaseTaskManager.java    From atlas with Apache License 2.0 5 votes vote down vote up
public AtlasBaseTaskManager(AtlasBuilder androidBuilder, T androidExtension, Project project,
                            AtlasExtension atlasExtension) {
    this.tAndroidBuilder = androidBuilder;
    this.androidExtension = androidExtension;
    this.project = project;
    this.tasks = new TaskContainerAdaptor(project.getTasks());
    this.atlasExtension = atlasExtension;
    this.logger = new LoggerWrapper(Logging.getLogger(AtlasBaseTaskManager.class));
    this.extraModelInfo = new ExtraModelInfo(new ProjectOptions(project), Logging.getLogger(AtlasBaseTaskManager.class));

    //this.dependencyManager = new DependencyManager(androidExtension, project, atlasExtension);
}
 
Example 10
Source File: QuarkusPluginTest.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldMakeAssembleDependOnQuarkusBuild() {
    Project project = ProjectBuilder.builder().build();
    project.getPluginManager().apply(QuarkusPlugin.ID);
    project.getPluginManager().apply("base");

    TaskContainer tasks = project.getTasks();

    assertThat(tasks.getByName(BasePlugin.ASSEMBLE_TASK_NAME).getDependsOn())
            .contains(tasks.getByName(QuarkusPlugin.QUARKUS_BUILD_TASK_NAME));
}
 
Example 11
Source File: QuarkusPluginTest.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldCreateTasks() {
    Project project = ProjectBuilder.builder().build();
    project.getPluginManager().apply(QuarkusPlugin.ID);

    assertTrue(project.getPluginManager().hasPlugin(QuarkusPlugin.ID));

    TaskContainer tasks = project.getTasks();
    assertNotNull(tasks.getByName(QuarkusPlugin.QUARKUS_BUILD_TASK_NAME));
    assertNotNull(tasks.getByName(QuarkusPlugin.QUARKUS_DEV_TASK_NAME));
    assertNotNull(tasks.getByName(QuarkusPlugin.BUILD_NATIVE_TASK_NAME));
    assertNotNull(tasks.getByName(QuarkusPlugin.LIST_EXTENSIONS_TASK_NAME));
    assertNotNull(tasks.getByName(QuarkusPlugin.ADD_EXTENSION_TASK_NAME));
}
 
Example 12
Source File: ProjectConverter.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Adds the tasks from the project to the GradleProject.
 *
 * @param project the source parent project. Where we get the sub projects from.
 * @param projectView the destination of the tasks from project.
 */
private void addTasks(Project project, ProjectView projectView) {
    List<String> defaultTasks = project.getDefaultTasks();
    for (Task task : project.getTasks()) {
        String taskName = task.getName();

        boolean isDefault = defaultTasks.contains(taskName);

        projectView.createTask(taskName, task.getDescription(), isDefault);
    }
}
 
Example 13
Source File: JigGradlePlugin.java    From jig with Apache License 2.0 5 votes vote down vote up
@Override
public void apply(Project project) {
    ExtensionContainer extensions = project.getExtensions();
    extensions.create("jig", JigConfig.class);
    TaskContainer tasks = project.getTasks();

    JigReportsTask jigReports = tasks.create("jigReports", JigReportsTask.class);
    jigReports.setGroup("JIG");
    jigReports.setDescription("Generates JIG documentation for the main source code.");

    VerifyJigEnvironmentTask verifyTask = tasks.create("verifyJigEnvironment", VerifyJigEnvironmentTask.class);
    verifyTask.setGroup("JIG");
    verifyTask.setDescription("Verify JIG environment.");
}
 
Example 14
Source File: BuildInvocationsBuilder.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void findTasks(Project project, Collection<String> tasks) {
    for (Project child : project.getSubprojects()) {
        findTasks(child, tasks);
    }
    for (Task task : project.getTasks()) {
        tasks.add(task.getName());
    }
}
 
Example 15
Source File: ProjectConverter.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Adds the tasks from the project to the GradleProject.
 *
 * @param project the source parent project. Where we get the sub projects from.
 * @param projectView the destination of the tasks from project.
 */
private void addTasks(Project project, ProjectView projectView) {
    List<String> defaultTasks = project.getDefaultTasks();
    for (Task task : project.getTasks()) {
        String taskName = task.getName();

        boolean isDefault = defaultTasks.contains(taskName);

        projectView.createTask(taskName, task.getDescription(), isDefault);
    }
}
 
Example 16
Source File: ProjectConverter.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Adds the tasks from the project to the GradleProject.
 *
 * @param project the source parent project. Where we get the sub projects from.
 * @param projectView the destination of the tasks from project.
 */
private void addTasks(Project project, ProjectView projectView) {
    List<String> defaultTasks = project.getDefaultTasks();
    for (Task task : project.getTasks()) {
        String taskName = task.getName();

        boolean isDefault = defaultTasks.contains(taskName);

        projectView.createTask(taskName, task.getDescription(), isDefault);
    }
}
 
Example 17
Source File: PluginClean.java    From scaffold-clean-architecture with MIT License 4 votes vote down vote up
public void apply(Project project) {
    List<TaskModel> tasks = initTasks();
    taskContainer = project.getTasks();
    tasks.forEach(this::appendTask);
}
 
Example 18
Source File: AndroidExtension.java    From javafxmobile-plugin with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public AndroidExtension(Project project, ToolingModelBuilderRegistry registry) {
    this.project = project;

    this.extraModelInfo = new ExtraModelInfo(new ProjectOptions(project), project.getLogger());

    this.signingConfig = project.getExtensions().create("signingConfig", SigningConfig.class, "signing");
    this.packagingOptions = project.getExtensions().create("packagingOptions", PackagingOptions.class);
    this.dexOptions = project.getExtensions().create("dexOptions", DexOptions.class, extraModelInfo);

    try {
        this.buildCache = FileCache.getInstanceWithMultiProcessLocking(new File(AndroidLocation.getFolder(), "build-cache"));
    } catch (AndroidLocation.AndroidLocationException e) {
        throw new RuntimeException(e);
    }

    LoggerWrapper loggerWrapper = new LoggerWrapper(project.getLogger());

    this.sdkHandler = new SdkHandler(project, loggerWrapper);
    this.androidBuilder = new AndroidBuilder(
            project == project.getRootProject() ? project.getName() : project.getPath(),
            "JavaFX Mobile",
            new GradleProcessExecutor(project),
            new GradleJavaProcessExecutor(project),
            extraModelInfo,
            loggerWrapper,
            false);

    this.androidTaskRegistry = new AndroidTaskRegistry();
    this.taskFactory = new TaskContainerAdaptor(project.getTasks());

    installDirectory = new File(project.getBuildDir(), "javafxports/android");
    project.getLogger().info("Android install directory: " + installDirectory);

    temporaryDirectory = new File(project.getBuildDir(), "javafxports/tmp/android");
    project.getLogger().info("Android temporary output directory: " + temporaryDirectory);

    resourcesDirectory = new File(temporaryDirectory, "resources");
    resourcesDirectory.mkdirs();
    project.getLogger().info("Resources directory: " + resourcesDirectory);

    multidexOutputDirectory = new File(temporaryDirectory, "multi-dex");
    multidexOutputDirectory.mkdirs();
    project.getLogger().info("Multi-dex output directory: " + multidexOutputDirectory);

    dexOutputDirectory = new File(temporaryDirectory, "dex");
    dexOutputDirectory.mkdirs();
    project.getLogger().info("Dex output directory: " + dexOutputDirectory);
}
 
Example 19
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 20
Source File: SmallRyeGraphQLPlugin.java    From smallrye-graphql with Apache License 2.0 4 votes vote down vote up
private void registerTasks(Project project) {
    TaskContainer tasks = project.getTasks();
    tasks.create(GENERATE_SCHEMA_TASK_NAME, GenerateSchemaTask.class);
}