当前位置: 首页>>代码示例>>Java>>正文


Java TaskContainer.create方法代码示例

本文整理汇总了Java中org.gradle.api.tasks.TaskContainer.create方法的典型用法代码示例。如果您正苦于以下问题:Java TaskContainer.create方法的具体用法?Java TaskContainer.create怎么用?Java TaskContainer.create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.gradle.api.tasks.TaskContainer的用法示例。


在下文中一共展示了TaskContainer.create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createTask

import org.gradle.api.tasks.TaskContainer; //导入方法依赖的package包/类
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;
    }
}
 
开发者ID:palantir,项目名称:gradle-circle-style,代码行数:17,代码来源:CircleStylePlugin.java

示例2: createTasksForVisualStudio

import org.gradle.api.tasks.TaskContainer; //导入方法依赖的package包/类
@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);
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:24,代码来源:VisualStudioPlugin.java

示例3: apply

import org.gradle.api.tasks.TaskContainer; //导入方法依赖的package包/类
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));
        }
    });
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:17,代码来源:MavenPublishPlugin.java

示例4: constructTask

import org.gradle.api.tasks.TaskContainer; //导入方法依赖的package包/类
@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.");
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:31,代码来源:IncludedBuildTaskReferenceResolver.java

示例5: configurePrefixHeaderGenerationTasks

import org.gradle.api.tasks.TaskContainer; //导入方法依赖的package包/类
@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());
                    }
                });
            }
        }
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:18,代码来源:NativeComponentModelPlugin.java

示例6: apply

import org.gradle.api.tasks.TaskContainer; //导入方法依赖的package包/类
@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));
}
 
开发者ID:mazzeb,项目名称:gradle-auto-version,代码行数:18,代码来源:AutoVersionPlugin.java

示例7: apply

import org.gradle.api.tasks.TaskContainer; //导入方法依赖的package包/类
@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);
    });
}
 
开发者ID:yahoo,项目名称:parsec,代码行数:27,代码来源:ParsecGradlePlugin.java

示例8: hideNativeTasks

import org.gradle.api.tasks.TaskContainer; //导入方法依赖的package包/类
/**
 * 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);
        }
    });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:NdkComponentModelPlugin.java

示例9: createLifecycleTaskForBinary

import org.gradle.api.tasks.TaskContainer; //导入方法依赖的package包/类
@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);
            }
        }
    }
}
 
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:17,代码来源:LanguageBasePlugin.java

示例10: createTasksForVisualStudio

import org.gradle.api.tasks.TaskContainer; //导入方法依赖的package包/类
@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);
}
 
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:25,代码来源:VisualStudioPlugin.java

示例11: apply

import org.gradle.api.tasks.TaskContainer; //导入方法依赖的package包/类
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));
        }
    });
}
 
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:17,代码来源:MavenPublishPlugin.java

示例12: createTestTasks

import org.gradle.api.tasks.TaskContainer; //导入方法依赖的package包/类
@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()));
    }
}
 
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:17,代码来源:NativeBinariesTestPlugin.java

示例13: apply

import org.gradle.api.tasks.TaskContainer; //导入方法依赖的package包/类
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));
}
 
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:20,代码来源:MavenPublishPlugin.java

示例14: createTasksForVisualStudio

import org.gradle.api.tasks.TaskContainer; //导入方法依赖的package包/类
@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);
}
 
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:24,代码来源:CreateVisualStudioTasks.java

示例15: setupBuildTasks

import org.gradle.api.tasks.TaskContainer; //导入方法依赖的package包/类
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);
}
 
开发者ID:checkstyle-addons,项目名称:checkstyle-addons,代码行数:21,代码来源:TaskCreator.java


注:本文中的org.gradle.api.tasks.TaskContainer.create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。