Skip to content

Commit c1612fe

Browse files
committed
HHH-8733 - General build cleanup
1 parent 1103304 commit c1612fe

File tree

6 files changed

+207
-248
lines changed

6 files changed

+207
-248
lines changed

build.gradle

+27-35
Original file line numberDiff line numberDiff line change
@@ -170,51 +170,43 @@ subprojects { subProject ->
170170
}
171171

172172
sourceSets.all {
173-
ext.originalJavaSrcDirs = java.srcDirs
174-
ext.generatedLoggingSrcDir = file( "${buildDir}/generated-src/logging/${name}" )
175-
java.srcDir generatedLoggingSrcDir
173+
ext.aptGeneratedSourceDir = file( "${buildDir}/generated-src/apt/${name}" )
174+
if ( !aptGeneratedSourceDir.exists() ) {
175+
aptGeneratedSourceDir.mkdirs()
176+
}
176177
}
177178

178-
task generateMainLoggingClasses(type: JavaCompile) {
179-
ext.aptDumpDir = subProject.file( "${buildDir}/tmp/apt/logging" )
180-
classpath = compileJava.classpath + configurations.jbossLoggingTool
181-
source = sourceSets.main.originalJavaSrcDirs
182-
destinationDir = aptDumpDir
183-
options.define(
179+
tasks.withType( JavaCompile.class ).all { task->
180+
task.options.define(
184181
compilerArgs: [
185182
"-nowarn",
186-
"-proc:only",
187183
"-encoding", "UTF-8",
188-
"-processor", "org.jboss.logging.processor.apt.LoggingToolsProcessor",
189-
"-s", "$sourceSets.main.generatedLoggingSrcDir.absolutePath",
190-
// "-AloggingVersion=3.0",
191-
"-Adebug=true",
192-
"-AskipTranslations=true",
193184
"-source", rootProject.javaLanguageLevel,
194185
"-target", rootProject.javaLanguageLevel,
195-
"-AtranslationFilesPath=${project.rootDir}/src/main/resources"
196-
197186
]
198-
);
199-
outputs.dir sourceSets.main.generatedLoggingSrcDir;
200-
doFirst {
201-
// source = sourceSets.main.originalJavaSrcDirs
202-
sourceSets.main.generatedLoggingSrcDir.mkdirs()
203-
}
204-
doLast {
205-
aptDumpDir.delete()
206-
}
187+
)
207188
}
208189

209-
// for the time being eat the annoying output from running the annotation processors
210-
generateMainLoggingClasses.logging.captureStandardError(LogLevel.INFO)
190+
// alter the compileJava (src/main/java javac task) to add JBoss Logging AP hooks
191+
compileJava {
192+
classpath += configurations.jbossLoggingTool
211193

212-
task generateSources( type: Task )
213-
generateSources.dependsOn generateMainLoggingClasses
194+
options.compilerArgs += [
195+
"-s", "$sourceSets.main.aptGeneratedSourceDir.absolutePath",
196+
"-Adebug=true",
197+
"-AskipTranslations=true",
198+
"-AtranslationFilesPath=${project.rootDir}/src/main/resources"
199+
]
200+
}
214201

215-
compileJava.dependsOn generateMainLoggingClasses
216-
compileJava.options.define(compilerArgs: ["-proc:none", "-encoding", "UTF-8"])
217-
compileTestJava.options.define(compilerArgs: ["-proc:none", "-encoding", "UTF-8"])
202+
// alter the compileTestJava (src/test/java javac task) to add AP hooks
203+
compileTestJava {
204+
options.compilerArgs += [
205+
"-s", "$sourceSets.test.aptGeneratedSourceDir.absolutePath"
206+
]
207+
}
208+
209+
task generateSources( type: Task )
218210

219211
jar {
220212
Set<String> exportPackages = new HashSet<String>()
@@ -362,7 +354,7 @@ subprojects { subProject ->
362354
checkstyleClasspath = checkstyleMain.checkstyleClasspath
363355
classpath = checkstyleMain.classpath
364356
configFile = rootProject.file( 'shared/config/checkstyle/checkstyle.xml' )
365-
source subProject.sourceSets.main.originalJavaSrcDirs
357+
source subProject.sourceSets.main.java.srcDirs
366358
// exclude generated sources
367359
exclude '**/generated-src/**'
368360
// because cfg package is a mess mainly from annotation stuff
@@ -489,7 +481,7 @@ subprojects { subProject ->
489481

490482
model {
491483
tasks.generatePomFileForMavenJavaPublication {
492-
destination = file("$buildDir/generated-pom.xml")
484+
destination = file( "$project.buildDir/generated-pom.xml" )
493485
}
494486
}
495487

documentation/documentation.gradle

+142-53
Original file line numberDiff line numberDiff line change
@@ -13,50 +13,158 @@ buildscript {
1313
jcenter()
1414
}
1515
dependencies {
16-
// classpath "org.jboss.jdocbook:gradle-jdocbook:1.2.1"
17-
classpath "org.jboss.jdocbook:gradle-jdocbook:1.2.2-SNAPSHOT"
16+
classpath "org.jboss.jdocbook:gradle-jdocbook:1.2.2"
1817
classpath 'org.asciidoctor:asciidoctor-gradle-plugin:0.7.0'
1918
}
2019
}
2120

2221
apply plugin: "java"
2322
apply plugin: "jdocbook"
23+
apply from: "../utilities.gradle"
2424

25-
ext.pressgangVersion = '3.0.0'
25+
defaultTasks 'buildDocs'
26+
27+
configurations {
28+
asciidoclet {
29+
description = 'Dependencies for Asciidoclet (the javadoc doclet tool for using Asciidoc)'
30+
}
31+
}
2632

2733
dependencies {
34+
ext.pressgangVersion = '3.0.0'
35+
36+
asciidoclet 'org.asciidoctor:asciidoclet:0.+'
37+
2838
jdocbookXsl "org.jboss.pressgang:pressgang-xslt-ns:${pressgangVersion}"
2939
jdocbookXsl "org.jboss.pressgang:pressgang-fonts:${pressgangVersion}"
3040
jdocbookStyles "org.jboss.pressgang:pressgang-jdocbook-style:${pressgangVersion}"
3141
}
3242

33-
defaultTasks 'buildDocs'
43+
44+
task buildDocs {
45+
group 'Documentation'
46+
description 'Grouping task for performing all documentation building tasks'
47+
}
48+
49+
50+
51+
// aggregated JavaDoc ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
52+
53+
final File javadocDir = mkdir( new File( (File) project.buildDir, 'javadocs' ) );
54+
55+
/**
56+
* Builds the JavaDocs aggregated (unified) across all the sub-projects
57+
*/
58+
task aggregateJavadocs(type: Javadoc) {
59+
description = 'Builds the aggregated (unified) JavaDocs across all sub-projects'
60+
options.docletpath = configurations.asciidoclet.files.asType(List)
61+
options.doclet = 'org.asciidoctor.Asciidoclet'
62+
63+
final int copyrightYear = new GregorianCalendar().get( Calendar.YEAR );
64+
65+
// exclude any generated sources (this is not working: http://forums.gradle.org/gradle/topics/excluding_generated_source_from_javadoc)
66+
exclude "**/generated-src/**"
67+
68+
// process each project, building up:
69+
// 1) appropriate sources
70+
// 2) classpath
71+
// 3) the package list for groups
72+
Set<String> apiPackages = new HashSet<String>()
73+
Set<String> spiPackages = new HashSet<String>()
74+
Set<String> internalPackages = new HashSet<String>()
75+
parent.subprojects.each{ Project subProject->
76+
// skip certain sub-projects
77+
if ( ! ['release','documentation'].contains( subProject.name ) ) {
78+
subProject.sourceSets.each { sourceSet ->
79+
// skip certain source sets
80+
if ( ! ['test','matrix'].contains( sourceSet.name ) ) {
81+
source sourceSet.java
82+
83+
if( classpath ) {
84+
classpath += sourceSet.output + sourceSet.compileClasspath
85+
}
86+
else {
87+
classpath = sourceSet.output + sourceSet.compileClasspath
88+
}
89+
90+
sourceSet.java.each { javaFile ->
91+
final String packageName = determinePackageName( sourceSet.java, javaFile );
92+
if ( packageName.endsWith( ".internal" ) || packageName.contains( ".internal." ) ) {
93+
internalPackages.add( packageName );
94+
}
95+
else if ( packageName.endsWith( ".spi" ) || packageName.contains( ".spi." ) ) {
96+
spiPackages.add( packageName );
97+
}
98+
else if ( packageName.startsWith( "org.hibernate.testing" ) ) {
99+
// do nothing as testing support is already handled...
100+
}
101+
else {
102+
apiPackages.add( packageName );
103+
}
104+
}
105+
}
106+
}
107+
}
108+
}
109+
110+
// apply standard config
111+
maxMemory = '512m'
112+
destinationDir = javadocDir
113+
configure( options ) {
114+
overview = rootProject.file( 'shared/javadoc/overview.html' )
115+
stylesheetFile = rootProject.file( 'shared/javadoc/stylesheet.css' )
116+
windowTitle = 'Hibernate JavaDocs'
117+
docTitle = "Hibernate JavaDoc ($project.version)"
118+
bottom = "Copyright &copy; 2001-$copyrightYear <a href=\"http://redhat.com\">Red Hat, Inc.</a> All Rights Reserved."
119+
use = true
120+
links = [ 'http://download.oracle.com/javase/6/docs/api/', 'http://download.oracle.com/javaee/6/api/' ]
121+
group( 'API', apiPackages.asList() )
122+
group( 'SPI', spiPackages.asList() )
123+
group( 'Internal', internalPackages.asList() )
124+
group ( 'Testing Support', ['org.hibernate.testing*'] )
125+
// ugh, http://issues.gradle.org/browse/GRADLE-1563
126+
// tags ["todo:X"]
127+
// work around:
128+
addStringOption( "tag", "todo:X" )
129+
}
130+
131+
doLast {
132+
copy {
133+
from rootProject.file( 'shared/javadoc/images' )
134+
into new File( javadocDir, "/images" )
135+
}
136+
}
137+
}
138+
139+
buildDocs.dependsOn aggregateJavadocs
140+
141+
142+
// jDocBook ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
34143

35144
jdocbook {
36-
// apply shared formatting config ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
37-
format('html_single') {
38-
finalName = "index.html"
39-
stylesheet = "classpath:/xslt/org/hibernate/jdocbook/xslt/xhtml-single.xsl"
40-
}
41-
42-
format('html') {
43-
finalName = "index.html"
44-
stylesheet = "classpath:/xslt/org/hibernate/jdocbook/xslt/xhtml.xsl"
45-
}
46-
47-
// book-specific config ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
48-
quickstart {
49-
masterSourceDocumentName = 'Hibernate_Getting_Started_Guide.xml'
50-
}
51-
52-
devguide {
53-
masterSourceDocumentName = 'Hibernate_Development_Guide.xml'
54-
useRelativeImageUris = false
55-
}
145+
// shared config
146+
format('html_single') {
147+
finalName = "index.html"
148+
stylesheet = "classpath:/xslt/org/hibernate/jdocbook/xslt/xhtml-single.xsl"
149+
}
150+
format('html') {
151+
finalName = "index.html"
152+
stylesheet = "classpath:/xslt/org/hibernate/jdocbook/xslt/xhtml.xsl"
153+
}
56154

57-
manual {
58-
masterSourceDocumentName = 'HIBERNATE_-_Relational_Persistence_for_Idiomatic_Java.xml'
59-
}
155+
// book-specific config
156+
quickstart {
157+
masterSourceDocumentName = 'Hibernate_Getting_Started_Guide.xml'
158+
}
159+
160+
devguide {
161+
masterSourceDocumentName = 'Hibernate_Development_Guide.xml'
162+
useRelativeImageUris = false
163+
}
164+
165+
manual {
166+
masterSourceDocumentName = 'HIBERNATE_-_Relational_Persistence_for_Idiomatic_Java.xml'
167+
}
60168
}
61169

62170
// todo : make this part of gradle-jdocbook.
@@ -73,14 +181,12 @@ stageStyles_devguide.doLast {
73181
}
74182

75183
[ 'devguide', 'manual', 'quickstart' ].each { bookName ->
76-
tasks[ "stageStyles_$bookName" ].doLast {
77-
logger.lifecycle( "Staging local style resources")
78-
copy {
79-
into project.file( "target/docbook/stage/$bookName" )
80-
from project.file( 'src/main/style' )
81-
includeEmptyDirs = false
82-
}
83-
}
184+
task "stageLocalStyles_$bookName"(type: Copy) {
185+
into project.file( "target/docbook/stage/$bookName" )
186+
from project.file( 'src/main/style' )
187+
includeEmptyDirs = false
188+
}
189+
tasks[ "stageStyles_$bookName" ].dependsOn "stageLocalStyles_$bookName"
84190
}
85191

86192
task buildTutorialZip(type: Zip) {
@@ -117,27 +223,14 @@ File[] dirList(File dir) {
117223

118224

119225
// asciidoctor ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
226+
120227
task asciidoctor(type: org.asciidoctor.gradle.AsciidoctorTask, group: 'Documentation') {
121228
description = 'Generates the Asciidoc(tor) topical guides in HTML format.'
122229
backend = 'html5'
123230
sourceDir = file( 'src/main/asciidoc/topical' )
124231
outputDir = new File("$buildDir/asciidoc/topical/html")
125232
}
126233

127-
//task generateRegistryGuideHtml(type: org.asciidoctor.gradle.AsciidoctorTask, group: 'Documentation') {
128-
// description = 'Generates the ServiceRegistry topical guide in HTML format.'
129-
// backend = 'html5'
130-
// sourceDir = file( 'src/main/asciidoc/topical/registries' )
131-
// outputDir = new File("$buildDir/asciidoc/topical/html")
132-
//}
133-
//
134-
//task generateMetamodelgenGuideHtml(type: org.asciidoctor.gradle.AsciidoctorTask, group: 'Documentation') {
135-
// description = 'Generates the Metamodel Generator topical guide in HTML format.'
136-
// backend = 'html5'
137-
// sourceDir = file( 'src/main/asciidoc/topical/metamodelgen' )
138-
// outputDir = new File("$buildDir/asciidoc/topical/html")
139-
//}
140-
141234
tasks.withType(org.asciidoctor.gradle.AsciidoctorTask) { docTask ->
142235
options = [
143236
logDocuments: true,
@@ -149,8 +242,4 @@ tasks.withType(org.asciidoctor.gradle.AsciidoctorTask) { docTask ->
149242
]
150243
}
151244

152-
// - aggregator
153-
//task asciidoctor(type: Task, group: 'Documentation')
154-
//asciidoctor.dependsOn generateRegistryGuideHtml, generateMetamodelgenGuideHtml
155-
156245
buildDocs.dependsOn asciidoctor

hibernate-core/hibernate-core.gradle

+2-3
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ jar {
8888
sourceSets.main {
8989
ext.jaxbTargetDir = file( "${buildDir}/generated-src/jaxb/main" )
9090
java.srcDir jaxbTargetDir
91-
originalJavaSrcDirs = java.srcDirs
9291
}
9392

9493
// resources inherently exclude sources
@@ -159,8 +158,8 @@ task jaxb {
159158

160159
}
161160

162-
generateMainLoggingClasses.dependsOn jaxb
163-
generateMainLoggingClasses.dependsOn generateGrammarSource
161+
//generateMainLoggingClasses.dependsOn jaxb
162+
//generateMainLoggingClasses.dependsOn generateGrammarSource
164163

165164
generateSources.dependsOn jaxb
166165
generateSources.dependsOn generateGrammarSource

0 commit comments

Comments
 (0)