Skip to content

Commit 08ab72d

Browse files
committed
HHH-8470 scripted hibernate-osgi test properties in Gradle, cleaned up
test environment
1 parent 1fc9efb commit 08ab72d

File tree

7 files changed

+64
-62
lines changed

7 files changed

+64
-62
lines changed

hibernate-osgi/hibernate-osgi.gradle

Lines changed: 55 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
configurations {
22
osgiRuntime
3+
osgiRuntimeBnd
34
}
45

56
sourceSets {
@@ -33,28 +34,24 @@ dependencies {
3334
testRuntime( "org.apache.felix:org.apache.felix.main:4.0.3" )
3435
testRuntime( "org.jboss.logmanager:jboss-logmanager:1.4.1.Final" )
3536

36-
// Local copies of all jars needed fur the OSGi runtime.
37-
osgiRuntime( "org.jboss.arquillian.osgi:arquillian-osgi-bundle:1.0.3.Final" )
38-
osgiRuntime( libraries.jpa )
39-
osgiRuntime( "javax.enterprise:cdi-api:1.1-PFD" )
40-
osgiRuntime( "org.jboss.spec.javax.interceptor:jboss-interceptors-api_1.2_spec:1.0.0.Alpha1" )
41-
osgiRuntime( libraries.jta )
42-
osgiRuntime( "commons-collections:commons-collections:3.2.1" )
43-
osgiRuntime( "commons-pool:commons-pool:1.6" )
44-
osgiRuntime( "commons-dbcp:commons-dbcp:1.4" )
45-
osgiRuntime( "commons-lang:commons-lang:2.6" )
46-
osgiRuntime( "net.sourceforge.serp:serp:1.14.1" )
47-
osgiRuntime( "com.h2database:h2:1.3.170" )
48-
osgiRuntime( "org.apache.servicemix.bundles:org.apache.servicemix.bundles.antlr:2.7.7_5" )
49-
osgiRuntime( libraries.javassist )
50-
osgiRuntime( "org.apache.servicemix.specs:org.apache.servicemix.specs.jsr303-api-1.0.0:2.2.0" )
51-
osgiRuntime( "org.apache.servicemix.bundles:org.apache.servicemix.bundles.ant:1.8.2_2" )
52-
osgiRuntime( "org.apache.servicemix.specs:org.apache.servicemix.specs.stax-api-1.2:2.2.0" )
53-
osgiRuntime( "org.apache.servicemix.bundles:org.apache.servicemix.bundles.dom4j:1.6.1_5" )
54-
osgiRuntime( libraries.commons_annotations )
55-
osgiRuntime( libraries.jandex )
56-
osgiRuntime( libraries.classmate )
57-
osgiRuntime( libraries.logging )
37+
// Local copies of all jars needed fur the OSGi runtime. Ignore the transitive dependencies.
38+
// ORDER DEPENDENT!!!
39+
osgiRuntime( "org.jboss.arquillian.osgi:arquillian-osgi-bundle:1.0.3.Final" ) { transitive = false }
40+
osgiRuntime( libraries.jpa ) { transitive = false }
41+
osgiRuntime( "org.jboss.spec.javax.interceptor:jboss-interceptors-api_1.2_spec:1.0.0.Alpha1" ) { transitive = false }
42+
osgiRuntime( libraries.jta ) { transitive = false }
43+
osgiRuntime( "com.h2database:h2:1.3.170" ) { transitive = false }
44+
osgiRuntime( "org.apache.servicemix.bundles:org.apache.servicemix.bundles.antlr:2.7.7_5" ) { transitive = false }
45+
osgiRuntime( libraries.javassist ) { transitive = false }
46+
osgiRuntime( "org.apache.servicemix.specs:org.apache.servicemix.specs.stax-api-1.2:2.2.0" ) { transitive = false }
47+
osgiRuntime( "org.apache.servicemix.bundles:org.apache.servicemix.bundles.dom4j:1.6.1_5" ) { transitive = false }
48+
osgiRuntime( libraries.commons_annotations ) { transitive = false }
49+
osgiRuntime( libraries.classmate ) { transitive = false }
50+
osgiRuntime( libraries.logging ) { transitive = false }
51+
// needed for BND
52+
osgiRuntimeBnd( libraries.jandex ) { transitive = false }
53+
osgiRuntimeBnd( "javax.enterprise:cdi-api:1.1" ) { transitive = false }
54+
osgiRuntimeBnd( "javax.el:el-api:2.2" ) { transitive = false }
5855

5956
testClientBundleCompile( project( ':hibernate-core' ) )
6057
testClientBundleCompile( project( ':hibernate-entitymanager' ) )
@@ -85,18 +82,49 @@ jar {
8582
}
8683

8784
task copyBnd(type: Copy) {
88-
into "$buildDir/osgi-lib/bnd"
8985
from "src/test/resources/bnd"
86+
into "$buildDir/osgi-lib/bnd"
9087
}
9188

9289
task runBnd(type: JavaExec){
9390
main = "-jar"
94-
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", "$buildDir/osgi-lib/bnd/serp.bnd"
91+
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"
9592
}
9693

9794
task copyToLib(type: Copy) {
98-
into "$buildDir/osgi-lib"
9995
from configurations.osgiRuntime
96+
from configurations.osgiRuntimeBnd
97+
into "$buildDir/osgi-lib"
98+
}
99+
100+
task felixProperties << {
101+
copy {
102+
from "src/test/resources/felix-framework.properties-ORIGINAL"
103+
into "$buildDir/osgi-lib"
104+
rename { String fileName ->
105+
fileName.replace("-ORIGINAL", "")
106+
}
107+
}
108+
109+
propertiesFile = file("$buildDir/osgi-lib/felix-framework.properties")
110+
111+
// append jars wrapped using BND
112+
FileTree tree = fileTree(dir: "$buildDir/osgi-lib/bnd")
113+
tree.exclude "*bnd*"
114+
tree.each {File file ->
115+
propertiesFile << " \\\nfile:target/osgi-lib/bnd/" + file.name
116+
}
117+
118+
// append all jars in osgiRuntime configuration
119+
configurations.osgiRuntime.each { File file ->
120+
propertiesFile << " \\\nfile:target/osgi-lib/" + file.name
121+
}
122+
123+
// append ORM jars
124+
// TODO: Is there a better, dynamic way of doing this?
125+
propertiesFile << " \\\nfile:../hibernate-core/target/libs/hibernate-core-" + hibernateTargetVersion + ".jar"
126+
propertiesFile << " \\\nfile:../hibernate-entitymanager/target/libs/hibernate-entitymanager-" + hibernateTargetVersion + ".jar"
127+
propertiesFile << " \\\nfile:target/libs/hibernate-osgi-" + hibernateTargetVersion + ".jar"
100128
}
101129

102130
task testClientBundleJar(type: Jar) {
@@ -117,6 +145,7 @@ task testClientBundleJar(type: Jar) {
117145

118146
runBnd.dependsOn copyToLib
119147
runBnd.dependsOn copyBnd
120-
test.dependsOn runBnd
148+
felixProperties.dependsOn runBnd
149+
test.dependsOn felixProperties
121150
test.dependsOn testClientBundleJar
122151
test.dependsOn jar

hibernate-osgi/src/test/java/org/hibernate/osgi/test/OsgiTestCase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@
5858
* Regardless, this is the most "realistic" type of test anyway with a *real* client bundle.
5959
*
6060
* IMPORTANT: There are a few maintenance points that need addressed for new versions of Hibernate and library upgrades:
61-
* 1.) Updated library versions in hibernate-osgi.gradle and src/test/resources/felix-framework.properties. Some
62-
* of this may be automatable with Gradle scripts.
61+
* 1.) Updated library versions in hibernate-osgi.gradle. libraries.gradle is used wherever possible. But, there
62+
* may be a few manual updates needed.
6363
* 2.) If a new version of Felix is used, download and start it manually in the command line. Run
6464
* "felix:headers 0" to obtain the list of packages exported and used by the framework. As of this writing,
6565
* the framework has javax.transaction.* and javax.xml.stream.* in "uses" attributes. I had to remove all instances

hibernate-osgi/src/test/resources/arquillian.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<container qualifier="jboss" default="true">
66
<configuration>
7-
<property name="frameworkProperties">src/test/resources/felix-framework.properties</property>
7+
<property name="frameworkProperties">target/osgi-lib/felix-framework.properties</property>
88
</configuration>
99
</container>
1010
</arquillian>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
Bundle-SymbolicName: cdi-api
22
Bundle-Version: 1.1
3-
Include-Resource: @../cdi-api-1.1-PFD.jar
3+
Include-Resource: @../cdi-api-1.1.jar
44
-exportcontents: *

hibernate-osgi/src/test/resources/bnd/jandex.bnd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22
Bundle-Version: 1.1.0
33

44
Include-Resource: @../jandex-1.1.0.Alpha1.jar
5+
6+
Import-Package: org.apache.tools.ant;resolution:=optional, org.apache.tools.ant.types;resolution:=optional, *
57
-exportcontents: *

hibernate-osgi/src/test/resources/bnd/serp.bnd

Lines changed: 0 additions & 5 deletions
This file was deleted.

hibernate-osgi/src/test/resources/felix-framework.properties renamed to hibernate-osgi/src/test/resources/felix-framework.properties-ORIGINAL

Lines changed: 3 additions & 27 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)