Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

file 215 lines (186 sloc) 9.39 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
apply plugin: 'base'
apply plugin: 'idea'

buildDir = "target"

idea.module {
}



// Javadocs ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ext.javadocBuildDir = mkdir( "${buildDir}/documentation/javadocs" )

def copyRightYear = new java.util.GregorianCalendar().get( java.util.Calendar.YEAR );

task aggregateJavadocs(type: Javadoc) {
    // exclude any generated sources (this is not working: http://forums.gradle.org/gradle/topics/excluding_generated_source_from_javadoc)
    exclude "**/generated-src/**"

    // process each project, building up:
    // 1) appropriate sources
    // 2) classpath
    // 3) the package list for groups
    Set<String> apiPackages = new HashSet<String>()
    Set<String> spiPackages = new HashSet<String>()
    Set<String> internalPackages = new HashSet<String>()
    parent.subprojects.each{ Project subProject->
        // skip certain sub-projects
        if ( ! ['release','documentation'].contains( subProject.name ) ) {
            subProject.sourceSets.each { SourceSet sourceSet ->
                // skip certain source sets
                if ( ! ['test','matrix'].contains( sourceSet.name ) ) {
                    source sourceSet.java

                    if( classpath ) {
                        classpath += sourceSet.output + sourceSet.compileClasspath
                    }
                    else {
                        classpath = sourceSet.output + sourceSet.compileClasspath
                    }

                    sourceSet.java.each { javaFile ->
                        final String packageName = determinePackageName( sourceSet.java, javaFile );
                        if ( packageName.endsWith( ".internal" ) || packageName.contains( ".internal." ) ) {
                            internalPackages.add( packageName );
                        }
                        else if ( packageName.endsWith( ".spi" ) || packageName.contains( ".spi." ) ) {
                            spiPackages.add( packageName );
                        }
                        else if ( packageName.startsWith( "org.hibernate.testing" ) ) {
                            // do nothing as testing support is already handled...
                        }
                        else {
                            apiPackages.add( packageName );
                        }
                    }
                }
            }
        }
    }

    // apply standard config
    description = "Build the aggregated JavaDocs for all modules"
    maxMemory = '512m'
    destinationDir = javadocBuildDir
    configure( options ) {
        overview = new File( projectDir, 'src/javadoc/overview.html' )
        stylesheetFile = new File( projectDir, 'src/javadoc/stylesheet.css' )
        windowTitle = 'Hibernate JavaDocs'
        docTitle = "Hibernate JavaDoc ($project.version)"
        bottom = "Copyright &copy; 2001-$copyRightYear <a href=\"http://redhat.com\">Red Hat, Inc.</a> All Rights Reserved."
        use = true
        links = [ 'http://download.oracle.com/javase/6/docs/api/', 'http://download.oracle.com/javaee/6/api/' ]
        group( 'API', apiPackages.asList() )
        group( 'SPI', spiPackages.asList() )
        group( 'Internal', internalPackages.asList() )
        group ( 'Testing Support', ['org.hibernate.testing*'] )
// ugh, http://issues.gradle.org/browse/GRADLE-1563
// tags ["todo:X"]
// work around:
        addStringOption( "tag", "todo:X" )
    }
}

String determinePackageName(SourceDirectorySet sourceDirectorySet, File javaFile) {
    final javaFileAbsolutePath = javaFile.absolutePath;
    for ( File sourceDirectory : sourceDirectorySet.srcDirs ) {
        final String sourceDirectoryAbsolutePath = sourceDirectory.absolutePath;
        if ( javaFileAbsolutePath.startsWith( sourceDirectoryAbsolutePath ) ) {
            final String javaFileRelativePath = javaFileAbsolutePath.substring(
                    sourceDirectoryAbsolutePath.length() + 1,
                    javaFileAbsolutePath.lastIndexOf( File.separator )
            );
            return javaFileRelativePath.replace( File.separator, "." );
        }
    }
    throw new RuntimeException( "ugh" );
}

aggregateJavadocs.doLast {
    copy {
        from new File( projectDir, 'src/javadoc/images' )
        into new File( javadocBuildDir, "/images" )
    }
}

// release bundles ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ext.releaseBuildDir = mkdir( buildDir )
task prepareReleaseBundles( dependsOn: [parent.project( 'documentation' ).tasks.buildDocs,aggregateJavadocs] )


ext.releaseCopySpec = copySpec {
    into( "hibernate-release-$project.version" ) {
        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/bytecode/javassist') {
// 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' )
            }
        }
    }
}

task buildReleaseZip( type: Zip, dependsOn: [prepareReleaseBundles] ) {
    description = "Build release bundle in ZIP format"
    baseName = 'hibernate-release'
    destinationDir = releaseBuildDir
    with project.releaseCopySpec
}

task buildReleaseTgz( type: Tar, dependsOn: [prepareReleaseBundles] ) {
    description = "Build release bundle in GZIP format"
    baseName = 'hibernate-release'
    destinationDir = releaseBuildDir
    compression = Compression.GZIP
    with project.releaseCopySpec
}

task buildReleaseBundles( dependsOn: [buildReleaseZip,buildReleaseTgz] ) {
    description = "Build release bundle in all formats"
}
Something went wrong with that request. Please try again.