org.gradle.api.tasks.TaskContainer Java Examples

The following examples show how to use org.gradle.api.tasks.TaskContainer. 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: 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 #2
Source File: DefaultAntBuilder.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void addDependencyOrdering(Enumeration<String> dependencies) {
    TaskContainer tasks = gradleProject.getTasks();
    String previous = null;
    for (final String dependency : Collections.list(dependencies)) {
        if (previous != null) {
            final String finalPrevious = previous;
            tasks.all(new Action<Task>() {
                public void execute(Task task) {
                    if (task.getName().equals(dependency)) {
                        task.shouldRunAfter(finalPrevious);
                    }
                }
            });
        }

        previous = dependency;
    }
}
 
Example #3
Source File: VisualStudioPlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Mutate
@SuppressWarnings("GroovyUnusedDeclaration")
public static void createTasksForVisualStudio(TaskContainer tasks, VisualStudioExtensionInternal visualStudioExtension) {
    for (VisualStudioProject vsProject : visualStudioExtension.getProjects()) {
        vsProject.builtBy(createProjectsFileTask(tasks, vsProject));
        vsProject.builtBy(createFiltersFileTask(tasks, vsProject));
    }

    for (VisualStudioSolution vsSolution : visualStudioExtension.getSolutions()) {
        Task solutionTask = tasks.create(vsSolution.getName() + "VisualStudio");
        solutionTask.setDescription(String.format("Generates the '%s' Visual Studio solution file.", vsSolution.getName()));
        vsSolution.setBuildTask(solutionTask);
        vsSolution.builtBy(createSolutionTask(tasks, vsSolution));

        // Lifecycle task for component
        NativeComponentSpec component = vsSolution.getComponent();
        Task lifecycleTask = tasks.maybeCreate(component.getName() + "VisualStudio");
        lifecycleTask.dependsOn(vsSolution);
        lifecycleTask.setGroup("IDE");
        lifecycleTask.setDescription(String.format("Generates the Visual Studio solution for %s.", component));
    }

    addCleanTask(tasks);
}
 
Example #4
Source File: CreateSourceTransformTask.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void createCompileTasksForBinary(final TaskContainer tasks, BinarySpec binarySpec) {
    final BinarySpecInternal binary = (BinarySpecInternal) binarySpec;
    if (binary.isLegacyBinary() || !language.applyToBinary(binary)) {
        return;
    }

    final SourceTransformTaskConfig taskConfig = language.getTransformTask();
    binary.getSource().withType(language.getSourceSetType(), new Action<LanguageSourceSet>() {
        public void execute(LanguageSourceSet languageSourceSet) {
            LanguageSourceSetInternal sourceSet = (LanguageSourceSetInternal) languageSourceSet;
            if (sourceSet.getMayHaveSources()) {
                String taskName = binary.getNamingScheme().getTaskName(taskConfig.getTaskPrefix(), sourceSet.getFullName());
                Task task = tasks.create(taskName, taskConfig.getTaskType());

                taskConfig.configureTask(task, binary, sourceSet);

                task.dependsOn(sourceSet);
                binary.getTasks().add(task);
            }
        }
    });
}
 
Example #5
Source File: BinaryTasksRuleDefinitionHandler.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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 #6
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 #7
Source File: VisualStudioPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Mutate
@SuppressWarnings("GroovyUnusedDeclaration")
public static void createTasksForVisualStudio(TaskContainer tasks, VisualStudioExtensionInternal visualStudioExtension) {
    for (VisualStudioProject vsProject : visualStudioExtension.getProjects()) {
        vsProject.builtBy(createProjectsFileTask(tasks, vsProject));
        vsProject.builtBy(createFiltersFileTask(tasks, vsProject));
    }

    for (VisualStudioSolution vsSolution : visualStudioExtension.getSolutions()) {
        Task solutionTask = tasks.create(vsSolution.getName() + "VisualStudio");
        solutionTask.setDescription(String.format("Generates the '%s' Visual Studio solution file.", vsSolution.getName()));
        vsSolution.setBuildTask(solutionTask);
        vsSolution.builtBy(createSolutionTask(tasks, vsSolution));

        // Lifecycle task for component
        NativeComponentSpec component = vsSolution.getComponent();
        Task lifecycleTask = tasks.maybeCreate(component.getName() + "VisualStudio");
        lifecycleTask.dependsOn(vsSolution);
        lifecycleTask.setGroup("IDE");
        lifecycleTask.setDescription(String.format("Generates the Visual Studio solution for %s.", component));
    }

    addCleanTask(tasks);
}
 
Example #8
Source File: CreateVisualStudioTasks.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@SuppressWarnings("UnusedDeclaration")
public void createTasksForVisualStudio(TaskContainer tasks, VisualStudioExtension visualStudioExtension) {
    for (VisualStudioProject vsProject : visualStudioExtension.getProjects()) {
        vsProject.builtBy(createProjectsFileTask(tasks, vsProject));
        vsProject.builtBy(createFiltersFileTask(tasks, vsProject));
    }

    for (VisualStudioSolution vsSolution : visualStudioExtension.getSolutions()) {
        Task solutionTask = tasks.create(vsSolution.getName() + "VisualStudio");
        solutionTask.setDescription(String.format("Generates the '%s' Visual Studio solution file.", vsSolution.getName()));
        vsSolution.setLifecycleTask(solutionTask);
        vsSolution.builtBy(createSolutionTask(tasks, vsSolution));

        // Lifecycle task for component
        ProjectNativeComponent component = vsSolution.getComponent();
        Task lifecycleTask = tasks.maybeCreate(component.getName() + "VisualStudio");
        lifecycleTask.dependsOn(vsSolution);
        lifecycleTask.setGroup("IDE");
        lifecycleTask.setDescription(String.format("Generates the Visual Studio solution for %s.", component));
    }

    addCleanTask(tasks);
}
 
Example #9
Source File: MavenPublishPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void apply(final Project project) {
    project.getPlugins().apply(PublishingPlugin.class);

    final TaskContainer tasks = project.getTasks();
    final Task publishLocalLifecycleTask = tasks.create(PUBLISH_LOCAL_LIFECYCLE_TASK_NAME);
    publishLocalLifecycleTask.setDescription("Publishes all Maven publications produced by this project to the local Maven cache.");
    publishLocalLifecycleTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);

    // Can't move this to rules yet, because it has to happen before user deferred configurable actions
    project.getExtensions().configure(PublishingExtension.class, new Action<PublishingExtension>() {
        public void execute(PublishingExtension extension) {
            // Register factory for MavenPublication
            extension.getPublications().registerFactory(MavenPublication.class, new MavenPublicationFactory(dependencyMetaDataProvider, instantiator, fileResolver));
        }
    });
}
 
Example #10
Source File: LayeredWheelCachePlugin.java    From pygradle with Apache License 2.0 6 votes vote down vote up
@Override
public void apply(Project project) {
    WheelExtension wheelExtension = ExtensionUtils.maybeCreateWheelExtension(project);
    EditablePythonAbiContainer supportedWheelFormats = ExtensionUtils.getEditablePythonAbiContainer(project);
    LayeredWheelCache wheelCache = new LayeredWheelCache(wheelExtension.getLayeredCacheMap(), supportedWheelFormats);

    TaskContainer tasks = project.getTasks();

    tasks.withType(ProvidesVenv.class, task -> task.setEditablePythonAbiContainer(supportedWheelFormats));

    tasks.withType(SupportsWheelCache.class, task -> task.setWheelCache(wheelCache));

    tasks.create(LayeredWheelCacheTask.TASK_LAYERED_WHEEL_CACHE, LayeredWheelCacheTask.class, task -> {
        tasks.getByName(TASK_VENV_CREATE.getValue()).dependsOn(task);
        tasks.getByName(TASK_FLAKE.getValue()).dependsOn(task);
    });
}
 
Example #11
Source File: DefaultAntBuilder.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private static void addDependencyOrdering(List<String> dependencies, TaskContainer tasks) {
    String previous = null;
    for (final String dependency : dependencies) {
        if (previous != null) {
            final String finalPrevious = previous;
            tasks.all(new Action<Task>() {
                public void execute(Task task) {
                    if (task.getName().equals(dependency)) {
                        task.shouldRunAfter(finalPrevious);
                    }
                }
            });
        }

        previous = dependency;
    }
}
 
Example #12
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 #13
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 #14
Source File: MavenPublishPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void apply(final Project project) {
    project.getPlugins().apply(PublishingPlugin.class);

    final TaskContainer tasks = project.getTasks();
    final Task publishLifecycleTask = tasks.getByName(PublishingPlugin.PUBLISH_LIFECYCLE_TASK_NAME);
    final Task publishLocalLifecycleTask = tasks.create(PUBLISH_LOCAL_LIFECYCLE_TASK_NAME);
    publishLocalLifecycleTask.setDescription("Publishes all Maven publications produced by this project to the local Maven cache.");
    publishLocalLifecycleTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);

    // Can't move this to rules yet, because it has to happen before user deferred configurable actions
    project.getExtensions().configure(PublishingExtension.class, new Action<PublishingExtension>() {
        public void execute(PublishingExtension extension) {
            // Register factory for MavenPublication
            extension.getPublications().registerFactory(MavenPublication.class, new MavenPublicationFactory(dependencyMetaDataProvider, instantiator, fileResolver));
        }
    });

    modelRules.rule(new MavenPublishTaskModelRule(project, publishLifecycleTask, publishLocalLifecycleTask));
}
 
