apply plugin: 'base' apply plugin: 'idea' apply plugin: 'distribution' apply from: "../utilities.gradle" buildDir = "target" idea.module { } final String[] versionComponents = version.split( '\\.' ); final String majorVersion = versionComponents[0]; final String majorMinorVersion = versionComponents[0] + '.' + versionComponents[1]; final File documentationDir = mkdir( new File( project.buildDir, 'documentation' ) ); final File javadocDir = mkdir( new File( documentationDir, 'javadocs' ) ); /** * Builds the JavaDocs aggregated (unified) across all the sub-projects */ task aggregateJavadocs(type: Javadoc) { description = 'Builds the aggregated (unified) JavaDocs across all sub-projects' final int copyrightYear = new GregorianCalendar().get( Calendar.YEAR ); // 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 apiPackages = new HashSet() Set spiPackages = new HashSet() Set internalPackages = new HashSet() parent.subprojects.each{ Project subProject-> // skip certain sub-projects if ( ! ['release','documentation'].contains( subProject.name ) ) { subProject.sourceSets.each { 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 maxMemory = '512m' destinationDir = javadocDir configure( options ) { overview = rootProject.file( 'shared/javadoc/overview.html' ) stylesheetFile = rootProject.file( 'shared/javadoc/stylesheet.css' ) windowTitle = 'Hibernate JavaDocs' docTitle = "Hibernate JavaDoc ($project.version)" bottom = "Copyright © 2001-$copyrightYear Red Hat, Inc. 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" ) } doLast { copy { from rootProject.file( 'shared/javadoc/images' ) into new File( javadocDir, "/images" ) } } } final File documentationUploadStagingDir = mkdir( "${project.buildDir}/tmp/documentation" ); final File versionedDocumentationDir = mkdir( new File( new File( documentationUploadStagingDir, "orm" ), majorMinorVersion ) ); /** * Builds the complete documentation set in preparation for upload to the doc server. * * It builds the docbook manuals as well as the aggregated, cross-project JavaDocs and stages them into * a single directory that can be directly rsync-ed to the doc server */ task buildDocumentation(type: Task, dependsOn: [rootProject.project( 'documentation' ).tasks.buildDocs, aggregateJavadocs]) { description = "Builds and consolidates all documentation" doLast { // copy docbook outputs into target/documentation (javadocs are already there). this is used in // building the dist bundles copy { from "${rootProject.project( 'documentation' ).buildDir}/docbook/publish" into documentationDir } // now prepare the upload staging directory versionedDocumentationDir.mkdirs() copy { from documentationDir into versionedDocumentationDir } if ( ! version.endsWith( 'SNAPSHOT' ) ) { final File currentSymLinkContainerDir = new File( documentationUploadStagingDir, 'stable' ) currentSymLinkContainerDir.mkdirs(); ant.symlink( action: 'delete', link: "${currentSymLinkContainerDir.absolutePath}/orm" ) ant.symlink( action: 'single', link: "${currentSymLinkContainerDir.absolutePath}/orm", resource: "../orm/${majorMinorVersion}" ) } } } /** * Upload the documentation to the JBoss doc server */ task uploadDocumentation(type:Exec, dependsOn: buildDocumentation) { description = "Uploads documentation to the JBoss doc server" final String url = 'filemgmt.jboss.org:/docs_htdocs/hibernate/'; executable 'rsync' args '-avz', '--links', '--protocol=28', "${documentationUploadStagingDir.absolutePath}/", url doFirst { if ( version.endsWith( "SNAPSHOT" ) ) { logger.error( "Cannot perform upload of SNAPSHOT documentation" ); throw new RuntimeException( "Cannot perform upload of SNAPSHOT documentation" ); } else { logger.lifecycle( "Uploading documentation [{$url}]..." ) } } doLast { logger.lifecycle( 'Done uploading documentation' ) } } /** * Configuration of the distribution plugin, used to build release bundle as both ZIP and TGZ */ distributions { main { baseName = 'hibernate-release' contents { from rootProject.file( 'lgpl.txt' ) from rootProject.file( 'changelog.txt' ) from rootProject.file( '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 ) } into( 'lib/osgi' ) { from( ( parent.project( 'hibernate-osgi' ).configurations.archives.allArtifacts.files.filter{ file -> !file.name.endsWith('-sources.jar') } + parent.project( 'hibernate-osgi' ).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 documentationDir } 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' ) } } } } } distZip.dependsOn buildDocumentation distTar.dependsOn buildDocumentation distTar { compression = Compression.GZIP } /** * "virtual" task for building both types of dist bundles */ task buildBundles(type: Task, dependsOn: [distZip,distTar]) { description = "Builds all release bundles" } task uploadBundles(type: Exec, dependsOn: buildBundles) { description = "Uploads release bundles to SourceForge" final String url = "frs.sourceforge.net:/home/frs/project/hibernate/hibernate${majorVersion}/${version}"; executable 'rsync' args '-vr', '-e ssh', "${project.buildDir}/distributions/", url doFirst { if ( version.endsWith( "SNAPSHOT" ) ) { logger.error( "Cannot perform upload of SNAPSHOT documentation" ); throw new RuntimeException( "Cannot perform upload of SNAPSHOT bundles" ) } else { logger.lifecycle( "Uploading release bundles [${url}]..." ) } } doLast { logger.lifecycle( 'Done uploading release bundles' ) } } // Full release related tasks ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ task cleanAllSubProjects(type: Task) { description = 'Performs clean on all sub-projects' } task testAllSubProjects(type: Task) { description = 'Performs test on all sub-projects' } task publishAllSubProjects(type: Task) { description = 'Performs publish on all sub-projects' } task buildAllSubProjects(type: Task, dependsOn: [testAllSubProjects,publishAllSubProjects]) task uploadReleaseArtifacts(type: Task, dependsOn: [uploadDocumentation, uploadBundles]) task announce(type: Task) { doFirst { println 'Hear ye, hear ye...' } } task release(type: Task, dependsOn: [cleanAllSubProjects, buildAllSubProjects, uploadReleaseArtifacts, announce]) { description = "Coordinates all release tasks" } // must-run-afters ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ buildAllSubProjects.mustRunAfter cleanAllSubProjects publishAllSubProjects.mustRunAfter testAllSubProjects publishAllSubProjects.mustRunAfter cleanAllSubProjects uploadReleaseArtifacts.mustRunAfter buildAllSubProjects announce.mustRunAfter uploadReleaseArtifacts // sub-project task dependencies ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ rootProject.subprojects { Project subproject -> final Task subprojectCleanTask = subproject.tasks.findByPath( 'clean' ); if ( subprojectCleanTask != null ) { cleanAllSubProjects.dependsOn subprojectCleanTask } final Task subprojectTestTask = subproject.tasks.findByPath( 'test' ); if ( subprojectTestTask != null ) { testAllSubProjects.dependsOn subprojectTestTask } final Task subprojectPublishTask = subproject.tasks.findByPath( 'publish' ); if ( subprojectPublishTask != null ) { publishAllSubProjects.dependsOn subprojectPublishTask } }