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

x33g5p2x  于2022-01-29 转载在 其他  
字(16.2k)|赞(0)|评价(0)|浏览(122)

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

Task.getOutputs介绍

暂无

代码示例

代码示例来源: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: gradle.plugin.com.liferay/gradle-plugins-wsdl-builder

@SuppressWarnings("unused")
public void doCall(CopySpec copySpec) {
  copySpec.from(generateTask.getOutputs());
}

代码示例来源:origin: gradle.plugin.org.cinchapi.jarsh/jarsh

@Override
public Void call() {
  File runnableJarFile = executableJarTask.getOutputs()
      .getFiles().iterator().next();
  Path stubPath = Paths.get(outputDir.getAbsolutePath()
      + File.separator + "stub.sh");
  try {
    Files.copy(this.getClass().getResourceAsStream("/stub.sh"),
        stubPath);
    TFiles.cat(jarshFile.getAbsolutePath(), stubPath.toFile()
        .getAbsolutePath(), runnableJarFile
        .getAbsolutePath());
    Files.delete(stubPath);
    jarshFile.setExecutable(true);
  }
  catch (Exception e) {
    throw new RuntimeException(e);
  }
  return null;
}

代码示例来源:origin: avianey/androidsvgdrawable-plugin

@Override
public Task configure(Closure closure) {
  Task task = super.configure(closure);
  if (svgMaskedSvgOutputDirectory == null) {
    svgMaskedSvgOutputDirectory = new File(getProject().getBuildDir(), "generated-svg");
  }
  if (!task.getInputs().getHasInputs()) {
    task.getInputs().files(
        from(asList(from, ninePatchConfig, svgMaskFiles, svgMaskResourceFiles))
            .filter(notNull).toArray(Object.class));
  }
  if (!task.getOutputs().getHasOutput()) {
    task.getOutputs().files(
        from(asList(to, svgMaskedSvgOutputDirectory))
            .filter(notNull).toArray(File.class));
  }
  return task;
}

代码示例来源:origin: gradle.plugin.com.google.cloud.tools/jib-gradle-plugin

/**
 * Returns the input files for a task.
 *
 * @param extraDirectory the image's configured extra directory
 * @param project the gradle project
 * @return the input files to the task are all the output files for all the dependencies of the
 *     {@code classes} task
 */
static FileCollection getInputFiles(File extraDirectory, Project project) {
 Task classesTask = project.getTasks().getByPath("classes");
 Set<? extends Task> classesDependencies =
   classesTask.getTaskDependencies().getDependencies(classesTask);
 List<FileCollection> dependencyFileCollections = new ArrayList<>();
 for (Task task : classesDependencies) {
  dependencyFileCollections.add(task.getOutputs().getFiles());
 }
 if (Files.exists(extraDirectory.toPath())) {
  return project.files(dependencyFileCollections, extraDirectory);
 } else {
  return project.files(dependencyFileCollections);
 }
}

代码示例来源:origin: palantir/gradle-baseline

public void apply(Project rootProject) {
  this.project = rootProject;
  if (!rootProject.equals(rootProject.getRootProject())) {
    throw new IllegalArgumentException(
        BaselineConfig.class.getCanonicalName() + " plugin can only be applied to the root project.");
  }
  Configuration configuration = rootProject.getConfigurations().create("baseline");
  // users can still override this default dependency, it just reduces boilerplate
  Optional<String> version = Optional.ofNullable(getClass().getPackage().getImplementationVersion());
  configuration.defaultDependencies(d -> d.add(rootProject.getDependencies().create(String.format(
      "com.palantir.baseline:gradle-baseline-java-config%s@zip", version.map(v -> ":" + v).orElse("")))));
  // Create task for generating configuration.
  rootProject.getTasks().register("baselineUpdateConfig", task -> {
    task.setGroup("Baseline");
    task.setDescription("Installs or updates Baseline configuration files in .baseline/");
    task.getInputs().files(configuration);
    task.getOutputs().dir(getConfigDir());
    task.getOutputs().dir(rootProject.getRootDir().toPath().resolve("project"));
    task.doLast(new BaselineUpdateConfigAction(configuration, rootProject));
  });
}

代码示例来源:origin: awslabs/aws-mobile-appsync-sdk-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(), ApolloIRGenTask.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: gradle.plugin.com.linkedin.pygradle/pygradle-plugin