Example #15
Source File: CreateVisualStudioTasks.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@SuppressWarnings("UnusedDeclaration")
public void createTasksForVisualStudio(TaskContainer tasks, VisualStudioExtension visualStudioExtension) {
    for (VisualStudioProject vsProject : visualStudioExtension.getProjects()) {
        vsProject.builtBy(createProjectsFileTask(tasks, vsProject));
        vsProject.builtBy(createFiltersFileTask(tasks, vsProject));
    }

    for (VisualStudioSolution vsSolution : visualStudioExtension.getSolutions()) {
        Task solutionTask = tasks.create(vsSolution.getName() + "VisualStudio");
        solutionTask.setDescription(String.format("Generates the '%s' Visual Studio solution file.", vsSolution.getName()));
        vsSolution.setLifecycleTask(solutionTask);
        vsSolution.builtBy(createSolutionTask(tasks, vsSolution));

        // Lifecycle task for component
        ProjectNativeComponent component = vsSolution.getComponent();
        Task lifecycleTask = tasks.maybeCreate(component.getName() + "VisualStudio");
        lifecycleTask.dependsOn(vsSolution);
        lifecycleTask.setGroup("IDE");
        lifecycleTask.setDescription(String.format("Generates the Visual Studio solution for %s.", component));
    }

    addCleanTask(tasks);
}
 
Example #16
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 #17
Source File: CredentialsPlugin.java    From gradle-credentials-plugin with Apache License 2.0 6 votes vote down vote up
private void addTasks(Pair result, TaskContainer tasks) {
    CredentialsEncryptor credentialsEncryptor = result.credentialsEncryptor;
    CredentialsPersistenceManager credentialsPersistenceManager = result.credentialsPersistenceManager;

    // add a task instance that stores new credentials through the credentials persistence manager
    AddCredentialsTask addCredentials = tasks.create(ADD_CREDENTIALS_TASK_NAME, AddCredentialsTask.class);
    addCredentials.setDescription("Adds the credentials specified through the project properties 'credentialsKey' and 'credentialsValue'.");
    addCredentials.setGroup("Credentials");
    addCredentials.setCredentialsEncryptor(credentialsEncryptor);
    addCredentials.setCredentialsPersistenceManager(credentialsPersistenceManager);
    addCredentials.getOutputs().upToDateWhen(AlwaysFalseSpec.INSTANCE);
    LOGGER.debug(String.format("Registered task '%s'", addCredentials.getName()));

    // add a task instance that removes some credentials through the credentials persistence manager
    RemoveCredentialsTask removeCredentials = tasks.create(REMOVE_CREDENTIALS_TASK_NAME, RemoveCredentialsTask.class);
    removeCredentials.setDescription("Removes the credentials specified through the project property 'credentialsKey'.");
    removeCredentials.setGroup("Credentials");
    removeCredentials.setCredentialsPersistenceManager(credentialsPersistenceManager);
    removeCredentials.getOutputs().upToDateWhen(AlwaysFalseSpec.INSTANCE);
    LOGGER.debug(String.format("Registered task '%s'", removeCredentials.getName()));
}
 
Example #18
Source File: DefaultAntBuilder.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private static void addDependencyOrdering(List<String> dependencies, TaskContainer tasks) {
    String previous = null;
    for (final String dependency : dependencies) {
        if (previous != null) {
            final String finalPrevious = previous;
            tasks.all(new Action<Task>() {
                public void execute(Task task) {
                    if (task.getName().equals(dependency)) {
                        task.shouldRunAfter(finalPrevious);
                    }
                }
            });
        }

        previous = dependency;
    }
}
 
Example #19
Source File: DefaultAntBuilder.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void addDependencyOrdering(Enumeration<String> dependencies) {
    TaskContainer tasks = gradleProject.getTasks();
    String previous = null;
    for (final String dependency : Collections.list(dependencies)) {
        if (previous != null) {
            final String finalPrevious = previous;
            tasks.all(new Action<Task>() {
                public void execute(Task task) {
                    if (task.getName().equals(dependency)) {
                        task.shouldRunAfter(finalPrevious);
                    }
                }
            });
        }

        previous = dependency;
    }
}
 
Example #20
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 #21
Source File: GaugePluginTest.java    From gauge-gradle-plugin with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void taskShouldBeAddedOnApply() {
    project.getPluginManager().apply(GAUGE);
    TaskContainer tasks = project.getTasks();
    assertEquals(1, tasks.size());

    SortedMap<String, Task> tasksMap = tasks.getAsMap();
    Task gauge = tasksMap.get(GAUGE);
    assertTrue(gauge instanceof GaugeTask);
}
 
