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

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

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

Project.zipTree介绍

暂无

代码示例

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

public void setWarFile(File warFile) {
 from(getProject().zipTree(warFile));
}

代码示例来源:origin: MinecraftForge/ForgeGradle

@Override
  public FileTree resolveDelayed(String replaced)
  {
    String name;
    File file;
    
    if (hardcoded != null)
    {
      name = hardcoded.getName();
      file = hardcoded;
    }
    else
    {
      name = replaced;
      file = project.file(replaced);
    }
    
    if (name.endsWith(".jar") || name.endsWith(".zip"))
    {
      return project.zipTree(file);
    }
    else
    {
      return project.fileTree(file);
    }
  }
}

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

public void setWarFile(File warFile) {
 from(getProject().zipTree(warFile));
}

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

public void setWarFile(Path warFile) {
 from(getProject().zipTree(warFile));
}

代码示例来源:origin: MinecraftForge/ForgeGradle

public Object call() {
    File file = delayedFile(retromappedSrc).call();
    if (file.exists())
      return sourceJar.getProject().zipTree(delayedFile(retromappedSrc));
    else
      return new ArrayList<File>();
  }
});

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

@Override
  public List<FileTree> call() throws Exception {
    List<FileTree> fileTrees = Lists.newArrayList();
    for (File file : scope.getProject().getConfigurations().getByName(
        JacocoPlugin.AGENT_CONFIGURATION_NAME)) {
      fileTrees.add(scope.getProject().zipTree(file));
    }
    return fileTrees;
  }
});

代码示例来源:origin: MinecraftForge/ForgeGradle

private void createOutput(File outJar, File sourceJar, File classDir, File resourceJar) throws IOException
{
  Set<String> elementsAdded = Sets.newHashSet();
  // make output
  JarOutputStream zout = new JarOutputStream(new FileOutputStream(outJar));
  Visitor visitor = new Visitor(zout, elementsAdded);
  // custom resources should override existing ones, so resources first.
  if (resourceJar != null)
  {
    getProject().zipTree(resourceJar).visit(visitor);
  }
  getProject().zipTree(sourceJar).visit(visitor); // then the ones from the the original sources
  getProject().fileTree(classDir).visit(visitor); // then the classes
  zout.close();
}

代码示例来源: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.enonic.gradle/xp-gradle-plugin

private void copySpec( final CopySpec spec )
  {
    getInputFiles().forEach( f -> spec.from( getProject().zipTree( f ) ) );
    spec.include( "dev/**" );
    spec.into( getOutputDir() );
  }
}

代码示例来源: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: gradle.plugin.com.enonic.xp/xp-gradle-plugin

private void copySpec( final CopySpec spec )
  {
    getInputFiles().forEach( f -> spec.from( getProject().zipTree( f ) ) );
    spec.include( "dev/**" );
    spec.into( getOutputDir() );
  }
}

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

public static Copy addTaskExpandCompileDependency(
  Project project, File file, File destinationDir, String taskNamePrefix,
  RenameDependencyClosure renameDependencyClosure) {
  String taskName = GradleUtil.getTaskName(taskNamePrefix, file);
  Copy copy = GradleUtil.addTask(project, taskName, Copy.class);
  copy.doFirst(
    new Action<Task>() {
      @Override
      public void execute(Task task) {
        Copy copy = (Copy)task;
        Project project = copy.getProject();
        project.delete(copy.getDestinationDir());
      }
    });
  copy.from(project.zipTree(file));
  String name = renameDependencyClosure.call(file.getName());
  name = name.substring(0, name.length() - 4);
  destinationDir = new File(destinationDir, name);
  copy.setDescription(
    "Expands " + file.getName() + " into " +
      project.relativePath(destinationDir) + ".");
  copy.setDestinationDir(destinationDir);
  return copy;
}

代码示例来源:origin: gradle.plugin.com.enonic.gradle/xp-gradle-plugin

