本文整理汇总了Java中org.gradle.api.tasks.TaskContainer.findByName方法的典型用法代码示例。如果您正苦于以下问题:Java TaskContainer.findByName方法的具体用法?Java TaskContainer.findByName怎么用?Java TaskContainer.findByName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.gradle.api.tasks.TaskContainer
的用法示例。
在下文中一共展示了TaskContainer.findByName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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.");
}
示例2: maybeAddTask
import org.gradle.api.tasks.TaskContainer; //导入方法依赖的package包/类
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);
}
示例3: setupRuntimeDependencies
import org.gradle.api.tasks.TaskContainer; //导入方法依赖的package包/类
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());
}
}
}