Java 类org.gradle.api.tasks.TaskContainer 实例源码

项目:gradle-circle-style    文件:CircleStylePlugin.java   
private static <T extends Task> T createTask(TaskContainer tasks, String preferredName, Class<T> type) {
    String name = preferredName;
    int count = 1;
    while (true) {
        try {
            Task existingTask = tasks.getByName(name);
            if (type.isInstance(existingTask)) {
                return null;
            }
        } catch (UnknownTaskException e) {
            return tasks.create(name, type);
        }
        count++;
        name = preferredName + count;
    }
}
项目:Reer    文件:VisualStudioPlugin.java   
@Mutate
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("Generates the '" + vsSolution.getName() + "' Visual Studio solution file.");
        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("Generates the Visual Studio solution for " + component + ".");
    }

    addCleanTask(tasks);
}
项目:Reer    文件:MavenPublishPlugin.java   
public void apply(final Project project) {
    project.getPluginManager().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));
        }
    });
}
项目:Reer    文件:NativeComponentModelPlugin.java   
@Mutate
void configurePrefixHeaderGenerationTasks(final TaskContainer tasks, ComponentSpecContainer components) {
    for (final SourceComponentSpec nativeComponentSpec : components.withType(SourceComponentSpec.class).values()) {
        for (final DependentSourceSetInternal dependentSourceSet : nativeComponentSpec.getSources().withType(DependentSourceSetInternal.class).values()) {
            if (dependentSourceSet.getPrefixHeaderFile() != null) {
                String taskName = "generate" + StringUtils.capitalize(nativeComponentSpec.getName()) + StringUtils.capitalize(dependentSourceSet.getName()) + "PrefixHeaderFile";
                tasks.create(taskName, PrefixHeaderFileGenerateTask.class, new Action<PrefixHeaderFileGenerateTask>() {
                    @Override
                    public void execute(PrefixHeaderFileGenerateTask prefixHeaderFileGenerateTask) {
                        prefixHeaderFileGenerateTask.setPrefixHeaderFile(dependentSourceSet.getPrefixHeaderFile());
                        prefixHeaderFileGenerateTask.setHeader(dependentSourceSet.getPreCompiledHeader());
                    }
                });
            }
        }
    }
}
项目:Reer    文件:NativeComponentModelPlugin.java   
@Mutate
void configurePreCompiledHeaderCompileTasks(final TaskContainer tasks, BinaryContainer binaries, final LanguageTransformContainer languageTransforms, final ServiceRegistry serviceRegistry) {
    for (final NativeBinarySpecInternal nativeBinarySpec : binaries.withType(NativeBinarySpecInternal.class)) {
        for (final PchEnabledLanguageTransform<?> transform : languageTransforms.withType(PchEnabledLanguageTransform.class)) {
            nativeBinarySpec.getInputs().withType(transform.getSourceSetType(), new Action<LanguageSourceSet>() {
                @Override
                public void execute(final LanguageSourceSet languageSourceSet) {
                    final DependentSourceSet dependentSourceSet = (DependentSourceSet) languageSourceSet;
                    if (dependentSourceSet.getPreCompiledHeader() != null) {
                        nativeBinarySpec.addPreCompiledHeaderFor(dependentSourceSet);
                        final SourceTransformTaskConfig pchTransformTaskConfig = transform.getPchTransformTask();
                        String pchTaskName = pchTransformTaskConfig.getTaskPrefix() + StringUtils.capitalize(nativeBinarySpec.getProjectScopedName()) + StringUtils.capitalize(dependentSourceSet.getName()) + "PreCompiledHeader";
                        Task pchTask = tasks.create(pchTaskName, pchTransformTaskConfig.getTaskType(), new Action<DefaultTask>() {
                            @Override
                            public void execute(DefaultTask task) {
                                pchTransformTaskConfig.configureTask(task, nativeBinarySpec, dependentSourceSet, serviceRegistry);
                            }
                        });
                        nativeBinarySpec.getTasks().add(pchTask);
                    }
                }
            });
        }
    }
}
项目:Reer    文件:DefaultAntBuilder.java   
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;
    }
}
项目:minikube-build-tools-for-java    文件:MinikubePluginTest.java   
@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");
      });
}
项目:gradle-auto-version    文件:AutoVersionPlugin.java   
@Override
public void apply(Project project) {
    logger.debug("plugin apply");
    project.afterEvaluate(this::afterEvaluate);
    TaskContainer taskContainer = project.getTasks();

    autoVersionConfig = project.getExtensions().create("autoversion", AutoVersionConfig.class);

    taskContainer.create("nextMajor",
            configureTask("update version to next Major Release", this::nextMajor));
    taskContainer.create("nextMinor",
            configureTask("update version to next minor Release", this::nextMinor));
    taskContainer.create("nextPatch",
            configureTask("update version to next patch Release", this::nextPatch));
    taskContainer.create("setVersion",
            configureTask("read version from commandline", this::readVersionInteractive));
}
项目:gradle-golang-plugin    文件:GolangPluginSupport.java   
@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);
}
项目:wildfly-swarm    文件:PackagePlugin.java   
@Override
public void apply(Project project) {
    project.getExtensions().create(SWARM_EXTENSION, SwarmExtension.class, project);
    project.afterEvaluate(__ -> {
        final TaskContainer tasks = project.getTasks();
        final PackageTask packageTask = tasks.create(WILDFLY_SWARM_PACKAGE_TASK_NAME, PackageTask.class);

        final Jar archiveTask = getArchiveTask(project);

        if (archiveTask == null) {
            throw new GradleException("No suitable Archive-Task found to include in Swarm Uber-JAR.");
        }

        packageTask.jarTask(archiveTask).dependsOn(archiveTask);

        tasks.getByName(JavaBasePlugin.BUILD_TASK_NAME).dependsOn(packageTask);
    });
}
项目:parsec    文件:ParsecGradlePlugin.java   
@Override
public void apply(Project project) {
    ParsecPluginExtension pluginExtension = project.getExtensions().create("parsec", ParsecPluginExtension.class);
    PathUtils pathUtils = new PathUtils(project, pluginExtension);
    TaskContainer tasks = project.getTasks();

    // Create tasks (when applied as a plugin)
    ParsecInitTask initTask = tasks.create("parsec-init", ParsecInitTask.class);
    ParsecGenerateTask generateTask = tasks.create("parsec-generate", ParsecGenerateTask.class);

    // Make generate trigger init.
    generateTask.dependsOn(initTask);

    project.getPlugins().withType(JavaPlugin.class, plugin -> {
        SourceSet sourceSet = ((SourceSetContainer) project.getProperties().get("sourceSets")).getByName("main");

        // Add ${buildDir}/generated-sources/java to sources
        sourceSet.getJava().srcDir(pathUtils.getGeneratedSourcesPath());

        // Add ${buildDir}/generated-resources/parsec to resources
        sourceSet.getResources().srcDir(pathUtils.getGeneratedResourcesPath());

        // Make compileJava trigger generate
        tasks.getByName(JavaPlugin.COMPILE_JAVA_TASK_NAME).dependsOn(generateTask);
    });
}
项目:intellij-ce-playground    文件:NdkComponentModelPlugin.java   
/**
 * Remove unintended tasks created by Gradle native plugin from task list.
 *
 * Gradle native plugins creates static library tasks automatically.  This method removes
 * them to avoid cluttering the task list.
 */
