activerecord-jdbc-adapter 1.0.3-java → 50.1-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (268) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +33 -0
  3. data/.travis.yml +79 -0
  4. data/.yardopts +4 -0
  5. data/CONTRIBUTING.md +50 -0
  6. data/Gemfile +91 -0
  7. data/History.md +1191 -0
  8. data/LICENSE.txt +22 -17
  9. data/README.md +169 -0
  10. data/RUNNING_TESTS.md +127 -0
  11. data/Rakefile +294 -5
  12. data/Rakefile.jdbc +20 -0
  13. data/activerecord-jdbc-adapter.gemspec +55 -0
  14. data/lib/active_record/connection_adapters/as400_adapter.rb +2 -0
  15. data/lib/active_record/connection_adapters/db2_adapter.rb +1 -0
  16. data/lib/active_record/connection_adapters/firebird_adapter.rb +1 -0
  17. data/lib/active_record/connection_adapters/mariadb_adapter.rb +1 -0
  18. data/lib/active_record/connection_adapters/sqlserver_adapter.rb +1 -0
  19. data/lib/activerecord-jdbc-adapter.rb +0 -5
  20. data/lib/arel/visitors/compat.rb +60 -0
  21. data/lib/arel/visitors/db2.rb +128 -6
  22. data/lib/arel/visitors/derby.rb +103 -10
  23. data/lib/arel/visitors/firebird.rb +79 -0
  24. data/lib/arel/visitors/h2.rb +25 -0
  25. data/lib/arel/visitors/hsqldb.rb +18 -10
  26. data/lib/arel/visitors/postgresql_jdbc.rb +6 -0
  27. data/lib/arel/visitors/sql_server.rb +225 -0
  28. data/lib/arel/visitors/sql_server/ng42.rb +293 -0
  29. data/lib/arjdbc.rb +11 -21
  30. data/lib/arjdbc/abstract/connection_management.rb +35 -0
  31. data/lib/arjdbc/abstract/core.rb +64 -0
  32. data/lib/arjdbc/abstract/database_statements.rb +64 -0
  33. data/lib/arjdbc/abstract/statement_cache.rb +58 -0
  34. data/lib/arjdbc/abstract/transaction_support.rb +86 -0
  35. data/lib/arjdbc/db2.rb +3 -1
  36. data/lib/arjdbc/db2/adapter.rb +630 -250
  37. data/lib/arjdbc/db2/as400.rb +130 -0
  38. data/lib/arjdbc/db2/column.rb +167 -0
  39. data/lib/arjdbc/db2/connection_methods.rb +44 -0
  40. data/lib/arjdbc/derby.rb +1 -5
  41. data/lib/arjdbc/derby/active_record_patch.rb +13 -0
  42. data/lib/arjdbc/derby/adapter.rb +409 -217
  43. data/lib/arjdbc/derby/connection_methods.rb +16 -14
  44. data/lib/arjdbc/derby/schema_creation.rb +15 -0
  45. data/lib/arjdbc/discover.rb +62 -50
  46. data/lib/arjdbc/firebird.rb +3 -1
  47. data/lib/arjdbc/firebird/adapter.rb +365 -62
  48. data/lib/arjdbc/firebird/connection_methods.rb +23 -0
  49. data/lib/arjdbc/h2.rb +2 -3
  50. data/lib/arjdbc/h2/adapter.rb +273 -6
  51. data/lib/arjdbc/h2/connection_methods.rb +23 -8
  52. data/lib/arjdbc/hsqldb.rb +2 -3
  53. data/lib/arjdbc/hsqldb/adapter.rb +204 -77
  54. data/lib/arjdbc/hsqldb/connection_methods.rb +24 -10
  55. data/lib/arjdbc/hsqldb/explain_support.rb +35 -0
  56. data/lib/arjdbc/hsqldb/schema_creation.rb +11 -0
  57. data/lib/arjdbc/informix.rb +4 -2
  58. data/lib/arjdbc/informix/adapter.rb +78 -54
  59. data/lib/arjdbc/informix/connection_methods.rb +8 -9
  60. data/lib/arjdbc/jdbc.rb +59 -2
  61. data/lib/arjdbc/jdbc/adapter.rb +356 -166
  62. data/lib/arjdbc/jdbc/adapter_java.jar +0 -0
  63. data/lib/arjdbc/jdbc/adapter_require.rb +46 -0
  64. data/lib/arjdbc/jdbc/base_ext.rb +15 -0
  65. data/lib/arjdbc/jdbc/callbacks.rb +27 -18
  66. data/lib/arjdbc/jdbc/column.rb +79 -20
  67. data/lib/arjdbc/jdbc/connection.rb +5 -119
  68. data/lib/arjdbc/jdbc/connection_methods.rb +32 -4
  69. data/lib/arjdbc/jdbc/error.rb +65 -0
  70. data/lib/arjdbc/jdbc/extension.rb +41 -29
  71. data/lib/arjdbc/jdbc/java.rb +5 -6
  72. data/lib/arjdbc/jdbc/jdbc.rake +3 -126
  73. data/lib/arjdbc/jdbc/railtie.rb +2 -9
  74. data/lib/arjdbc/jdbc/rake_tasks.rb +3 -10
  75. data/lib/arjdbc/jdbc/serialized_attributes_helper.rb +3 -0
  76. data/lib/arjdbc/jdbc/type_cast.rb +166 -0
  77. data/lib/arjdbc/jdbc/type_converter.rb +35 -19
  78. data/lib/arjdbc/mssql.rb +6 -3
  79. data/lib/arjdbc/mssql/adapter.rb +630 -298
  80. data/lib/arjdbc/mssql/column.rb +200 -0
  81. data/lib/arjdbc/mssql/connection_methods.rb +66 -17
  82. data/lib/arjdbc/mssql/explain_support.rb +99 -0
  83. data/lib/arjdbc/mssql/limit_helpers.rb +189 -50
  84. data/lib/arjdbc/mssql/lock_methods.rb +77 -0
  85. data/lib/arjdbc/mssql/types.rb +343 -0
  86. data/lib/arjdbc/mssql/utils.rb +82 -0
  87. data/lib/arjdbc/mysql.rb +2 -3
  88. data/lib/arjdbc/mysql/adapter.rb +86 -356
  89. data/lib/arjdbc/mysql/connection_methods.rb +159 -23
  90. data/lib/arjdbc/oracle/adapter.rb +714 -263
  91. data/lib/arjdbc/postgresql.rb +2 -3
  92. data/lib/arjdbc/postgresql/_bc_time_cast_patch.rb +24 -0
  93. data/lib/arjdbc/postgresql/adapter.rb +570 -400
  94. data/lib/arjdbc/postgresql/base/array_decoder.rb +26 -0
  95. data/lib/arjdbc/postgresql/base/array_encoder.rb +25 -0
  96. data/lib/arjdbc/postgresql/base/array_parser.rb +95 -0
  97. data/lib/arjdbc/postgresql/base/pgconn.rb +11 -0
  98. data/lib/arjdbc/postgresql/column.rb +51 -0
  99. data/lib/arjdbc/postgresql/connection_methods.rb +57 -18
  100. data/lib/arjdbc/postgresql/name.rb +24 -0
  101. data/lib/arjdbc/postgresql/oid_types.rb +192 -0
  102. data/lib/arjdbc/railtie.rb +11 -0
  103. data/lib/arjdbc/sqlite3.rb +2 -3
  104. data/lib/arjdbc/sqlite3/adapter.rb +518 -198
  105. data/lib/arjdbc/sqlite3/connection_methods.rb +49 -24
  106. data/lib/arjdbc/sybase.rb +2 -2
  107. data/lib/arjdbc/sybase/adapter.rb +7 -6
  108. data/lib/arjdbc/tasks.rb +13 -0
  109. data/lib/arjdbc/tasks/database_tasks.rb +52 -0
  110. data/lib/arjdbc/tasks/databases.rake +91 -0
  111. data/lib/arjdbc/tasks/databases3.rake +215 -0
  112. data/lib/arjdbc/tasks/databases4.rake +39 -0
  113. data/lib/arjdbc/tasks/db2_database_tasks.rb +104 -0
  114. data/lib/arjdbc/tasks/derby_database_tasks.rb +95 -0
  115. data/lib/arjdbc/tasks/h2_database_tasks.rb +31 -0
  116. data/lib/arjdbc/tasks/hsqldb_database_tasks.rb +70 -0
  117. data/lib/arjdbc/tasks/jdbc_database_tasks.rb +169 -0
  118. data/lib/arjdbc/tasks/mssql_database_tasks.rb +46 -0
  119. data/lib/arjdbc/util/quoted_cache.rb +60 -0
  120. data/lib/arjdbc/util/serialized_attributes.rb +98 -0
  121. data/lib/arjdbc/util/table_copier.rb +110 -0
  122. data/lib/arjdbc/version.rb +1 -6
  123. data/lib/generators/jdbc/USAGE +9 -0
  124. data/lib/generators/jdbc/jdbc_generator.rb +8 -0
  125. data/lib/jdbc_adapter.rb +1 -1
  126. data/lib/jdbc_adapter/rake_tasks.rb +3 -2
  127. data/lib/jdbc_adapter/version.rb +2 -1
  128. data/pom.xml +114 -0
  129. data/rails_generators/jdbc_generator.rb +1 -1
  130. data/rails_generators/templates/config/initializers/jdbc.rb +8 -5
  131. data/rails_generators/templates/lib/tasks/jdbc.rake +7 -4
  132. data/rakelib/01-tomcat.rake +51 -0
  133. data/rakelib/02-test.rake +132 -0
  134. data/rakelib/bundler_ext.rb +11 -0
  135. data/rakelib/compile.rake +67 -22
  136. data/rakelib/db.rake +61 -0
  137. data/rakelib/rails.rake +204 -29
  138. data/src/java/arjdbc/ArJdbcModule.java +286 -0
  139. data/src/java/arjdbc/db2/DB2Module.java +76 -0
  140. data/src/java/arjdbc/db2/DB2RubyJdbcConnection.java +126 -0
  141. data/src/java/arjdbc/derby/DerbyModule.java +99 -243
  142. data/src/java/arjdbc/derby/DerbyRubyJdbcConnection.java +152 -0
  143. data/src/java/arjdbc/firebird/FirebirdRubyJdbcConnection.java +174 -0
  144. data/src/java/arjdbc/{jdbc/JdbcConnectionFactory.java → h2/H2Module.java} +20 -6
  145. data/src/java/arjdbc/h2/H2RubyJdbcConnection.java +27 -12
  146. data/src/java/arjdbc/hsqldb/HSQLDBModule.java +73 -0
  147. data/src/java/arjdbc/informix/InformixRubyJdbcConnection.java +7 -6
  148. data/src/java/arjdbc/jdbc/AdapterJavaService.java +7 -29
  149. data/src/java/arjdbc/jdbc/Callable.java +44 -0
  150. data/src/java/arjdbc/jdbc/ConnectionFactory.java +132 -0
  151. data/src/java/arjdbc/jdbc/DataSourceConnectionFactory.java +157 -0
  152. data/src/java/arjdbc/jdbc/DriverConnectionFactory.java +63 -0
  153. data/src/java/arjdbc/jdbc/DriverWrapper.java +119 -0
  154. data/src/java/arjdbc/jdbc/JdbcResult.java +130 -0
  155. data/src/java/arjdbc/jdbc/RubyJdbcConnection.java +3622 -948
  156. data/src/java/arjdbc/mssql/MSSQLModule.java +90 -0
  157. data/src/java/arjdbc/mssql/MSSQLRubyJdbcConnection.java +181 -0
  158. data/src/java/arjdbc/mysql/MySQLModule.java +99 -81
  159. data/src/java/arjdbc/mysql/MySQLRubyJdbcConnection.java +294 -0
  160. data/src/java/arjdbc/oracle/OracleModule.java +80 -0
  161. data/src/java/arjdbc/oracle/OracleRubyJdbcConnection.java +387 -17
  162. data/src/java/arjdbc/postgresql/ByteaUtils.java +157 -0
  163. data/src/java/arjdbc/postgresql/PgResultSetMetaDataWrapper.java +23 -0
  164. data/src/java/arjdbc/postgresql/PostgreSQLModule.java +77 -0
  165. data/src/java/arjdbc/postgresql/PostgreSQLResult.java +184 -0
  166. data/src/java/arjdbc/postgresql/PostgreSQLRubyJdbcConnection.java +952 -0
  167. data/src/java/arjdbc/sqlite3/SQLite3Module.java +73 -0
  168. data/src/java/arjdbc/sqlite3/SQLite3RubyJdbcConnection.java +525 -0
  169. data/src/java/arjdbc/util/CallResultSet.java +826 -0
  170. data/src/java/arjdbc/util/DateTimeUtils.java +580 -0
  171. data/src/java/arjdbc/util/ObjectSupport.java +65 -0
  172. data/src/java/arjdbc/util/QuotingUtils.java +138 -0
  173. data/src/java/arjdbc/util/StringCache.java +63 -0
  174. data/src/java/arjdbc/util/StringHelper.java +159 -0
  175. metadata +245 -268
  176. data/History.txt +0 -369
  177. data/Manifest.txt +0 -180
  178. data/README.txt +0 -181
  179. data/lib/active_record/connection_adapters/oracle_adapter.rb +0 -1
  180. data/lib/arel/engines/sql/compilers/db2_compiler.rb +0 -9
  181. data/lib/arel/engines/sql/compilers/derby_compiler.rb +0 -6
  182. data/lib/arel/engines/sql/compilers/h2_compiler.rb +0 -6
  183. data/lib/arel/engines/sql/compilers/hsqldb_compiler.rb +0 -15
  184. data/lib/arel/engines/sql/compilers/jdbc_compiler.rb +0 -6
  185. data/lib/arel/engines/sql/compilers/mssql_compiler.rb +0 -46
  186. data/lib/arel/visitors/mssql.rb +0 -44
  187. data/lib/arjdbc/jdbc/compatibility.rb +0 -51
  188. data/lib/arjdbc/jdbc/core_ext.rb +0 -24
  189. data/lib/arjdbc/jdbc/discover.rb +0 -18
  190. data/lib/arjdbc/jdbc/driver.rb +0 -44
  191. data/lib/arjdbc/jdbc/missing_functionality_helper.rb +0 -87
  192. data/lib/arjdbc/jdbc/quoted_primary_key.rb +0 -28
  193. data/lib/arjdbc/jdbc/require_driver.rb +0 -16
  194. data/lib/arjdbc/mimer.rb +0 -2
  195. data/lib/arjdbc/mimer/adapter.rb +0 -142
  196. data/lib/arjdbc/mssql/tsql_helper.rb +0 -61
  197. data/lib/arjdbc/oracle.rb +0 -3
  198. data/lib/arjdbc/oracle/connection_methods.rb +0 -11
  199. data/lib/pg.rb +0 -4
  200. data/rakelib/package.rake +0 -92
  201. data/rakelib/test.rake +0 -81
  202. data/src/java/arjdbc/jdbc/SQLBlock.java +0 -48
  203. data/src/java/arjdbc/mssql/MssqlRubyJdbcConnection.java +0 -127
  204. data/src/java/arjdbc/postgresql/PostgresqlRubyJdbcConnection.java +0 -57
  205. data/src/java/arjdbc/sqlite3/Sqlite3RubyJdbcConnection.java +0 -64
  206. data/test/abstract_db_create.rb +0 -117
  207. data/test/activerecord/connection_adapters/type_conversion_test.rb +0 -31
  208. data/test/activerecord/connections/native_jdbc_mysql/connection.rb +0 -25
  209. data/test/db/db2.rb +0 -11
  210. data/test/db/derby.rb +0 -12
  211. data/test/db/h2.rb +0 -11
  212. data/test/db/hsqldb.rb +0 -13
  213. data/test/db/informix.rb +0 -11
  214. data/test/db/jdbc.rb +0 -11
  215. data/test/db/jndi_config.rb +0 -40
  216. data/test/db/logger.rb +0 -3
  217. data/test/db/mssql.rb +0 -9
  218. data/test/db/mysql.rb +0 -10
  219. data/test/db/oracle.rb +0 -34
  220. data/test/db/postgres.rb +0 -9
  221. data/test/db/sqlite3.rb +0 -11
  222. data/test/db2_simple_test.rb +0 -66
  223. data/test/derby_migration_test.rb +0 -68
  224. data/test/derby_multibyte_test.rb +0 -12
  225. data/test/derby_simple_test.rb +0 -99
  226. data/test/generic_jdbc_connection_test.rb +0 -29
  227. data/test/h2_simple_test.rb +0 -41
  228. data/test/has_many_through.rb +0 -79
  229. data/test/helper.rb +0 -5
  230. data/test/hsqldb_simple_test.rb +0 -6
  231. data/test/informix_simple_test.rb +0 -48
  232. data/test/jdbc_common.rb +0 -25
  233. data/test/jndi_callbacks_test.rb +0 -40
  234. data/test/jndi_test.rb +0 -25
  235. data/test/manualTestDatabase.rb +0 -191
  236. data/test/models/add_not_null_column_to_table.rb +0 -12
  237. data/test/models/auto_id.rb +0 -18
  238. data/test/models/data_types.rb +0 -28
  239. data/test/models/entry.rb +0 -43
  240. data/test/models/mixed_case.rb +0 -25
  241. data/test/models/reserved_word.rb +0 -18
  242. data/test/models/string_id.rb +0 -18
  243. data/test/models/validates_uniqueness_of_string.rb +0 -19
  244. data/test/mssql_db_create_test.rb +0 -26
  245. data/test/mssql_identity_insert_test.rb +0 -19
  246. data/test/mssql_legacy_types_test.rb +0 -58
  247. data/test/mssql_limit_offset_test.rb +0 -136
  248. data/test/mssql_multibyte_test.rb +0 -18
  249. data/test/mssql_simple_test.rb +0 -55
  250. data/test/mysql_db_create_test.rb +0 -27
  251. data/test/mysql_info_test.rb +0 -113
  252. data/test/mysql_multibyte_test.rb +0 -10
  253. data/test/mysql_nonstandard_primary_key_test.rb +0 -42
  254. data/test/mysql_simple_test.rb +0 -49
  255. data/test/oracle_simple_test.rb +0 -18
  256. data/test/oracle_specific_test.rb +0 -83
  257. data/test/pick_rails_version.rb +0 -3
  258. data/test/postgres_db_create_test.rb +0 -32
  259. data/test/postgres_drop_db_test.rb +0 -16
  260. data/test/postgres_mixed_case_test.rb +0 -29
  261. data/test/postgres_nonseq_pkey_test.rb +0 -38
  262. data/test/postgres_reserved_test.rb +0 -22
  263. data/test/postgres_schema_search_path_test.rb +0 -44
  264. data/test/postgres_simple_test.rb +0 -51
  265. data/test/postgres_table_alias_length_test.rb +0 -15
  266. data/test/simple.rb +0 -546
  267. data/test/sqlite3_simple_test.rb +0 -233
  268. data/test/sybase_jtds_simple_test.rb +0 -28
