gpt4 book ai didi

io.fabric8.utils.Zips类的使用及代码示例

转载 作者:知者 更新时间:2024-03-16 05:29:31 27 4
gpt4 key购买 nike

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

Zips介绍

暂无

代码示例

代码示例来源:origin: io.fabric8/fabric-utils

/**
 * Creates a zip fie from the given source directory and output zip file name
 */
public static void createZipFile(Logger log, File sourceDir, File outputZipFile) throws IOException {
  FileFilter filter = null;
  createZipFile(log, sourceDir, outputZipFile, filter);
}

代码示例来源:origin: io.fabric8/fabric-utils

if (f.isDirectory()) {
  String prefix = path + f.getName() + "/";
  if (matches(filter, f)) {
    zos.putNextEntry(new ZipEntry(prefix));
    zipDirectory(log, f, zos, prefix, filter);
  if (matches(filter, f)) {
    FileInputStream fis = new FileInputStream(f);
    try {

代码示例来源:origin: io.fabric8/arquillian-fabric8

public static List<String> getMavenDependencies(Session session) throws IOException {
  List<String> dependencies = new ArrayList<>();
  try {
    File[] files = Maven.resolver().loadPomFromFile("pom.xml").importTestDependencies().resolve().withoutTransitivity().asFile();
    for (File f : files) {
      if (f.getName().endsWith("jar") && hasKubernetesJson(f)) {
        Path dir = Files.createTempDirectory(session.getId());
        try (FileInputStream fis = new FileInputStream(f); JarInputStream jis = new JarInputStream(fis)) {
          Zips.unzip(new FileInputStream(f), dir.toFile());
          File jsonPath = dir.resolve(DEFAULT_CONFIG_FILE_NAME).toFile();
          if (jsonPath.exists()) {
            dependencies.add(jsonPath.toURI().toString());
          }
        }
      } else if (f.getName().endsWith(".json")) {
        dependencies.add(f.toURI().toString());
      }
    }
  } catch (Exception e) {
    session.getLogger().warn("Skipping maven project dependencies. Caused by:" + e.getMessage());
  }
  return dependencies;
}

代码示例来源:origin: io.fabric8/fabric-utils

public static void createZipFile(Logger log, File sourceDir, File outputZipFile, FileFilter filter) throws IOException {
  outputZipFile.getParentFile().mkdirs();
  OutputStream os = new FileOutputStream(outputZipFile);
  ZipOutputStream zos = new ZipOutputStream(os);
  try {
    //zos.setLevel(Deflater.DEFAULT_COMPRESSION);
    //zos.setLevel(Deflater.NO_COMPRESSION);
    String path = "";
    zipDirectory(log, sourceDir, zos, path, filter);
  } finally {
    Closeables.closeQuietly(zos);
  }
}

代码示例来源:origin: io.fabric8/fabric-utils

/**
 * Unzips the given input stream of a ZIP to the given directory
 */
public static void unzip(InputStream in, File toDir) throws IOException {
  ZipInputStream zis = new ZipInputStream(new BufferedInputStream(in));
  try {
    ZipEntry entry = zis.getNextEntry();
    while (entry != null) {
      if (!entry.isDirectory()) {
        String entryName = entry.getName();
        File toFile = new File(toDir, entryName);
        toFile.getParentFile().mkdirs();
        OutputStream os = new FileOutputStream(toFile);
        try {
          try {
            copy(zis, os);
          } finally {
            zis.closeEntry();
          }
        } finally {
          Closeables.closeQuietly(os);
        }
      }
      entry = zis.getNextEntry();
    }
  } finally {
    closeQuietly(zis);
  }
}

代码示例来源:origin: io.fabric8/fabric8-arquillian

public List<String> resolve(Session session) throws IOException {
  List<String> dependencies = new ArrayList<>();
  try {
    File[] files = Maven.resolver().loadPomFromFile(pathToPomFile).importTestDependencies().resolve().withoutTransitivity().asFile();
    for (File f : files) {
      if (f.getName().endsWith("jar") && hasKubernetesJson(f)) {
        Path dir = Files.createTempDirectory(session.getId());
        try (FileInputStream fis = new FileInputStream(f); JarInputStream jis = new JarInputStream(fis)) {
          Zips.unzip(new FileInputStream(f), dir.toFile());
          File jsonPath = dir.resolve(DEFAULT_CONFIG_FILE_NAME).toFile();
          if (jsonPath.exists()) {
            dependencies.add(jsonPath.toURI().toString());
          }
        }
      } else if (f.getName().endsWith(".json")) {
        dependencies.add(f.toURI().toString());
      }
    }
  } catch (Exception e) {
    if (rethrowExcpetions) {
      throw e;
    } else {
      session.getLogger().warn("Skipping maven project dependencies. Caused by:" + e.getMessage());
    }
  }
  return dependencies;
}

代码示例来源:origin: fabric8io/jube

@Override
  public void install(InstallContext installContext, ProcessConfig config, String id, File installDir) throws Exception {
    config.setName(options.getName());
    installDir.mkdirs();
    File archive = getDownloadStrategy(options).downloadContent(options.getUrl(), installDir);
    if (archive == null) {
      archive = new File(installDir, INSTALLED_BINARY);
    }
    File nestedProcessDirectory = null;
    if (archive.exists()) {
      Zips.unzip(new FileInputStream(archive), installDir);
      InstallHelper.chmodAllScripts(installDir);
      nestedProcessDirectory = findInstallDir(installDir);
      allocatePorts(options, nestedProcessDirectory);
      exportInstallDirEnvVar(options, nestedProcessDirectory, installContext, config);
    }
  }
};

代码示例来源:origin: fabric8io/jube

Zips.createZipFile(LOG, buildDir, outputZipFile);
getLog().info("Created image zip: " + outputZipFile);

代码示例来源:origin: fabric8io/jube

protected void unpackBaseImage(File buildDir, boolean useDefaultPrefix) throws Exception {
  String imageName = project.getProperties().getProperty(DOCKER_BASE_IMAGE_PROPERTY);
  Objects.notNull(imageName, DOCKER_BASE_IMAGE_PROPERTY);
  ImageMavenCoords baseImageCoords = ImageMavenCoords.parse(imageName, useDefaultPrefix);
  String coords = baseImageCoords.getAetherCoords();
  Artifact artifact = repositorySystem.createArtifactWithClassifier(baseImageCoords.getGroupId(),
      baseImageCoords.getArtifactId(), baseImageCoords.getVersion(), baseImageCoords.getType(),
      baseImageCoords.getClassifier());
  getLog().info("Resolving Jube image: " + artifact);
  ArtifactResolutionRequest request = new ArtifactResolutionRequest();
  request.setArtifact(artifact);
  request.setLocalRepository(localRepository);
  request.setRemoteRepositories(pomRemoteRepositories);
  ArtifactResolutionResult result = artifactResolver.resolve(request);
  if (!result.isSuccess()) {
    throw new ArtifactNotFoundException("Cannot download Jube image", artifact);
  }
  getLog().info("Resolved Jube image: " + artifact);
  if (artifact.getFile() != null) {
    File file = artifact.getFile();
    getLog().info("File: " + file);
    if (!file.exists() || file.isDirectory()) {
      throw new MojoExecutionException("Resolved file for " + coords + " is not a valid file: " + file.getAbsolutePath());
    }
    getLog().info("Unpacking base image " + file.getAbsolutePath() + " to build dir: " + buildDir);
    Zips.unzip(new FileInputStream(file), buildDir);
  }
}

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