@Override
public void applyTo(final Project project) {
  // XXX: This needs to be adjusted to work with a build matrix one day. Until
  // that is ready, we always assume pure Python 2.7 on Linux.
  String version = project.getVersion().toString().replace("-", "_");
  String name = project.getName().replace("-", "_");
  final File wheelArtifact = new File(project.getProjectDir(), "/dist/" + name + "-" + version + "-py2-none-any.whl");
  /*
   * Create a Python wheel distribution.
   */
  project.getTasks().create(TASK_PACKAGE_WHEEL, task -> {
    task.dependsOn(project.getTasks().getByName(StandardTextValues.TASK_INSTALL_PROJECT.getValue()));
    task.getOutputs().file(wheelArtifact);
    task.doLast(it -> project.exec(execSpec -> {
      execSpec.environment(settings.pythonEnvironmentDistgradle);
      execSpec.commandLine(settings.getDetails().getVirtualEnvInterpreter(), "setup.py", "bdist_wheel");
    }));
  });
  LinkedHashMap<String, Object> wheelArtifactInfo = new LinkedHashMap<>(5);
  wheelArtifactInfo.put("name", name);
  wheelArtifactInfo.put("classifier", "py2-none-any");
  wheelArtifactInfo.put("type", "whl");
  wheelArtifactInfo.put("file", wheelArtifact);
  wheelArtifactInfo.put("builtBy", project.getTasks().getByName(TASK_PACKAGE_WHEEL));
  if (!version.contains("SNAPSHOT")) {
    project.getArtifacts().add(StandardTextValues.CONFIGURATION_WHEEL.getValue(), wheelArtifactInfo);
  }
}

代码示例来源:origin: linkedin/pygradle

@Override
public void applyTo(final Project project) {
  // XXX: This needs to be adjusted to work with a build matrix one day. Until
  // that is ready, we always assume pure Python 2.7 on Linux.
  String version = project.getVersion().toString().replace("-", "_");
  String name = project.getName().replace("-", "_");
  final File wheelArtifact = new File(project.getProjectDir(), "/dist/" + name + "-" + version + "-py2-none-any.whl");
  /*
   * Create a Python wheel distribution.
   */
  project.getTasks().create(TASK_PACKAGE_WHEEL, task -> {
    task.dependsOn(project.getTasks().getByName(StandardTextValues.TASK_INSTALL_PROJECT.getValue()));
    task.getOutputs().file(wheelArtifact);
    task.doLast(it -> project.exec(execSpec -> {
      execSpec.environment(settings.pythonEnvironmentDistgradle);
      execSpec.commandLine(settings.getDetails().getVirtualEnvInterpreter(), "setup.py", "bdist_wheel");
    }));
  });
  LinkedHashMap<String, Object> wheelArtifactInfo = new LinkedHashMap<>(5);
  wheelArtifactInfo.put("name", name);
  wheelArtifactInfo.put("classifier", "py2-none-any");
  wheelArtifactInfo.put("type", "whl");
  wheelArtifactInfo.put("file", wheelArtifact);
  wheelArtifactInfo.put("builtBy", project.getTasks().getByName(TASK_PACKAGE_WHEEL));
  if (!version.contains("SNAPSHOT")) {
    project.getArtifacts().add(StandardTextValues.CONFIGURATION_WHEEL.getValue(), wheelArtifactInfo);
  }
}

代码示例来源:origin: GoogleCloudPlatform/app-gradle-plugin

/**
 * Returns the appengine service directory for this project and modifies the task dependencies of
 * run/start to ensure {@code serviceProject} is built first.
 */
public File projectAsService(Project serviceProject) {
 if (!serviceProject.equals(project)) {
  project.evaluationDependsOn(serviceProject.getPath());
 }
 project
   .getTasks()
   .findByName(AppEngineStandardPlugin.RUN_TASK_NAME)
   .dependsOn(serviceProject.getTasks().findByPath(BasePlugin.ASSEMBLE_TASK_NAME));
 project
   .getTasks()
   .findByName(AppEngineStandardPlugin.START_TASK_NAME)
   .dependsOn(serviceProject.getTasks().findByPath(BasePlugin.ASSEMBLE_TASK_NAME));
 return serviceProject
   .getTasks()
   .findByName(AppEngineStandardPlugin.EXPLODE_WAR_TASK_NAME)
   .getOutputs()
   .getFiles()
   .getSingleFile();
}

代码示例来源:origin: gradle.plugin.com.liferay/gradle-plugins-xsd-builder

