gpt4 book ai didi

io.fabric8.utils.Zips.unzip()方法的使用及代码示例

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

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

Zips.unzip介绍

[英]Unzips the given input stream of a ZIP to the given directory
[中]

代码示例

代码示例来源: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/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

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);
  }
}

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