本文整理了Java中org.gradle.api.Project.getTasksByName()
方法的一些代码示例,展示了Project.getTasksByName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Project.getTasksByName()
方法的具体详情如下:
包路径:org.gradle.api.Project
类名称:Project
方法名:getTasksByName
暂无
代码示例来源:origin: gradle.plugin.com.github.opengl-8080/assertjGen-gradle-plugin
public Tasks getTasks(String name) {
Set<Task> tasksByName = this.project.getTasksByName(name, false);
return new Tasks(tasksByName);
}
//
代码示例来源:origin: gradle.plugin.com.google.cloud.tools/jib-gradle-plugin
@Nullable
@Override
public String getMainClassFromJar() {
List<Task> jarTasks = new ArrayList<>(project.getTasksByName("jar", false));
if (jarTasks.size() != 1) {
return null;
}
return (String) ((Jar) jarTasks.get(0)).getManifest().getAttributes().get("Main-Class");
}
代码示例来源:origin: avianey/androidsvgdrawable-plugin
@Override
public void execute(Project project) {
Set<Task> preBuildTasks = project.getTasksByName("preBuild", false);
if (preBuildTasks.isEmpty()) {
project.getLogger().error("The Android plugin 'preBuild' task could not be found. Skipping SVG generation...");
} else {
preBuildTasks.iterator().next().dependsOn(project.getTasks().withType(SvgDrawableTask.class));
}
}
});
代码示例来源:origin: offbynull/coroutines
@SuppressWarnings("unchecked")
@Override
public void apply(Project target) {
// Add config block
CoroutinesPluginConfiguration config = new CoroutinesPluginConfiguration();
target.getExtensions().add("coroutines", config);
Set<Task> compileJavaTasks = target.getTasksByName("compileJava", true);
for (Task task : compileJavaTasks) {
addInstrumentActionToTask("main", task, config);
}
Set<Task> compileJavaTestTasks = target.getTasksByName("compileTestJava", true);
for (Task task : compileJavaTestTasks) {
addInstrumentActionToTask("test", task, config);
}
log = target.getLogger();
}
代码示例来源:origin: gradle.plugin.com.digitalascent/digitalascent-gradle-project
private void registerPublishArtifactsTask(Project project) {
Action<DefaultTask> configureAction = task -> {
task.dependsOn("release", "bintrayUpload", "artifactoryPublish");
task.setGroup("publishing");
Task bintrayUploadTask = project.getTasksByName("bintrayUpload", false).stream().findFirst().orElseThrow(() -> new IllegalStateException("Unable to find bintrayUpload task"));
Task artifactoryPublishTask = project.getTasksByName("artifactoryPublish", false).stream().findFirst().orElseThrow(() -> new IllegalStateException("Unable to find artifactoryPublish task"));
artifactoryPublishTask.setEnabled(false);
bintrayUploadTask.setEnabled(false);
// TODO - can these come from gradle-info-plugin?
String tag = System.getenv("TRAVIS_TAG");
String branch = System.getenv("TRAVIS_BRANCH");
String pullRequest = System.getenv("TRAVIS_PULL_REQUEST");
if ((tag != null && !tag.isEmpty()) || ("master".equals(branch) && "false".equals(pullRequest))) {
if (tag != null && !tag.isEmpty()) {
bintrayUploadTask.setEnabled(true);
} else {
artifactoryPublishTask.setEnabled(true);
}
}
project.getLogger().lifecycle("Publish artifacts task configured; tag={}, branch={}, pullRequest={},bintrayUploadTask.enabled={},artifactoryPublishTask={}",
tag, branch, pullRequest, bintrayUploadTask.getEnabled(), artifactoryPublishTask.getEnabled());
};
project.getTasks().create("publishArtifacts", DefaultTask.class, configureAction);
}
代码示例来源:origin: gradle.plugin.tui.sse.mde4cpp/MDE4CPPGeneratePlugin
setDependsOn(getProject().getRootProject().getTasksByName(m_generator.getCreateTaskName(), true));
代码示例来源:origin: dsyer/spring-boot-thin-launcher
private void createCopyTask(final Project project, final Jar jar) {
String task = "bootRepackage";
Jar thinJar = jar;
if (project.getTasksByName(task, true).isEmpty()) {
task = "thinJar" + suffix(jar);
if (suffix(jar).startsWith("ThinJar")) {
return;
if (!project.getTasksByName(task, true).isEmpty()) {
return;
代码示例来源:origin: gradle.plugin.com.greensopinion.gradle-android-eclipse/gradle-android-eclipse
@Override
public void execute(Project project) {
logger.info("Updating eclipse model with Android dependencies");
EclipseModel eclipseModel = eclipseModel(project);
eclipseModel.getClasspath().getFile().beforeMerged(new AddSourceFoldersAction());
eclipseModel.getClasspath().getFile().whenMerged(new GenerateLibraryDependenciesAction(project));
eclipseModel.getClasspath().getFile().whenMerged(new AndroidSdkLibraryDependenciesAction(project));
project.getTasksByName("eclipseClasspath", false).forEach(t -> t.dependsOn("generateDebugSources"));
logger.info("Android dependencies done");
}
});
代码示例来源:origin: gradle.plugin.org.cinchapi.jarsh/jarsh
task.setGroup(BasePlugin.BUILD_GROUP);
final Task executableJarTask = project
.getTasksByName(ExecutableJarPlugin.EXECUTABLE_JAR_TASK_NAME,
false).iterator().next();
task.dependsOn(executableJarTask);
代码示例来源:origin: diffplug/goomph
@Override
protected void applyOnce(Project project) {
ProjectDepsExtension extension = project.getExtensions().create(ProjectDepsExtension.NAME, ProjectDepsExtension.class);
EclipseProjectPlugin.modifyEclipseProject(project, eclipseModel -> {
// find the project's referenced projects and reference them explicitly in the eclipse model
Task prepareEclipse = project.task("prepareEclipse");
prepareEclipse.doLast(task -> {
Set<String> referencedProjects = eclipseModel.getProject().getReferencedProjects();
project.getConfigurations().stream()
.flatMap(config -> config.getDependencies().stream())
.filter(dep -> dep instanceof ProjectDependency)
.forEach(dep -> {
referencedProjects.add(dep.getName());
});
});
// it's needed for generating the eclipseClasspath and eclipseProject
Iterables.getOnlyElement(project.getTasksByName("eclipseClasspath", false)).dependsOn(prepareEclipse);
Iterables.getOnlyElement(project.getTasksByName("eclipseProject", false)).dependsOn(prepareEclipse);
// create robust classpath entries for all referenced projects
eclipseModel.getClasspath().getFile().getXmlTransformer().addAction(xmlProvider -> {
modifyClasspath(xmlProvider.asNode(), eclipseModel, extension);
});
});
}
内容来源于网络,如有侵权,请联系作者删除!