protected void configureTaskBuildXSD(BuildXSDTask buildXSDTask) {
  FileCollection inputFiles = buildXSDTask.getInputFiles();
  if (inputFiles.isEmpty()) {
    return;
  }
  Task generateTask = addTaskBuildXSDGenerate(buildXSDTask);
  Task compileTask = addTaskBuildXSDCompile(buildXSDTask, generateTask);
  buildXSDTask.from(compileTask.getOutputs());
  buildXSDTask.from(generateTask.getOutputs());
  TaskOutputs taskOutputs = buildXSDTask.getOutputs();
  GradleUtil.addDependency(
    buildXSDTask.getProject(), JavaPlugin.COMPILE_CONFIGURATION_NAME,
    taskOutputs.getFiles());
}

代码示例来源:origin: gradle.plugin.com.liferay/gradle-plugins-wsdl-builder

private Task _addTaskBuildWSDLCompile(
  BuildWSDLTask buildWSDLTask, FileCollection classpath, File inputFile,
  File tmpDir, Task generateTask) {
  Project project = buildWSDLTask.getProject();
  String taskName = GradleUtil.getTaskName(
    buildWSDLTask.getName() + "Compile", inputFile);
  JavaCompile javaCompile = GradleUtil.addTask(
    project, taskName, JavaCompile.class);
  javaCompile.setClasspath(classpath);
  File tmpBinDir = new File(tmpDir, "bin");
  javaCompile.setDestinationDir(tmpBinDir);
  javaCompile.setSource(generateTask.getOutputs());
  return javaCompile;
}

代码示例来源:origin: gradle.plugin.com.palantir.python/gradle-miniconda-plugin

public static Delete createCleanupTask(TaskContainer tasks, Task task) {
  String cleanTaskName = getCleanTaskName(task);
  Delete clean = tasks.create(cleanTaskName, Delete.class);
  clean.setGroup(task.getGroup());
  clean.setDescription("Cleans for " + task.getName());
  clean.delete(task.getOutputs().getFiles());
  task.mustRunAfter(clean);
  return clean;
}

代码示例来源:origin: com.amazon.device.tools.build/gradle-core

@Override
  public Set<File> call() {
    // when the application is obfuscated, the original resources may have been
    // adapted to match changing package names for instance, so we take the
    // resources from the obfuscation process results rather than the original
    // exploded library's classes.jar files.
    if (config.isMinifyEnabled() && variantData.obfuscationTask != null) {
      return variantData.obfuscationTask.getOutputs().getFiles().getFiles();
    }
    return scope.getGlobalScope().getAndroidBuilder().getPackagedJars(config);
  }
});

代码示例来源:origin: gradle.plugin.com.liferay/gradle-plugins-xsd-builder

protected Task addTaskBuildXSDCompile(
  BuildXSDTask buildXSDTask, Task generateTask) {
  Project project = buildXSDTask.getProject();
  JavaCompile javaCompile = GradleUtil.addTask(
    project, buildXSDTask.getName() + "Compile", JavaCompile.class);
  javaCompile.dependsOn(
    BasePlugin.CLEAN_TASK_NAME +
      StringUtil.capitalize(javaCompile.getName()));
  javaCompile.setClasspath(
    GradleUtil.getConfiguration(project, CONFIGURATION_NAME));
  javaCompile.setDescription("Compiles the generated Java types.");
  File tmpBinDir = new File(
    project.getBuildDir(), buildXSDTask.getName() + "/bin");
  javaCompile.setDestinationDir(tmpBinDir);
  javaCompile.setSource(generateTask.getOutputs());
  return javaCompile;
}

代码示例来源:origin: gradle.plugin.de.otto.shopoffice/otto-classycle-plugin

private Task createClassycleTask(final Project project, final ClassycleExtension extension, final SourceSet sourceSet) {
  final String taskName = sourceSet.getTaskName("classycle", null);
  final FileCollection classesDirs = sourceSet.getOutput().getClassesDirs();
  final File reportFile = getReportingExtension(project).file("classycle_" + sourceSet.getName() + ".txt");
  final Task task = project.task(taskName);
  task.getInputs().files(classesDirs, extension.getDefinitionFile());
  task.getOutputs().file(reportFile);
  task.doLast(new ClassyclePlugin.ClassycleAction(classesDirs, reportFile, extension));
  // the classycle task depends on the corresponding classes task
  final String classesTask = sourceSet.getClassesTaskName();
  task.dependsOn(classesTask);
  if (project.getLogger().isDebugEnabled()) {
    final StringBuilder sb = new StringBuilder();
    for (final File file : classesDirs) {
      sb.append(file.getAbsolutePath()).append(" ");
    }
    project.getLogger()
        .debug("Created classycle task: " + taskName + ", report file: " + reportFile + ", depends on: "
            + classesTask + " - sourceSetDirs: " + sb.toString());
  }
  return task;
}

