Class ParallelZip
- All Implemented Interfaces:
Comparable<org.gradle.api.Task>,org.gradle.api.file.ContentFilterable,org.gradle.api.file.CopyProcessingSpec,org.gradle.api.file.CopySourceSpec,org.gradle.api.file.CopySpec,org.gradle.api.internal.DynamicObjectAware,org.gradle.api.internal.file.copy.CopySpecSource,org.gradle.api.internal.IConventionAware,org.gradle.api.internal.TaskInternal,org.gradle.api.Named,org.gradle.api.plugins.ExtensionAware,org.gradle.api.Task,org.gradle.api.tasks.util.PatternFilterable,org.gradle.util.Configurable<org.gradle.api.Task>
Zip task that compresses entries in parallel.
Because it extends AbstractArchiveTask it accepts the full CopySpec
DSL — from / into / include / exclude / rename /
filter / duplicatesStrategy, nesting, and the archiveFileName /
destinationDirectory conventions — exactly like Zip. Swapping
type: Zip for type: ParallelZip needs no other changes.
tasks.register('dist', ParallelZip) {
from 'build/staging'
into 'myapp-1.0'
archiveFileName = 'dist.zip'
destinationDirectory = layout.buildDirectory
store = false // true = STORE everything (fastest, ~7% larger)
skipAlreadyCompressed = true // false = always attempt DEFLATE, 1.3.x-like size
level = 6 // DEFLATE level 0..9 (ignored when store = true)
threads = 12 // default: available processors
preserveFileTimestamps = false // inherited; false = reproducible archive
}
Marked CacheableTask, unlike Gradle's own Zip/AbstractArchiveTask
(both @DisableCachingByDefault upstream -- Zip explicitly "not worth
caching", a judgment call from when archive packaging was assumed cheap). This task already
produces byte-for-byte reproducible output for identical inputs and correctly separates
@Input properties (affect the archive bytes) from @Internal ones (
threads, which doesn't), so participating in the build cache is safe: an unchanged rebuild
can skip both the copy-walk and compression entirely via a cache hit instead of re-paying for
either.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.gradle.api.Task
org.gradle.api.Task.Namer -
Field Summary
Fields inherited from interface org.gradle.api.Task
TASK_ACTION, TASK_CONSTRUCTOR_ARGS, TASK_DEPENDS_ON, TASK_DESCRIPTION, TASK_GROUP, TASK_NAME, TASK_OVERWRITE, TASK_TYPE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected org.gradle.api.internal.file.copy.CopyActionabstract org.gradle.api.provider.Property<Integer>getLevel()DEFLATE level 0..9, or -1 for the zlib default (6).abstract org.gradle.api.provider.Property<Boolean>When true (the default), an entry recognized by file-signature as already compressed (jars, gzip, images, and more -- seeARCHITECTURE.md) is STORED without even attempting DEFLATE.abstract org.gradle.api.provider.Property<Boolean>getStore()When true, every entry is STORED (no compression).abstract org.gradle.api.provider.Property<Integer>Number of compression threads.Methods inherited from class org.gradle.api.tasks.bundling.AbstractArchiveTask
createCopyActionExecuter, getArchiveAppendix, getArchiveBaseName, getArchiveClassifier, getArchiveExtension, getArchiveFile, getArchiveFileName, getArchivePath, getArchiveVersion, getDestinationDirectory, into, into, into, isPreserveFileTimestamps, isReproducibleFileOrder, setPreserveFileTimestamps, setReproducibleFileOrderMethods inherited from class org.gradle.api.tasks.AbstractCopyTask
copy, createRootSpec, dirPermissions, eachFile, eachFile, exclude, exclude, exclude, exclude, expand, expand, filePermissions, filesMatching, filesMatching, filesNotMatching, filesNotMatching, filter, filter, filter, filter, from, from, from, getDirectoryFileTreeFactory, getDirMode, getDirPermissions, getDocumentationRegistry, getDuplicatesStrategy, getExcludes, getFileLookup, getFileMode, getFilePermissions, getFileResolver, getFileSystem, getFilteringCharset, getIncludeEmptyDirs, getIncludes, getInstantiator, getMainSpec, getObjectFactory, getPropertyFactory, getRootSpec, getSource, include, include, include, include, isCaseSensitive, rename, rename, rename, rename, setCaseSensitive, setDirMode, setDuplicatesStrategy, setExcludes, setFileMode, setFilteringCharset, setIncludeEmptyDirs, setIncludes, withMethods inherited from class org.gradle.api.internal.ConventionTask
conventionMapping, conventionMapping, getConventionMappingMethods inherited from class org.gradle.api.DefaultTask
compareTo, configure, dependsOn, doFirst, doFirst, doFirst, doLast, doLast, doLast, finalizedBy, getActions, getAnt, getDependsOn, getDescription, getDestroyables, getDidWork, getEnabled, getExtensions, getFinalizedBy, getGroup, getInputs, getLocalState, getLogger, getLogging, getMustRunAfter, getName, getOutputs, getPath, getProject, getShouldRunAfter, getState, getTaskDependencies, getTemporaryDir, getTimeout, hasProperty, mustRunAfter, onlyIf, onlyIf, onlyIf, property, setActions, setDependsOn, setDescription, setDidWork, setEnabled, setFinalizedBy, setGroup, setMustRunAfter, setOnlyIf, setOnlyIf, setOnlyIf, setProperty, setShouldRunAfter, shouldRunAfter, usesServiceMethods inherited from class org.gradle.api.internal.AbstractTask
acceptServiceReferences, appendParallelSafeAction, doNotTrackState, getAsDynamicObject, getConvention, getIdentityPath, getImpliesSubProjects, getLifecycleDependencies, getOnlyIf, getReasonNotToTrackState, getReasonTaskIsIncompatibleWithConfigurationCache, getRequiredServices, getServices, getSharedResources, getStandardOutputCapture, getTaskActions, getTaskIdentity, getTemporaryDirFactory, hasTaskActions, injectIntoNewInstance, isCompatibleWithConfigurationCache, isEnabled, isHasCustomActions, notCompatibleWithConfigurationCache, prependParallelSafeAction, setImpliesSubProjectsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.gradle.api.Task
doNotTrackState, getConvention, notCompatibleWithConfigurationCache
-
Constructor Details
-
ParallelZip
public ParallelZip()
-
-
Method Details
-
getStore
When true, every entry is STORED (no compression). Default: false. -
getLevel
DEFLATE level 0..9, or -1 for the zlib default (6). Ignored whengetStore()is true. -
getSkipAlreadyCompressed
@Input @Optional public abstract org.gradle.api.provider.Property<Boolean> getSkipAlreadyCompressed()When true (the default), an entry recognized by file-signature as already compressed (jars, gzip, images, and more -- seeARCHITECTURE.md) is STORED without even attempting DEFLATE. Set tofalseto always attempt DEFLATE regardless of signature -- matching 1.3.x's behavior, which relied only on the statistical incompressibility sniff (still active either way). Trades some of 1.4.0's speed win back for a smaller archive closer to 1.3.x's size. -
getThreads
Number of compression threads. Default: available processors. Marked@Internalbecause it does not affect the archive bytes (output is identical for any thread count), so changing it must not invalidate the task's up-to-date state. -
createCopyAction
protected org.gradle.api.internal.file.copy.CopyAction createCopyAction()- Specified by:
createCopyActionin classorg.gradle.api.tasks.AbstractCopyTask
-