Skip to content

Commit abbf1fd

Browse files
committed
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
1 parent 78bc62f commit abbf1fd

File tree

2 files changed

+42
-15
lines changed

2 files changed

+42
-15
lines changed

build.gradle

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -330,25 +330,39 @@ subprojects { subProject ->
330330
}
331331
classpath = configurations.runtime
332332

333+
334+
String moduleSimpleName = java9ModuleName( subProject )
335+
String moduleName = "org.hibernate.orm.$moduleSimpleName"
336+
337+
// Java 9 module name
338+
instruction 'Automatic-Module-Name', moduleName
339+
340+
// the OSGi metadata
341+
symbolicName moduleName
342+
vendor 'Hibernate.org'
343+
description subProject.osgiDescription()
344+
docURL "http://www.hibernate.org/orm/${hibernateMajorMinorVersion}"
345+
333346
instruction 'Import-Package',
334-
// Temporarily support JTA 1.1 -- Karaf and other frameworks still
335-
// use it. Without this, the plugin generates [1.2,2).
336-
'javax.transaction;version="[1.1,2)"',
337-
// Tell Gradle OSGi to still dynamically import the other packages.
338-
// IMPORTANT: Do not include the * in the modules' .gradle files.
339-
// If it exists more than once, the manifest will physically contain a *.
340-
'*'
341-
342-
instruction 'Bundle-Vendor', 'Hibernate.org'
343-
instruction 'Bundle-Description', subProject.osgiDescription()
344-
instruction 'Implementation-Url', 'http://hibernate.org'
345-
instruction 'Implementation-Version', version
346-
instruction 'Implementation-Vendor', 'Hibernate.org'
347-
instruction 'Implementation-Vendor-Id', 'org.hibernate'
348-
instruction 'Implementation-Title', name
347+
// Temporarily support JTA 1.1 -- Karaf and other frameworks still
348+
// use it. Without this, the plugin generates [1.2,2).
349+
'javax.transaction;version="[1.1,2)"',
350+
// Tell Gradle OSGi to still dynamically import the other packages.
351+
// IMPORTANT: Do not include the * in the modules' .gradle files.
352+
// If it exists more than once, the manifest will physically contain a *.
353+
'*'
354+
355+
// Basic JAR manifest metadata
349356
instruction 'Specification-Title', name
350357
instruction 'Specification-Version', version
351358
instruction 'Specification-Vendor', 'Hibernate.org'
359+
instruction 'Implementation-Title', name
360+
instruction 'Implementation-Version', version
361+
instruction 'Implementation-VersionFamily', hibernateMajorMinorVersion
362+
instruction 'Implementation-Vendor', 'Hibernate.org'
363+
instruction 'Implementation-Vendor-Id', 'org.hibernate'
364+
instruction 'Implementation-Url', 'http://hibernate.org/orm'
365+
352366
}
353367
}
354368

utilities.gradle

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class UtilitiesPlugin implements Plugin<Project> {
1414
}
1515

1616
class UtilitiesPluginDef {
17+
@SuppressWarnings("GrUnnecessarySemicolon")
1718
public String determinePackageName(SourceDirectorySet sourceDirectorySet, File javaFile) {
1819
final javaFileAbsolutePath = javaFile.absolutePath;
1920
for ( File sourceDirectory : sourceDirectorySet.srcDirs ) {
@@ -28,4 +29,16 @@ class UtilitiesPluginDef {
2829
}
2930
throw new RuntimeException( "ugh" );
3031
}
32+
33+
String java9ModuleName(Project project) {
34+
String name = project.name
35+
36+
// alternative is to just use the full project name (don't drop the 'hibernate-' prefix)
37+
38+
if ( name.startsWith( 'hibernate-' ) ) {
39+
name = name.drop( 'hibernate-'.length() )
40+
}
41+
42+
return name
43+
}
3144
}

0 commit comments

Comments
 (0)