hibernate-orm/documentation/documentation.gradle

333 lines
11 KiB
Groovy
Raw Normal View History

import org.apache.tools.ant.filters.ReplaceTokens
import org.asciidoctor.gradle.AsciidoctorTask
2017-12-13 10:15:22 -05:00
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
buildscript {
2013-11-21 14:46:03 -05:00
repositories {
jcenter()
}
dependencies {
classpath 'org.asciidoctor:asciidoctor-gradle-plugin:1.5.2'
2013-11-21 14:46:03 -05:00
}
}
apply plugin: "java"
apply plugin: 'org.asciidoctor.convert'
apply plugin: 'hibernate-matrix-testing'
2013-11-22 15:51:56 -05:00
defaultTasks 'buildDocs'
2015-03-24 21:38:39 -04:00
dependencies {
ext.pressgangVersion = '3.0.0'
2013-11-22 15:51:56 -05:00
compile( libraries.jpa )
compile( project( ':hibernate-core' ) )
compile( project( ':hibernate-jpamodelgen' ) )
testCompile( 'org.apache.commons:commons-lang3:3.4' )
testCompile( project(':hibernate-ehcache') )
testCompile( project(':hibernate-envers') )
testCompile( project(':hibernate-spatial') )
2016-05-06 14:38:48 -04:00
testCompile( project(path: ':hibernate-core', configuration: 'tests') )
testCompile( project(':hibernate-testing') )
testCompile( libraries.mockito )
testCompile( libraries.mockito_inline )
testRuntime( libraries.h2 )
testRuntime( libraries.hsqldb )
testRuntime( libraries.postgresql )
testRuntime( libraries.mysql )
testRuntime( libraries.mariadb )
testRuntime( libraries.mssql )
testCompile "org.osgi:org.osgi.core:4.3.1"
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Java 9 ftw!
if ( JavaVersion.current().isJava9Compatible() ) {
// The JDK used to run Gradle is Java 9+, and we assume that that is the same
// JDK for executing tasks
compile( 'com.sun.xml.bind:jaxb-impl:2.2.11' )
compile( 'org.glassfish.jaxb:jaxb-xjc:2.2.11' )
compile( 'org.jvnet.jaxb2_commons:jaxb2-basics:0.11.0' )
compile( 'org.jvnet.jaxb2_commons:jaxb2-basics-ant:0.11.0' )
compile( 'javax:javaee-api:7.0' )
testCompile( 'com.sun.xml.bind:jaxb-impl:2.2.11' )
testCompile( 'org.glassfish.jaxb:jaxb-xjc:2.2.11' )
testCompile( 'org.jvnet.jaxb2_commons:jaxb2-basics:0.11.0' )
testCompile( 'org.jvnet.jaxb2_commons:jaxb2-basics-ant:0.11.0' )
testCompile( 'javax:javaee-api:7.0' )
testRuntime( 'com.sun.xml.bind:jaxb-impl:2.2.11' )
testRuntime( 'org.glassfish.jaxb:jaxb-xjc:2.2.11' )
testRuntime( 'org.jvnet.jaxb2_commons:jaxb2-basics:0.11.0' )
testRuntime( 'org.jvnet.jaxb2_commons:jaxb2-basics-ant:0.11.0' )
testRuntime( 'javax:javaee-api:7.0' )
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
}
2013-11-22 15:51:56 -05:00
2016-02-11 16:59:13 -05:00
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// grouping tasks - declaration, see below for task dependency definitions
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2013-11-22 15:51:56 -05:00
task buildDocs {
2016-02-11 16:59:13 -05:00
group 'Documentation'
description 'Grouping task for performing all documentation building tasks'
}
task buildDocsForPublishing {
group 'Documentation'
description 'Grouping task for building all documentation for publishing (release)'
2013-11-22 15:51:56 -05:00
}
2016-02-11 16:59:13 -05:00
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// aggregated JavaDoc
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2013-11-22 15:51:56 -05:00
final File javadocDir = mkdir( new File( (File) project.buildDir, 'javadocs' ) );
/**
* Builds the JavaDocs aggregated (unified) across all the sub-projects
*/
task aggregateJavadocs(type: Javadoc) {
String[] projectsToSkip = ['release','documentation', 'hibernate-orm-modules']
2013-11-22 15:51:56 -05:00
description = 'Builds the aggregated (unified) JavaDocs across all sub-projects'
final int currentYear = new GregorianCalendar().get( Calendar.YEAR )
// exclude any generated sources and internal packages
exclude( '**/generated-src/**' )
exclude( '**/internal/**' )
2013-11-22 15:51:56 -05:00
// apply standard config
maxMemory = '512m'
destinationDir = javadocDir
configure( options ) {
overview = project.file( 'src/main/javadoc/overview.html' )
windowTitle = 'Hibernate JavaDocs'
docTitle = "Hibernate JavaDoc ($project.version)"
bottom = "Copyright &copy; 2001-$currentYear <a href=\"http://redhat.com\">Red Hat, Inc.</a> All Rights Reserved."
use = true
options.encoding = 'UTF-8'
links = [
'https://docs.oracle.com/javase/8/docs/api/',
'https://docs.jboss.org/hibernate/beanvalidation/spec/2.0/api/',
'http://docs.jboss.org/cdi/api/2.0/',
'https://docs.oracle.com/javaee/7/api/'
]
if ( JavaVersion.current().isJava8Compatible() ) {
options.addStringOption( 'Xdoclint:none', '-quiet' )
}
}
2013-11-22 15:51:56 -05:00
// process each project, building up:
// 1) appropriate sources
// 2) classpath
parent.subprojects.each { Project subProject->
2013-11-22 15:51:56 -05:00
// skip certain sub-projects
if ( projectsToSkip.contains( subProject.name ) ) {
return
2013-12-02 21:53:19 -05:00
}
// we only care about the main SourceSet...
source subProject.sourceSets.main.java
// if( classpath ) {
2013-12-02 21:53:19 -05:00
classpath += subProject.sourceSets.main.output + subProject.sourceSets.main.compileClasspath
// }
// else {
// classpath = subProject.sourceSets.main.output + subProject.sourceSets.main.compileClasspath
// }
2013-11-22 15:51:56 -05:00
}
doFirst {
Set<String> apiPackages = new HashSet<String>()
Set<String> spiPackages = new HashSet<String>()
Set<String> testingPackages = new HashSet<String>()
parent.subprojects.each { Project subProject ->
// skip certain sub-projects
if ( projectsToSkip.contains( subProject.name ) ) {
return
}
2013-11-22 15:51:56 -05:00
subProject.sourceSets.main.java.each { javaFile ->
final String packageName = determinePackageName( subProject.sourceSets.main.java, javaFile );
if ( packageName.endsWith( ".internal" ) || packageName.contains( ".internal." ) ) {
// do nothing - we exclude internal packages
}
else if ( packageName.endsWith( ".spi" ) || packageName.contains( ".spi." ) ) {
spiPackages.add( packageName )
}
else if ( packageName.startsWith( "org.hibernate.testing" ) ) {
testingPackages += packageName
}
else {
apiPackages.add( packageName )
}
}
}
options.group( 'API', apiPackages.asList() )
options.group( 'SPI', spiPackages.asList() )
options.group( 'Testing Support', testingPackages.asList() )
}
2013-11-22 15:51:56 -05:00
}
asciidoctor {
// we do not want it creating its "default task"
enabled = false
}
// Topical Guides ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
task renderTopicalGuides(type: AsciidoctorTask, group: 'Documentation') {
description = 'Renders the Topical Guides in HTML format using Asciidoctor.'
sourceDir = file( 'src/main/asciidoc/topical' )
2016-02-11 16:59:13 -05:00
outputDir = new File("$buildDir/asciidoc/topical/html_single")
backends "html5"
separateOutputDirs false
options logDocuments: true
attributes icons: 'font', experimental: true, 'source-highlighter': 'prettify', majorMinorVersion: rootProject.hibernateMajorMinorVersion, fullVersion: rootProject.hibernateFullVersion
}
// Getting Started Guides (quick starts) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2013-11-22 15:51:56 -05:00
task renderGettingStartedGuides(type: AsciidoctorTask, group: 'Documentation') {
description = 'Renders the Getting Started Guides (quick starts) in HTML format using Asciidoctor.'
sourceDir = file( 'src/main/asciidoc/quickstart/guides' )
2016-02-11 16:59:13 -05:00
outputDir = new File("$buildDir/asciidoc/quickstart/html_single")
backends "html5"
separateOutputDirs false
options logDocuments: true
attributes icons: 'font', experimental: true, 'source-highlighter': 'prettify'
}
2016-02-11 16:59:13 -05:00
task buildTutorialZip(type: Zip) {
from 'src/main/asciidoc/quickstart/tutorials'
destinationDir = tasks.renderGettingStartedGuides.outputDir
archiveName = 'hibernate-tutorials.zip'
expand(
version: project.version,
slf4j: "1.7.5",
junit: parent.junitVersion,
h2: parent.h2Version
)
}
renderGettingStartedGuides.dependsOn buildTutorialZip
// Mapping Guides ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
task renderMappingGuide(type: AsciidoctorTask, group: 'Documentation') {
description = 'Renders the Mapping Guides in HTML format using Asciidoctor.'
sourceDir = file( 'src/main/asciidoc/mapping' )
outputDir = new File("$buildDir/asciidoc/mapping/html")
backends "html5"
separateOutputDirs false
options logDocuments: true
//attributes icons: 'font', experimental: true, 'source-highlighter': 'prettify', linkcss: true, stylesheet: "css/hibernate.css"
attributes icons: 'font', experimental: true, 'source-highlighter': 'prettify', linkcss: true
resources {
from('src/main/asciidoc/') {
include 'images/**'
include 'css/**'
}
}
}
// User Guide ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
task renderUserGuide(type: AsciidoctorTask, group: 'Documentation') {
description = 'Renders the User Guides in HTML format using Asciidoctor.'
sourceDir = file( 'src/main/asciidoc/userguide' )
2016-02-11 16:59:13 -05:00
outputDir = new File("$buildDir/asciidoc/userguide/html_single")
backends "html5"
separateOutputDirs false
options logDocuments: true
attributes icons: 'font', experimental: true,
'source-highlighter': 'prettify',
linkcss: true,
stylesheet: "css/hibernate.css",
majorMinorVersion: rootProject.hibernateMajorMinorVersion,
fullVersion: rootProject.hibernateFullVersion,
docinfo: true
resources {
from('src/main/asciidoc/userguide/') {
include 'images/**'
}
from('src/main/style/asciidoctor') {
include 'images/**'
}
from('src/main/style/asciidoctor') {
include 'css/**'
}
from('src/main/style/asciidoctor') {
include 'js/**'
}
}
}
// Integration Guide ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
task renderIntegrationGuide(type: AsciidoctorTask, group: 'Documentation') {
description = 'Renders the User Guides in HTML format using Asciidoctor.'
sourceDir = file( 'src/main/asciidoc/integrationguide' )
outputDir = new File("$buildDir/asciidoc/integrationguide/html_single")
backends "html5"
separateOutputDirs false
options logDocuments: true
attributes icons: 'font', experimental: true, 'source-highlighter': 'prettify', linkcss: true, stylesheet: "css/hibernate.css", majorMinorVersion: rootProject.hibernateMajorMinorVersion
resources {
from('src/main/asciidoc/integrationguide/') {
include 'images/**'
}
from('src/main/style/asciidoctor') {
include 'images/**'
}
from('src/main/style/asciidoctor') {
include 'css/**'
}
}
}
2016-02-11 16:59:13 -05:00
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// grouping tasks
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2016-02-11 16:59:13 -05:00
buildDocs.dependsOn aggregateJavadocs
buildDocs.dependsOn renderTopicalGuides
buildDocs.dependsOn renderGettingStartedGuides
buildDocs.dependsOn renderUserGuide
buildDocs.dependsOn renderIntegrationGuide
2016-02-11 16:59:13 -05:00
buildDocsForPublishing.dependsOn aggregateJavadocs
buildDocsForPublishing.dependsOn renderTopicalGuides
buildDocsForPublishing.dependsOn renderGettingStartedGuides
buildDocsForPublishing.dependsOn renderUserGuide
buildDocsForPublishing.dependsOn renderIntegrationGuide
checkstyleMain.exclude '**/org/hibernate/userguide/model/*'