Example #22
Source File: PackagePlugin.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 5 votes vote down vote up
@Override
public void apply(Project project) {
    project.getExtensions().create("swarm", SwarmExtension.class);
    project.afterEvaluate(__ -> {
        final TaskContainer tasks = project.getTasks();
        final PackageTask packageTask = tasks.create("wildfly-swarm-package", PackageTask.class);
        tasks.withType(Jar.class, task -> packageTask.jarTask(task).dependsOn(task));
        tasks.getByName("build").dependsOn(packageTask);
    });
}
 
Example #23
Source File: MavenPublishTaskModelRule.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void createLocalInstallTask(TaskContainer tasks, MavenPublicationInternal publication, String publicationName) {
    String installTaskName = String.format("publish%sPublicationToMavenLocal", capitalize(publicationName));

    PublishToMavenLocal publishLocalTask = tasks.create(installTaskName, PublishToMavenLocal.class);
    publishLocalTask.setPublication(publication);
    publishLocalTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
    publishLocalTask.setDescription(String.format("Publishes Maven publication '%s' to the local Maven repository.", publicationName));

    publishLocalLifecycleTask.dependsOn(installTaskName);
}
 
Example #24
Source File: IvyPublicationTasksModelRule.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void createTasks(TaskContainer tasks, PublishingExtension publishingExtension) {
    PublicationContainer publications = publishingExtension.getPublications();
    RepositoryHandler repositories = publishingExtension.getRepositories();

    for (final IvyPublicationInternal publication : publications.withType(IvyPublicationInternal.class)) {

        final String publicationName = publication.getName();
        final String descriptorTaskName = String.format("generateDescriptorFileFor%sPublication", capitalize(publicationName));

        GenerateIvyDescriptor descriptorTask = tasks.create(descriptorTaskName, GenerateIvyDescriptor.class);
        descriptorTask.setDescription(String.format("Generates the Ivy Module Descriptor XML file for publication '%s'.", publication.getName()));
        descriptorTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
        descriptorTask.setDescriptor(publication.getDescriptor());

        ConventionMapping descriptorTaskConventionMapping = new DslObject(descriptorTask).getConventionMapping();
        descriptorTaskConventionMapping.map("destination", new Callable<Object>() {
            public Object call() throws Exception {
                return new File(project.getBuildDir(), "publications/" + publication.getName() + "/ivy.xml");
            }
        });

        publication.setDescriptorFile(descriptorTask.getOutputs().getFiles());

        for (IvyArtifactRepository repository : repositories.withType(IvyArtifactRepository.class)) {
            final String repositoryName = repository.getName();
            final String publishTaskName = String.format("publish%sPublicationTo%sRepository", capitalize(publicationName), capitalize(repositoryName));

            PublishToIvyRepository publishTask = tasks.create(publishTaskName, PublishToIvyRepository.class);
            publishTask.setPublication(publication);
            publishTask.setRepository(repository);
            publishTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
            publishTask.setDescription(String.format("Publishes Ivy publication '%s' to Ivy repository '%s'.", publicationName, repositoryName));

            tasks.getByName(PublishingPlugin.PUBLISH_LIFECYCLE_TASK_NAME).dependsOn(publishTask);
        }
    }
}
 
Example #25
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 #26
Source File: CUnitPlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Mutate
public void createCUnitLauncherTasks(TaskContainer tasks, TestSuiteContainer testSuites, ProjectSourceSet sources) {
    for (final CUnitTestSuiteSpec suite : testSuites.withType(CUnitTestSuiteSpec.class)) {

        String taskName = suite.getName() + "CUnitLauncher";
        GenerateCUnitLauncher skeletonTask = tasks.create(taskName, GenerateCUnitLauncher.class);

        CSourceSet launcherSources = findLaucherSources(suite);
        skeletonTask.setSourceDir(launcherSources.getSource().getSrcDirs().iterator().next());
        skeletonTask.setHeaderDir(launcherSources.getExportedHeaders().getSrcDirs().iterator().next());
        launcherSources.builtBy(skeletonTask);
    }
}
 
Example #27
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 #28
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 #29
Source File: SimpleCodeGenerationTest.java    From gradle-plugins with MIT License 5 votes vote down vote up
@Test
public void applyAfterJava() {
    project.getPlugins().apply(JavaPlugin.class);
    project.getPlugins().apply(CodeGeneratorPlugin.class);

    TaskContainer tasks = project.getTasks();
    assertThat(tasks.parallelStream().anyMatch(t -> t.getName().equals("generateCode")), is(equalTo(true)));
}
 
Example #30
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));
}