All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.jengelman.gradle.plugins.shadow.internal.DefaultZipCompressor.kt Maven / Gradle / Ivy

Go to download

Gradle plugin to create fat/uber JARs, apply file transforms, and relocate packages for applications and libraries. Gradle version of Maven's Shade plugin.

There is a newer version: 9.0.0-beta4
Show newest version
package com.github.jengelman.gradle.plugins.shadow.internal

import java.io.File
import org.apache.tools.zip.Zip64Mode
import org.apache.tools.zip.ZipOutputStream
import org.gradle.api.UncheckedIOException

internal class DefaultZipCompressor(
  allowZip64Mode: Boolean,
  private val entryCompressionMethod: Int,
) : ZipCompressor {
  private val zip64Mode = if (allowZip64Mode) Zip64Mode.AsNeeded else Zip64Mode.Never

  override fun createArchiveOutputStream(destination: File): ZipOutputStream {
    try {
      return ZipOutputStream(destination).apply {
        setUseZip64(zip64Mode)
        setMethod(entryCompressionMethod)
      }
    } catch (e: Exception) {
      throw UncheckedIOException("Unable to create ZIP output stream for file $destination.", e)
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy