2013-06-12 16:50:06 -04:00
|
|
|
configurations {
|
|
|
|
osgiRuntime
|
2013-09-09 19:35:01 -04:00
|
|
|
osgiRuntimeBnd
|
2013-06-12 16:50:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
sourceSets {
|
|
|
|
testClientBundle
|
|
|
|
}
|
|
|
|
|
|
|
|
sourceSets.test {
|
2014-03-18 17:52:37 -04:00
|
|
|
compileClasspath += sourceSets.testClientBundle.output
|
|
|
|
runtimeClasspath += sourceSets.testClientBundle.output
|
2013-06-12 16:50:06 -04:00
|
|
|
}
|
|
|
|
|
2013-01-23 18:22:03 -05:00
|
|
|
dependencies {
|
2013-06-12 16:50:06 -04:00
|
|
|
compile( project( ':hibernate-core' ) )
|
|
|
|
compile( project( ':hibernate-entitymanager' ) )
|
|
|
|
// MUST use 4.3.1! 4.3.0 was compiled with "-target jsr14".
|
|
|
|
// http://blog.osgi.org/2012/10/43-companion-code-for-java-7.html
|
|
|
|
compile( "org.osgi:org.osgi.core:4.3.1" )
|
2013-10-28 12:40:06 -04:00
|
|
|
compile( "org.osgi:org.osgi.compendium:4.3.1" )
|
2013-06-12 16:50:06 -04:00
|
|
|
|
|
|
|
testCompile( libraries.shrinkwrap_api )
|
|
|
|
testCompile( libraries.shrinkwrap )
|
|
|
|
testCompile( "org.jboss.arquillian.junit:arquillian-junit-container:1.0.3.Final" )
|
|
|
|
testCompile( "org.jboss.osgi.metadata:jbosgi-metadata:3.0.0.CR1" )
|
|
|
|
testRuntime( "org.jboss.arquillian.container:arquillian-osgi-felix:2.0.0.CR4" )
|
|
|
|
testRuntime( "org.apache.felix:org.apache.felix.framework:4.0.3" )
|
|
|
|
testRuntime( "org.apache.felix:org.apache.felix.main:4.0.3" )
|
2015-03-05 09:20:52 -05:00
|
|
|
testRuntime( libraries.slf4j_api );
|
|
|
|
testRuntime( libraries.slf4j_log4j );
|
2015-03-05 09:31:27 -05:00
|
|
|
testRuntime( "org.jboss.logmanager:jboss-logmanager:2.0.0.Beta1" )
|
2013-06-12 16:50:06 -04:00
|
|
|
|
2013-09-09 19:35:01 -04:00
|
|
|
// Local copies of all jars needed fur the OSGi runtime. Ignore the transitive dependencies.
|
|
|
|
// ORDER DEPENDENT!!!
|
|
|
|
osgiRuntime( "org.jboss.arquillian.osgi:arquillian-osgi-bundle:1.0.3.Final" ) { transitive = false }
|
|
|
|
osgiRuntime( libraries.jpa ) { transitive = false }
|
|
|
|
osgiRuntime( "org.jboss.spec.javax.interceptor:jboss-interceptors-api_1.2_spec:1.0.0.Alpha1" ) { transitive = false }
|
|
|
|
osgiRuntime( libraries.jta ) { transitive = false }
|
|
|
|
osgiRuntime( "com.h2database:h2:1.3.170" ) { transitive = false }
|
|
|
|
osgiRuntime( "org.apache.servicemix.bundles:org.apache.servicemix.bundles.antlr:2.7.7_5" ) { transitive = false }
|
|
|
|
osgiRuntime( libraries.javassist ) { transitive = false }
|
|
|
|
osgiRuntime( "org.apache.servicemix.specs:org.apache.servicemix.specs.stax-api-1.2:2.2.0" ) { transitive = false }
|
|
|
|
osgiRuntime( "org.apache.servicemix.bundles:org.apache.servicemix.bundles.dom4j:1.6.1_5" ) { transitive = false }
|
|
|
|
osgiRuntime( libraries.commons_annotations ) { transitive = false }
|
|
|
|
osgiRuntime( libraries.classmate ) { transitive = false }
|
2015-03-10 12:45:54 -04:00
|
|
|
osgiRuntime( "org.apache.logging.log4j:log4j-api:2.0" ) { transitive = false }
|
2013-09-09 19:35:01 -04:00
|
|
|
osgiRuntime( libraries.logging ) { transitive = false }
|
2013-12-04 10:13:23 -05:00
|
|
|
|
2013-09-09 19:35:01 -04:00
|
|
|
// needed for BND
|
|
|
|
osgiRuntimeBnd( libraries.jandex ) { transitive = false }
|
|
|
|
osgiRuntimeBnd( "javax.enterprise:cdi-api:1.1" ) { transitive = false }
|
|
|
|
osgiRuntimeBnd( "javax.el:el-api:2.2" ) { transitive = false }
|
2013-06-12 16:50:06 -04:00
|
|
|
|
|
|
|
testClientBundleCompile( project( ':hibernate-core' ) )
|
|
|
|
testClientBundleCompile( project( ':hibernate-entitymanager' ) )
|
|
|
|
// MUST use 4.3.1! 4.3.0 was compiled with "-target jsr14".
|
|
|
|
// http://blog.osgi.org/2012/10/43-companion-code-for-java-7.html
|
|
|
|
testClientBundleCompile( "org.osgi:org.osgi.core:4.3.1" )
|
2013-01-23 18:22:03 -05:00
|
|
|
}
|
|
|
|
|
2013-04-16 19:25:20 -04:00
|
|
|
def pomName() {
|
2013-06-12 16:50:06 -04:00
|
|
|
return 'Hibernate OSGi Support'
|
2013-04-16 19:25:20 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
def pomDescription() {
|
2013-06-12 16:50:06 -04:00
|
|
|
return 'Support for running Hibernate O/RM in OSGi environments'
|
2013-04-16 19:25:20 -04:00
|
|
|
}
|
|
|
|
|
2013-12-02 21:53:19 -05:00
|
|
|
def osgiDescription() {
|
|
|
|
return pomDescription()
|
|
|
|
}
|
|
|
|
|
2013-01-23 18:22:03 -05:00
|
|
|
jar {
|
2013-06-12 16:50:06 -04:00
|
|
|
manifest {
|
|
|
|
instruction 'Bundle-Activator', 'org.hibernate.osgi.HibernateBundleActivator'
|
2013-04-08 18:53:44 -04:00
|
|
|
|
2013-09-06 15:47:47 -04:00
|
|
|
instructionFirst 'Import-Package',
|
2013-06-12 16:50:06 -04:00
|
|
|
// TODO: Shouldn't have to explicitly list this, but the plugin
|
|
|
|
// generates it with a [1.0,2) version.
|
|
|
|
'javax.persistence;version="2.1.0"',
|
|
|
|
'javax.persistence.spi;version="2.1.0"'
|
|
|
|
}
|
2013-01-23 18:22:03 -05:00
|
|
|
}
|
2013-06-12 16:50:06 -04:00
|
|
|
|
2014-12-17 16:18:09 -05:00
|
|
|
test {
|
2015-03-05 09:20:52 -05:00
|
|
|
systemProperties['java.util.logging.manager'] = "org.jboss.logmanager.LogManager"
|
|
|
|
systemProperties['log4j.configuration'] = "file://$projectDir/src/test/resources/logging.properties"
|
2014-12-17 16:18:09 -05:00
|
|
|
}
|
|
|
|
|
2013-06-12 16:50:06 -04:00
|
|
|
task copyBnd(type: Copy) {
|
|
|
|
from "src/test/resources/bnd"
|
2013-09-09 19:35:01 -04:00
|
|
|
into "$buildDir/osgi-lib/bnd"
|
2013-06-12 16:50:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
task runBnd(type: JavaExec){
|
|
|
|
main = "-jar"
|
2013-09-09 19:35:01 -04:00
|
|
|
args "$buildDir/osgi-lib/bnd/bnd-2.1.0.jar", "$buildDir/osgi-lib/bnd/cdi-api.bnd", "$buildDir/osgi-lib/bnd/el-api.bnd", "$buildDir/osgi-lib/bnd/jandex.bnd"
|
2013-06-12 16:50:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
task copyToLib(type: Copy) {
|
|
|
|
from configurations.osgiRuntime
|
2013-09-09 19:35:01 -04:00
|
|
|
from configurations.osgiRuntimeBnd
|
|
|
|
into "$buildDir/osgi-lib"
|
|
|
|
}
|
|
|
|
|
|
|
|
task felixProperties << {
|
|
|
|
copy {
|
|
|
|
from "src/test/resources/felix-framework.properties-ORIGINAL"
|
|
|
|
into "$buildDir/osgi-lib"
|
|
|
|
rename { String fileName ->
|
|
|
|
fileName.replace("-ORIGINAL", "")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
propertiesFile = file("$buildDir/osgi-lib/felix-framework.properties")
|
|
|
|
|
|
|
|
// append jars wrapped using BND
|
|
|
|
FileTree tree = fileTree(dir: "$buildDir/osgi-lib/bnd")
|
|
|
|
tree.exclude "*bnd*"
|
|
|
|
tree.each {File file ->
|
|
|
|
propertiesFile << " \\\nfile:target/osgi-lib/bnd/" + file.name
|
|
|
|
}
|
|
|
|
|
|
|
|
// append all jars in osgiRuntime configuration
|
|
|
|
configurations.osgiRuntime.each { File file ->
|
|
|
|
propertiesFile << " \\\nfile:target/osgi-lib/" + file.name
|
|
|
|
}
|
|
|
|
|
|
|
|
// append ORM jars
|
|
|
|
// TODO: Is there a better, dynamic way of doing this?
|
|
|
|
propertiesFile << " \\\nfile:../hibernate-core/target/libs/hibernate-core-" + hibernateTargetVersion + ".jar"
|
|
|
|
propertiesFile << " \\\nfile:../hibernate-entitymanager/target/libs/hibernate-entitymanager-" + hibernateTargetVersion + ".jar"
|
|
|
|
propertiesFile << " \\\nfile:target/libs/hibernate-osgi-" + hibernateTargetVersion + ".jar"
|
2013-06-12 16:50:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
task testClientBundleJar(type: Jar) {
|
2014-03-18 17:52:37 -04:00
|
|
|
from sourceSets.testClientBundle.output
|
2013-06-12 16:50:06 -04:00
|
|
|
destinationDir new File("$buildDir/osgi-lib")
|
|
|
|
archiveName "testClientBundle.jar"
|
|
|
|
|
|
|
|
// The OSGi plugin acts up when we need to export multiple source sets. Just do it manually.
|
|
|
|
manifest {
|
|
|
|
attributes("Export-Package" : "org.hibernate.osgi.test.client,org.hibernate.osgi.test.result",
|
|
|
|
"Bundle-Name" : "testClientBundle",
|
|
|
|
"Bundle-Activator" : "org.hibernate.osgi.test.client.OsgiTestActivator",
|
|
|
|
"Bundle-ManifestVersion" : "2",
|
|
|
|
"Bundle-SymbolicName" : "testClientBundle",
|
2013-12-04 10:13:23 -05:00
|
|
|
"Import-Package" : "javassist.util.proxy,javax.persistence,javax.persistence.spi,org.h2,org.osgi.framework,"
|
|
|
|
+ "org.hibernate,"
|
2015-03-05 09:20:52 -05:00
|
|
|
+ "org.hibernate.boot.model,"
|
2013-12-04 10:13:23 -05:00
|
|
|
+ "org.hibernate.boot.registry.selector,"
|
|
|
|
+ "org.hibernate.boot.registry.selector.spi,"
|
|
|
|
+ "org.hibernate.cfg,"
|
|
|
|
+ "org.hibernate.engine.spi,"
|
|
|
|
+ "org.hibernate.integrator.spi,"
|
|
|
|
+ "org.hibernate.proxy,"
|
|
|
|
+ "org.hibernate.service,"
|
|
|
|
+ "org.hibernate.service.spi")
|
2013-06-12 16:50:06 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
runBnd.dependsOn copyToLib
|
|
|
|
runBnd.dependsOn copyBnd
|
2013-09-09 19:35:01 -04:00
|
|
|
felixProperties.dependsOn runBnd
|
|
|
|
test.dependsOn felixProperties
|
2013-06-12 16:50:06 -04:00
|
|
|
test.dependsOn testClientBundleJar
|
|
|
|
test.dependsOn jar
|