@@ -1,21 +1,26 @@
1
- Copyright (c) 2006-2008 Nick Sieger <nick@nicksieger.com>
1
+ Copyright (c) 2017-2018 The JRuby Team
2
+ Copyright (c) 2012-2016 Karol Bucek <self@kares.org>
3
+ Copyright (c) 2006-2012 Nick Sieger <nick@nicksieger.com>
2
4
  Copyright (c) 2006-2008 Ola Bini <ola.bini@gmail.com>
3
5
 
4
- Permission is hereby granted, free of charge, to any person obtaining
5
- a copy of this software and associated documentation files (the
6
- "Software"), to deal in the Software without restriction, including
7
- without limitation the rights to use, copy, modify, merge, publish,
8
- distribute, sublicense, and/or sell copies of the Software, and to
9
- permit persons to whom the Software is furnished to do so, subject to
10
- the following conditions:
6
+ All rights reserved.
11
7
 
12
- The above copyright notice and this permission notice shall be
13
- included in all copies or substantial portions of the Software.
8
+ Redistribution and use in source and binary forms, with or without modification,
9
+ are permitted provided that the following conditions are met:
14
10
 
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11
+ - Redistributions of source code must retain the above copyright notice, this
12
+ list of conditions and the following disclaimer.
13
+ - Redistributions in binary form must reproduce the above copyright notice, this
14
+ list of conditions and the following disclaimer in the documentation and/or
15
+ other materials provided with the distribution.
16
+
17
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
21
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
24
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,169 @@
1
+ # ActiveRecord JDBC Adapter
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/activerecord-jdbc-adapter.svg)][7]
4
+
5
+ ActiveRecord-JDBC-Adapter (AR-JDBC) is the main database adapter for Rails'
6
+ *ActiveRecord* component that can be used with [JRuby][0].
7
+ ActiveRecord-JDBC-Adapter provides full or nearly full support for:
8
+ **MySQL**, **PostgreSQL**, **SQLite3**. In the near future there are plans to
9
+ add support **MSSQL**. Unless we get more contributions we will not be going
10
+ beyond these four adapters. Note that the amount of work needed to get
11
+ another adapter is not huge but the amount of testing required to make sure
12
+ that adapter continues to work is not something we can do with the resources
13
+ we currently have.
14
+
15
+ For Oracle database users you are encouraged to use
16
+ https://github.com/rsim/oracle-enhanced.
17
+
18
+ Version **50.x** supports Rails version 5.0.x and it lives on branch 50-stable.
19
+ Version **51.x** supports Rails version 5.1.x and is currently on master until
20
+ its first release. The minimum version of JRuby for 50+ is JRuby **9.1.x** and
21
+ JRuby 9.1+ requires Java 7 or newer (we recommend Java 8 at minimum).
22
+
23
+ ## Using ActiveRecord JDBC
24
+
25
+ ### Inside Rails
26
+
27
+ To use AR-JDBC with JRuby on Rails:
28
+
29
+ 1. Choose the adapter you wish to gem install. The following pre-packaged
30
+ adapters are available:
31
+
32
+ - MySQL (`activerecord-jdbcmysql-adapter`)
33
+ - PostgreSQL (`activerecord-jdbcpostgresql-adapter`)
34
+ - SQLite3 (`activerecord-jdbcsqlite3-adapter`)
35
+
36
+ 2. If you're generating a new Rails application, use the following command:
37
+
38
+ jruby -S rails new sweetapp
39
+
40
+ 3. Configure your *database.yml* in the normal Rails style:
41
+
42
+ ```yml
43
+ development:
44
+ adapter: mysql2 # or mysql
45
+ database: blog_development
46
+ username: blog
47
+ password: 1234
48
+ ```
49
+
50
+ For JNDI data sources, you may simply specify the JNDI location as follows, it's
51
+ recommended to use the same adapter: setting as one would configure when using
52
+ "bare" (JDBC) connections e.g. :
53
+
54
+ ```yml
55
+ production:
56
+ adapter: postgresql
57
+ jndi: jdbc/PostgreDS
58
+ ```
59
+
60
+ **NOTE:** any other settings such as *database:*, *username:*, *properties:* make
61
+ no difference since everything is already configured on the JNDI DataSource end.
62
+
63
+ JDBC driver specific properties might be set if you use an URL to specify the DB
64
+ or preferably using the *properties:* syntax:
65
+
66
+ ```yml
67
+ production:
68
+ adapter: mysql
69
+ username: blog
70
+ password: blog
71
+ url: "jdbc:mysql://localhost:3306/blog?profileSQL=true"
72
+ properties: # specific to com.mysql.jdbc.Driver
73
+ socketTimeout: 60000
74
+ connectTimeout: 60000
75
+ ```
76
+
77
+ ### Standalone with ActiveRecord
78
+
79
+ Once the setup is made (see below) you can establish a JDBC connection like this
80
+ (e.g. for `activerecord-jdbcderby-adapter`):
81
+
82
+ ```ruby
83
+ ActiveRecord::Base.establish_connection(
84
+ adapter: 'sqlite3',
85
+ database: 'db/my-database'
86
+ )
87
+ ```
88
+
89
+ #### Using Bundler
90
+
91
+ Proceed as with Rails; specify `ActiveRecord` in your Bundle along with the
92
+ chosen JDBC adapter(s), this time sample *Gemfile* for MySQL:
93
+
94
+ ```ruby
95
+ gem 'activerecord', '~> 5.0.6'
96
+ gem 'activerecord-jdbcmysql-adapter', :platform => :jruby
97
+ ```
98
+
99
+ When you `require 'bundler/setup'` everything will be set up for you as expected.
100
+
101
+ #### Without Bundler
102
+
103
+ Install the needed gems with JRuby, for example:
104
+
105
+ gem install activerecord -v "~> 5.0.6"
106
+ gem install activerecord-jdbc-adapter --ignore-dependencies
107
+
108
+ If you wish to use the adapter for a specific database, you can install it
109
+ directly and the (jdbc-) driver gem (dependency) will be installed as well:
110
+
111
+ jruby -S gem install activerecord-jdbcmysql-adapter
112
+
113
+ Your program should include:
114
+
115
+ ```ruby
116
+ require 'active_record'
117
+ require 'activerecord-jdbc-adapter' if defined? JRUBY_VERSION
118
+ ```
119
+
120
+ ## Source
121
+
122
+ The source for activerecord-jdbc-adapter is available using git:
123
+
124
+ git clone git://github.com/jruby/activerecord-jdbc-adapter.git
125
+
126
+ Please note that the project manages multiple gems from a single repository,
127
+ if you're using *Bundler* >= 1.2 it should be able to locate all gemspecs from
128
+ the git repository. Sample *Gemfile* for running with (MySQL) master:
129
+
130
+ ```ruby
131
+ gem 'activerecord-jdbc-adapter', :github => 'jruby/activerecord-jdbc-adapter'
132
+ gem 'activerecord-jdbcmysql-adapter', :github => 'jruby/activerecord-jdbc-adapter'
133
+ ```
134
+
135
+ ## Getting Involved
136
+
137
+ Please read our [CONTRIBUTING](CONTRIBUTING.md) & [RUNNING_TESTS](RUNNING_TESTS.md)
138
+ guides for starters. You can always help us by maintaining AR-JDBC's [wiki][5].
139
+
140
+ ## Feedback
141
+
142
+ Please report bugs at our [issue tracker][3]. If you're not sure if
143
+ something's a bug, feel free to pre-report it on the [mailing lists][1] or
144
+ ask on the #JRuby IRC channel on http://freenode.net/ (try [web-chat][6]).
145
+
146
+ ## Authors
147
+
148
+ This project was originally written by [Nick Sieger](http://github.com/nicksieger)
149
+ and [Ola Bini](http://github.com/olabini) with lots of help from the JRuby community.
150
+ Polished 3.x compatibility and 4.x support (for AR-JDBC >= 1.3.0) was managed by
151
+ [Karol Bucek](http://github.com/kares) among others.
152
+
153
+ ## License
154
+
155
+ ActiveRecord-JDBC-Adapter is open-source released under the BSD/MIT license.
156
+ See [LICENSE.txt](LICENSE.txt) included with the distribution for details.
157
+
158
+ Open-source driver gems within AR-JDBC's sources are licensed under the same
159
+ license the database's drivers are licensed. See each driver gem's LICENSE.txt.
160
+
161
+ [0]: http://www.jruby.org/
162
+ [1]: http://jruby.org/community
163
+ [2]: http://github.com/jruby/activerecord-jdbc-adapter/blob/master/activerecord-jdbcmssql-adapter
164
+ [3]: https://github.com/jruby/activerecord-jdbc-adapter/issues
165
+ [4]: http://github.com/nicksieger/activerecord-cachedb-adapter
166
+ [5]: https://github.com/jruby/activerecord-jdbc-adapter/wiki
167
+ [6]: https://webchat.freenode.net/?channels=#jruby
168
+ [7]: http://badge.fury.io/rb/activerecord-jdbc-adapter
169
+ [8]: https://github.com/jruby/activerecord-jdbc-adapter/wiki/Migrating-from-1.2.x-to-1.3.0
@@ -0,0 +1,127 @@
1
+ There are two sets of tests which we run in CI. Local (AR-JDBC) test and
2
+ Rails activerecord tests. The next two sections details how to run each
3
+ and customize behavior.
4
+
5
+
6
+ ## Running AR-JDBC's Tests
7
+
8
+ After you have built arjdbc (run rake), then you can try testing it (if you
9
+ do not build then adapter_java.jar is not put into the lib dir). If you
10
+ change any of the .java files you will need to rebuild.
11
+
12
+ Most DB specific unit tests hide under the **test/db** directory, the files
13
+ included in the *test* directory are mostly shared test modules and helpers.
14
+
15
+ Rake tasks are loaded from **rakelib/02-test-rake**, most adapters have a
16
+ corresponding test_[adapter] task e.g. `rake test_sqlite3` that run against DB.
17
+ To check all available (test related) tasks simply `rake -T | grep test`.
18
+
19
+ If the adapter supports creating a database it will try to do so automatically
20
+ (most embed databases such as SQLite3) for some adapters (MySQL, PostgreSQL) we
21
+ do this auto-magically (see the `rake db:create` tasks), but otherwise you'll
22
+ need to setup a database dedicated for tests (using the standard tools that come
23
+ with your DB installation).
24
+
25
+ Connection parameters: database, host etc. can usually be changed from the shell
26
+ `env` for adapters where there might be no direct control over the DB
27
+ instance/configuration, e.g. for Oracle (by looking at **test/db/oracle.rb**)
28
+ one might adapt the test database configuration using :
29
+ ```
30
+ export ORACLE_HOST=192.168.1.2
31
+ export ORACLE_USER=SAMPLE
32
+ export ORACLE_PASS=sample
33
+ export ORACLE_SID=MAIN
34
+ ```
35
+
36
+ Tests are run by calling the rake task corresponding the database adapter being
37
+ tested, e.g. for MySQL :
38
+
39
+ rake test_mysql TEST=test/db/mysql/rake_test.rb
40
+
41
+ Observe the **TEST** variable used to specify a single file to be used to resolve
42
+ test cases, you pick tests by matching their names as well using **TESTOPTS** :
43
+
44
+ rake test_postgres TESTOPTS="--name=/integer/"
45
+
46
+ Since 1.3.0 we also support prepared statements, these are enabled by default (AR)
47
+ but one can easily run tests with prepared statements disabled using env vars :
48
+
49
+ rake test_derby PREPARED_STATEMENTS=false
50
+
51
+
52
+ ### ActiveRecord (Rails) Tests
53
+
54
+ We also can run our adapters against Rails ActiveRecord tests. There are two
55
+ ways you can do this:
56
+
57
+ - Run against local clone (by setting RAILS environment variable). This is helpful when you are adding puts or hacking on activerecord code directly.
58
+
59
+ - Run against bundler provided clone (by setting AR_VERSION environment variable). This is useful when you want to submit to travis and want all the adapters to run against your code.
60
+
61
+ Note: RAILS will trump AR_VERSION and setting neither will assume version as
62
+ set in the gemspec.
63
+
64
+ ### Run against local clone
65
+
66
+ Make sure you have rails cloned somewhere:
67
+
68
+ ```text
69
+ git clone git://github.com/rails/rails.git
70
+ ```
71
+
72
+ Set up a fully qualified RAILS environment variable. For example, if you were
73
+ in activerecord direction you can just do something like:
74
+
75
+ ```ext
76
+ export RAILS=`pwd`/../rails
77
+ ```
78
+
79
+ Now that is this set up we may have changed the gems we need so we have
80
+ to run bundler:
81
+
82
+ ```text
83
+ bundle install
84
+ ```
85
+
86
+ Before you run tests you need to be aware that each support branch we have is
87
+ written to run with a single significant release of rails (50-stable will only
88
+ work well with rails 5.0.x). So you need to make sure you local copy of rails
89
+ is checked out to match whatever you are testing (e.g. git checkout v5.0.6).
90
+ Now you can run rails tests:
91
+
92
+ ```text
93
+ jruby -S rake rails:test_sqlite3
94
+ jruby -S rake rails:test_postgres
95
+ jruby -S rake rails:test_mysql
96
+ ```
97
+
98
+ ### Run against bundler provided clone
99
+
100
+ AR_VERSION is a very flexible variable. You can:
101
+
102
+ - specify tag (export AR_VERSION=v5.0.6)
103
+ - specify version (export AR_VERSION=5.0.6)
104
+ - specify SHA hash (export AR_VERSION=875bb788f56311ac4628402667187f755c1a331c)
105
+ - specify branch (export AR_VERSION=verify-release)
106
+ - specify nothing to assume LOADPATH has loaded it (export AR_VERSION=false)
107
+
108
+ Now that is this set up we may have changed the gems we need so we have
109
+ to run bundler:
110
+
111
+ ```text
112
+ bundle install
113
+ ```
114
+
115
+ Once you have picked what you want to test you can run:
116
+
117
+ ```text
118
+ jruby -S rake rails:test_sqlite3
119
+ jruby -S rake rails:test_postgres
120
+ jruby -S rake rails:test_mysql
121
+ ```
122
+
123
+ [![Build Status][0]](http://travis-ci.org/#!/jruby/activerecord-jdbc-adapter)
124
+
125
+ Happy Testing!
126
+
127
+ [0]: https://secure.travis-ci.org/jruby/activerecord-jdbc-adapter.png
data/Rakefile CHANGED
@@ -1,10 +1,299 @@
1
- require 'rake/testtask'
2
1
  require 'rake/clean'
3
- CLEAN.include 'derby*', 'test.db.*','test/reports', 'test.sqlite3','lib/**/*.jar','manifest.mf', '*.log'
4
2
 
5
- task :default => [:java_compile, :test]
3
+ CLEAN.include 'derby*', 'test.db.*', '*test.sqlite3', 'test/reports'
4
+ CLEAN.include 'lib/**/*.jar', 'MANIFEST.MF', '*.log', 'target/*'
5
+
6
+ task :default => :jar # RubyGems extention will do a bare `rake' e.g. :
7
+ # jruby" -rubygems /opt/local/rvm/gems/jruby-1.7.16@jdbc/gems/rake-10.3.2/bin/rake
8
+ # RUBYARCHDIR=/opt/local/rvm/gems/jruby-1.7.16@jdbc/gems/activerecord-jdbc-adapter-1.4.0.dev/lib
9
+ # RUBYLIBDIR=/opt/local/rvm/gems/jruby-1.7.16@jdbc/gems/activerecord-jdbc-adapter-1.4.0.dev/lib
10
+ #
11
+ # under Bundler it points those DIRs to an empty one where only built extensions are stored :
12
+ # jruby -rubygems /opt/local/rvm/gems/jruby-1.7.19@temp/gems/rake-10.4.2/bin/rake
13
+ # RUBYARCHDIR=/opt/local/rvm/gems/jruby-1.7.19@temp/bundler/gems/extensions/universal-java-1.7/1.9/activerecord-jdbc-adapter-472b5fddba43
14
+ # RUBYLIBDIR=/opt/local/rvm/gems/jruby-1.7.19@temp/bundler/gems/extensions/universal-java-1.7/1.9/activerecord-jdbc-adapter-472b5fddba43
15
+ #
16
+ # javac -target 1.6 -source 1.6 -Xlint:unchecked -g -cp
17
+ # "/opt/local/rvm/rubies/jruby-1.7.19/lib/jruby.jar:
18
+ # /opt/local/maven-repo/mysql/mysql-connector-java/5.1.33/mysql-connector-java-5.1.33.jar:
19
+ # /opt/local/maven-repo/org/postgresql/postgresql/9.4-1200-jdbc4/postgresql-9.4-1200-jdbc4.jar"
20
+ # -d /tmp/d20150417-32100-7mb1bk src/java/arjdbc/ArJdbcModule.java ...
21
+
22
+
23
+ base_dir = Dir.pwd
24
+ gem_name = 'activerecord-jdbc-adapter'
25
+ gemspec_path = File.expand_path('activerecord-jdbc-adapter.gemspec', File.dirname(__FILE__))
26
+ gemspec = lambda do
27
+ @_gemspec_ ||= Dir.chdir(File.dirname(__FILE__)) do
28
+ Gem::Specification.load(gemspec_path)
29
+ end
30
+ end
31
+ built_gem_path = lambda do
32
+ Dir[File.join(base_dir, "#{gem_name}-*.gem")].sort_by{ |f| File.mtime(f) }.last
33
+ end
34
+ current_version = lambda { gemspec.call.version }
35
+ rake = lambda { |task| ruby "-S", "rake", task }
36
+
37
+ # NOTE: avoid Bundler loading due native extension building!
38
+
39
+ desc "Build #{gem_name} gem into the pkg directory."
40
+ task :build => :jar do
41
+ sh("RELEASE=#{ENV['RELEASE']} gem build -V '#{gemspec_path}'") do
42
+ gem_path = built_gem_path.call
43
+ file_name = File.basename(gem_path)
44
+ FileUtils.mkdir_p(File.join(base_dir, 'pkg'))
45
+ FileUtils.mv(gem_path, 'pkg')
46
+ puts "\n#{gem_name} #{current_version.call} built to 'pkg/#{file_name}'"
47
+ end
48
+ end
49
+
50
+ desc "Build and install #{gem_name} gem into system gems."
51
+ task :install => :build do
52
+ gem_path = built_gem_path.call
53
+ sh("gem install '#{gem_path}' --local") do |ok|
54
+ raise "Couldn't install gem, run `gem install #{gem_path}' for more detailed output" unless ok
55
+ puts "\n#{gem_name} (#{current_version.call}) installed"
56
+ end
57
+ end
58
+
59
+ desc "Releasing AR-JDBC gems (use NOOP=true to disable gem pushing)"
60
+ task 'release:do' do
61
+ ENV['RELEASE'] = 'true' # so that .gemspec is built with adapter_java.jar
62
+ Rake::Task['build'].invoke
63
+ Rake::Task['build:adapters'].invoke
64
+
65
+ noop = ENV.key?('NOOP') && (ENV['NOOP'] != 'false' && ENV['NOOP'] != '')
66
+
67
+ version = current_version.call; version_tag = "v#{version}"
6
68
 
7
- task :filelist do
8
- puts FileList['pkg/**/*'].inspect
69
+ sh("git diff --no-patch --exit-code", :noop => noop) { |ok| fail "git working dir is not clean" unless ok }
70
+ sh("git diff-index --quiet --cached HEAD", :noop => noop) { |ok| fail "git index is not clean" unless ok }
71
+
72
+ sh "git tag -a -m \"AR-JDBC #{version}\" #{version_tag}", :noop => noop
73
+ branch = `git rev-parse --abbrev-ref HEAD`.strip
74
+ puts "releasing from (current) branch #{branch.inspect}"
75
+ sh "for gem in `ls pkg/*-#{version}-java.gem`; do gem push $gem; done", :noop => noop do |ok|
76
+ sh "git push origin #{branch} --tags", :noop => noop if ok
77
+ end
78
+ end
79
+
80
+ task 'release:push' do
81
+ sh "for gem in `ls pkg/*-#{current_version.call}-java.gem`; do gem push $gem; done"
82
+ end
83
+
84
+ ADAPTERS = %w[mysql postgresql sqlite3].map { |a| "activerecord-jdbc#{a}-adapter" }
85
+ DRIVERS = %w[mysql postgres sqlite3].map { |a| "jdbc-#{a}" }
86
+ TARGETS = ( ADAPTERS + DRIVERS )
87
+
88
+ ADAPTERS.each do |target|
89
+ namespace target do
90
+ task :build do
91
+ version = current_version.call
92
+ Dir.chdir(target) { rake.call "build" }
93
+ cp FileList["#{target}/pkg/#{target}-#{version}-java.gem"], "pkg"
94
+ end
95
+ end
96
+ end
97
+ DRIVERS.each do |target|
98
+ namespace target do
99
+ task :build do
100
+ Dir.chdir(target) { rake.call "build" }
101
+ cp FileList["#{target}/pkg/#{target}-*.gem"], "pkg"
102
+ end
103
+ end
9
104
  end
105
+ TARGETS.each do |target|
106
+ namespace target do
107
+ task :install do
108
+ Dir.chdir(target) { rake.call "install" }
109
+ end
110
+ #task :release do
111
+ # Dir.chdir(target) { rake.call "release" }
112
+ #end
113
+ end
114
+ end
115
+
116
+ # DRIVERS
117
+
118
+ desc "Build drivers"
119
+ task "build:drivers" => DRIVERS.map { |name| "#{name}:build" }
120
+ task "drivers:build" => 'build:drivers'
121
+
122
+ desc "Install drivers"
123
+ task "install:drivers" => DRIVERS.map { |name| "#{name}:install" }
124
+ task "drivers:install" => 'install:drivers'
125
+
126
+ # ADAPTERS
127
+
128
+ desc "Build adapters"
129
+ task "build:adapters" => [ 'build' ] + ADAPTERS.map { |name| "#{name}:build" }
130
+ task "adapters:build" => 'build:adapters'
131
+
132
+ desc "Install adapters"
133
+ task "install:adapters" => [ 'install' ] + ADAPTERS.map { |name| "#{name}:install" }
134
+ task "adapters:install" => 'install:adapters'
10
135
 
136
+ # ALL
137
+
138
+ task "build:all" => [ 'build' ] + TARGETS.map { |name| "#{name}:build" }
139
+ task "all:build" => 'build:all'
140
+ task "install:all" => [ 'install' ] + TARGETS.map { |name| "#{name}:install" }
141
+ task "all:install" => 'install:all'
142
+
143
+ require 'rake/testtask'
144
+
145
+ # native JRuby extension (adapter_java.jar) compilation :
146
+
147
+ if defined? JRUBY_VERSION
148
+ jar_file = 'lib/arjdbc/jdbc/adapter_java.jar'; CLEAN << jar_file
149
+ desc "Compile the native (Java) extension."
150
+ task :jar => jar_file
151
+
152
+ namespace :jar do
153
+ task :force do
154
+ rm jar_file if File.exist?(jar_file)
155
+ Rake::Task['jar'].invoke
156
+ end
157
+ end
158
+
159
+ #directory classes = 'pkg/classes'; CLEAN << classes
160
+
161
+ file jar_file => FileList[ 'src/java/**/*.java' ] do
162
+ source = target = '1.7'; debug = true
163
+
164
+ get_driver_jars_local = lambda do |*args|
165
+ driver_deps = args.empty? ? [ :Postgres, :MySQL ] : args
166
+ driver_jars = []
167
+ driver_deps.each do |name|
168
+ driver_jars << Dir.glob("jdbc-#{name.to_s.downcase}/lib/*.jar").sort.last
169
+ end
170
+ if driver_jars.empty? # likely on a `gem install ...'
171
+ # NOTE: we're currently assuming jdbc-xxx (compile) dependencies are
172
+ # installed, they are declared as gemspec.development_dependencies !
173
+ # ... the other option is to simply `mvn prepare-package'
174
+ driver_deps.each do |name|
175
+ #require "jdbc/#{name.to_s.downcase}"
176
+ #driver_jars << Jdbc.const_get(name).driver_jar
177
+ # thanks Bundler for mocking RubyGems completely :
178
+ #spec = Gem::Specification.find_by_name("jdbc-#{name.to_s.downcase}")
179
+ #driver_jars << Dir.glob(File.join(spec.gem_dir, 'lib/*.jar')).sort.last
180
+ gem_name = "jdbc-#{name.to_s.downcase}"; matched_gem_paths = []
181
+ Gem.paths.path.each do |path|
182
+ base_path = File.join(path, "gems/")
183
+ Dir.glob(File.join(base_path, "*")).each do |gem_path|
184
+ if gem_path.sub(base_path, '').start_with?(gem_name)
185
+ matched_gem_paths << gem_path
186
+ end
187
+ end
188
+ end
189
+ if gem_path = matched_gem_paths.sort.last
190
+ driver_jars << Dir.glob(File.join(gem_path, 'lib/*.jar')).sort.last
191
+ end
192
+ end
193
+ end
194
+ driver_jars
195
+ end
196
+
197
+ get_driver_jars_maven = lambda do
198
+ require 'jar_dependencies'
199
+
200
+ requirements = gemspec.call.requirements
201
+ match_driver_jars = lambda do
202
+ matched_jars = []
203
+ gemspec.call.requirements.each do |requirement|
204
+ if match = requirement.match(/^jar\s+([\w\-\.]+):([\w\-]+),\s+?([\w\.\-]+)?/)
205
+ matched_jar = Jars.send :to_jar, match[1], match[2], match[3], nil
206
+ matched_jar = File.join( Jars.home, matched_jar )
207
+ matched_jars << matched_jar if File.exists?( matched_jar )
208
+ end
209
+ end
210
+ matched_jars
211
+ end
212
+
213
+ driver_jars = match_driver_jars.call
214
+ if driver_jars.size < requirements.size
215
+ if (ENV['JARS_SKIP'] || ENV_JAVA['jars.skip']) == 'true'
216
+ warn "jar resolving skipped, extension might not compile"
217
+ else
218
+ require 'jars/installer'
219
+ ENV['JARS_QUIET'] = 'true'
220
+ puts "resolving jar dependencies to build extension (should only happen once) ..."
221
+ installer = Jars::Installer.new( gemspec_path )
222
+ installer.install_jars( false )
223
+
224
+ driver_jars = match_driver_jars.call
225
+ end
226
+ end
227
+
228
+ driver_jars
229
+ end
230
+
231
+ # TODO not good but since jar-dependencies doesn't do the job, let's default to local (for now)
232
+ if ENV['BUILD_EXT_MAVEN'] == 'true' # || ENV['RUBYARCHDIR']
233
+ driver_jars = get_driver_jars_maven.call
234
+ else
235
+ driver_jars = get_driver_jars_local.call
236
+ end
237
+
238
+ classpath = []
239
+ [ 'java.class.path', 'sun.boot.class.path' ].each do |key|
240
+ classpath += ENV_JAVA[key].split(File::PATH_SEPARATOR).find_all { |jar| jar =~ /jruby/i }
241
+ end
242
+
243
+ #classpath += ENV_JAVA['java.class.path'].split(File::PATH_SEPARATOR)
244
+ #classpath += ENV_JAVA['sun.boot.class.path'].split(File::PATH_SEPARATOR)
245
+
246
+ classpath += driver_jars
247
+ classpath = classpath.compact.join(File::PATH_SEPARATOR)
248
+
249
+ source_files = FileList[ 'src/java/**/*.java' ]
250
+
251
+ require 'tmpdir'
252
+
253
+ Dir.mktmpdir do |classes_dir|
254
+ # Cross-platform way of finding an executable in the $PATH.
255
+ # Thanks to @mislav
256
+ which = lambda do |cmd|
257
+ exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
258
+ ENV['PATH'].split(File::PATH_SEPARATOR).map do |path|
259
+ exts.map { |ext| File.join(path, "#{cmd}#{ext}") }
260
+ end.flatten.select{|f| File.executable? f}.first
261
+ end
262
+
263
+ args = [ '-Xlint:unchecked' ]
264
+
265
+ unless javac = which.call('javac')
266
+ warn "could not find javac, please make sure it's on the PATH"
267
+ end
268
+ javac = "#{javac} -target #{target} -source #{source} #{args.join(' ')}"
269
+ javac << " #{debug ? '-g' : ''}"
270
+ javac << " -cp \"#{classpath}\" -d #{classes_dir} #{source_files.join(' ')}"
271
+ sh(javac) do |ok|
272
+ raise 'could not build .jar extension - compilation failure' unless ok
273
+ end
274
+
275
+ # class_files = FileList["#{classes_dir}/**/*.class"].gsub("#{classes_dir}/", '')
276
+ # avoid environment variable expansion using backslash
277
+ # class_files.gsub!('$', '\$') unless windows?
278
+ # args = class_files.map { |path| [ "-C #{classes_dir}", path ] }.flatten
279
+ args = [ '-C', "#{classes_dir}/ ." ] # args = class_files
280
+
281
+ jar_path = jar_file
282
+ if ext_lib_dir = ENV['RUBYLIBDIR']
283
+ jar_path = File.join(ext_lib_dir, File.basename(jar_file))
284
+ end
285
+
286
+ unless jar = which.call('jar')
287
+ warn "could not find jar tool, please make sure it's on the PATH"
288
+ end
289
+ sh("#{jar} cf #{jar_path} #{args.join(' ')}") do |ok|
290
+ raise 'could not build .jar extension - packaging failure' unless ok
291
+ end
292
+ cp jar_path, jar_file if ext_lib_dir # NOTE: hopefully RG won't mind?!
293
+ end
294
+ end
295
+ else
296
+ task :jar do
297
+ puts "please run `rake jar' under JRuby to re-compile the native (Java) extension"
298
+ end
299
+ end