hibernate-orm/hibernate-osgi/hibernate-osgi.gradle

169 lines
6.2 KiB
Groovy

configurations {
osgiRuntime
osgiRuntimeBnd
}
sourceSets {
testClientBundle
}
sourceSets.test {
compileClasspath += sourceSets.testClientBundle.output
runtimeClasspath += sourceSets.testClientBundle.output
}
dependencies {
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" )
compile( "org.osgi:org.osgi.compendium:4.3.1" )
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" )
testRuntime( libraries.slf4j_api );
testRuntime( libraries.slf4j_log4j );
testRuntime( "org.jboss.logmanager:jboss-logmanager:2.0.0.Beta1" )
// 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 }
osgiRuntime( "org.apache.logging.log4j:log4j-api:2.0" ) { transitive = false }
osgiRuntime( libraries.logging ) { transitive = false }
// 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 }
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" )
}
def pomName() {
return 'Hibernate OSGi Support'
}
def pomDescription() {
return 'Support for running Hibernate O/RM in OSGi environments'
}
def osgiDescription() {
return pomDescription()
}
jar {
manifest {
instruction 'Bundle-Activator', 'org.hibernate.osgi.HibernateBundleActivator'
instructionFirst 'Import-Package',
// 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"'
}
}
test {
systemProperties['java.util.logging.manager'] = "org.jboss.logmanager.LogManager"
systemProperties['log4j.configuration'] = "file://$projectDir/src/test/resources/logging.properties"
}
task copyBnd(type: Copy) {
from "src/test/resources/bnd"
into "$buildDir/osgi-lib/bnd"
}
task runBnd(type: JavaExec){
main = "-jar"
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"
}
task copyToLib(type: Copy) {
from configurations.osgiRuntime
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"
}
task testClientBundleJar(type: Jar) {
from sourceSets.testClientBundle.output
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",
"Import-Package" : "javassist.util.proxy,javax.persistence,javax.persistence.spi,org.h2,org.osgi.framework,"
+ "org.hibernate,"
+ "org.hibernate.boot.model,"
+ "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")
}
}
runBnd.dependsOn copyToLib
runBnd.dependsOn copyBnd
felixProperties.dependsOn runBnd
test.dependsOn felixProperties
test.dependsOn testClientBundleJar
test.dependsOn jar