本文整理汇总了Java中org.gradle.api.tasks.TaskContainer类的典型用法代码示例。如果您正苦于以下问题:Java TaskContainer类的具体用法?Java TaskContainer怎么用?Java TaskContainer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TaskContainer类属于org.gradle.api.tasks包,在下文中一共展示了TaskContainer类的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;
}
}
示例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);
}
示例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));
}
});
}
示例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.");
}
示例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());
}
});
}
}
}
}
示例6: configurePreCompiledHeaderCompileTasks
import org.gradle.api.tasks.TaskContainer; //导入依赖的package包/类
@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);
}
}
});
}
}
}
示例7: addDependencyOrdering
import org.gradle.api.tasks.TaskContainer; //导入依赖的package包/类
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;
}
}
示例8: testMinikubeExtensionSetProperties
import org.gradle.api.tasks.TaskContainer; //导入依赖的package包/类
@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");
});
}
示例9: 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));
}
示例10: apply
import org.gradle.api.tasks.TaskContainer; //导入依赖的package包/类
@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);
}
示例11: apply
import org.gradle.api.tasks.TaskContainer; //导入依赖的package包/类
@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);
});
}
示例12: 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);
});
}
示例13: 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);
}
});
}
示例14: doRegister
import org.gradle.api.tasks.TaskContainer; //导入依赖的package包/类
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);
}
}
示例15: createCompileTasksForBinary
import org.gradle.api.tasks.TaskContainer; //导入依赖的package包/类
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);
}
}
});
}