@Mutate
public void hideNativeTasks(TaskContainer tasks, BinaryContainer binaries) {
    // Gradle do not support a way to remove created tasks.  The best workaround is to clear the
    // group of the task and have another task depends on it.  Therefore, we have to create
    // a dummy task to depend on all the tasks that we do not want to show up on the task
    // list. The dummy task dependsOn itself, effectively making it non-executable and
    // invisible unless the --all option is use.
    final Task nonExecutableTask = tasks.create("nonExecutableTask");
    nonExecutableTask.dependsOn(nonExecutableTask);
    nonExecutableTask
            .setDescription("Dummy task to hide other unwanted tasks in the task list.");

    binaries.withType(NativeLibraryBinarySpec.class, new Action<NativeLibraryBinarySpec>() {
        @Override
        public void execute(NativeLibraryBinarySpec binary) {
            Task buildTask = binary.getBuildTask();
            nonExecutableTask.dependsOn(buildTask);
            buildTask.setGroup(null);
        }
    });
}
项目:Pushjet-Android    文件:BinaryTasksRuleDefinitionHandler.java   
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);
    }
}
项目:Pushjet-Android    文件:CreateSourceTransformTask.java   
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);
            }
        }
    });
}
项目:Pushjet-Android    文件:LanguageBasePlugin.java   
@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);
            }
        }
    }
}
项目:Pushjet-Android    文件:VisualStudioPlugin.java   
@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);
}
项目:Pushjet-Android    文件:MavenPublishPlugin.java   
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));
        }
    });
}
项目:Pushjet-Android    文件:NativeBinariesTestPlugin.java   
@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()));
    }
}
项目:Pushjet-Android    文件:DefaultAntBuilder.java   
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;
    }
}
项目:Pushjet-Android    文件:MavenPublishPlugin.java   
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));
}
项目:Pushjet-Android    文件:CreateVisualStudioTasks.java   
@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);
}
项目:Pushjet-Android    文件:DefaultAntBuilder.java   
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;
    }
}
项目:checkstyle-addons    文件:TaskCreator.java   
public void establishSonarQubeSourceSet()
{
    final JavaPluginConvention javaConvention = project.getConvention().getPlugin(JavaPluginConvention.class);
    final SourceSetContainer sourceSets = javaConvention.getSourceSets();
    final ConfigurationContainer configs = project.getConfigurations();

    final SourceSet testSourceSet = sourceSets.getByName(SourceSet.TEST_SOURCE_SET_NAME);
    final SourceSet sqSourceSet = sourceSets.create(BuildUtil.SONARQUBE_SOURCE_SET_NAME);

    configs.getByName(testSourceSet.getImplementationConfigurationName()).extendsFrom(
        configs.getByName(sqSourceSet.getImplementationConfigurationName()));
    configs.getByName(testSourceSet.getRuntimeOnlyConfigurationName()).extendsFrom(
        configs.getByName(sqSourceSet.getRuntimeOnlyConfigurationName()));

    final TaskContainer tasks = project.getTasks();
    tasks.getByName(JavaPlugin.COMPILE_TEST_JAVA_TASK_NAME).dependsOn(
        tasks.getByName(sqSourceSet.getClassesTaskName()));

    final FileCollection sqOutputs = sqSourceSet.getOutput().getClassesDirs().plus(
        project.files(sqSourceSet.getOutput().getResourcesDir()));
    testSourceSet.setCompileClasspath(testSourceSet.getCompileClasspath().plus(sqOutputs));
    testSourceSet.setRuntimeClasspath(testSourceSet.getRuntimeClasspath().plus(sqOutputs));
}
项目:checkstyle-addons    文件:TaskCreator.java   
public void setupBuildTasks(@Nonnull final DependencyConfig pDepConfig)
{
    final TaskContainer tasks = project.getTasks();

    // compile, classes
    setupCompileTaskForSourceSet(pDepConfig, SourceSet.MAIN_SOURCE_SET_NAME, TaskNames.compileJava,
        TaskNames.mainClasses);
    setupCompileTaskForSourceSet(pDepConfig, BuildUtil.SONARQUBE_SOURCE_SET_NAME, TaskNames.compileSonarqubeJava,
        TaskNames.sonarqubeClasses);
    setupCompileTaskForSourceSet(pDepConfig, SourceSet.TEST_SOURCE_SET_NAME, TaskNames.compileTestJava,
        TaskNames.testClasses);

    // test
    final TestTask testTask = tasks.create(TaskNames.test.getName(pDepConfig), TestTask.class);
    testTask.configureFor(pDepConfig, pDepConfig.getCheckstyleBaseVersion());

    // javadoc
    final JavadocTask javadocTask = tasks.create(TaskNames.javadoc.getName(pDepConfig), JavadocTask.class);
    javadocTask.configureFor(pDepConfig);
}
项目:checkstyle-addons    文件:TaskCreator.java   
private void setupCompileTaskForSourceSet(@Nonnull final DependencyConfig pDepConfig,
    @Nonnull final String pSourceSetName, @Nonnull final TaskNames pCompileTaskName,
    @Nonnull final TaskNames pClassesTaskName)
{
    final TaskContainer tasks = project.getTasks();
    final boolean isTest = SourceSet.TEST_SOURCE_SET_NAME.equals(pSourceSetName);

    final SourceSet sourceSet = buildUtil.getSourceSet(pSourceSetName);
    final CompileTask compileTask = tasks.create(pCompileTaskName.getName(pDepConfig), CompileTask.class);
    compileTask.configureFor(pDepConfig, sourceSet, isTest);

    final Task classesTask = tasks.create(pClassesTaskName.getName(pDepConfig));
    classesTask.setDescription(
        buildUtil.getLongName() + ": Assembles '" + pSourceSetName + "' classes for dependency configuration '"
            + pDepConfig.getName() + "'");
    classesTask.setGroup(BasePlugin.BUILD_GROUP);
    classesTask.dependsOn(compileTask, tasks.getByName(sourceSet.getProcessResourcesTaskName()));
}
项目:checkstyle-addons    文件:TaskCreator.java   
/**
 * Assign some standard tasks and tasks created by third-party plugins to their task groups according to the
 * order of things for Checkstyle Addons.
 */
