org.gradle.api.Project.getTasks()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(10.1k)|赞(0)|评价(0)|浏览(255)

本文整理了Java中org.gradle.api.Project.getTasks()方法的一些代码示例,展示了Project.getTasks()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Project.getTasks()方法的具体详情如下:
包路径:org.gradle.api.Project
类名称:Project
方法名:getTasks

Project.getTasks介绍

暂无

代码示例

代码示例来源:origin: jooby-project/jooby

private void configureApiTool(final Project project) {
 project.getTasks()
   .withType(ApiToolTask.class, task -> {
    ConventionMapping mapping = task.getConventionMapping();
    mapping.map("mainClassName", () -> project.getProperties().get("mainClassName"));
   });
 Map<String, Object> options = new HashMap<>();
 options.put(Task.TASK_TYPE, ApiToolTask.class);
 options.put(Task.TASK_DEPENDS_ON, "classes");
 options.put(Task.TASK_NAME, "joobyApiTool");
 options
   .put(Task.TASK_DESCRIPTION, "Export your HTTP API to open standards like Swagger and RAML");
 options.put(Task.TASK_GROUP, "jooby");
 project.getTasks().create(options);
}

代码示例来源:origin: uber/okbuck

@Override
public TestOptions getTestOptions() {
 String testTaskName =
   VariantType.UNIT_TEST_PREFIX
     + StringUtils.capitalize(getName())
     + VariantType.UNIT_TEST_SUFFIX;
 List<Test> testTasks = ImmutableList.copyOf(getProject().getTasks().withType(Test.class));
 Optional<Test> optionalTest =
   testTasks.stream().filter(test -> test.getName().equals(testTaskName)).findFirst();
 List<String> jvmArgs =
   optionalTest.map(Test::getAllJvmArgs).orElseGet(Collections::<String>emptyList);
 Map<String, Object> env =
   optionalTest.map(Test::getEnvironment).orElseGet(Collections::emptyMap);
 System.getenv().keySet().forEach(env::remove);
 return new TestOptions(jvmArgs, env);
}

代码示例来源:origin: uber/okbuck

public Set<String> getExcludes() {
 Jar jarTask = (Jar) getProject().getTasks().findByName(JavaPlugin.JAR_TASK_NAME);
 return jarTask != null ? jarTask.getExcludes() : ImmutableSet.of();
}

代码示例来源:origin: uber/okbuck

/**
 * The test options
 *
 * @return The test options
 */
public TestOptions getTestOptions() {
 Test testTask = (Test) getProject().getTasks().getByName(JavaPlugin.TEST_TASK_NAME);
 Map<String, Object> env = testTask.getEnvironment();
 env.keySet().removeAll(System.getenv().keySet());
 return new TestOptions(testTask.getAllJvmArgs(), testTask.getEnvironment());
}

代码示例来源:origin: jooby-project/jooby

private void configureJoobyAssets(final Project project) {
 project.getTasks()
   .withType(AssetTask.class, task -> {
    ConventionMapping mapping = task.getConventionMapping();
    mapping.map("env", () -> "dist");
    mapping.map("maxAge", () -> "365d");
    mapping.map("mainClassName", () -> project.getProperties().get("mainClassName"));
    mapping.map("output", () -> new JoobyProject(project).classes());
    mapping.map("assemblyOutput", () -> new File(project.getBuildDir(), "__public_"));
   });
 Map<String, Object> options = new HashMap<>();
 options.put(Task.TASK_TYPE, AssetTask.class);
 options.put(Task.TASK_DEPENDS_ON, "classes");
 options.put(Task.TASK_NAME, "joobyAssets");
 options.put(Task.TASK_DESCRIPTION, "Process, optimize and compress static files");
 options.put(Task.TASK_GROUP, "jooby");
 project.getTasks().create(options);
}

代码示例来源:origin: f2prateek/dart