代码示例来源:origin: gradle.plugin.com.liferay/gradle-plugins-wsdl-builder

private Jar _addTaskBuildWSDLJar(
  BuildWSDLTask buildWSDLTask, File inputFile, Task compileTask,
  final Task generateTask) {
  Project project = buildWSDLTask.getProject();
  String taskName = GradleUtil.getTaskName(
    buildWSDLTask.getName(), inputFile);
  Jar jar = GradleUtil.addTask(project, taskName, Jar.class);
  jar.from(compileTask.getOutputs());
  if (buildWSDLTask.isIncludeSource()) {
    jar.into(
      "OSGI-OPT/src",
      new Closure<Void>(project) {
        @SuppressWarnings("unused")
        public void doCall(CopySpec copySpec) {
          copySpec.from(generateTask.getOutputs());
        }
      });
  }
  jar.setDestinationDir(buildWSDLTask.getDestinationDir());
  String wsdlName = FileUtil.stripExtension(inputFile.getName());
  jar.setArchiveName(wsdlName + "-ws.jar");
  return jar;
}

代码示例来源:origin: gradle.plugin.com.jonaslasauskas.capsule/gradle-capsule-plugin

void executesInside(Project project) {
 this.setBaseName(project.getName());
 
 project.afterEvaluate(p -> {
  mergeContentOf(p.getConfigurations().getAt("capsule"), p);
  
  from(p.getTasks().getAt("jar").getOutputs().getFiles());
  from(p.getConfigurations().getAt(RUNTIME_CONFIGURATION_NAME));
  
  defaultAttributesUsingDetailsFrom(p);
  capsuleManifest.writeTo(getManifest());
 });
}

代码示例来源:origin: org.shipkit/shipkit

private static void configureDetailedNotes(final UpdateReleaseNotesTask task,
                        final FetchReleaseNotesTask releaseNotesFetcher,
                        final Project project,
                        final ShipkitConfiguration conf,
                        final Task contributorsFetcher) {
    task.dependsOn(releaseNotesFetcher);
    task.dependsOn(contributorsFetcher);

    task.setVersion(project.getVersion().toString());
    task.setTagPrefix(conf.getGit().getTagPrefix());

    task.setGitHubRepository(conf.getGitHub().getRepository());
    task.setDevelopers(conf.getTeam().getDevelopers());

    task.setContributors(conf.getTeam().getContributors());
    if (conf.getTeam().getContributors().isEmpty()) {
      task.setContributorsDataFile(contributorsFetcher.getOutputs().getFiles().getSingleFile());
    }

    task.setGitHubLabelMapping(conf.getReleaseNotes().getLabelMapping());
    task.setReleaseNotesFile(project.file(conf.getReleaseNotes().getFile()));
    task.setGitHubUrl(conf.getGitHub().getUrl());
    task.setPreviousVersion(project.getExtensions().getByType(VersionInfo.class).getPreviousVersion());

    task.setReleaseNotesData(releaseNotesFetcher.getOutputFile());
  }
}

代码示例来源:origin: mockito/shipkit

private static void configureDetailedNotes(final UpdateReleaseNotesTask task,
                        final FetchReleaseNotesTask releaseNotesFetcher,
                        final Project project,
                        final ShipkitConfiguration conf,
                        final Task contributorsFetcher) {
    task.dependsOn(releaseNotesFetcher);
    task.dependsOn(contributorsFetcher);

    task.setVersion(project.getVersion().toString());
    task.setTagPrefix(conf.getGit().getTagPrefix());

    task.setGitHubRepository(conf.getGitHub().getRepository());
    task.setDevelopers(conf.getTeam().getDevelopers());

    task.setContributors(conf.getTeam().getContributors());
    if (conf.getTeam().getContributors().isEmpty()) {
      task.setContributorsDataFile(contributorsFetcher.getOutputs().getFiles().getSingleFile());
    }

    task.setGitHubLabelMapping(conf.getReleaseNotes().getLabelMapping());
    task.setReleaseNotesFile(project.file(conf.getReleaseNotes().getFile()));
    task.setGitHubUrl(conf.getGitHub().getUrl());
    task.setPreviousVersion(project.getExtensions().getByType(VersionInfo.class).getPreviousVersion());

    task.setReleaseNotesData(releaseNotesFetcher.getOutputFile());
  }
}

相关文章