Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

HHH-6618 running hibernate functional test cases on DB matrix

  • Loading branch information...
commit e941eca2d55614d8daae991bc299a2ee9cc298ee 1 parent 68f7d9b
@stliu stliu authored
Showing with 3,736 additions and 447 deletions.
  1. +2 −1  build.gradle
  2. +32 −4 buildSrc/build.gradle
  3. +62 −0 buildSrc/readme.txt
  4. +113 −0 buildSrc/src/main/groovy/hudson/util/DBAllocation.groovy
  5. +85 −0 buildSrc/src/main/groovy/hudson/util/DBAllocationHelper.groovy
  6. +57 −0 buildSrc/src/main/groovy/org/hibernate/build/gradle/inject/Injection.java
  7. +253 −0 buildSrc/src/main/groovy/org/hibernate/build/gradle/inject/InjectionAction.java
  8. +38 −0 buildSrc/src/main/groovy/org/hibernate/build/gradle/inject/InjectionException.java
  9. +46 −0 buildSrc/src/main/groovy/org/hibernate/build/gradle/inject/InjectionPlugin.java
  10. +51 −0 buildSrc/src/main/groovy/org/hibernate/build/gradle/inject/TargetMember.java
  11. +276 −0 buildSrc/src/main/groovy/org/hibernate/gradle/testing/database/DatabaseMatrixPlugin.java
  12. +37 −0 buildSrc/src/main/groovy/org/hibernate/gradle/testing/database/DependencyResolver.java
  13. +89 −0 buildSrc/src/main/groovy/org/hibernate/gradle/testing/database/IvyDependencyResolver.java
  14. +218 −0 buildSrc/src/main/groovy/org/hibernate/gradle/testing/database/IvyXmlDependency.java
  15. +88 −0 buildSrc/src/main/groovy/org/hibernate/gradle/testing/database/LocalJdbcDependencyResolver.java
  16. +136 −0 buildSrc/src/main/groovy/org/hibernate/gradle/testing/matrix/AbstractMatrixNode.java
  17. +61 −0 buildSrc/src/main/groovy/org/hibernate/gradle/testing/matrix/MatrixNode.java
  18. +36 −0 buildSrc/src/main/groovy/org/hibernate/gradle/testing/matrix/MatrixNodeProvider.java
  19. +203 −0 buildSrc/src/main/groovy/org/hibernate/gradle/testing/matrix/MatrixTestingPlugin.groovy
  20. +40 −0 buildSrc/src/main/groovy/org/hibernate/gradle/util/BuildException.java
  21. +38 −0 buildSrc/src/main/groovy/org/hibernate/gradle/util/DuplicatedDBConfigException.java
  22. +58 −0 buildSrc/src/main/groovy/org/hibernate/gradle/util/FileUtil.java
  23. +215 −0 buildSrc/src/main/groovy/org/hibernate/gradle/util/IvyResolutionHelper.java
  24. +66 −0 buildSrc/src/main/groovy/org/hibernate/gradle/util/JavaVersion.java
  25. +161 −0 buildSrc/src/main/groovy/org/hibernate/gradle/util/Jdk.java
  26. +51 −0 buildSrc/src/main/groovy/org/hibernate/gradle/util/ResolutionException.java
  27. +0 −56 buildSrc/src/main/java/org/hibernate/build/gradle/inject/Injection.java
  28. +0 −252 buildSrc/src/main/java/org/hibernate/build/gradle/inject/InjectionAction.java
  29. +0 −37 buildSrc/src/main/java/org/hibernate/build/gradle/inject/InjectionException.java
  30. +0 −45 buildSrc/src/main/java/org/hibernate/build/gradle/inject/InjectionPlugin.java
  31. +0 −50 buildSrc/src/main/java/org/hibernate/build/gradle/inject/TargetMember.java
  32. +25 −0 databases/mysql50/matrix.gradle
  33. +42 −0 databases/mysql50/resources/hibernate.properties
  34. +25 −0 databases/mysql51/matrix.gradle
  35. +46 −0 databases/mysql51/resources/hibernate.properties
  36. +24 −0 databases/postgresql82/matrix.gradle
  37. +42 −0 databases/postgresql82/resources/hibernate.properties
  38. +24 −0 databases/postgresql83/matrix.gradle
  39. +43 −0 databases/postgresql83/resources/hibernate.properties
  40. +24 −0 databases/postgresql84/matrix.gradle
  41. +42 −0 databases/postgresql84/resources/hibernate.properties
  42. +1 −1  gradle/wrapper/gradle-wrapper.properties
  43. +1 −0  hibernate-c3p0/src/main/java/org/hibernate/service/jdbc/connections/internal/C3P0ConnectionProvider.java
  44. +1 −1  hibernate-core/hibernate-core.gradle
  45. +1 −0  hibernate-core/src/main/java/org/hibernate/dialect/MySQLDialect.java
  46. 0  ...rc/{test → matrix}/java/org/hibernate/test/abstractembeddedcomponents/cid/AbstractCompositeIdTest.java
  47. +20 −0 hibernate-core/src/matrix/java/org/hibernate/test/abstractembeddedcomponents/cid/Mappings.hbm.xml
  48. +14 −0 hibernate-core/src/matrix/java/org/hibernate/test/abstractembeddedcomponents/cid/MyInterface.java
  49. +36 −0 hibernate-core/src/matrix/java/org/hibernate/test/abstractembeddedcomponents/cid/MyInterfaceImpl.java
  50. 0  ...atrix}/java/org/hibernate/test/abstractembeddedcomponents/propertyref/AbstractComponentPropertyRefTest.java
  51. +14 −0 hibernate-core/src/matrix/java/org/hibernate/test/abstractembeddedcomponents/propertyref/Address.java
  52. +36 −0 hibernate-core/src/matrix/java/org/hibernate/test/abstractembeddedcomponents/propertyref/AddressImpl.java
  53. +43 −0 hibernate-core/src/matrix/java/org/hibernate/test/abstractembeddedcomponents/propertyref/Mappings.hbm.xml
  54. +15 −0 hibernate-core/src/matrix/java/org/hibernate/test/abstractembeddedcomponents/propertyref/Server.java
  55. +36 −0 hibernate-core/src/matrix/java/org/hibernate/test/abstractembeddedcomponents/propertyref/ServerImpl.java
  56. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/A320.java
  57. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/A320b.java
  58. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/AlternativeNamingStrategy.java
  59. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/AmericaCupClass.java
  60. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/Boat.java
  61. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/Company.java
  62. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/ConfigurationTest.java
  63. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/Country.java
  64. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/Customer.java
  65. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/Discount.java
  66. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/EntityTest.java
  67. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/Ferry.java
  68. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/Flight.java
  69. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/FlyingObject.java
  70. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/IncorrectEntity.java
  71. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/JoinedSubclassTest.java
  72. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/Passport.java
  73. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/Plane.java
  74. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/Port.java
  75. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/SafeMappingTest.java
  76. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/SecuredBindingTest.java
  77. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/Sky.java
  78. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/Thing.java
  79. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/Ticket.java
  80. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/TicketComparator.java
  81. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/access/AccessTest.java
  82. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/access/Bed.java
  83. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/access/BigBed.java
  84. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/access/Chair.java
  85. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/access/Closet.java
  86. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/access/Foobar.java
  87. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/access/Furniture.java
  88. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/access/Gardenshed.java
  89. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/access/Thingy.java
  90. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/access/Woody.java
  91. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/access/jpa/AccessMappingTest.java
  92. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/access/jpa/AccessTest.java
  93. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/access/jpa/Animal.java
  94. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/access/jpa/Bed.java
  95. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/access/jpa/Being.java
  96. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/access/jpa/BigBed.java
  97. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/access/jpa/Chair.java
  98. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/access/jpa/Circle.java
  99. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/access/jpa/Color.java
  100. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/access/jpa/Course1.java
  101. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/access/jpa/Course2.java
  102. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/access/jpa/Course3.java
  103. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/access/jpa/Course4.java
  104. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/access/jpa/Course5.java
  105. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/access/jpa/Course6.java
  106. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/access/jpa/Course7.java
  107. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/access/jpa/Course8.java
  108. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/access/jpa/Furniture.java
  109. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/access/jpa/Gardenshed.java
  110. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/access/jpa/Horse.java
  111. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/access/jpa/Person.java
  112. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/access/jpa/Position.java
  113. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/access/jpa/Shape.java
  114. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/access/jpa/Square.java
  115. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/access/jpa/Student.java
  116. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/access/jpa/Thingy.java
  117. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/access/jpa/User.java
  118. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/access/jpa/Woody.java
  119. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/access/xml/Boy.java
  120. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/access/xml/Cook.java
  121. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/access/xml/Crew.java
  122. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/access/xml/Driver.java
  123. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/access/xml/Knive.java
  124. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/access/xml/RentalCar.java
  125. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/access/xml/Tourist.java
  126. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/access/xml/Waiter.java
  127. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/access/xml/XmlAccessTest.java
  128. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/any/AnyTest.java
  129. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/any/CharProperty.java
  130. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/any/IntegerProperty.java
  131. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/any/LongProperty.java
  132. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/any/Property.java
  133. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/any/PropertyList.java
  134. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/any/PropertyMap.java
  135. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/any/PropertySet.java
  136. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/any/StringProperty.java
  137. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/any/package-info.java
  138. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/array/ArrayTest.java
  139. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/array/Competitor.java
  140. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/array/Contest.java
  141. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/backquotes/BackquoteTest.java
  142. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/backquotes/Bug.java
  143. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/backquotes/Category.java
  144. +47 −0 hibernate-core/src/matrix/java/org/hibernate/test/annotations/backquotes/Printer.java
  145. +57 −0 hibernate-core/src/matrix/java/org/hibernate/test/annotations/backquotes/PrinterCable.java
  146. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/beanvalidation/Address.java
  147. 0  ...ore/src/{test → matrix}/java/org/hibernate/test/annotations/beanvalidation/BeanValidationAutoTest.java
  148. 0  ...src/{test → matrix}/java/org/hibernate/test/annotations/beanvalidation/BeanValidationDisabledTest.java
  149. 0  ...e/src/{test → matrix}/java/org/hibernate/test/annotations/beanvalidation/BeanValidationGroupsTest.java
  150. 0  ...st → matrix}/java/org/hibernate/test/annotations/beanvalidation/BeanValidationProvidedFactoryTest.java
  151. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/beanvalidation/Button.java
  152. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/beanvalidation/Color.java
  153. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/beanvalidation/CupHolder.java
  154. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/beanvalidation/DDLTest.java
  155. 0  ...ore/src/{test → matrix}/java/org/hibernate/test/annotations/beanvalidation/DDLWithoutCallbackTest.java
  156. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/beanvalidation/Display.java
  157. 0  ...nate-core/src/{test → matrix}/java/org/hibernate/test/annotations/beanvalidation/DisplayConnector.java
  158. 0  ...est → matrix}/java/org/hibernate/test/annotations/beanvalidation/HibernateTraversableResolverTest.java
  159. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/beanvalidation/MinMax.java
  160. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/beanvalidation/Music.java
  161. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/beanvalidation/PowerSupply.java
  162. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/beanvalidation/Range.java
  163. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/beanvalidation/Rock.java
  164. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/beanvalidation/Screen.java
  165. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/beanvalidation/Strict.java
  166. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/beanvalidation/Tv.java
  167. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/beanvalidation/TvOwner.java
  168. +22 −0 hibernate-core/src/matrix/java/org/hibernate/test/annotations/bytecode/Hammer.java
  169. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/bytecode/ProxyBreakingTest.java
  170. +14 −0 hibernate-core/src/matrix/java/org/hibernate/test/annotations/bytecode/Tool.java
  171. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/cascade/CascadeTest.java
  172. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/cascade/Mouth.java
  173. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/cascade/Tooth.java
  174. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/cid/A.java
  175. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/cid/AId.java
  176. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/cid/B.java
  177. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/cid/C.java
  178. +15 −0 hibernate-core/src/matrix/java/org/hibernate/test/annotations/cid/Channel.java
  179. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/cid/Child.java
  180. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/cid/ChildPk.java
  181. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/cid/CompositeIdTest.java
  182. +18 −0 hibernate-core/src/matrix/java/org/hibernate/test/annotations/cid/LittleGenius.java
  183. +16 −0 hibernate-core/src/matrix/java/org/hibernate/test/annotations/cid/Order.java
  184. +16 −0 hibernate-core/src/matrix/java/org/hibernate/test/annotations/cid/OrderLine.java
  185. +16 −0 hibernate-core/src/matrix/java/org/hibernate/test/annotations/cid/OrderLinePk.java
  186. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/cid/Parent.java
  187. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/cid/ParentPk.java
  188. +13 −0 hibernate-core/src/matrix/java/org/hibernate/test/annotations/cid/Presenter.java
  189. +12 −0 hibernate-core/src/matrix/java/org/hibernate/test/annotations/cid/Product.java
  190. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/cid/SomeEntity.java
  191. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/cid/SomeEntityId.java
  192. +24 −0 hibernate-core/src/matrix/java/org/hibernate/test/annotations/cid/TvMagazin.java
  193. +20 −0 hibernate-core/src/matrix/java/org/hibernate/test/annotations/cid/TvMagazinPk.java
  194. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/cid/TvProgram.java
  195. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/cid/TvProgramIdClass.java
  196. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/cid/keymanytoone/Card.java
  197. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/cid/keymanytoone/CardField.java
  198. 0  ...re/src/{test → matrix}/java/org/hibernate/test/annotations/cid/keymanytoone/EagerKeyManyToOneTest.java
  199. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/cid/keymanytoone/Key.java
  200. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/cid/keymanytoone/PrimaryKey.java
  201. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/collectionelement/Boy.java
  202. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/collectionelement/Brand.java
  203. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/collectionelement/Bug.java
  204. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/collectionelement/BugSystem.java
  205. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/collectionelement/Character.java
  206. 0  ...e/src/{test → matrix}/java/org/hibernate/test/annotations/collectionelement/CollectionElementTest.java
  207. 0  ...te-core/src/{test → matrix}/java/org/hibernate/test/annotations/collectionelement/CountryAttitude.java
  208. 0  ...rnate-core/src/{test → matrix}/java/org/hibernate/test/annotations/collectionelement/FavoriteFood.java
  209. 0  ...te-core/src/{test → matrix}/java/org/hibernate/test/annotations/collectionelement/LocalizedString.java
  210. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/collectionelement/Matrix.java
  211. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/collectionelement/OrderByTest.java
  212. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/collectionelement/Person.java
  213. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/collectionelement/Products.java
  214. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/collectionelement/TestCourse.java
  215. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/collectionelement/Toy.java
  216. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/collectionelement/Widgets.java
  217. 0  ...rc/{test → matrix}/java/org/hibernate/test/annotations/collectionelement/deepcollectionelements/A.java
  218. 0  ...rc/{test → matrix}/java/org/hibernate/test/annotations/collectionelement/deepcollectionelements/B.java
  219. 0  ...rc/{test → matrix}/java/org/hibernate/test/annotations/collectionelement/deepcollectionelements/C.java
  220. 0  ...java/org/hibernate/test/annotations/collectionelement/deepcollectionelements/DeepCollectionElementTest.java
  221. 0  ...c/{test → matrix}/java/org/hibernate/test/annotations/collectionelement/indexedCollection/Contact.java
  222. 0  ...ava/org/hibernate/test/annotations/collectionelement/indexedCollection/IndexedCollectionOfElementsTest.java
  223. 0  .../src/{test → matrix}/java/org/hibernate/test/annotations/collectionelement/indexedCollection/Sale.java
  224. 0  ...nate-core/src/{test → matrix}/java/org/hibernate/test/annotations/configuration/ConfigurationTest.java
  225. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/configuration/package-info.java
  226. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/dataTypes/BasicOperationsTest.java
  227. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/dataTypes/Grade.java
  228. +104 −0 hibernate-core/src/matrix/java/org/hibernate/test/annotations/dataTypes/SomeEntity.java
  229. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/dataTypes/SomeOtherEntity.java
  230. 0  ...te-core/src/{test → matrix}/java/org/hibernate/test/annotations/duplicatedgenerator/DuplicateTest.java
  231. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/duplicatedgenerator/Flight.java
  232. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/embedded/Address.java
  233. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/embedded/AddressType.java
  234. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/embedded/Book.java
  235. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/embedded/CorpType.java
  236. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/embedded/Country.java
  237. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/embedded/Deal.java
  238. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/embedded/EmbeddedTest.java
  239. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/embedded/FavoriteThings.java
  240. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/embedded/FixedLeg.java
  241. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/embedded/FloatLeg.java
  242. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/embedded/InternetFavorites.java
  243. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/embedded/InternetProvider.java
  244. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/embedded/Leg.java
  245. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/embedded/LegalStructure.java
  246. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/embedded/Manager.java
  247. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/embedded/Nationality.java
  248. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/embedded/NotonialDeal.java
  249. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/embedded/Person.java
  250. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/embedded/RegionalArticle.java
  251. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/embedded/RegionalArticlePk.java
  252. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/embedded/SpreadDeal.java
  253. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/embedded/Summary.java
  254. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/embedded/Swap.java
  255. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/embedded/URLFavorite.java
  256. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/embedded/VanillaSwap.java
  257. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/embedded/WealthyPerson.java
  258. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/embedded/many2one/Address.java
  259. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/embedded/many2one/Country.java
  260. 0  .../{test → matrix}/java/org/hibernate/test/annotations/embedded/many2one/EmbeddableWithMany2OneTest.java
  261. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/embedded/many2one/Person.java
  262. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/embedded/one2many/Alias.java
  263. 0  .../{test → matrix}/java/org/hibernate/test/annotations/embedded/one2many/EmbeddableWithOne2ManyTest.java
  264. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/embedded/one2many/Name.java
  265. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/embedded/one2many/Person.java
  266. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/embedded/one2many/PersonName.java
  267. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/engine/collection/Father.java
  268. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/engine/collection/Mother.java
  269. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/engine/collection/Son.java
  270. 0  ...r; matrix}/java/org/hibernate/test/annotations/engine/collection/UnidirCollectionWithMultipleOwnerTest.java
  271. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/entity/Address.java
  272. 0  ...core/src/{test → matrix}/java/org/hibernate/test/annotations/entity/BasicHibernateAnnotationsTest.java
  273. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/entity/Bid.java
  274. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/entity/Car.java
  275. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/entity/CasterStringType.java
  276. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/entity/CommunityBid.java
  277. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/entity/ContactDetails.java
  278. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/entity/Country.java
  279. +56 −0 hibernate-core/src/matrix/java/org/hibernate/test/annotations/entity/Drill.java
  280. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/entity/FirstName.java
  281. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/entity/Flight.java
  282. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/entity/Forest.java
  283. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/entity/FormalLastName.java
  284. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/entity/Java5FeaturesTest.java
  285. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/entity/LastName.java
  286. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/entity/Length.java
  287. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/entity/LocalContactDetails.java
  288. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/entity/MonetaryAmount.java
  289. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/entity/MonetaryAmountUserType.java
  290. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/entity/Name.java
  291. +65 −0 hibernate-core/src/matrix/java/org/hibernate/test/annotations/entity/Narrative.java
  292. +40 −0 hibernate-core/src/matrix/java/org/hibernate/test/annotations/entity/OverseasPhoneNumber.java
  293. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/entity/Peugot.java
  294. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/entity/PhoneNumber.java
  295. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/entity/PhoneNumberType.java
  296. +78 −0 hibernate-core/src/matrix/java/org/hibernate/test/annotations/entity/Player.java
  297. +36 −0 hibernate-core/src/matrix/java/org/hibernate/test/annotations/entity/PowerDrill.java
  298. 0  ...e-core/src/{test → matrix}/java/org/hibernate/test/annotations/entity/PropertyDefaultMappingsTest.java
  299. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/entity/Race.java
  300. 0  hibernate-core/src/{test → matrix}/java/org/hibernate/test/annotations/entity/Ransom.java
Sorry, we could not display the entire diff because too many files (4,782) changed.
View
3  build.gradle
@@ -229,7 +229,8 @@ subprojects { subProject ->
file("$buildDir/libs"),
file("$buildDir/reports"),
file("$buildDir/test-results"),
- file("$buildDir/tmp")
+ file("$buildDir/tmp"),
+ file("$buildDir/matrix")
] as Set
}
View
36 buildSrc/build.gradle
@@ -1,3 +1,27 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2011, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+
apply plugin: 'groovy'
apply plugin: 'idea'
@@ -8,17 +32,18 @@ repositories {
mavenLocal()
mavenRepo name: "jboss", urls: "http://repository.jboss.org/nexus/content/groups/public/"
}
-
+targetCompatibility = "1.6"
+sourceCompatibility = "1.6"
dependencies {
// common
compile gradleApi()
compile localGroovy()
- compile 'org.apache.ant:ant:1.7.0'
- compile 'org.apache.maven:maven-ant-tasks:2.1.0'
+// compile 'org.apache.ant:ant:1.7.0'
+// compile 'org.apache.maven:maven-ant-tasks:2.1.0'
// needed?
- compile 'org.apache.maven.wagon:wagon-http:1.0-beta-6'
+// compile 'org.apache.maven.wagon:wagon-http:1.0-beta-6'
// injection plugin
compile 'javassist:javassist:3.12.0.GA'
@@ -27,4 +52,7 @@ dependencies {
}
ideaModule {
+ downloadSources =true
+ downloadJavadoc= true
+ javaVersion = '1.6'
}
View
62 buildSrc/readme.txt
@@ -0,0 +1,62 @@
+org.hibernate.gradle.testing.matrix.MatrixTestingPlugin
+
+Goal:
+Run hibernate-core functional test on other DBs besides default H2 easily.
+
+Usage:
+1. Databases configuration
+In the root hibernate-core project, we have a 'databases' directory, this is the default DB profiles location, take it as an example and you can create your db profile easily.
+
+Take a look of the sub-directories of 'databases' to see how each DB profile is defined.
+Each default DB profile has a matrix.gradle, we use this to get jdbc driver from a maven repo.
+but we also accept a 'jbdc' directory which contains jdbc driver directly to replace this matrix.gradle, this is useful for non-opensource jdbc drivers.
+
+And each DB profile also needs a "resources/hibernate.properties", which, as you expected, defines DB connection info and others hibernate properties.
+
+For now, we have 5 default DB profiles, mysql50, mysql51, postgresql82, postgresql83 and postgresql84.
+
+You can create your DB profile under 'hibernate-core/databases', but if you do that, GIT will ask you check in or remove it everytime when you run git command.
+so, you should create a 'databases/${your db profile}' in other place and use system property 'hibernate-matrix-databases' with the full path of your 'databases'.
+Btw, to add a system properties, you can either use '-Dhibernate-matrix-databases' or add it to ${user.home}/.gradle/gradle.properties with a 'systemProp' perfix, like 'systemProp.hibernate-matrix-databases=${your databases directory path}'
+and if this property is given, MatrixTestingPlugin will take profiles defined in there as well as default 'hibernate-core/databases'
+
+MatrixTestingPlugin also has a system property "hibernate-matrix-ignore" which can be use to ignore some DB profiles or all of them, it accepts values like:
+'all' -- ignore all DB profiles, so matrix testing will be ignored.
+'${profile name1},${profile name2},${profile name3}'
+
+2. Gradle Tasks
+
+run './gradlew tasks --all', you will see there is a 'matrix' task and also 'matrix_${profile_name}' tasks against your DB profiles (not ignored).
+
+3. Source Set separation
+All functional tests[1] should go into src/matrix/java
+All unit tests[2] should go into src/test/java
+
+if you run gradle task 'test', tests in src/test/java and src/matrix/java will be ran, and resources of src/test/resource will be used.
+so, "functional tests" defined in 'src/matrix/java' here are also 'unit test' which run on default H2.
+all test results (test and matrix) are in target/test-results.
+
+if you run gradle task 'matrix' (or its sub-task 'matrix_${profile name}), only tests in 'src/matrix/java' will be ran, and hibernate.properties come from your db profile/resources/hibernate.properties.
+
+3. DBAllocation
+
+For users who has access to JBoss QA lab (need redhat vpn), here is an better way to run matrix tests, you don't need to have a DB instance on your side, but you can use DB instance in JBoss QA Lab.
+And the connection info can be queried by DBAllocation automatically.
+This feature is disabled by default, to enable it, you need system property 'hibernate-matrix-dballcoation', it accepts value like: 'all', '${profile name1},${profile name2},${profile name3}'
+
+for example, if you want to run matrix test on postgresql84, default DB profile, you can
+'./gradlew clean test matrix_postgresql84 -Dhibernate-matrix-dballocation=postgresql84'
+
+what does this command do actually?
+1. test
+run 'src/test/java' on default H2, test results in 'target/test-results'
+run 'src/matrix/java' on default H2, test results in 'target/test-results'
+
+2. query postgresql 84 db instance connection info
+3. run 'src/matrix/java' on postgresql 84 with 'databases/postgresql84/matrix.gradle' defined jdbc driver and 'databases/postgresql84/resources/hibernate.properties' and postgresql84 db instance connection info (this info will override those defined in hibernate.properties), test results in 'target/matrix/postgresql84/results'
+
+
+[1] Functional Test in this document means test need to run on DB matrix
+[2] Unit Test in this document means test does not care the underlying DB (H2) or does not need a DB involved.
+* others may have different "functional test"/"unit test" definition :)
+* use 'hibernate-matrix-dballocation-requestee' to define requestee, default is 'hibernate'
View
113 buildSrc/src/main/groovy/hudson/util/DBAllocation.groovy
@@ -0,0 +1,113 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2011, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+
+package hudson.util
+
+/**
+ *
+ * @author mvecera
+ */
+class DBAllocation {
+ private final static String DB_ALLOCATOR_URL = "http://dballocator.mw.lab.eng.bos.redhat.com:8080/Allocator/AllocatorServlet";
+ private dbinstallPath = "dbinstall"
+ private retries = 30
+ private UUID = ""
+ private ant
+ private File dbConfigFile;
+ private String requestee;
+
+ def DBAllocation(dbinstallPath) {
+ this(new AntBuilder(), dbinstallPath)
+ }
+
+ def DBAllocation(ant, dbinstallPath, outPropsFileName = "allocated.db.properties") {
+ this.ant = ant;
+ this.dbinstallPath = dbinstallPath;
+ this.dbConfigFile = new File(dbinstallPath, outPropsFileName);
+ if(System.properties.containsKey("hibernate-matrix-dballocation-requestee"))
+ requestee = System.properties["hibernate-matrix-dballocation-requestee"]
+ else
+ requestee = "hibernate"
+ }
+
+ def getProperties() {
+ def props = new Properties();
+ props.load(new FileInputStream(dbConfigFile));
+ return props;
+ }
+
+ def allocate(label, expiry) {
+ if ( dbConfigFile.exists() ) {
+ dbConfigFile.delete()
+ }
+ def i = 0
+ while ( !(dbConfigFile.exists() && dbConfigFile.length() > 0) ) {
+ if ( i >= retries ) {
+ throw new Exception('Database unavailable')
+ }
+ if ( i > 0 ) {
+ println "Waiting before trying to allocate DB again."
+ Thread.sleep(60000)
+ }
+ println "Allocating DB..."
+ def allocatorUrl = DB_ALLOCATOR_URL + "?operation=alloc&label=$label&requestee=${requestee}&expiry=$expiry"
+ ant.get(src: allocatorUrl, dest: dbConfigFile.absolutePath, ignoreerrors: 'true')
+ i++
+ }
+ def dbProps = getProperties();
+ this.UUID = dbProps['uuid']
+ return this.UUID
+ }
+
+ def release() {
+ release(this.UUID)
+ }
+
+ def release(UUID) {
+ println 'De-allocating DB...'
+ def allocatorUrl = DB_ALLOCATOR_URL + "?operation=dealloc&uuid=$UUID"
+ ant.get(src: allocatorUrl, dest: "/tmp/.tmpfile")
+ }
+
+ def clean() {
+ clean(this.UUID);
+ }
+
+ def clean(UUID) {
+ println 'Cleaning DB...'
+ def allocatorUrl = DB_ALLOCATOR_URL + "?operation=erase&uuid=$UUID"
+ ant.get(src: allocatorUrl, dest: "/tmp/.tmpfile")
+ }
+
+ def reallocate(newExpiry) {
+ reallocate(this.UUID, newExpiry)
+ }
+
+ def reallocate(UUID, newExpiry) {
+ println 'Re-allocating DB...'
+ def allocatorUrl = DB_ALLOCATOR_URL + "?operation=realloc&uuid=$UUID&expiry=$newExpiry"
+ ant.get(src: allocatorUrl, dest: "/tmp/.tmpfile")
+ }
+}
+
View
85 buildSrc/src/main/groovy/hudson/util/DBAllocationHelper.groovy
@@ -0,0 +1,85 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2011, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+
+package hudson.util
+
+import org.gradle.api.logging.Logger
+import org.gradle.api.logging.Logging
+import org.hibernate.gradle.testing.matrix.MatrixNode
+import org.hibernate.gradle.util.FileUtil
+
+/**
+ *
+ * @author Strong Liu
+ */
+public class DBAllocationHelper {
+ private static final Logger log = Logging.getLogger(DBAllocationHelper.class);
+
+ private static final String DRIVER_PROP = "hibernate.connection.driver_class";
+ private static final String URL_PROP = "hibernate.connection.url";
+ private static final String USERNAME_PROP = "hibernate.connection.username";
+ private static final String PASSWORD_PROP = "hibernate.connection.password";
+ //DBAllocator supports the following DBs
+ private static def supportedDB = ["oracle9i", "oracle10g", "oracle11gR1", "oracle11gR2",
+ "postgresql82", "postgresql83", "postgresql84", "mysql50", "mysql51",
+ "db2-91", "db2-97", "mssql2005", "mssql2008R1", "mssql2008R2", "sybase155"];
+
+ public static Map<String, String> getProperties(MatrixNode node) {
+ Map<String, String> map = new HashMap<String, String>();
+ if ( FileUtil.isFile(node.hibernatePropertyFile) ) {
+ Properties hibernateProperties = new Properties();
+ hibernateProperties.load(new FileInputStream(node.hibernatePropertyFile));
+ map.putAll(hibernateProperties);
+ }
+ if ( isDBAllocationEnabled(node.name) ) {
+ log.lifecycle("using DBAllocator to get DB[${node.name}] connection info");
+ try {
+ DBAllocation db = node.DBAllocation
+ db.allocate(node.name, 300);
+ Properties prop = db.properties
+ log.lifecycle("DBAllocating finished for DB[${node.name}], uuid is [${prop['uuid']}]")
+ map[DRIVER_PROP] = prop["db.jdbc_class"]
+ map[URL_PROP] = prop["db.jdbc_url"]
+ map[USERNAME_PROP] = prop["db.username"]
+ map[PASSWORD_PROP] = prop["db.password"]
+ map["uuid"] = prop["uuid"];
+ db.clean();
+ }
+ catch (RuntimeException e) {
+ log.debug("DBAllocating error, ignore", e);
+ }
+ }
+ return map;
+ }
+ /**
+ * use -Dhibernate-matrix-dballocation=all to enable DBAllocation for all matrix node
+ * or
+ * add systemProp.hibernate-matrix-dballocation=all to ${user.home}/.gradle/gradle.properties
+ */
+ public static boolean isDBAllocationEnabled(String name) {
+ if ( !supportedDB.contains(name) ) return false;
+ String value = System.properties["hibernate-matrix-dballocation"]
+ return value != null && (value.contains(name) || value.equals("all"));
+ }
+}
View
57 buildSrc/src/main/groovy/org/hibernate/build/gradle/inject/Injection.java
@@ -0,0 +1,57 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2011, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+
+package org.hibernate.build.gradle.inject;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Steve Ebersole
+ */
+public class Injection {
+ private final String expression;
+ private List<TargetMember> targetMembers = new ArrayList<TargetMember>();
+
+ public Injection(String expression) {
+ this.expression = expression;
+ }
+
+ public String getExpression() {
+ return expression;
+ }
+
+ public void into(String className, String member) {
+ into( new TargetMember( className, member ) );
+ }
+
+ public void into(TargetMember targetMember) {
+ targetMembers.add( targetMember );
+ }
+
+ public Iterable<TargetMember> getTargetMembers() {
+ return targetMembers;
+ }
+
+}
View
253 buildSrc/src/main/groovy/org/hibernate/build/gradle/inject/InjectionAction.java
@@ -0,0 +1,253 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2011, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+
+package org.hibernate.build.gradle.inject;
+
+import java.io.BufferedOutputStream;
+import java.io.DataOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.List;
+
+import javassist.ClassPool;
+import javassist.CtClass;
+import javassist.CtField;
+import javassist.CtMethod;
+import javassist.LoaderClassPath;
+import javassist.Modifier;
+import javassist.NotFoundException;
+import javassist.bytecode.ClassFile;
+import javassist.bytecode.ConstantAttribute;
+import javassist.bytecode.FieldInfo;
+import org.gradle.api.Action;
+import org.gradle.api.Project;
+import org.gradle.api.plugins.JavaPluginConvention;
+import org.gradle.api.tasks.SourceSet;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @author Steve Ebersole
+ */
+public class InjectionAction implements Action {
+ private static final Logger log = LoggerFactory.getLogger( InjectionAction.class );
+
+ private final Project project;
+
+ private List<Injection> injections = new ArrayList<Injection>();
+
+ private LoaderClassPath loaderClassPath;
+ private ClassPool classPool;
+
+ public InjectionAction(Project project) {
+ this.project = project;
+ }
+
+ void addInjection(Injection injection) {
+ injections.add( injection );
+ }
+
+ @Override
+ public void execute(Object o) {
+ final ClassLoader runtimeScopeClassLoader = buildRuntimeScopeClassLoader();
+
+ loaderClassPath = new LoaderClassPath( runtimeScopeClassLoader );
+ classPool = new ClassPool( true );
+ classPool.appendClassPath( loaderClassPath );
+
+ try {
+ performInjections();
+ }
+ finally {
+ loaderClassPath.close();
+ }
+ }
+
+ private ClassLoader buildRuntimeScopeClassLoader() {
+ final ArrayList<URL> classPathUrls = new ArrayList<URL>();
+ final SourceSet mainSourceSet = project
+ .getConvention()
+ .getPlugin( JavaPluginConvention.class )
+ .getSourceSets()
+ .findByName( SourceSet.MAIN_SOURCE_SET_NAME );
+ for ( File file : mainSourceSet.getRuntimeClasspath() ) {
+ try {
+ classPathUrls.add( file.toURI().toURL() );
+ }
+ catch (MalformedURLException e) {
+ throw new InjectionException( "Could not determine artifact URL [" + file.getPath() + "]", e );
+ }
+ }
+ return new URLClassLoader( classPathUrls.toArray( new URL[classPathUrls.size()] ), getClass().getClassLoader() );
+ }
+
+ private void performInjections() {
+ for ( Injection injection : injections ) {
+ for ( TargetMember targetMember : injection.getTargetMembers() ) {
+ resolveInjectionTarget( targetMember ).inject( injection.getExpression() );
+ }
+ }
+ }
+
+ private InjectionTarget resolveInjectionTarget(TargetMember targetMember) {
+ try {
+ final CtClass ctClass = classPool.get( targetMember.getClassName() );
+ // see if it is a field...
+ try {
+ CtField field = ctClass.getField( targetMember.getMemberName() );
+ return new FieldInjectionTarget( targetMember, ctClass, field );
+ }
+ catch( NotFoundException ignore ) {
+ }
+
+ // see if it is a method...
+ for ( CtMethod method : ctClass.getMethods() ) {
+ if ( method.getName().equals( targetMember.getMemberName() ) ) {
+ return new MethodInjectionTarget( targetMember, ctClass, method );
+ }
+ }
+
+ // finally throw an exception
+ throw new InjectionException( "Unknown member [" + targetMember.getQualifiedName() + "]" );
+ }
+ catch ( Throwable e ) {
+ throw new InjectionException( "Unable to resolve class [" + targetMember.getClassName() + "]", e );
+ }
+ }
+
+ /**
+ * Strategy for performing an injection
+ */
+ private static interface InjectionTarget {
+ /**
+ * Inject the given value per this target's strategy.
+ *
+ * @param value The value to inject.
+ *
+ * @throws org.hibernate.build.gradle.inject.InjectionException Indicates a problem performing the injection.
+ */
+ public void inject(String value);
+ }
+
+ private abstract class BaseInjectionTarget implements InjectionTarget {
+ @SuppressWarnings( {"UnusedDeclaration"})
+ private final TargetMember targetMember;
+ private final CtClass ctClass;
+ private final File classFileLocation;
+
+ protected BaseInjectionTarget(TargetMember targetMember, CtClass ctClass) {
+ this.targetMember = targetMember;
+ this.ctClass = ctClass;
+ try {
+ classFileLocation = new File( loaderClassPath.find( targetMember.getClassName() ).toURI() );
+ }
+ catch ( Throwable e ) {
+ throw new InjectionException( "Unable to resolve class file path", e );
+ }
+ }
+
+ @Override
+ public void inject(String value) {
+ doInjection( value );
+ writeOutChanges();
+ }
+
+ protected abstract void doInjection(String value);
+
+ protected void writeOutChanges() {
+ log.info( "writing injection changes back [" + classFileLocation.getAbsolutePath() + "]" );
+ long timeStamp = classFileLocation.lastModified();
+ ClassFile classFile = ctClass.getClassFile();
+ classFile.compact();
+ try {
+ DataOutputStream out = new DataOutputStream( new BufferedOutputStream( new FileOutputStream( classFileLocation ) ) );
+ try {
+
+ classFile.write( out );
+ out.flush();
+ if ( ! classFileLocation.setLastModified( System.currentTimeMillis() ) ) {
+ log.info( "Unable to manually update class file timestamp" );
+ }
+ }
+ finally {
+ out.close();
+ classFileLocation.setLastModified( timeStamp );
+ }
+ }
+ catch ( IOException e ) {
+ throw new InjectionException( "Unable to write out modified class file", e );
+ }
+ }
+ }
+
+ private class FieldInjectionTarget extends BaseInjectionTarget {
+ private final CtField ctField;
+
+ private FieldInjectionTarget(TargetMember targetMember, CtClass ctClass, CtField ctField) {
+ super( targetMember, ctClass );
+ this.ctField = ctField;
+ if ( ! Modifier.isStatic( ctField.getModifiers() ) ) {
+ throw new InjectionException( "Field is not static [" + targetMember.getQualifiedName() + "]" );
+ }
+ }
+
+ @Override
+ protected void doInjection(String value) {
+ final FieldInfo ctFieldInfo = ctField.getFieldInfo();
+
+ ctFieldInfo.addAttribute(
+ new ConstantAttribute(
+ ctFieldInfo.getConstPool(),
+ ctFieldInfo.getConstPool().addStringInfo( value )
+ )
+ );
+
+ }
+ }
+
+ private class MethodInjectionTarget extends BaseInjectionTarget {
+ private final CtMethod ctMethod;
+
+ private MethodInjectionTarget(TargetMember targetMember, CtClass ctClass, CtMethod ctMethod) {
+ super( targetMember, ctClass );
+ this.ctMethod = ctMethod;
+ }
+
+ @Override
+ protected void doInjection(String value) {
+ try {
+ ctMethod.setBody( "{return \"" + value + "\";}" );
+ }
+ catch ( Throwable t ) {
+ throw new InjectionException( "Unable to replace method body", t );
+ }
+ }
+ }
+}
View
38 buildSrc/src/main/groovy/org/hibernate/build/gradle/inject/InjectionException.java
@@ -0,0 +1,38 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2011, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+
+package org.hibernate.build.gradle.inject;
+
+/**
+ * @author Steve Ebersole
+ */
+public class InjectionException extends RuntimeException {
+ public InjectionException(String message) {
+ super( message );
+ }
+
+ public InjectionException(String message, Throwable cause) {
+ super( message, cause );
+ }
+}
View
46 buildSrc/src/main/groovy/org/hibernate/build/gradle/inject/InjectionPlugin.java
@@ -0,0 +1,46 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2011, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+
+package org.hibernate.build.gradle.inject;
+
+import org.gradle.api.Plugin;
+import org.gradle.api.Project;
+
+/**
+ * @author Steve Ebersole
+ */
+public class InjectionPlugin implements Plugin<Project> {
+
+ @Override
+ public void apply(Project project) {
+ final InjectionAction injectionAction = new InjectionAction( project );
+
+ // For now, just do what Hibernate needs rather than a full blown "convention" object
+ Injection versionInjection = new Injection( project.getVersion().toString() );
+ versionInjection.into( "org.hibernate.Version", "getVersionString" );
+ injectionAction.addInjection( versionInjection );
+ project.getTasks().findByName( "jar" ).doLast( injectionAction );
+ }
+
+}
View
51 buildSrc/src/main/groovy/org/hibernate/build/gradle/inject/TargetMember.java
@@ -0,0 +1,51 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2011, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+
+package org.hibernate.build.gradle.inject;
+
+/**
+ * @author Steve Ebersole
+ */
+public class TargetMember {
+ private final String className;
+ private final String memberName;
+
+ public TargetMember(String className, String memberName) {
+ this.className = className;
+ this.memberName = memberName;
+ }
+
+ public String getClassName() {
+ return className;
+ }
+
+ public String getMemberName() {
+ return memberName;
+ }
+
+ public String getQualifiedName() {
+ return getClassName() + "#" + getMemberName();
+ }
+
+}
View
276 buildSrc/src/main/groovy/org/hibernate/gradle/testing/database/DatabaseMatrixPlugin.java
@@ -0,0 +1,276 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2011, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+
+package org.hibernate.gradle.testing.database;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import groovy.lang.Closure;
+import org.gradle.api.Plugin;
+import org.gradle.api.Project;
+import org.gradle.api.artifacts.Configuration;
+import org.gradle.api.logging.Logger;
+import org.gradle.api.logging.Logging;
+
+import org.hibernate.gradle.testing.matrix.AbstractMatrixNode;
+import org.hibernate.gradle.testing.matrix.MatrixNode;
+import org.hibernate.gradle.testing.matrix.MatrixNodeProvider;
+import org.hibernate.gradle.util.DuplicatedDBConfigException;
+import org.hibernate.gradle.util.FileUtil;
+import org.hibernate.gradle.util.Jdk;
+
+/**
+ * TODO : javadoc
+ *
+ * @author Steve Ebersole
+ * @author Strong Liu
+ */
+public class DatabaseMatrixPlugin implements Plugin<Project>, MatrixNodeProvider {
+ private static final Logger log = Logging.getLogger( DatabaseMatrixPlugin.class );
+ public static final String DEFAULT_DATABASE_DIRECTORY = "databases";
+ private Project project;
+ private Map<String, MatrixNode> matrixNodeMap = new HashMap();
+
+ public void apply(Project project) {
+ this.project = project;
+ applyDatabaseDirectories( getRootProject( project ).file( DEFAULT_DATABASE_DIRECTORY ) );
+ String databasesDirPath = System.getProperty( "hibernate-matrix-databases" );
+ if(databasesDirPath!=null){
+ File databaseDir = new File( databasesDirPath );
+ if(FileUtil.isDirectory( databaseDir )){
+ applyDatabaseDirectories( databaseDir );
+ }
+ }
+ }
+
+ private Project getRootProject(Project project) {
+ return project.getParent() != null ? getRootProject( project.getParent() ) : project;
+ }
+
+
+ private void applyDatabaseDirectories(Object databasesBaseDirObject) {
+ if ( databasesBaseDirObject == null ) {
+ return;
+ }
+ log.debug( "Applying database directory: " + databasesBaseDirObject );
+ final File databasesBaseDir = project.file( databasesBaseDirObject );
+ for ( File entry : databasesBaseDir.listFiles() ) {
+ if ( entry.isDirectory() ) {
+ applyPossibleDatabaseDirectory( entry );
+ }
+ }
+ }
+
+ private static final String MATRIX_NODE_CONVENTION_KEY = "matrixNode";
+ private static final String MATRIX_BUILD_FILE = "matrix.gradle";
+// private static final String IVY_XML_FILE = "ivy.xml";
+
+ private boolean ignoreDefault(String databaseName) {
+ String value = System.getProperty( "hibernate-matrix-ignore" );
+ return ( value != null && ( value.equals( "all" ) || value.contains( databaseName ) ) );
+ }
+
+ private void applyPossibleDatabaseDirectory(final File databaseDir) {
+ final String databaseName = databaseDir.getName();
+ if ( ignoreDefault( databaseName ) ) {
+ return;
+ }
+ log.debug( "Checking potential database directory : {}", databaseName );
+
+ MatrixNode node = null;
+
+ // 3 types of support here:
+ // 1) directory contains a file named 'matrix.gradle'
+ // 2) directory contains a file named 'ivy.xml' (we prefer matrix.gradle --stliu)
+ // 3) directory contains a sub-directory named 'jdbc' containing the driver artifacts
+
+ final File matrixFile = new File( databaseDir, MATRIX_BUILD_FILE );
+ if ( FileUtil.isFile( matrixFile ) ) {
+
+ // (1) we found the 'matrix.gradle' file
+ node = prepareFromGradleFile( matrixFile );
+ }
+ else {
+// final File ivyXmlFile = new File( databaseDir, IVY_XML_FILE );
+// if ( FileUtil.isFile( ivyXmlFile ) ) {
+// // (2) we found the 'ivy.xml' file
+// node = prepareFromIvyXmlFile( ivyXmlFile );
+// }
+// else {
+ final File jdbcDir = new File( databaseDir, "jdbc" );
+ if ( FileUtil.isDirectory( jdbcDir ) ) {
+ node = prepareFromJdbcDir( jdbcDir );
+ }
+// }
+ }
+
+ if ( node == null ) {
+ log.info( "Doesn't found valid Matrix database configuration file in directory : {}", databaseDir );
+ return;
+ }
+
+ final File propertiesFile = new File( new File( databaseDir, "resources" ), "hibernate.properties" );
+ if ( FileUtil.isFile( propertiesFile ) ) {
+ node.setHibernatePropertyFile( propertiesFile );
+ }
+ else {
+ log.warn( "No 'hibernate.properties' found in {}/resources", databaseDir );
+ }
+ log.debug( "Adding node[{}] " + node.getName() );
+ if ( matrixNodeMap.containsKey( node.getName() ) ) {
+ throw new DuplicatedDBConfigException( "There is already a Matrix node named " + node.getName() );
+ }
+ else {
+ matrixNodeMap.put( node.getName(), node );
+ }
+ }
+
+ private MatrixNode prepareFromGradleFile(File matrixFile) {
+ log.debug( "Found matrix file : " + matrixFile );
+ MatrixDotGradleMatrixNodeImpl matrixNode = new MatrixDotGradleMatrixNodeImpl(
+ matrixFile.getParentFile()
+ .getName()
+ );
+ MatrixDotGradleMatrixNodeConvention convention = new MatrixDotGradleMatrixNodeConvention( matrixNode );
+ project.getConvention().getPlugins().put( MATRIX_NODE_CONVENTION_KEY, convention );
+ try {
+ project.apply( Collections.singletonMap( "from", matrixFile ) );
+ }
+ finally {
+ project.getConvention().getPlugins().remove( MATRIX_NODE_CONVENTION_KEY );
+ }
+ return matrixNode;
+ }
+
+ /**
+ * {@link MatrixNode} implementation for handling 'matrix.gradle' files
+ */
+ private class MatrixDotGradleMatrixNodeImpl extends AbstractMatrixNode {
+ private final Configuration jdbcDependencies;
+ private Jdk jdk;
+
+ public MatrixDotGradleMatrixNodeImpl(String name) {
+ super( project, name );
+ this.jdbcDependencies = prepareConfiguration( name );
+ this.jdk = getDefaultJdk();
+ }
+
+ public Jdk getTestingRuntimeJdk() {
+ return jdk;
+ }
+
+ @Override
+ public DependencyResolver getDependencyResolver() {
+ return new DependencyResolver() {
+ @Override
+ public Project getProject() {
+ return project;
+ }
+
+ @Override
+ public Configuration resolve() {
+ return jdbcDependencies;
+ }
+ };
+ }
+ }
+
+ /**
+ * Provides simplified convention object to the database-specific script for convenient configuration.
+ */
+ private class MatrixDotGradleMatrixNodeConvention {
+ private final MatrixDotGradleMatrixNodeImpl matrixNode;
+
+ private MatrixDotGradleMatrixNodeConvention(MatrixDotGradleMatrixNodeImpl matrixNode) {
+ this.matrixNode = matrixNode;
+ }
+
+ public void jdbcDependency(Object dependencyNotation, Closure closure) {
+ project.getDependencies().add( matrixNode.jdbcDependencies.getName(), dependencyNotation, closure );
+ }
+
+ public void jdbcDependency(Object dependencyNotation) {
+ log.debug(
+ "Adding JDBC dependency[{}] resolved from matrix.gradle",
+ matrixNode.jdbcDependencies.getName()
+ );
+ project.getDependencies().add( matrixNode.jdbcDependencies.getName(), dependencyNotation );
+ }
+
+ public void jdk(Jdk jdk) {
+ matrixNode.jdk = jdk;
+ }
+ }
+
+ private MatrixNode prepareFromJdbcDir(File jdbcDir) {
+ log.debug( "Found local jdbc dir : " + jdbcDir );
+ return new LocalMatrixNode( jdbcDir );
+ }
+
+ private class LocalMatrixNode extends AbstractMatrixNode {
+ private final Jdk jdk = getDefaultJdk();
+ private final LocalJdbcDependencyResolver resolver;
+
+ private LocalMatrixNode(File jdbcDir) {
+ super( project, jdbcDir.getParentFile().getName() );
+ resolver = new LocalJdbcDependencyResolver( project, jdbcDir.getParentFile() );
+ }
+
+ public Jdk getTestingRuntimeJdk() {
+ return jdk;
+ }
+
+ @Override
+ public DependencyResolver getDependencyResolver() {
+ return resolver;
+ }
+ }
+
+ public List<MatrixNode> getMatrixNodes() {
+ return Collections.unmodifiableList( new ArrayList<MatrixNode>( matrixNodeMap.values() ) );
+ }
+
+ private Configuration prepareConfiguration(String name) {
+ Configuration configuration = getOrCreateConfiguration( name );
+ configuration.setDescription( "The [" + name + "] JDBC dependency configuration" );
+ return configuration;
+ }
+
+ private Configuration getOrCreateConfiguration(String configurationName) {
+ Configuration configuration = project.getConfigurations().findByName( configurationName );
+ if ( configuration == null ) {
+ configuration = project.getConfigurations().add( configurationName );
+ }
+ return configuration;
+ }
+
+ private Jdk getDefaultJdk() {
+ return new Jdk();
+ }
+}
View
37 buildSrc/src/main/groovy/org/hibernate/gradle/testing/database/DependencyResolver.java
@@ -0,0 +1,37 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2011, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+
+package org.hibernate.gradle.testing.database;
+
+import org.gradle.api.Project;
+import org.gradle.api.artifacts.Configuration;
+
+/**
+ * @author Strong Liu
+ */
+public interface DependencyResolver {
+ Project getProject();
+ Configuration resolve();
+
+}
View
89 buildSrc/src/main/groovy/org/hibernate/gradle/testing/database/IvyDependencyResolver.java
@@ -0,0 +1,89 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2011, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+
+package org.hibernate.gradle.testing.database;
+
+import java.io.File;
+
+import org.gradle.api.Project;
+import org.gradle.api.artifacts.Configuration;
+import org.gradle.api.logging.Logger;
+import org.gradle.api.logging.Logging;
+
+import org.hibernate.gradle.util.FileUtil;
+import org.hibernate.gradle.util.IvyResolutionHelper;
+import org.hibernate.gradle.util.ResolutionException;
+
+/**
+ * @author Strong Liu
+ */
+public class IvyDependencyResolver implements DependencyResolver {
+ private static final Logger log = Logging.getLogger( IvyDependencyResolver.class );
+
+ private final File ivyXml;
+ private final Project project;
+ private final IvyResolutionHelper ivyResolutionHelper;
+ private Configuration configuration;
+
+ public IvyDependencyResolver(File ivyXml, Project project) {
+ this.ivyXml = ivyXml;
+ this.project = project;
+ this.ivyResolutionHelper = new IvyResolutionHelper( project );
+ }
+
+ @Override
+ public Project getProject() {
+ return project;
+ }
+
+ @Override
+ public Configuration resolve() {
+ if ( configuration == null ) {
+ if ( FileUtil.isFile( ivyXml ) ) {
+ String databaseName = ivyXml.getParentFile().getName();
+ try {
+ log.debug(
+ "Using IvyDependencyResolver to resolve {} dependencies with file {} ",
+ databaseName,
+ ivyXml
+ );
+ configuration = ivyResolutionHelper.resolve( ivyXml, databaseName );
+ }
+ catch ( ResolutionException e ) {
+ log.warn( "Skipping database '{}' due to problems resolving dependencies", databaseName );
+ }
+
+ if ( configuration != null ) {
+ configuration.setVisible( true );
+ configuration.setDescription(
+ "The [" + ivyXml.getParentFile()
+ .getName() + "] JDBC dependency configuration"
+ );
+
+ }
+ }
+ }
+ return configuration;
+ }
+}
View
218 buildSrc/src/main/groovy/org/hibernate/gradle/testing/database/IvyXmlDependency.java
@@ -0,0 +1,218 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2011, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+
+package org.hibernate.gradle.testing.database;
+
+import java.io.File;
+import java.io.IOException;
+import java.text.ParseException;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.ivy.Ivy;
+import org.apache.ivy.core.cache.DefaultRepositoryCacheManager;
+import org.apache.ivy.core.cache.RepositoryCacheManager;
+import org.apache.ivy.core.module.descriptor.DependencyDescriptor;
+import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
+import org.apache.ivy.core.module.id.ModuleRevisionId;
+import org.apache.ivy.core.report.ResolveReport;
+import org.apache.ivy.core.settings.IvySettings;
+import org.apache.ivy.plugins.resolver.DependencyResolver;
+import org.gradle.api.Project;
+import org.gradle.api.internal.artifacts.IvyService;
+import org.gradle.api.internal.artifacts.configurations.DefaultConfigurationContainer;
+import org.gradle.api.internal.artifacts.configurations.ResolverProvider;
+import org.gradle.api.internal.artifacts.dependencies.DefaultSelfResolvingDependency;
+import org.gradle.api.internal.artifacts.ivyservice.DefaultIvyService;
+import org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingIvyService;
+import org.gradle.api.internal.artifacts.ivyservice.IvyFactory;
+import org.gradle.api.internal.artifacts.ivyservice.SettingsConverter;
+import org.gradle.api.internal.artifacts.ivyservice.ShortcircuitEmptyConfigsIvyService;
+import org.gradle.api.internal.artifacts.repositories.InternalRepository;
+import org.gradle.api.internal.file.AbstractFileCollection;
+import org.gradle.invocation.DefaultGradle;
+
+import org.hibernate.gradle.util.BuildException;
+import org.hibernate.gradle.util.ResolutionException;
+
+/**
+ * TODO : javadoc
+ *
+ * @author Steve Ebersole
+ */
+public class IvyXmlDependency extends DefaultSelfResolvingDependency {
+ private final String name;
+
+ public IvyXmlDependency(Project project, File ivyXmlFile) {
+ super( new IvyXmlDependencyFileCollection( project, ivyXmlFile ) );
+ this.name = ivyXmlFile.getParentFile().getName() + '/' + ivyXmlFile.getName();
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public IvyXmlDependencyFileCollection getSource() {
+ return (IvyXmlDependencyFileCollection) super.getSource();
+ }
+
+ private static class IvyXmlDependencyFileCollection extends AbstractFileCollection {
+ private final Project project;
+ private final File ivyXmlFile;
+ private Set<File> resolvedDependencyFiles;
+
+ private IvyXmlDependencyFileCollection(Project project, File ivyXmlFile) {
+ this.project = project;
+ this.ivyXmlFile = ivyXmlFile;
+ }
+
+ public File getIvyXmlFile() {
+ return ivyXmlFile;
+ }
+
+ @Override
+ public String getDisplayName() {
+ return ivyXmlFile.getAbsolutePath();
+ }
+
+ public Set<File> getFiles() {
+ if ( resolvedDependencyFiles == null ) {
+ resolvedDependencyFiles = resolveDependencyFiles();
+ }
+ return resolvedDependencyFiles;
+ }
+
+ private Set<File> resolveDependencyFiles() {
+ DefaultIvyService ivyService = unwrap(
+ ( (DefaultConfigurationContainer) project.getConfigurations() ).getIvyService()
+ );
+
+ final ModuleDescriptor moduleDescriptor = resolveIvyXml( ivyService );
+
+ DefaultRepositoryCacheManager repositoryCacheManager = null;
+ final ResolverProvider resolverProvider = ivyService.getResolverProvider();
+ for ( DependencyResolver resolver : resolverProvider.getResolvers() ) {
+ RepositoryCacheManager potentialRepositoryCacheManager = resolver.getRepositoryCacheManager();
+ if ( DefaultRepositoryCacheManager.class.isInstance( potentialRepositoryCacheManager ) ) {
+ repositoryCacheManager = (DefaultRepositoryCacheManager) potentialRepositoryCacheManager;
+ }
+ }
+ if ( repositoryCacheManager == null ) {
+ throw buildResolutionException( moduleDescriptor.getModuleRevisionId(), "Unable to locate proper dependency cache manager" );
+ }
+
+ HashSet<File> dependencyFiles = new HashSet<File>();
+ for ( DependencyDescriptor dependencyDescriptor : moduleDescriptor.getDependencies() ) {
+ final ModuleRevisionId info = dependencyDescriptor.getDynamicConstraintDependencyRevisionId();
+
+ dependencyFiles.add( repositoryCacheManager.getIvyFileInCache( info ) );
+ }
+
+ return dependencyFiles;
+ }
+
+ private DefaultIvyService unwrap(IvyService ivyService) {
+ if ( DefaultIvyService.class.isInstance( ivyService ) ) {
+ return (DefaultIvyService) ivyService;
+ }
+
+ if ( ErrorHandlingIvyService.class.isInstance( ivyService ) ) {
+ return unwrap( ( (ErrorHandlingIvyService) ivyService ).getIvyService() );
+ }
+
+ if ( ShortcircuitEmptyConfigsIvyService.class.isInstance( ivyService ) ) {
+ return unwrap( ( (ShortcircuitEmptyConfigsIvyService) ivyService ).getIvyService() );
+ }
+
+ throw new BuildException( "Do not know how to extract needed ivy config from ivy service of type " + ivyService.getClass().getName() );
+ }
+
+ private ModuleDescriptor resolveIvyXml(DefaultIvyService ivyService) {
+ Ivy ivy = locateIvyService( ivyService );
+ ResolveReport resolveReport = performResolve( ivy, ivyXmlFile );
+ return resolveReport.getModuleDescriptor();
+ }
+
+ @SuppressWarnings({ "unchecked" })
+ private ResolveReport performResolve(Ivy ivy, File ivyXmlFile) {
+ try {
+ ResolveReport resolveReport = ivy.resolve( ivyXmlFile );
+ if ( resolveReport.hasError() ) {
+ throw buildResolutionException(
+ resolveReport.getModuleDescriptor().getModuleRevisionId(),
+ resolveReport.getAllProblemMessages()
+ );
+ }
+ return resolveReport;
+ }
+ catch ( ParseException e ) {
+ throw new BuildException( "Malformed ivy dependency file [" + ivyXmlFile.getName() + "]", e );
+ }
+ catch ( IOException e ) {
+ throw new BuildException( "Problem reading ivy dependency file [" + ivyXmlFile.getName() + "]", e );
+ }
+ }
+
+ private Ivy locateIvyService(DefaultIvyService ivyService) {
+ final IvyFactory ivyFactory = ivyService.getIvyFactory();
+ final SettingsConverter settingsConverter = ivyService.getSettingsConverter();
+ final ResolverProvider resolverProvider = ivyService.getResolverProvider();
+
+ // Ugh, can absolutely find no way to access this other than a bunch of recursive reflection calls to
+ // locate the build's org.gradle.api.internal.project.TopLevelBuildServiceRegistry and access its
+ // private org.gradle.api.internal.project.TopLevelBuildServiceRegistry.clientModuleRegistry field.
+ //
+ // Not sure if it is critical to reuse that map instance or not. seems to work without, but i have no
+ // idea about the ramifications.
+ Map<String, ModuleDescriptor> clientModuleRegistry = new HashMap<String, ModuleDescriptor>();
+
+ // this part is mainly DefaultIvyService#ivyForResolve
+ IvySettings ivySettings = settingsConverter.convertForResolve(
+ resolverProvider.getResolvers(),
+ project.getGradle().getGradleUserHomeDir(),
+ getGradeService( InternalRepository.class ),
+ clientModuleRegistry
+ );
+ return ivyFactory.createIvy( ivySettings );
+ }
+
+ protected <T> T getGradeService(Class<T> type) {
+ return ( (DefaultGradle) project.getGradle() ).getServices().get( type );
+ }
+ }
+
+ private static ResolutionException buildResolutionException(ModuleRevisionId descriptor, List<String> messages) {
+ return new ResolutionException( descriptor.toString(), messages );
+ }
+
+ private static ResolutionException buildResolutionException(ModuleRevisionId descriptor, String... messages) {
+ return buildResolutionException( descriptor, Arrays.asList( messages ) );
+ }
+}
View
88 ...rc/src/main/groovy/org/hibernate/gradle/testing/database/LocalJdbcDependencyResolver.java
@@ -0,0 +1,88 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2011, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+
+package org.hibernate.gradle.testing.database;
+
+import java.io.File;
+
+import org.gradle.api.Project;
+import org.gradle.api.artifacts.Configuration;
+import org.gradle.api.internal.artifacts.dependencies.DefaultSelfResolvingDependency;
+import org.gradle.api.logging.Logger;
+import org.gradle.api.logging.Logging;
+
+import org.hibernate.gradle.util.FileUtil;
+import org.hibernate.gradle.util.IvyResolutionHelper;
+
+/**
+ * @author Strong Liu
+ */
+@SuppressWarnings("cast")
+public class LocalJdbcDependencyResolver implements DependencyResolver {
+ private static final Logger log = Logging.getLogger( LocalJdbcDependencyResolver.class );
+
+ private final File databaseDir;
+ private final Project project;
+ private final IvyResolutionHelper ivyResolutionHelper;
+ private Configuration configuration;
+
+ public LocalJdbcDependencyResolver(Project project, File databaseDir) {
+ this.databaseDir = databaseDir;
+ this.project = project;
+ this.ivyResolutionHelper = new IvyResolutionHelper( project );
+ }
+
+ @Override
+ public Project getProject() {
+ return project;
+ }
+
+ @Override
+ public Configuration resolve() {
+ if ( configuration == null ) {
+ final File jdbcDir = new File( databaseDir, "jdbc" );
+ if ( FileUtil.isDirectory( jdbcDir ) ) {
+ configuration = createSelfContainedConfiguration( jdbcDir, databaseDir.getName() );
+ }
+ else {
+ log.warn( "Found 'jdbc' directory, but no entries" );
+ }
+ if ( configuration != null ) {
+ configuration.setVisible( true );
+ configuration.setDescription( "The [" + databaseDir.getName() + "] JDBC dependency configuration" );
+
+ }
+ }
+ return configuration;
+ }
+
+ private Configuration createSelfContainedConfiguration(File directory, String configurationName) {
+ Configuration configuration = ivyResolutionHelper.getOrCreateConfiguration( configurationName );
+ DefaultSelfResolvingDependency dependency =
+ new DefaultSelfResolvingDependency( project.files( (File[]) directory.listFiles() ) );
+ configuration.addDependency( dependency );
+ return configuration;
+ }
+
+}
View
136 buildSrc/src/main/groovy/org/hibernate/gradle/testing/matrix/AbstractMatrixNode.java
@@ -0,0 +1,136 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2011, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+
+package org.hibernate.gradle.testing.matrix;
+
+import java.io.File;
+import java.util.Map;
+
+import hudson.util.DBAllocation;
+import hudson.util.DBAllocationHelper;
+import org.gradle.api.Project;
+import org.gradle.api.artifacts.Configuration;
+import org.gradle.api.logging.Logger;
+import org.gradle.api.logging.Logging;
+
+import org.hibernate.gradle.util.FileUtil;
+
+/**
+ * @author Strong Liu
+ */
+public abstract class AbstractMatrixNode implements MatrixNode {
+ private static final Logger log = Logging.getLogger( AbstractMatrixNode.class );
+ private final String name;
+ private final File baseOutputDirectory;
+ private final DBAllocation dbAllocation;
+ private File propertyFile;
+ private Map<String, String> properties;
+ private String uuid;
+
+ protected AbstractMatrixNode(final Project project, final String name) {
+ this.name = name;
+ this.baseOutputDirectory = new File( new File( project.getBuildDir(), "matrix" ), getName() );
+ FileUtil.mkdir( baseOutputDirectory );
+ this.dbAllocation = new DBAllocation( baseOutputDirectory );
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public File getBaseOutputDirectory() {
+ return baseOutputDirectory;
+ }
+
+ @Override
+ public Configuration getTestingRuntimeConfiguration() {
+ return getDependencyResolver().resolve();
+ }
+
+ @Override
+ public void release() {
+ if ( DBAllocationHelper.isDBAllocationEnabled( getName() ) ) {
+ if ( uuid != null ) {
+ try {
+ dbAllocation.release( uuid );
+ }
+ catch ( RuntimeException e ) {
+ log.warn( "DBAllocator failed to release db["+getName()+"]", e );
+ }
+ } else {
+ log.warn( getName() + "is enabled to use DBAllocation, but the allocated uuid is null" );
+ }
+
+ }
+ }
+
+ @Override
+ public DBAllocation getDBAllocation() {
+ return dbAllocation;
+ }
+
+ @Override
+ public void setHibernatePropertyFile(File file) {
+ this.propertyFile = file;
+ }
+
+ @Override
+ public File getHibernatePropertyFile() {
+ return propertyFile;
+ }
+
+ @Override
+ public Map<String, String> getProperties() {
+ if ( properties == null ) {
+ properties = DBAllocationHelper.getProperties( this );
+ uuid = properties.get( "uuid" );
+ }
+ return properties;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if ( this == o ) {
+ return true;
+ }
+ if ( o == null || getClass() != o.getClass() ) {
+ return false;
+ }
+
+ AbstractMatrixNode that = (AbstractMatrixNode) o;
+
+ if ( name != null ? !name.equals( that.name ) : that.name != null ) {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return name != null ? name.hashCode() : 0;
+ }
+}
View
61 buildSrc/src/main/groovy/org/hibernate/gradle/testing/matrix/MatrixNode.java
@@ -0,0 +1,61 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2011, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+
+package org.hibernate.gradle.testing.matrix;
+
+import java.io.File;
+import java.util.Map;
+
+import hudson.util.DBAllocation;
+import org.gradle.api.artifacts.Configuration;
+
+import org.hibernate.gradle.testing.database.DependencyResolver;
+import org.hibernate.gradle.util.Jdk;
+
+/**
+ * Describes the various pieces of information being contributed to the matrix by a given node.
+ *
+ * @author Steve Ebersole
+ * @author Strong Liu
+ */
+public interface MatrixNode {
+ /**
+ * Get the name of this node.
+ *
+ * @return The node.
+ */
+ String getName();
+
+ Configuration getTestingRuntimeConfiguration();
+
+ Jdk getTestingRuntimeJdk();
+
+ DependencyResolver getDependencyResolver();
+ File getBaseOutputDirectory();
+ DBAllocation getDBAllocation();
+ Map<String,String> getProperties();
+ File getHibernatePropertyFile();
+ void setHibernatePropertyFile(File file);
+ void release();
+}
View
36 buildSrc/src/main/groovy/org/hibernate/gradle/testing/matrix/MatrixNodeProvider.java
@@ -0,0 +1,36 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2011, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+
+package org.hibernate.gradle.testing.matrix;
+
+import java.util.List;
+
+/**
+ * TODO : javadoc
+ *
+ * @author Steve Ebersole
+ */
+public interface MatrixNodeProvider {
+ public List<MatrixNode> getMatrixNodes();
+}
View
203 buildSrc/src/main/groovy/org/hibernate/gradle/testing/matrix/MatrixTestingPlugin.groovy
@@ -0,0 +1,203 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2011, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+
+package org.hibernate.gradle.testing.matrix;
+
+
+import org.gradle.api.Plugin
+import org.gradle.api.Project
+import org.gradle.api.Task
+import org.gradle.api.artifacts.Configuration
+import org.gradle.api.logging.Logger
+import org.gradle.api.logging.Logging
+import org.gradle.api.plugins.JavaPluginConvention
+import org.gradle.api.tasks.SourceSet
+import org.gradle.api.tasks.SourceSetContainer
+import org.gradle.api.tasks.testing.Test
+import org.hibernate.gradle.testing.database.DatabaseMatrixPlugin
+import static org.gradle.api.plugins.JavaPlugin.COMPILE_CONFIGURATION_NAME
+import static org.gradle.api.plugins.JavaPlugin.RUNTIME_CONFIGURATION_NAME
+import static org.gradle.api.plugins.JavaPlugin.TEST_COMPILE_CONFIGURATION_NAME
+import static org.gradle.api.plugins.JavaPlugin.TEST_RUNTIME_CONFIGURATION_NAME
+
+/**
+ * TODO : 1) add a base configuration of common attribute across all matrix node tasks (convention)
+ * TODO: 2) somehow allow applying just a single database to a project (non matrix testing).
+ *
+ * @author Steve Ebersole
+ * @author Strong Liu
+ */
+public class MatrixTestingPlugin implements Plugin<Project> {
+ private static final Logger log = Logging.getLogger(MatrixTestingPlugin.class);
+
+ public static final String MATRIX_COMPILE_CONFIG_NAME = "matrixCompile";
+ public static final String MATRIX_RUNTIME_CONFIG_NAME = "matrixRuntime";
+ public static final String MATRIX_TASK_NAME = "matrix";
+ public static final String MATRIX_SOURCE_SET_NAME = "matrix";
+ private Project project;
+ private Configuration matrixCompileConfig;
+ private Configuration matrixRuntimeConfig;
+ private Task matrixTask;
+ private SourceSet matrixSourceSet;
+ private List<MatrixNode> matrixNodes;
+
+ public void apply(Project project) {
+ this.project = project;
+ project.plugins.apply(DatabaseMatrixPlugin);
+ matrixNodes = locateMatrixNodes(project);
+ if ( matrixNodes == null || matrixNodes.isEmpty() ) return; //no db matrix defined.
+ matrixCompileConfig = prepareCompileConfiguration();
+ matrixRuntimeConfig = prepareRuntimeConfiguration();
+ matrixSourceSet = prepareSourceSet();
+ // create a "grouping task" for all the matrix nodes
+ matrixTask = project.tasks.add(MATRIX_TASK_NAME);
+ matrixTask.group = "Verification"
+ matrixTask.description = "Runs the unit tests on Database Matrix"
+ generateNodes();
+ createTestTaskForMatrixSourceSet();
+ }
+
+ /**
+ * we need create a Test task which runs tests in matrix and also use resources in test.resources
+ */
+ private void createTestTaskForMatrixSourceSet() {
+ final Test test = project.tasks.test
+ final Test matrixUnitTask = project.tasks.add("matrixUnitTest", Test)
+ matrixUnitTask.description = "Run matrix sources as unit test"
+ matrixUnitTask.classpath = matrixSourceSet.runtimeClasspath
+ matrixUnitTask.testClassesDir = matrixSourceSet.classesDir
+
+ matrixUnitTask.workingDir = test.workingDir
+ matrixUnitTask.testReportDir = test.testReportDir
+ matrixUnitTask.testResultsDir = test.testResultsDir
+ matrixUnitTask.systemProperties = test.systemProperties
+ test.dependsOn matrixUnitTask
+ def sourceSets = project.convention.getPlugin(JavaPluginConvention).sourceSets
+ project.tasks.getByName("processMatrixResources").doLast({
+ project.copy {
+ from(sourceSets.test.java.srcDirs) {
+ include '**/*.properties'
+ include '**/*.xml'
+ }
+ into matrixSourceSet.classesDir
+ }
+ project.copy {
+ from(sourceSets.test.resources.srcDirs) {
+ include '**/*.properties'
+ include '**/*.xml'
+ }
+ into matrixSourceSet.classesDir
+ }
+ project.copy {
+ from(matrixSourceSet.java.srcDirs) {
+ include '**/*.properties'
+ include '**/*.xml'
+ }
+ into matrixSourceSet.classesDir
+ }
+ })
+
+ }
+
+ /**
+ * Prepare compile configuration for matrix source set.
+ */
+ private Configuration prepareCompileConfiguration() {
+ return project.configurations.add(MATRIX_COMPILE_CONFIG_NAME).setDescription("Dependencies used to compile the matrix tests").extendsFrom(project.configurations.getByName(COMPILE_CONFIGURATION_NAME)).extendsFrom(project.configurations.getByName(TEST_COMPILE_CONFIGURATION_NAME));
+ }
+
+ /**
+ * Prepare runtime configuration for matrix source set.
+ */
+ private Configuration prepareRuntimeConfiguration() {
+ return project.configurations.add(MATRIX_RUNTIME_CONFIG_NAME).setDescription("Dependencies (baseline) used to run the matrix tests").extendsFrom(matrixCompileConfig).extendsFrom(project.configurations.getByName(RUNTIME_CONFIGURATION_NAME)).extendsFrom(project.configurations.getByName(TEST_RUNTIME_CONFIGURATION_NAME));
+ }
+
+ private SourceSet prepareSourceSet() {
+ final SourceSetContainer sourceSets = project.convention.getPlugin(JavaPluginConvention).sourceSets;
+ SourceSet sourceSet = sourceSets.findByName(MATRIX_SOURCE_SET_NAME);
+ if ( sourceSet == null ) {
+ sourceSet = sourceSets.add(MATRIX_SOURCE_SET_NAME);
+ }
+ final SourceSet mainSourceSet = sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME); //sourceSets.main
+ final SourceSet unitTestSourceSet = sourceSets.getByName(SourceSet.TEST_SOURCE_SET_NAME); //sourceSets.test
+ sourceSet.compileClasspath = mainSourceSet.classes + unitTestSourceSet.classes + matrixCompileConfig
+ sourceSet.runtimeClasspath = sourceSet.classes + mainSourceSet.classes + unitTestSourceSet.classes + matrixRuntimeConfig
+ sourceSet.classesDir = new File(unitTestSourceSet.classesDir.parentFile, "matrix")
+ sourceSet.resources {
+ setSrcDirs(['src/matrix/java', 'src/matrix/resources'])
+ }
+ return sourceSet;
+ }
+
+ private void generateNodes() {
+ // For now we just hard code this to locate the databases processed by
+ // org.hibernate.gradle.testing.database.DatabaseMatrixPlugin. But long term would be much better to
+ // abstract this idea via the MatrixNode/MatrixNodeProvider interfaces; this would allow the jvm variance
+ // needed for jdbc3/jdbc4 testing for example. Not to mention its much more generally applicable
+ //
+ // Also the notion that the plugin as a MatrixNodeProducer might not be appropriate. probably a split there
+ // is in order too (config producer and jvm producer and somehow they get wired into a matrix).
+ //
+ // but again this is just a start.
+
+ for ( MatrixNode node: matrixNodes ) {
+ Task nodeTask = prepareNodeTask(node);
+ matrixTask.dependsOn(nodeTask);
+ }
+ }
+
+ private List<MatrixNode> locateMatrixNodes(Project project) {
+ if ( project == null ) return null;
+ if ( project.plugins.hasPlugin(DatabaseMatrixPlugin) ) {
+ return project.plugins[DatabaseMatrixPlugin].matrixNodes;
+ }
+ else {
+ locateMatrixNodes(project.parent)
+ }
+ }
+
+ private Task prepareNodeTask(MatrixNode node) {
+ String taskName = MATRIX_TASK_NAME + '_' + node.name
+ log.debug("Adding Matrix Testing task $taskName");
+ final Test nodeTask = project.tasks.add(taskName, Test);
+ nodeTask.description = "Runs the matrix against ${node.name}"
+ nodeTask.classpath = node.testingRuntimeConfiguration + matrixSourceSet.runtimeClasspath
+ nodeTask.testClassesDir = matrixSourceSet.classesDir
+ nodeTask.ignoreFailures = true
+ nodeTask.workingDir = node.baseOutputDirectory
+ nodeTask.testReportDir = new File(node.baseOutputDirectory, "reports")
+ nodeTask.testResultsDir = new File(node.baseOutputDirectory, "results")
+
+ nodeTask.dependsOn(project.tasks.getByName(matrixSourceSet.classesTaskName));
+ nodeTask.systemProperties = node.properties
+ nodeTask.systemProperties['hibernate.test.validatefailureexpected'] = true
+ nodeTask.jvmArgs = ['-Xms1024M', '-Xmx1024M' ]//, '-XX:MaxPermSize=512M', '-Xss4096k', '-Xverify:none', '-XX:+UseFastAccessorMethods', '-XX:+DisableExplicitGC']
+ nodeTask.maxHeapSize = "1024M"
+ nodeTask.doLast {
+ node.release()
+ }
+