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

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

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

Project.tarTree介绍

暂无

代码示例

代码示例来源:origin: com.palantir.gradle.conjure/gradle-conjure

@Override
  public void execute(Task task) {
    Set<String> rootDirectories = new HashSet<>();
    getProject().tarTree(tarFile.get()).visit(new FileVisitor() {
      @Override
      public void visitDir(FileVisitDetails dirDetails) {
        // Note: If root dir contains only another dir (e.g. a/b), we won't get called with just that
        // root dir 'a', but with 'a/b' directly. Hence, we look at all dirs and extract their first
        // 'segment'.
        String[] segments = dirDetails.getRelativePath().getSegments();
        if (segments.length >= 1) {
          rootDirectories.add(segments[0]);
        }
      }
      @Override
      public void visitFile(FileVisitDetails fileDetails) { }
    });
    if (rootDirectories.size() != 1) {
      throw new GradleException(String.format(
          "Expected exactly one root directory in tar '%s', aborting: %s",
          tarFile.get(),
          rootDirectories));
    }
  }
});

代码示例来源:origin: com.liferay/com.liferay.gradle.plugins.node

@Override
public void execute(CopySpec copySpec) {
  String nodeFileName = nodeFile.getName();
  if (nodeFileName.endsWith(".exe")) {
    copySpec.from(nodeFile.getParentFile());
  }
  else {
    copySpec.eachFile(new StripPathSegmentsAction(1));
    copySpec.setIncludeEmptyDirs(false);
    if (nodeFileName.endsWith(".zip")) {
      copySpec.from(project.zipTree(nodeFile));
    }
    else {
      copySpec.from(project.tarTree(nodeFile));
    }
  }
  copySpec.into(nodeDir);
}

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

@Override
public void execute(CopySpec copySpec) {
  String nodeFileName = nodeFile.getName();
  if (nodeFileName.endsWith(".exe")) {
    copySpec.from(nodeFile.getParentFile());
  }
  else {
    copySpec.eachFile(new StripPathSegmentsAction(1));
    copySpec.setIncludeEmptyDirs(false);
    if (nodeFileName.endsWith(".zip")) {
      copySpec.from(project.zipTree(nodeFile));
    }
    else {
      copySpec.from(project.tarTree(nodeFile));
    }
  }
  copySpec.into(nodeDir);
}

代码示例来源:origin: com.liferay/com.liferay.gradle.plugins.node

@Override
public void execute(CopySpec copySpec) {
  copySpec.eachFile(new StripPathSegmentsAction(1));
  copySpec.from(project.tarTree(npmFile));
  copySpec.into(npmDir);
  copySpec.setIncludeEmptyDirs(false);
}

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

@Override
public void execute(CopySpec copySpec) {
  copySpec.eachFile(new StripPathSegmentsAction(1));
  copySpec.from(project.tarTree(npmFile));
  copySpec.into(npmDir);
  copySpec.setIncludeEmptyDirs(false);
}

代码示例来源:origin: gradle.plugin.com.outlinegames/plugin

public static FileTree mergeArchives(Project project, HashMultimap<File, String> filesAndPaths) {
 FileTree result = null;
 for (File file : filesAndPaths.keys()) {
  ReadableResource resource = project.getResources().gzip(file);
  PatternSet pattern = new PatternSet();
  for (String s : filesAndPaths.get(file)) {
   pattern.include(String.format("**/%s/**", s));
  }
  FileTree tree = project.tarTree(resource).matching(pattern);
  if (null == result) {
   result = tree;
  } else {
   result = result.plus(tree);
  }
 }
 return result;
}

代码示例来源:origin: gradle.plugin.com.banderous.gpm/plugin

public static FileTree mergeArchives(Project project, HashMultimap<File, String> filesAndPaths) {
 FileTree result = null;
 for (File file : filesAndPaths.keys()) {
  ReadableResource resource = project.getResources().gzip(file);
  PatternSet pattern = new PatternSet();
  for (String s : filesAndPaths.get(file)) {
   pattern.include(String.format("**/%s/**", s));
  }
  FileTree tree = project.tarTree(resource).matching(pattern);
  if (null == result) {
   result = tree;
  } else {
   result = result.plus(tree);
  }
 }
 return result;
}

代码示例来源:origin: gradle.plugin.com.linkedin.pygradle/pygradle-plugin

getPyGradleBootstrap(project).getFiles().forEach(file -> {
  project.copy(copySpec -> {
    copySpec.from(project.tarTree(file.getPath()));
    copySpec.into(packageDir);
    copySpec.eachFile(it -> {

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

getPyGradleBootstrap(project).getFiles().forEach(file -> {
  project.copy(copySpec -> {
    copySpec.from(project.tarTree(file.getPath()));
    copySpec.into(packageDir);
    copySpec.eachFile(it -> {

代码示例来源:origin: com.palantir.gradle.conjure/gradle-conjure

from((Callable) () -> getProject().tarTree(tarFile.get())); // will get lazily resolved
eachFile(fcd -> fcd.setRelativePath(stripFirstName(fcd.getRelativePath())));
into((Callable) this::getOutputDirectory); // will get lazily resolved

代码示例来源:origin: gradle.plugin.com.github.rmee/kubernetes

copySpec.from(project.zipTree(compressedFile));
} else {
  copySpec.from(project.tarTree(project.getResources().gzip(compressedFile)));

相关文章