HHH-12188 - Add Java 9 automatic module name hinting

aligned OSGi symbolic name with Java 9 module name;
cleaned up jar/osgi manifest configuration block
This commit is contained in:
Steve Ebersole 2017-12-22 21:08:14 -06:00
parent 78bc62fe1e
commit abbf1fdbbe
2 changed files with 42 additions and 15 deletions

View File

@ -330,25 +330,39 @@ subprojects { subProject ->
}
classpath = configurations.runtime
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 *.
'*'
instruction 'Bundle-Vendor', 'Hibernate.org'
instruction 'Bundle-Description', subProject.osgiDescription()
instruction 'Implementation-Url', 'http://hibernate.org'
instruction 'Implementation-Version', version
instruction 'Implementation-Vendor', 'Hibernate.org'
instruction 'Implementation-Vendor-Id', 'org.hibernate'
instruction 'Implementation-Title', name
String moduleSimpleName = java9ModuleName( subProject )
String moduleName = "org.hibernate.orm.$moduleSimpleName"
// Java 9 module name
instruction 'Automatic-Module-Name', moduleName
// the OSGi metadata
symbolicName moduleName
vendor 'Hibernate.org'
description subProject.osgiDescription()
docURL "http://www.hibernate.org/orm/${hibernateMajorMinorVersion}"
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', name
instruction 'Specification-Version', version
instruction 'Specification-Vendor', 'Hibernate.org'
instruction 'Implementation-Title', name
instruction 'Implementation-Version', version
instruction 'Implementation-VersionFamily', hibernateMajorMinorVersion
instruction 'Implementation-Vendor', 'Hibernate.org'
instruction 'Implementation-Vendor-Id', 'org.hibernate'
instruction 'Implementation-Url', 'http://hibernate.org/orm'
}
}

View File

@ -14,6 +14,7 @@ class UtilitiesPlugin implements Plugin<Project> {
}
class UtilitiesPluginDef {
@SuppressWarnings("GrUnnecessarySemicolon")
public String determinePackageName(SourceDirectorySet sourceDirectorySet, File javaFile) {
final javaFileAbsolutePath = javaFile.absolutePath;
for ( File sourceDirectory : sourceDirectorySet.srcDirs ) {
@ -28,4 +29,16 @@ class UtilitiesPluginDef {
}
throw new RuntimeException( "ugh" );
}
String java9ModuleName(Project project) {
String name = project.name
// alternative is to just use the full project name (don't drop the 'hibernate-' prefix)
if ( name.startsWith( 'hibernate-' ) ) {
name = name.drop( 'hibernate-'.length() )
}
return name
}
}