hibernate-orm/gradle/published-java-module.gradle

227 lines
6.5 KiB
Groovy

/*
* 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
*/
apply from: rootProject.file( 'gradle/java-module.gradle' )
apply from: rootProject.file( 'gradle/publishing-repos.gradle' )
apply from: rootProject.file( 'gradle/publishing-pom.gradle' )
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Jar
jar {
manifest = osgiManifest {
// GRADLE-1411: Even if we override Imports and Exports
// auto-generation with instructions, classesDir and classpath
// need to be here (temporarily).
if ( project.pluginManager.hasPlugin( 'groovy' ) ) {
classesDir = sourceSets.main.groovy.outputDir
}
else {
classesDir = sourceSets.main.output.classesDir
}
classpath = configurations.runtime
// Java 9 module name
instruction 'Automatic-Module-Name', project.java9ModuleName
// the OSGi metadata
symbolicName project.java9ModuleName
vendor 'Hibernate.org'
description project.description
docURL "http://www.hibernate.org/orm/${project.ormVersion.family}"
instruction 'Import-Package',
// Temporarily support JTA 1.1 -- Karaf and other frameworks still
// use it. Without this, the plugin generates [1.2,2).
'javax.transaction;version="[1.1,2)"',
// Tell Gradle OSGi to still dynamically import the other packages.
// IMPORTANT: Do not include the * in the modules' .gradle files.
// If it exists more than once, the manifest will physically contain a *.
'*'
// Basic JAR manifest metadata
instruction 'Specification-Title', project.name
instruction 'Specification-Version', project.version
instruction 'Specification-Vendor', 'Hibernate.org'
instruction 'Implementation-Title', project.name
instruction 'Implementation-Version', project.version
instruction 'Implementation-Vendor', 'Hibernate.org'
instruction 'Implementation-Vendor-Id', 'org.hibernate'
instruction 'Implementation-Url', 'http://hibernate.org/orm'
instruction 'Hibernate-VersionFamily', project.ormVersion.family
instruction 'Hibernate-JpaVersion', project.jpaVersion.name
}
}
task sourcesJar(type: Jar) {
from project.sourceSets.main.allSource
manifest = project.tasks.jar.manifest
classifier = 'sources'
}
task javadocJar(type: Jar) {
from project.tasks.javadoc.outputs
manifest = project.tasks.jar.manifest
classifier = 'javadoc'
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Javadoc
javadoc {
exclude( "**/internal/*" )
exclude( "**/generated-src/**" )
final int currentYear = new GregorianCalendar().get( Calendar.YEAR )
configure( options ) {
// docletpath = configurations.asciidoclet.files.asType(List)
// doclet = 'org.asciidoctor.Asciidoclet'
windowTitle = "$project.name JavaDocs"
docTitle = "$project.name JavaDocs ($project.version)"
bottom = "Copyright &copy; 2001-$currentYear <a href=\"http://redhat.com\">Red Hat, Inc.</a> All Rights Reserved."
use = true
encoding = 'UTF-8'
links += [
'https://docs.oracle.com/javase/8/docs/api/',
'http://docs.jboss.org/hibernate/beanvalidation/spec/2.0/api/',
'http://docs.jboss.org/cdi/api/2.0/',
'https://javaee.github.io/javaee-spec/javadocs/'
]
if ( JavaVersion.current().isJava11Compatible() ) {
//The need to set `--source 1.8` applies to all JVMs after 11, and also to 11
// but after excluding the first two builds; see also specific comments on
// https://bugs.openjdk.java.net/browse/JDK-8212233?focusedCommentId=14245762
// For now, let's be compatible with JDK 11.0.3+. We can improve on it if people
// complain they cannot build with JDK 11.0.0, 11.0.1 and 11.0.2.
System.out.println("Forcing Javadoc in Java 8 compatible mode");
options.source = project.baselineJavaVersion
}
if ( JavaVersion.current().isJava8Compatible() ) {
addStringOption( 'Xdoclint:none', '-quiet' )
}
tags(
'todo:X"',
'apiNote:a:"API Note:"',
'implSpec:a:"Implementation Requirements:"',
'implNote:a:"Implementation Note:"'
)
}
doFirst {
// ordering problems if we try to do this during config phase :(
classpath += project.sourceSets.main.output + project.sourceSets.main.compileClasspath + project.configurations.provided
}
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Publishing
publishing {
publications {
publishedArtifacts {
from components.java
artifact( sourcesJar ) {
// todo : do these really need to be specified twice?
classifier 'sources'
}
artifact( javadocJar ) {
// todo : do these really need to be specified twice?
classifier "javadoc"
}
}
}
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Relocation for the published artifacts based on the old groupId
publishing {
publications {
relocationArtifacts( MavenPublication ) {
pom {
name = project.name + ' - relocation'
groupId = 'org.hibernate'
artifactId = project.name
version = project.version
description = project.description
url = 'http://hibernate.org/orm'
organization {
name = 'Hibernate.org'
url = 'http://hibernate.org'
}
licenses {
license {
name = 'GNU Library General Public License v2.1 or later'
url = 'http://www.opensource.org/licenses/LGPL-2.1'
comments = 'See discussion at http://hibernate.org/community/license/ for more details.'
distribution = 'repo'
}
}
scm {
url = 'http://github.com/hibernate/hibernate-orm'
connection = 'scm:git:http://github.com/hibernate/hibernate-orm.git'
developerConnection = 'scm:git:git@github.com:hibernate/hibernate-orm.git'
}
developers {
developer {
id = 'hibernate-team'
name = 'The Hibernate Development Team'
organization = 'Hibernate.org'
organizationUrl = 'http://hibernate.org'
}
}
issueManagement {
system = 'jira'
url = 'https://hibernate.atlassian.net/browse/HHH'
}
distributionManagement {
relocation {
groupId = 'org.hibernate.orm'
artifactId = project.name
version = project.version
}
}
}
}
}
}
task ciBuild( dependsOn: [test, publish] )
task release( dependsOn: [test, bintrayUpload] )
afterEvaluate { Project project ->
project.rootProject.subprojects { Project subproject ->
// NOTE : we want this even when `project == subproject`
project.tasks.bintrayUpload.dependsOn( subproject.tasks.build )
}
}