private void doCopy( final CopySpec spec )
  {
    for ( final File dependency : getFrom() )
    {
      spec.from( getProject().zipTree( dependency ) );
    }

    spec.into( getOutputDir() );
  }
}

代码示例来源:origin: gradle.plugin.com.enonic.xp/xp-gradle-plugin

private void doCopy( final CopySpec spec )
  {
    for ( final File dependency : getFrom() )
    {
      spec.from( getProject().zipTree( dependency ) );
    }

    spec.into( getOutputDir() );
  }
}

代码示例来源:origin: MinecraftForge/ForgeGradle

@TaskAction
public void doTask() throws IOException
{
  File dest = getDestinationDir();
  if (shouldClean())
  {
    delete(dest);
  }
  dest.mkdirs();
  ExtractionVisitor visitor = new ExtractionVisitor(dest, isIncludeEmptyDirs(), patternSet.getAsSpec());
  for (File source : getConfigFiles())
  {
    getLogger().debug("Extracting: " + source);
    getProject().zipTree(source).visit(visitor);
  }
}

代码示例来源:origin: MinecraftForge/ForgeGradle

@TaskAction
public void doTask() throws IOException
{
  File dest = getDestinationDir();
  if (shouldClean())
  {
    delete(dest);
  }
  dest.mkdirs();
  
  ExtractionVisitor visitor = new ExtractionVisitor(dest, isIncludeEmptyDirs(), patternSet.getAsSpec());
  for (File source : getSourcePaths())
  {
    getLogger().debug("Extracting: " + source);
    getProject().zipTree(source).visit(visitor);
  }
}

代码示例来源:origin: gradle.plugin.com.enonic.gradle/xp-gradle-plugin

private void configureCopySpec( final CopySpec spec )
{
  spec.into( getInstallDir() );
  spec.from( getProject().zipTree( resolveDependency() ) );
  spec.setIncludeEmptyDirs( false );
  spec.eachFile( this::configureRename );
}

代码示例来源:origin: io.freefair.gradle/jsass-plugin

@TaskAction
  public void extractWebjars() {
    getProject().sync(sync -> {
      sync.into(outputDirectory);

      sync.setDuplicatesStrategy(DuplicatesStrategy.WARN);

      webjars.filter(File::isFile).getFiles().forEach(file ->
          sync.from(getProject().zipTree(file), jarSpec -> {
            jarSpec.include("META-INF/resources/webjars/**");
            jarSpec.setIncludeEmptyDirs(false);
            jarSpec.eachFile(fcd -> fcd.setPath(fcd.getPath().replaceFirst("META-INF/resources/webjars/(.*?)/(.*?)/", "$1/")));

          })
      );
    });
  }
}

代码示例来源:origin: gradle.plugin.com.enonic.xp/xp-gradle-plugin

private void configureCopySpec( final CopySpec spec )
{
  spec.into( getInstallDir() );
  spec.from( getProject().zipTree( resolveDependency() ) );
  spec.setIncludeEmptyDirs( false );
  spec.eachFile( this::configureRename );
}

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

@Override
 public void execute(CopySpec copySpec) {
  copySpec.from(project.zipTree(zip));
  copySpec.include(includes);
  copySpec.setIncludeEmptyDirs(false);
  copySpec.into(project.file("Assets"));
  copySpec.eachFile(new Action<FileCopyDetails>() {
   @Override
   public void execute(FileCopyDetails details) {
    Log.L.info("Including {}", details.getRelativePath());
    String[] segments = details.getRelativePath().getSegments();
    // Chop off the 'Assets' folder.
    if (segments[0].equals("Assets")) {
     String[] tail = Arrays.copyOfRange(segments, 1, segments.length);
     boolean isFile = details.getFile().isFile();
     RelativePath path = new RelativePath(isFile, tail);
     details.setRelativePath(path);
    }
   }
  });
 }
});

相关文章