2013-06-12 16:50:06 -04:00
|
|
|
configurations {
|
2015-03-19 13:40:29 -04:00
|
|
|
osgiRuntime {
|
|
|
|
// Ignore the transitive dependencies.
|
|
|
|
transitive = false
|
|
|
|
}
|
|
|
|
osgiRuntimeBnd {
|
|
|
|
// Ignore the transitive dependencies.
|
|
|
|
transitive = false
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2015-04-10 12:58:22 -04:00
|
|
|
test {
|
|
|
|
// for now, always disable!!
|
|
|
|
enabled = false
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( project.properties.java6Home == null ) {
|
|
|
|
// hibernate-osgi *must* be run using Java 6 or 7. So disable its tests if
|
|
|
|
// java6Home is not available
|
|
|
|
enabled = false
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
compileTestJava {
|
|
|
|
options.fork = true
|
|
|
|
options.forkOptions.executable = project.properties.java6Home.javacExecutable
|
|
|
|
options.bootClasspath = project.properties.java6Home.runtimeJar.absolutePath
|
|
|
|
}
|
|
|
|
compileTestClientBundleJava {
|
|
|
|
options.fork = true
|
|
|
|
options.forkOptions.executable = project.properties.java6Home.javacExecutable
|
|
|
|
options.bootClasspath = project.properties.java6Home.runtimeJar.absolutePath
|
|
|
|
}
|
|
|
|
|
|
|
|
test {
|
|
|
|
executable = project.properties.java6Home
|
|
|
|
maxHeapSize = '2G'
|
|
|
|
jvmArgs += ['-XX:MaxPermGen=512M']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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!!!
|
2015-03-19 13:40:29 -04:00
|
|
|
osgiRuntime( "org.jboss.arquillian.osgi:arquillian-osgi-bundle:1.0.3.Final" )
|
|
|
|
osgiRuntime( libraries.jpa )
|
|
|
|
osgiRuntime( "org.jboss.spec.javax.interceptor:jboss-interceptors-api_1.2_spec:1.0.0.Alpha1" )
|
|
|
|
osgiRuntime( libraries.jta )
|
|
|
|
osgiRuntime( "com.h2database:h2:1.3.170" )
|
|
|
|
osgiRuntime( "org.apache.servicemix.bundles:org.apache.servicemix.bundles.antlr:2.7.7_5" )
|
|
|
|
osgiRuntime( libraries.javassist )
|
|
|
|
osgiRuntime( "org.apache.servicemix.specs:org.apache.servicemix.specs.stax-api-1.2:2.2.0" )
|
|
|
|
osgiRuntime( "org.apache.servicemix.bundles:org.apache.servicemix.bundles.dom4j:1.6.1_5" )
|
|
|
|
osgiRuntime( libraries.commons_annotations )
|
|
|
|
osgiRuntime( libraries.classmate )
|
|
|
|
osgiRuntime( "org.apache.logging.log4j:log4j-api:2.0" )
|
|
|
|
osgiRuntime( libraries.logging )
|
|
|
|
osgiRuntime( libraries.woodstox )
|
|
|
|
osgiRuntime( 'org.codehaus.woodstox:stax2-api:3.1.4' )
|
|
|
|
|
2013-09-09 19:35:01 -04:00
|
|
|
// needed for BND
|
2015-03-19 13:40:29 -04:00
|
|
|
osgiRuntimeBnd( libraries.jandex )
|
|
|
|
osgiRuntimeBnd( "javax.enterprise:cdi-api:1.1" )
|
|
|
|
osgiRuntimeBnd( "javax.el:el-api:2.2" )
|
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
|
|
|
}
|
|
|
|
|
2015-04-10 12:58:22 -04:00
|
|
|
mavenPom {
|
|
|
|
name = 'Hibernate OSGi Support'
|
|
|
|
description = '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() {
|
2015-04-10 12:58:22 -04:00
|
|
|
return mavenPom.description
|
2013-12-02 21:53:19 -05:00
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2015-03-24 17:01:15 -04:00
|
|
|
task runBnd(type: JavaExec) {
|
2013-06-12 16:50:06 -04:00
|
|
|
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", "")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-23 16:27:02 -04:00
|
|
|
File propertiesFile = file("$buildDir/osgi-lib/felix-framework.properties")
|
2013-09-09 19:35:01 -04:00
|
|
|
|
|
|
|
// 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
|
2015-03-24 17:01:15 -04:00
|
|
|
copyBnd.dependsOn copyToLib
|
|
|
|
|
2013-09-09 19:35:01 -04:00
|
|
|
felixProperties.dependsOn runBnd
|
2015-03-24 17:01:15 -04:00
|
|
|
|
2013-09-09 19:35:01 -04:00
|
|
|
test.dependsOn felixProperties
|
2013-06-12 16:50:06 -04:00
|
|
|
test.dependsOn testClientBundleJar
|
|
|
|
test.dependsOn jar
|