public void adjustTaskGroupAssignments()
{
    final TaskContainer tasks = project.getTasks();
    tasks.getByName(BasePlugin.ASSEMBLE_TASK_NAME).setGroup(ARTIFACTS_GROUP_NAME);
    tasks.getByName(JavaPlugin.JAR_TASK_NAME).setGroup(ARTIFACTS_GROUP_NAME);

    final SourceSet sqSourceSet = buildUtil.getSourceSet(BuildUtil.SONARQUBE_SOURCE_SET_NAME);
    tasks.getByName(JavaPlugin.COMPILE_JAVA_TASK_NAME).setGroup(BasePlugin.BUILD_GROUP);
    tasks.getByName(sqSourceSet.getCompileJavaTaskName()).setGroup(BasePlugin.BUILD_GROUP);
    tasks.getByName(JavaPlugin.COMPILE_TEST_JAVA_TASK_NAME).setGroup(BasePlugin.BUILD_GROUP);

    for (final FindBugs fbTask : tasks.withType(FindBugs.class)) {
        fbTask.setGroup(LifecycleBasePlugin.VERIFICATION_GROUP);
    }
    for (final Checkstyle csTask : tasks.withType(Checkstyle.class)) {
        csTask.setGroup(LifecycleBasePlugin.VERIFICATION_GROUP);
    }
    for (final Copy task : tasks.withType(Copy.class)) {
        if (task.getName().startsWith("process") && task.getName().endsWith("Resources")) {
            task.setGroup(LifecycleBasePlugin.BUILD_GROUP);
        }
    }
}
项目:Reer    文件:CUnitPlugin.java   
@Mutate
public void createCUnitLauncherTasks(TaskContainer tasks, TestSuiteContainer testSuites) {
    for (final CUnitTestSuiteSpec suite : testSuites.withType(CUnitTestSuiteSpec.class).values()) {

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

        CSourceSet launcherSources = findLauncherSources(suite);
        skeletonTask.setSourceDir(launcherSources.getSource().getSrcDirs().iterator().next());
        skeletonTask.setHeaderDir(launcherSources.getExportedHeaders().getSrcDirs().iterator().next());
        launcherSources.builtBy(skeletonTask);
    }
}
项目:Reer    文件:BinaryBasePlugin.java   
@Mutate
void copyBinaryTasksToTaskContainer(TaskContainer tasks, BinaryContainer binaries) {
    for (BinarySpec binary : binaries) {
        tasks.addAll(binary.getTasks());
        Task buildTask = binary.getBuildTask();
        if (buildTask != null) {
            tasks.add(buildTask);
        }
    }
}
项目:Reer    文件:ComponentModelBasePlugin.java   
@Finalize
void createSourceTransformTasks(final TaskContainer tasks, @Path("binaries") final ModelMap<BinarySpecInternal> binaries, LanguageTransformContainer languageTransforms, ServiceRegistry serviceRegistry) {
    BinarySourceTransformations transformations = new BinarySourceTransformations(tasks, languageTransforms, serviceRegistry);
    for (BinarySpecInternal binary : binaries) {
        if (binary.isLegacyBinary()) {
            continue;
        }

        transformations.createTasksFor(binary);
    }
}
项目:Reer    文件:TestingModelBasePlugin.java   
@Finalize
void copyBinariesCheckTasksToTaskContainer(TaskContainer tasks, BinaryContainer binaries) {
    for (BinarySpec binary : binaries) {
        Task checkTask = binary.getCheckTask();
        if (checkTask != null) {
            tasks.add(checkTask);
        }
    }
}
项目:Reer    文件:IncludedBuildTaskReferenceResolver.java   
@Override
public Task constructTask(final TaskReference reference, TaskContainer tasks) {
    if (!(reference instanceof IncludedBuildTaskReference)) {
        return null;
    }

    final IncludedBuildTaskReference ref = (IncludedBuildTaskReference) reference;
    String delegateTaskName = ref.getBuildName();

    Task task = tasks.findByName(delegateTaskName);

    if (task == null) {
        return tasks.create(delegateTaskName, CompositeBuildTaskDelegate.class, new Action<CompositeBuildTaskDelegate>() {
            @Override
            public void execute(CompositeBuildTaskDelegate compositeBuildTaskDelegate) {
                compositeBuildTaskDelegate.setBuild(ref.getBuildName());
                compositeBuildTaskDelegate.addTask(ref.getTaskPath());
            }
        });
    }

    if (task instanceof CompositeBuildTaskDelegate) {
        CompositeBuildTaskDelegate delegateTask = (CompositeBuildTaskDelegate) task;
        Preconditions.checkState(((CompositeBuildTaskDelegate) task).getBuild().equals(ref.getBuildName()));
        delegateTask.addTask(ref.getTaskPath());
        return task;
    }

    throw new TaskInstantiationException("Cannot create delegating task '" + delegateTaskName + "' as task with same name already exists.");
}
项目:Reer    文件:EclipsePlugin.java   
private static <T extends Task> void maybeAddTask(Project project, IdePlugin plugin, String taskName, Class<T> taskType, Action<T> action) {
    TaskContainer tasks = project.getTasks();
    if (tasks.findByName(taskName) != null) {
        return;
    }

    T task = tasks.create(taskName, taskType);
    action.execute(task);
    plugin.addWorker(task);
}
项目:minikube-build-tools-for-java    文件:MinikubePluginTest.java   
@Test
public void testDefaultMinikubeTasks() {
  Project project = ProjectBuilder.builder().withProjectDir(tmp.getRoot()).build();
  project.getPluginManager().apply(MinikubePlugin.class);
  ((ProjectInternal) project).evaluate();

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

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

  AssertMinikubeTaskConfig(tc, "minikubeStart", "start");
  AssertMinikubeTaskConfig(tc, "minikubeStop", "stop");
  AssertMinikubeTaskConfig(tc, "minikubeDelete", "delete");
}
项目:crnk-framework    文件:TSGeneratorPlugin.java   
private void setupRuntimeDependencies(Project project, Task generateTask) {
    TSGeneratorConfig config = project.getExtensions().getByType(TSGeneratorConfig.class);
    String runtimeConfiguration = config.getRuntime().getConfiguration();
    if (runtimeConfiguration != null) {
        String runtimeConfigurationFirstUpper =
                Character.toUpperCase(runtimeConfiguration.charAt(0)) + runtimeConfiguration.substring(1);

        // make sure applications is compiled in order to startup and extract meta information
        String processResourcesName = "process" + runtimeConfigurationFirstUpper + "Resources";
        String compileJavaName = "compile" + runtimeConfigurationFirstUpper + "Java";
        TaskContainer tasks = project.getTasks();
        Task processResourceTask = tasks.findByName(processResourcesName);
        Task compileJavaTask = tasks.findByName(compileJavaName);
        if (processResourceTask != null) {
            generateTask.dependsOn(processResourceTask);
        }
        if (compileJavaTask != null) {
            generateTask.dependsOn(compileJavaTask, compileJavaTask);
        }

        // setup up-to-date checking
        Configuration compileConfiguration = project.getConfigurations().findByName(runtimeConfiguration);
        if (compileConfiguration != null) {
            generateTask.getInputs().file(compileConfiguration.getFiles());
            generateTask.getOutputs().dir(config.getGenDir());
        }
    }
}
项目:gradle-golang-plugin    文件:GolangPluginSupport.java   
protected void addTasks(@Nonnull TaskContainer tasks) {
    tasks.replace(realTaskNameFor("clean"), Clean.class);
    tasks.replace(realTaskNameFor("baseClean"), BaseClean.class);
    tasks.replace(realTaskNameFor("validate"), Validate.class);
    tasks.replace(realTaskNameFor("baseValidate"), BaseValidate.class);
    tasks.replace(realTaskNameFor("prepareToolchain"), PrepareToolchain.class);
    tasks.replace(realTaskNameFor("prepareSources"), PrepareSources.class);
    tasks.replace(realTaskNameFor("basePrepareSources"), BasePrepareSources.class);
    tasks.replace(realTaskNameFor("getTools"), GetTools.class);
    tasks.replace(realTaskNameFor("baseGetTools"), BaseGetTools.class);
    tasks.replace(realTaskNameFor("test"), Test.class);
    tasks.replace(realTaskNameFor("baseTest"), BaseTest.class);
    tasks.replace(realTaskNameFor("build"), Build.class);
    tasks.replace(realTaskNameFor("baseBuild"), BaseBuild.class);
}
项目:core-java    文件:ModelVerifierShould.java   
@Before
public void setUp() {
    project = mock(Project.class);
    when(project.getSubprojects()).thenReturn(Collections.<Project>emptySet());
    when(project.getRootProject()).thenReturn(project);
    final TaskContainer tasks = mock(TaskContainer.class);
    final TaskCollection emptyTaskCollection = mock(TaskCollection.class);
    when(emptyTaskCollection.iterator()).thenReturn(Iterators.emptyIterator());
    when(emptyTaskCollection.toArray()).thenReturn(EMPTY_ARRAY);
    when(tasks.withType(any(Class.class))).thenReturn(emptyTaskCollection);
    when(project.getTasks()).thenReturn(tasks);
}
项目:gauge-gradle-plugin    文件:GaugePluginTest.java   
@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);
}
项目:Pushjet-Android    文件:JvmComponentPlugin.java   
@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);
    }
}
项目:Pushjet-Android    文件:JvmComponentPlugin.java   
private Task createJarTask(TaskContainer tasks, JarBinarySpecInternal binary) {
    Jar jar = tasks.create(binary.getNamingScheme().getTaskName("create"), Jar.class);
    jar.setDescription(String.format("Creates the binary file for %s.", binary.getNamingScheme().getDescription()));
    jar.from(binary.getClassesDir());
    jar.from(binary.getResourcesDir());

    jar.setDestinationDir(binary.getJarFile().getParentFile());
    jar.setArchiveName(binary.getJarFile().getName());

    return jar;
}
项目:Pushjet-Android    文件:BinaryTasksRuleDefinitionHandler.java   
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);
    }
}