diff --git a/build.gradle b/build.gradle index 1f2837f599..cc0dcf36a3 100644 --- a/build.gradle +++ b/build.gradle @@ -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' + } } diff --git a/utilities.gradle b/utilities.gradle index 32de0c340a..ebab80d300 100644 --- a/utilities.gradle +++ b/utilities.gradle @@ -14,6 +14,7 @@ class UtilitiesPlugin implements Plugin { } 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 + } } \ No newline at end of file