Skip to content

Commit

Permalink
HHH-12188 - Add Java 9 automatic module name hinting
Browse files Browse the repository at this point in the history
aligned OSGi symbolic name with Java 9 module name;
cleaned up jar/osgi manifest configuration block
  • Loading branch information
sebersole committed Dec 28, 2017
1 parent 78bc62f commit abbf1fd
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 15 deletions.
44 changes: 29 additions & 15 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -330,25 +330,39 @@ subprojects { subProject ->
}
classpath = configurations.runtime


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 *.
'*'

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
// 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'

}
}

Expand Down
13 changes: 13 additions & 0 deletions utilities.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand All @@ -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
}
}

0 comments on commit abbf1fd

Please sign in to comment.