HHH-8733 - General build cleanup

This commit is contained in:
Steve Ebersole 2013-11-22 14:51:56 -06:00
parent 11033040e6
commit c1612fe004
6 changed files with 205 additions and 246 deletions

View File

@ -170,51 +170,43 @@ subprojects { subProject ->
}
sourceSets.all {
ext.originalJavaSrcDirs = java.srcDirs
ext.generatedLoggingSrcDir = file( "${buildDir}/generated-src/logging/${name}" )
java.srcDir generatedLoggingSrcDir
ext.aptGeneratedSourceDir = file( "${buildDir}/generated-src/apt/${name}" )
if ( !aptGeneratedSourceDir.exists() ) {
aptGeneratedSourceDir.mkdirs()
}
}
task generateMainLoggingClasses(type: JavaCompile) {
ext.aptDumpDir = subProject.file( "${buildDir}/tmp/apt/logging" )
classpath = compileJava.classpath + configurations.jbossLoggingTool
source = sourceSets.main.originalJavaSrcDirs
destinationDir = aptDumpDir
options.define(
tasks.withType( JavaCompile.class ).all { task->
task.options.define(
compilerArgs: [
"-nowarn",
"-proc:only",
"-encoding", "UTF-8",
"-processor", "org.jboss.logging.processor.apt.LoggingToolsProcessor",
"-s", "$sourceSets.main.generatedLoggingSrcDir.absolutePath",
// "-AloggingVersion=3.0",
"-Adebug=true",
"-AskipTranslations=true",
"-source", rootProject.javaLanguageLevel,
"-target", rootProject.javaLanguageLevel,
"-AtranslationFilesPath=${project.rootDir}/src/main/resources"
]
);
outputs.dir sourceSets.main.generatedLoggingSrcDir;
doFirst {
// source = sourceSets.main.originalJavaSrcDirs
sourceSets.main.generatedLoggingSrcDir.mkdirs()
}
doLast {
aptDumpDir.delete()
}
)
}
// for the time being eat the annoying output from running the annotation processors
generateMainLoggingClasses.logging.captureStandardError(LogLevel.INFO)
// alter the compileJava (src/main/java javac task) to add JBoss Logging AP hooks
compileJava {
classpath += configurations.jbossLoggingTool
options.compilerArgs += [
"-s", "$sourceSets.main.aptGeneratedSourceDir.absolutePath",
"-Adebug=true",
"-AskipTranslations=true",
"-AtranslationFilesPath=${project.rootDir}/src/main/resources"
]
}
// alter the compileTestJava (src/test/java javac task) to add AP hooks
compileTestJava {
options.compilerArgs += [
"-s", "$sourceSets.test.aptGeneratedSourceDir.absolutePath"
]
}
task generateSources( type: Task )
generateSources.dependsOn generateMainLoggingClasses
compileJava.dependsOn generateMainLoggingClasses
compileJava.options.define(compilerArgs: ["-proc:none", "-encoding", "UTF-8"])
compileTestJava.options.define(compilerArgs: ["-proc:none", "-encoding", "UTF-8"])
jar {
Set<String> exportPackages = new HashSet<String>()
@ -362,7 +354,7 @@ subprojects { subProject ->
checkstyleClasspath = checkstyleMain.checkstyleClasspath
classpath = checkstyleMain.classpath
configFile = rootProject.file( 'shared/config/checkstyle/checkstyle.xml' )
source subProject.sourceSets.main.originalJavaSrcDirs
source subProject.sourceSets.main.java.srcDirs
// exclude generated sources
exclude '**/generated-src/**'
// because cfg package is a mess mainly from annotation stuff
@ -489,7 +481,7 @@ subprojects { subProject ->
model {
tasks.generatePomFileForMavenJavaPublication {
destination = file("$buildDir/generated-pom.xml")
destination = file( "$project.buildDir/generated-pom.xml" )
}
}

View File

@ -13,50 +13,158 @@ buildscript {
jcenter()
}
dependencies {
// classpath "org.jboss.jdocbook:gradle-jdocbook:1.2.1"
classpath "org.jboss.jdocbook:gradle-jdocbook:1.2.2-SNAPSHOT"
classpath "org.jboss.jdocbook:gradle-jdocbook:1.2.2"
classpath 'org.asciidoctor:asciidoctor-gradle-plugin:0.7.0'
}
}
apply plugin: "java"
apply plugin: "jdocbook"
apply from: "../utilities.gradle"
ext.pressgangVersion = '3.0.0'
defaultTasks 'buildDocs'
configurations {
asciidoclet {
description = 'Dependencies for Asciidoclet (the javadoc doclet tool for using Asciidoc)'
}
}
dependencies {
ext.pressgangVersion = '3.0.0'
asciidoclet 'org.asciidoctor:asciidoclet:0.+'
jdocbookXsl "org.jboss.pressgang:pressgang-xslt-ns:${pressgangVersion}"
jdocbookXsl "org.jboss.pressgang:pressgang-fonts:${pressgangVersion}"
jdocbookStyles "org.jboss.pressgang:pressgang-jdocbook-style:${pressgangVersion}"
}
defaultTasks 'buildDocs'
task buildDocs {
group 'Documentation'
description 'Grouping task for performing all documentation building tasks'
}
// aggregated JavaDoc ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
final File javadocDir = mkdir( new File( (File) project.buildDir, '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'
options.docletpath = configurations.asciidoclet.files.asType(List)
options.doclet = 'org.asciidoctor.Asciidoclet'
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<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 ->
// 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 &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" )
}
doLast {
copy {
from rootProject.file( 'shared/javadoc/images' )
into new File( javadocDir, "/images" )
}
}
}
buildDocs.dependsOn aggregateJavadocs
// jDocBook ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
jdocbook {
// apply shared formatting config ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
format('html_single') {
finalName = "index.html"
stylesheet = "classpath:/xslt/org/hibernate/jdocbook/xslt/xhtml-single.xsl"
}
// shared config
format('html_single') {
finalName = "index.html"
stylesheet = "classpath:/xslt/org/hibernate/jdocbook/xslt/xhtml-single.xsl"
}
format('html') {
finalName = "index.html"
stylesheet = "classpath:/xslt/org/hibernate/jdocbook/xslt/xhtml.xsl"
}
format('html') {
finalName = "index.html"
stylesheet = "classpath:/xslt/org/hibernate/jdocbook/xslt/xhtml.xsl"
}
// book-specific config
quickstart {
masterSourceDocumentName = 'Hibernate_Getting_Started_Guide.xml'
}
// book-specific config ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
quickstart {
masterSourceDocumentName = 'Hibernate_Getting_Started_Guide.xml'
}
devguide {
masterSourceDocumentName = 'Hibernate_Development_Guide.xml'
useRelativeImageUris = false
}
devguide {
masterSourceDocumentName = 'Hibernate_Development_Guide.xml'
useRelativeImageUris = false
}
manual {
masterSourceDocumentName = 'HIBERNATE_-_Relational_Persistence_for_Idiomatic_Java.xml'
}
manual {
masterSourceDocumentName = 'HIBERNATE_-_Relational_Persistence_for_Idiomatic_Java.xml'
}
}
// todo : make this part of gradle-jdocbook.
@ -73,14 +181,12 @@ stageStyles_devguide.doLast {
}
[ 'devguide', 'manual', 'quickstart' ].each { bookName ->
tasks[ "stageStyles_$bookName" ].doLast {
logger.lifecycle( "Staging local style resources")
copy {
into project.file( "target/docbook/stage/$bookName" )
from project.file( 'src/main/style' )
includeEmptyDirs = false
}
}
task "stageLocalStyles_$bookName"(type: Copy) {
into project.file( "target/docbook/stage/$bookName" )
from project.file( 'src/main/style' )
includeEmptyDirs = false
}
tasks[ "stageStyles_$bookName" ].dependsOn "stageLocalStyles_$bookName"
}
task buildTutorialZip(type: Zip) {
@ -117,6 +223,7 @@ File[] dirList(File dir) {
// asciidoctor ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
task asciidoctor(type: org.asciidoctor.gradle.AsciidoctorTask, group: 'Documentation') {
description = 'Generates the Asciidoc(tor) topical guides in HTML format.'
backend = 'html5'
@ -124,20 +231,6 @@ task asciidoctor(type: org.asciidoctor.gradle.AsciidoctorTask, group: 'Documenta
outputDir = new File("$buildDir/asciidoc/topical/html")
}
//task generateRegistryGuideHtml(type: org.asciidoctor.gradle.AsciidoctorTask, group: 'Documentation') {
// description = 'Generates the ServiceRegistry topical guide in HTML format.'
// backend = 'html5'
// sourceDir = file( 'src/main/asciidoc/topical/registries' )
// outputDir = new File("$buildDir/asciidoc/topical/html")
//}
//
//task generateMetamodelgenGuideHtml(type: org.asciidoctor.gradle.AsciidoctorTask, group: 'Documentation') {
// description = 'Generates the Metamodel Generator topical guide in HTML format.'
// backend = 'html5'
// sourceDir = file( 'src/main/asciidoc/topical/metamodelgen' )
// outputDir = new File("$buildDir/asciidoc/topical/html")
//}
tasks.withType(org.asciidoctor.gradle.AsciidoctorTask) { docTask ->
options = [
logDocuments: true,
@ -149,8 +242,4 @@ tasks.withType(org.asciidoctor.gradle.AsciidoctorTask) { docTask ->
]
}
// - aggregator
//task asciidoctor(type: Task, group: 'Documentation')
//asciidoctor.dependsOn generateRegistryGuideHtml, generateMetamodelgenGuideHtml
buildDocs.dependsOn asciidoctor

View File

@ -88,7 +88,6 @@ jar {
sourceSets.main {
ext.jaxbTargetDir = file( "${buildDir}/generated-src/jaxb/main" )
java.srcDir jaxbTargetDir
originalJavaSrcDirs = java.srcDirs
}
// resources inherently exclude sources
@ -159,8 +158,8 @@ task jaxb {
}
generateMainLoggingClasses.dependsOn jaxb
generateMainLoggingClasses.dependsOn generateGrammarSource
//generateMainLoggingClasses.dependsOn jaxb
//generateMainLoggingClasses.dependsOn generateGrammarSource
generateSources.dependsOn jaxb
generateSources.dependsOn generateGrammarSource

View File

@ -68,41 +68,10 @@ jar {
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
// JPA model-gen set up
////////////////////////////////////////////////////////////////////////////////////////////////////////
sourceSets.test {
originalJavaSrcDirs = java.srcDirs
ext.generatedJpaMetamodelSrcDir = file( "${buildDir}/generated-src/jpamodelgen/${name}" )
java.srcDir generatedJpaMetamodelSrcDir
compileTestJava {
classpath += configurations.hibernateJpaModelGenTool
}
task generateTestJpaMetamodelClasses(type: JavaCompile) {
ext.aptDumpDir = file( "${buildDir}/tmp/apt/jpamodelgen" )
classpath = compileTestJava.classpath + configurations.hibernateJpaModelGenTool
source = sourceSets.test.originalJavaSrcDirs
destinationDir = aptDumpDir
options.define(
compilerArgs: [
"-proc:only",
"-processor", "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor",
"-s", "$sourceSets.test.generatedJpaMetamodelSrcDir.absolutePath"
]
);
outputs.dir sourceSets.test.generatedJpaMetamodelSrcDir;
doFirst {
sourceSets.test.generatedJpaMetamodelSrcDir.mkdirs()
}
doLast {
aptDumpDir.delete()
}
}
// for the time being eat the annoying output from running the annotation processors
generateTestJpaMetamodelClasses.logging.captureStandardError(LogLevel.INFO)
compileTestJava.dependsOn generateTestJpaMetamodelClasses
compileTestJava.options.define(compilerArgs: ["-proc:none"])
generateSources.dependsOn generateTestJpaMetamodelClasses
////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -9,10 +9,13 @@ configurations {
dependencies {
compile( project( ':hibernate-core' ) )
compile( project( ':hibernate-entitymanager' ) )
provided( [group: 'org.hibernate', name: 'hibernate-tools', version: '3.2.0.ga'] )
provided( libraries.ant )
testCompile( project(':hibernate-testing') )
testCompile( project(path: ':hibernate-entitymanager', configuration: 'tests') )
testRuntime( libraries.javassist )
hibernateJpaModelGenTool( project( ':hibernate-jpamodelgen' ) )
@ -26,13 +29,8 @@ def pomDescription() {
return 'Entity versioning support'
}
sourceSets {
main {
ext.generatedJpaMetamodelSrcDir = file( "${buildDir}/generated-src/jpamodelgen/${name}" )
java {
srcDir generatedJpaMetamodelSrcDir
}
}
test {
ext.enversDemoJavaDir = file( "src/demo/java" )
ext.enversDemoResourcesDir = file( "src/demo/resources" )
@ -45,25 +43,9 @@ sourceSets {
}
}
// Generate JPA2 static metamodel for default revision entities
task generateJpaMetamodelClasses(type: JavaCompile) {
classpath = compileJava.classpath + configurations.hibernateJpaModelGenTool
source = sourceSets.main.originalJavaSrcDirs
destinationDir = file( "${buildDir}/tmp/apt" )
options.define(
compilerArgs: [
"-proc:only",
"-processor", "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor",
"-s", "$sourceSets.main.generatedJpaMetamodelSrcDir.absolutePath"
]
);
outputs.dir sourceSets.main.generatedJpaMetamodelSrcDir;
doFirst {
sourceSets.main.generatedJpaMetamodelSrcDir.mkdirs()
}
compileTestJava {
classpath += configurations.hibernateJpaModelGenTool
}
compileJava.dependsOn generateJpaMetamodelClasses
generateSources.dependsOn generateJpaMetamodelClasses
jar {
manifest {

View File

@ -1,113 +1,30 @@
apply plugin: 'base'
apply plugin: 'idea'
apply plugin: 'distribution'
apply from: "../utilities.gradle"
buildDir = "target"
idea.module {
}
final File documentationDir = mkdir( "${project.buildDir}/documentation" );
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<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 ->
// 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 &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" )
}
doLast {
copy {
from rootProject.file( 'shared/javadoc/images' )
into new File( javadocDir, "/images" )
}
}
}
final File documentationUploadStagingDir = mkdir( "${project.buildDir}/tmp/documentation" );
final File stagingDir = mkdir( "${project.buildDir}/staging" );
final File documentationUploadStagingDir = mkdir( new File( stagingDir, "docs" ) );
final File versionedDocumentationDir = mkdir( new File( new File( documentationUploadStagingDir, "orm" ), majorMinorVersion ) );
/**
* Builds the complete documentation set in preparation for upload to the doc server.
* Assembles all documentation into the {buildDir}/documentation directory.
*
* 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
* Depends on building the docs
*/
task buildDocumentation(type: Task, dependsOn: [rootProject.project( 'documentation' ).tasks.buildDocs, aggregateJavadocs]) {
description = "Builds and consolidates all documentation"
task assembleDocumentation(type: Task, dependsOn: [rootProject.project( 'documentation' ).tasks.buildDocs]) {
description = 'Assembles all documentation into the {buildDir}/documentation directory'
doLast {
// copy docbook outputs into target/documentation (javadocs are already there). this is used in
@ -120,14 +37,25 @@ task buildDocumentation(type: Task, dependsOn: [rootProject.project( 'documentat
from "${rootProject.project( 'documentation' ).buildDir}/asciidoc"
into documentationDir
}
// now prepare the upload staging directory
versionedDocumentationDir.mkdirs()
copy {
from documentationDir
into versionedDocumentationDir
from "${rootProject.project( 'documentation' ).buildDir}/javadoc"
into documentationDir
}
}
}
/**
* Stages the documentation into a version specific directory in preparation for uploading them to the JBoss
* doc server. Essentially copies the output from the {buildDir}/documentation directory (output of the
* assembleDocumentation task) into a version-specific directory
*/
task stageDocumentationForUpload(type: Copy, dependsOn: assembleDocumentation) {
description = 'Stages the documentation in preparation for uploading to the JBoss doc server'
from documentationDir
into versionedDocumentationDir
doLast {
if ( ! version.endsWith( 'SNAPSHOT' ) ) {
final File currentSymLinkContainerDir = new File( documentationUploadStagingDir, 'stable' )
currentSymLinkContainerDir.mkdirs();
@ -147,7 +75,7 @@ task buildDocumentation(type: Task, dependsOn: [rootProject.project( 'documentat
/**
* Upload the documentation to the JBoss doc server
*/
task uploadDocumentation(type:Exec, dependsOn: buildDocumentation) {
task uploadDocumentation(type:Exec, dependsOn: stageDocumentationForUpload) {
description = "Uploads documentation to the JBoss doc server"
final String url = 'filemgmt.jboss.org:/docs_htdocs/hibernate/';
@ -268,8 +196,8 @@ distributions {
}
}
distZip.dependsOn buildDocumentation
distTar.dependsOn buildDocumentation
distZip.dependsOn assembleDocumentation
distTar.dependsOn assembleDocumentation
distTar {
compression = Compression.GZIP
}