gpt4 book ai didi

com.atlassian.maven.plugins.amps.util.ZipUtils类的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 12:28:03 33 4
gpt4 key购买 nike

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

ZipUtils介绍

暂无

代码示例

代码示例来源:origin: com.atlassian.maven.plugins/amps-maven-plugin

/**
 * @param prefix the prefix. If empty, uses the srcDir's name. That means you can't create a zip with no
 * root folder.
 */
public static void zipDir(File zipFile, File srcDir, String prefix) throws IOException
{
  try (ZipArchiveOutputStream out = new ZipArchiveOutputStream(zipFile))
  {
    addZipPrefixes(srcDir, out, prefix);
    addZipDir(srcDir, out, prefix);
  }
}

代码示例来源:origin: com.atlassian.maven.plugins/amps-maven-plugin

/**
 * Count the number of nested root folders. A root folder is a folder which contains 0 or 1 file or folder.
 *
 * Example: A zip with only "generated-resources/home/database.log" has 2 root folders.
 *
 * @param zip the zip file
 * @return the number of root folders.
 */
public static int countNestingLevel(File zip) throws IOException
{
  try (ZipFile zipFile = new ZipFile(zip))
  {
    List<String> filenames = toList(zipFile.getEntries());
    return countNestingLevel(filenames);
  }
}

代码示例来源:origin: com.atlassian.maven.plugins/maven-amps-plugin

/**
 * Ungzips and extracts the specified tar.gz file into the specified directory.
 * @param targz the tar.gz file to use
 * @param destDir the directory to contain the extracted contents
 * @throws IOException
 */
public static void untargz(final File targz, final String destDir) throws IOException
{
  untargz(targz, destDir, 0);
}

代码示例来源:origin: com.atlassian.maven.plugins/amps-maven-plugin

String entryPrefix = ensurePrefixWithSlash(dirObj, prefix);
    addZipDir(currentFile, out, entryName);
      copyViaBuffer(in, out, tmpBuf);

代码示例来源:origin: com.atlassian.maven.plugins/amps-maven-plugin

public static void unzip(File zipFile, String destDir) throws IOException
{
  unzip(zipFile, destDir, 0);
}

代码示例来源:origin: com.atlassian.maven.plugins/amps-maven-plugin

@Override
protected File extractApplication(Product ctx, File homeDir) throws MojoExecutionException
{
  File appDir = createDirectory(getAppDirectory(ctx));
  ProductArtifact defaults = getArtifact();
  ProductArtifact artifact = new ProductArtifact(
      firstNotNull(ctx.getGroupId(), defaults.getGroupId()),
      firstNotNull(ctx.getArtifactId(), defaults.getArtifactId()),
      firstNotNull(ctx.getVersion(), defaults.getVersion()));
  final File cruDistZip = goals.copyDist(getBuildDirectory(), artifact);
  try
  {
    // We remove one level of root folder from the zip if present
    int nestingLevel = ZipUtils.countNestingLevel(cruDistZip);
    unzip(cruDistZip, appDir.getPath(), nestingLevel > 0 ? 1 : 0);
  }
  catch (final IOException ex)
  {
    throw new MojoExecutionException("Unable to extract application ZIP artifact", ex);
  }
  return appDir;
}

代码示例来源:origin: com.atlassian.maven.plugins/maven-amps-plugin

byte[] tmpBuf = new byte[1024];
File currentFile;
String entryPrefix = ensurePrefixWithSlash(dirObj, prefix);
String entryName = "";
    addZipDir(currentFile, out, entryName);

代码示例来源:origin: com.atlassian.maven.plugins/amps-maven-plugin

if (!appDir.exists())
  unzip(app, appDir.getAbsolutePath());
ZipUtils.zipChildren(warFile, appDir);
return warFile;

代码示例来源:origin: com.atlassian.maven.plugins/amps-maven-plugin

if(pattern == null || pattern.matcher(name).matches())
  String zipPath = trimPathSegments(name, leadingPathSegmentsToTrim);
  if (flatten)
    zipPath = flattenPath(zipPath);

代码示例来源:origin: com.atlassian.maven.plugins/maven-amps-plugin

trimPathSegments(entry.getName(), leadingPathSegmentsToTrim));

代码示例来源:origin: com.atlassian.maven.plugins/maven-amps-plugin

private static void addZipPrefixes(File dirObj, ZipArchiveOutputStream out, String prefix) throws IOException
{
  // need to manually add the prefix folders
  String entryPrefix = ensurePrefixWithSlash(dirObj, prefix);
  String[] prefixes = entryPrefix.split("/");
  String lastPrefix = "";
  for (int i = 0; i < prefixes.length; i++)
  {
    ZipArchiveEntry entry = new ZipArchiveEntry(lastPrefix + prefixes[i] + "/");
    out.putArchiveEntry(entry);
    out.closeArchiveEntry();
    lastPrefix = prefixes[i] + "/";
  }
}

