Distribution plugin and g-zip compression

Just updated the Hibernate build to use the distribution plugin. One thought/suggestion is to allow the tar output to be g-zip compressed

1 Like

Hello Steve, well you can configure the compression directly in the according tar task:

apply plugin:'distribution'
              distributions {
                custom{
                    contents {
                        from { "someFile" }
                    }
                }
            }
              customDistTar{
                compression = Compression.GZIP
            }
2 Likes

Thanks Rene! I will try. Out of curiosity, why would g-zip not be the default?

To be honest I don’t know. I was a frustrated ant user at the time this decision had been made I guess :wink:

But you can simply made it the default for all Tars in your build:

tasks.withType(Tar){
    compression = Compression.GZIP
}

Hehe. Ok. I will say this plugin works great, and this is not a trivial config:

distributions {
    main {
        baseName = 'hibernate-release'
        contents {
            from new File( parent.projectDir, 'lgpl.txt' )
            from new File( parent.projectDir, 'changelog.txt' )
            from new File( parent.projectDir, 'hibernate_logo.gif' )
              into('lib/required') {
                from parent.project( 'hibernate-core' ).configurations.provided.files { dep -> dep.name == 'jta' }
                from parent.project( 'hibernate-core' ).configurations.runtime
                from parent.project( 'hibernate-core' ).configurations.archives.allArtifacts.files.filter{ file -> !file.name.endsWith('-sources.jar') }
                // for now,
                from parent.project( 'hibernate-core' ).configurations.provided.files { dep -> dep.name == 'javassist' }
            }
              into( 'lib/jpa' ) {
                from parent.project( 'hibernate-entitymanager' ).configurations.archives.allArtifacts.files.filter{ file -> !file.name.endsWith('-sources.jar') }
            }
              into( 'lib/envers' ) {
                from(
                        ( parent.project( 'hibernate-envers' ).configurations.archives.allArtifacts.files.filter{ file -> !file.name.endsWith('-sources.jar') }
                                + parent.project( 'hibernate-envers' ).configurations.runtime )
                                - parent.project( 'hibernate-core' ).configurations.runtime
                                - parent.project( 'hibernate-core' ).configurations.archives.allArtifacts.files
                                - parent.project( 'hibernate-entitymanager' ).configurations.runtime
                                - parent.project( 'hibernate-entitymanager' ).configurations.archives.allArtifacts.files
                )
            }
              // todo : this closure is problematic as it does not write into the hibernate-release-$project.version directory
            // due to http://issues.gradle.org/browse/GRADLE-1450
            [ 'hibernate-c3p0', 'hibernate-proxool', 'hibernate-ehcache', 'hibernate-infinispan' ].each { feature ->
                final String shortName = feature.substring( 'hibernate-'.length() );
// WORKAROUND http://issues.gradle.org/browse/GRADLE-1450
//
              into('lib/optional/' + shortName) {
                owner.into('lib/optional/' + shortName) {
                    from (
                            ( parent.project( feature ).configurations.archives.allArtifacts.files.filter{ file -> !file.name.endsWith('-sources.jar') }
                                    + parent.project( feature ).configurations.runtime )
                                    - parent.project( 'hibernate-core' ).configurations.runtime
                                    - parent.project( 'hibernate-core' ).configurations.archives.allArtifacts.files
                    )
                }
            }
              into('documentation') {
                from new File( parent.project( 'documentation' ).buildDir, 'docbook/publish' )
            }
              into('documentation/javadocs') {
                from javadocBuildDir
            }
              into( 'project' ) {
                from ( rootProject.projectDir ) {
                    exclude( '.git' )
                    exclude( '.gitignore' )
                    exclude( 'changelog.txt' )
                    exclude( 'lgpl.txt' )
                    exclude( 'hibernate_logo.gif' )
                    exclude( 'tagRelease.sh' )
                    exclude( 'gradlew' )
                    exclude( 'gradlew.bat' )
                    exclude( 'wrapper/*' )
                    exclude( '**/.gradle/**' )
                    exclude( '**/target/**' )
                    exclude( '.idea' )
                    exclude( '**/*.ipr' )
                    exclude( '**/*.iml' )
                    exclude( '**/*.iws' )
                    exclude( '**/atlassian-ide-plugin.xml' )
                    exclude( '**/.classpath' )
                    exclude( '**/.project' )
                    exclude( '**/.settings' )
                    exclude( '**/.nbattrs' )
                }
            }
        }
    }
}

So kudos!

1 Like

thanks for sharing and the feedback!