GenerateHensonNavigatorTask generateHensonNavigatorTask =
  project
    .getTasks()
    .create(
      "generate" + capitalize(variant.getName()) + "HensonNavigator",

代码示例来源:origin: uber/okbuck

public JvmTarget(
  Project project, String name, String aptConfigurationName, String testAptConfigurationName) {
 super(project, name);
 this.aptConfigurationName = aptConfigurationName;
 this.testAptConfigurationName = testAptConfigurationName;
 sourceSets = getProject().getConvention().getPlugin(JavaPluginConvention.class).getSourceSets();
 isKotlin =
   project.getPlugins().stream().anyMatch(plugin -> plugin instanceof KotlinBasePluginWrapper);
 Optional<Task> compileTask =
   project.getTasks().stream().filter(it -> it instanceof AbstractCompile).findFirst();
 if (compileTask.isPresent()) {
  fakeCompile = (AbstractCompile) compileTask.get();
 } else {
  fakeCompile = null;
 }
}

代码示例来源:origin: uber/okbuck

.getTasks()
.withType(KotlinCompile.class)
.stream()

代码示例来源:origin: apollographql/apollo-android

@Override
public void exec() {
 if (Utils.isNullOrEmpty(url) || Utils.isNullOrEmpty(output)) {
  throw new IllegalArgumentException("Schema URL and output path can't be empty");
 }
 setScript(new File(getProject().getTasks().getByPath(ApolloCodegenInstallTask.NAME).getOutputs().getFiles()
   .getAsPath(), ApolloLocalCodegenGenerationTask.APOLLO_CODEGEN_EXEC_FILE));
 List<String> args = Lists.newArrayList("introspect-schema", url, "--output", getProject().file(output)
   .getAbsolutePath());
 if (!headers.isEmpty()) {
  for(String h : headers) {
   args.add("--header");
   args.add(h);
  }
 }
 if (insecure) {
  args.add("--insecure");
  args.add("true");
 }
 setArgs(args);
 super.exec();
}

代码示例来源:origin: jooby-project/jooby

private void configureJoobyRun(final Project project) {
 project.getTasks()
   .withType(JoobyTask.class, joobyRun -> {
    ConventionMapping mapping = joobyRun.getConventionMapping();
    mapping.map("classpath", () -> new JoobyProject(project).classpath());
    mapping.map("src", () -> new JoobyProject(project).sources());
    mapping.map("mainClassName", () -> project.getProperties().get("mainClassName"));
    mapping.map("srcExtensions", () -> Arrays.asList(".java", ".conf", ".properties", ".kt"));
    mapping.map("compiler", () -> {
     File eclipseClasspath = new File(project.getProjectDir(), ".classpath");
     return eclipseClasspath.exists() ? "off" : "on";
    });
    Gradle gradle = project.getGradle();
    mapping.map("block", () -> !gradle.getStartParameter().isContinuous());
    mapping.map("logLevel", () -> gradle.getStartParameter().getLogLevel().name());
   });
 Map<String, Object> options = new HashMap<>();
 options.put(Task.TASK_TYPE, JoobyTask.class);
 options.put(Task.TASK_DEPENDS_ON, "classes");
 options.put(Task.TASK_NAME, "joobyRun");
 options.put(Task.TASK_DESCRIPTION, "Run, debug and hot reload applications");
 options.put(Task.TASK_GROUP, "jooby");
 project.getTasks().create(options);
}

代码示例来源:origin: uber/okbuck

public boolean hasLintRegistry() {
 Jar jarTask = (Jar) getProject().getTasks().findByName(JavaPlugin.JAR_TASK_NAME);
 return jarTask != null
   && (jarTask.getManifest().getAttributes().containsKey("Lint-Registry")
     || jarTask.getManifest().getAttributes().containsKey("Lint-Registry-v2"));
}

代码示例来源:origin: uber/okbuck

rootBuckProject -> {
 Task setupOkbuck = rootBuckProject.getTasks().create("setupOkbuck");
 setupOkbuck.setGroup(GROUP);
 setupOkbuck.setDescription("Setup okbuck cache and dependencies");
     .getTasks()
     .create(OKBUCK, OkBuckTask.class, okbuckExt, kotlin, scala, buckFileManager);
 rootOkBuckTask.dependsOn(setupOkbuck);
   .getTasks()
   .create(
     BUCK_WRAPPER,
     .getTasks()
     .create(OKBUCK_CLEAN, OkBuckCleanTask.class, okbuckExt.buckProjects);
 rootOkBuckTask.dependsOn(okBuckClean);
      bp.getConfigurations().maybeCreate(BUCK_LINT);
      Task okbuckProjectTask = bp.getTasks().maybeCreate(OKBUCK);
      okbuckProjectTask.doLast(
        task -> {

代码示例来源:origin: uber/okbuck

public Scope getMain() {
 JavaCompile compileJavaTask =
   (JavaCompile) getProject().getTasks().getByName(JavaPlugin.COMPILE_JAVA_TASK_NAME);
 return Scope.builder(getProject())
   .configuration(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME)
   .sourceDirs(getMainSrcDirs())
   .javaResourceDirs(getMainJavaResourceDirs())
   .compilerOptions(
     Scope.Builder.COMPILER.JAVA, compileJavaTask.getOptions().getCompilerArgs())
   .compilerOptions(Scope.Builder.COMPILER.KOTLIN, getKotlinCompilerOptions(false))
   .build();
}

代码示例来源:origin: uber/okbuck

public Scope getTest() {
 JavaCompile testCompileJavaTask =
   (JavaCompile) getProject().getTasks().getByName(JavaPlugin.COMPILE_TEST_JAVA_TASK_NAME);
 return Scope.builder(getProject())
   .configuration(JavaPlugin.TEST_RUNTIME_CLASSPATH_CONFIGURATION_NAME)
   .sourceDirs(getTestSrcDirs())
   .javaResourceDirs(getTestJavaResourceDirs())
   .compilerOptions(
     Scope.Builder.COMPILER.JAVA, testCompileJavaTask.getOptions().getCompilerArgs())
   .compilerOptions(Scope.Builder.COMPILER.KOTLIN, getKotlinCompilerOptions(true))
   .build();
}

代码示例来源:origin: hibernate/hibernate-orm

project.getLogger().debug( "Applying Hibernate enhancement action to SourceSet.{}", sourceSet.getName() );
final Task compileTask = project.getTasks().findByName( sourceSet.getCompileJavaTaskName() );
compileTask.doLast(
    new Action<Task>() {

代码示例来源:origin: diffplug/spotless

@Before
public void createTask() {
  Project project = ProjectBuilder.builder().build();
  checkTask = project.getTasks().create("checkTaskUnderTest", SpotlessTask.class);
  checkTask.setCheck();
  applyTask = project.getTasks().create("applyTaskUnderTest", SpotlessTask.class);
  applyTask.setApply();
}

代码示例来源:origin: diffplug/spotless

@Override
public void runAllTasks(Project project) {
  project.getTasks().stream()
      .filter(task -> task instanceof SpotlessTask)
      .map(task -> (SpotlessTask) task)
      .forEach(task -> Errors.rethrow().run(() -> {
        IncrementalTaskInputs inputs = Mocks.mockIncrementalTaskInputs(task.getTarget());
        task.setApply();
        task.performAction(inputs);
      }));
}

代码示例来源:origin: diffplug/spotless

@Override
public void runAllTasks(Project project) {
  project.getTasks().stream()
      .filter(task -> task instanceof SpotlessTask)
      .map(task -> (SpotlessTask) task)
      .forEach(task -> Errors.rethrow().run(() -> {
        IncrementalTaskInputs inputs = Mocks.mockIncrementalTaskInputs(task.getTarget());
        task.setCheck();
        task.performAction(inputs);
      }));
}

代码示例来源:origin: diffplug/spotless

private SpotlessTask createCheckTask(String name, FormatterStep step) {
  SpotlessTask task = project.getTasks().create("spotless" + SpotlessPlugin.capitalize(name), SpotlessTask.class);
  task.setCheck();
  task.addStep(step);
  task.setLineEndingsPolicy(LineEnding.UNIX.createPolicy());
  task.setTarget(Collections.singletonList(file));
  return task;
}

代码示例来源:origin: diffplug/spotless

private SpotlessTask create(List<File> files) throws IOException {
  Project project = ProjectBuilder.builder().withProjectDir(rootFolder()).build();
  SpotlessTask task = project.getTasks().create("underTest", SpotlessTask.class);
  task.setLineEndingsPolicy(LineEnding.UNIX.createPolicy());
  task.setTarget(files);
  task.setCheck();
  return task;
}

相关文章