代码示例来源:origin: com.atlassian.maven.plugins/amps-maven-plugin

/**
 * Count the number of nested root directories in the filenames.
 *
 * A root directory is a directory that has no sibling.
 * @param filenames the list of filenames, using / as a separator. Must be a mutable copy,
 * as it will be modified.
 */
static int countNestingLevel(List<String> filenames)
{
  String prefix = StringUtils.getCommonPrefix(filenames.toArray(new String[0]));
  if (!prefix.endsWith("/"))
  {
    prefix = prefix.substring(0, prefix.lastIndexOf("/") + 1);
  }
  // The first prefix may be wrong, example:
  // root/ <- to be discarded
  // root/nested/ <- to be discarded
  // root/nested/folder1/file.txt <- the root "root/nested/" will be detected properly
  // root/nested/folder2/file.txt
  if (filenames.remove(prefix))
  {
    return countNestingLevel(filenames);
  }
  // The client can't use these filenames anymore.
  filenames.clear();
  return StringUtils.countMatches(prefix, "/");
}

代码示例来源:origin: com.atlassian.maven.plugins/maven-amps-plugin

ZipUtils.zipDir(targetZip, homeSnapshot, entryBase);

代码示例来源:origin: com.atlassian.maven.plugins/amps-maven-plugin

copyViaBuffer(content, out, buffer);

代码示例来源:origin: com.atlassian.maven.plugins/maven-amps-plugin

public static void unzip(final File zipFile, final String destDir) throws IOException
{
  unzip(zipFile, destDir, 0);
}

代码示例来源:origin: com.atlassian.maven.plugins/maven-amps-plugin

@Override
protected File extractApplication(Product ctx, File homeDir) throws MojoExecutionException
{
  File appDir = createDirectory(getAppDirectory(ctx));
  ProductArtifact defaults = getArtifact();
  ProductArtifact artifact = new ProductArtifact(
      firstNotNull(ctx.getGroupId(), defaults.getGroupId()),
      firstNotNull(ctx.getArtifactId(), defaults.getArtifactId()),
      firstNotNull(ctx.getVersion(), defaults.getVersion()));
  final File cruDistZip = goals.copyDist(getBuildDirectory(), artifact);
  try
  {
    // We remove one level of root folder from the zip if present
    int nestingLevel = ZipUtils.countNestingLevel(cruDistZip);
    unzip(cruDistZip, appDir.getPath(), nestingLevel > 0 ? 1 : 0);
  }
  catch (final IOException ex)
  {
    throw new MojoExecutionException("Unable to extract application ZIP artifact", ex);
  }
  return appDir;
}

代码示例来源:origin: com.atlassian.maven.plugins/amps-maven-plugin

unzip(bundledPluginsFile, bundledPluginsDir.getPath());
ZipUtils.zipChildren(bundledPluginsFile, bundledPluginsDir);

代码示例来源:origin: com.atlassian.maven.plugins/amps-maven-plugin

trimPathSegments(entry.getName(), leadingPathSegmentsToTrim));

代码示例来源:origin: com.atlassian.maven.plugins/amps-maven-plugin

private static void addZipPrefixes(File dirObj, ZipArchiveOutputStream out, String prefix) throws IOException
{
  // need to manually add the prefix folders
  String entryPrefix = ensurePrefixWithSlash(dirObj, prefix);
  String[] prefixes = entryPrefix.split("/");
  String lastPrefix = "";
  for (String p : prefixes)
  {
    ZipArchiveEntry entry = new ZipArchiveEntry(lastPrefix + p + "/");
    out.putArchiveEntry(entry);
    out.closeArchiveEntry();
    lastPrefix = p + "/";
  }
}

代码示例来源:origin: com.atlassian.maven.plugins/maven-amps-plugin

/**
 * Count the number of nested root directories in the filenames.
 *
 * A root directory is a directory that has no sibling.
 * @param filenames the list of filenames, using / as a separator. Must be a mutable copy,
 * as it will be modified.
 */
static int countNestingLevel(List<String> filenames)
{
  String prefix = StringUtils.getCommonPrefix(filenames.toArray(new String[filenames.size()]));
  if (!prefix.endsWith("/"))
  {
    prefix = prefix.substring(0, prefix.lastIndexOf("/") + 1);
  }
  // The first prefix may be wrong, example:
  // root/ <- to be discarded
  // root/nested/ <- to be discarded
  // root/nested/folder1/file.txt <- the root "root/nested/" will be detected properly
  // root/nested/folder2/file.txt
  if (filenames.remove(prefix))
  {
    return countNestingLevel(filenames);
  }
  // The client can't use these filenames anymore.
  filenames.clear();
  return StringUtils.countMatches(prefix, "/");
}

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com