Skip to content

Commit 135b4e2

Browse files
committed
Change ENV from RELEASE to INCLUDE_JAR_IN_GEM to make it a little more clear
what the environment variable is for. Change build task to set INCLUDE_JAR_IN_GEM by default. This should make all except the default target include the jar into the resulting base adapter gem. Note: default target does not include the gem so that github: tag in bundler will pull our repo and compile it at that point (this allowed us to stop commiting our jar file).
1 parent 9bffcda commit 135b4e2

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

Rakefile

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,29 @@
1+
# Common usage
2+
#
3+
# rake build:adapters - to build all specific adapter gems and the base gem
4+
# rake release:do - build:adapters + git tag + push gems
5+
#
6+
# Environment variables used by this Rakefile:
7+
#
8+
# INCLUDE_JAR_IN_GEM [default task - false, other taks - true]:
9+
# Note: This is something you should not normally have to set.
10+
# For local development we always will end up including the jar file
11+
# in any task which generates our main gem. The wrinkle to this
12+
# is when we do a custom github link in bundler:
13+
#
14+
# gem 'ar-jdbc', github: '...'
15+
#
16+
# Because we stopped committing a .jar file for every change and so when
17+
# we include a gem like this it clones the repository and does a default
18+
# build in rake. This in turn will end up forcing a compile to generate
19+
# that jar (similar to how c-extensions compile at the time of install).
20+
# For shipped gems we do include the jar so that people do not require
21+
# this compile step.
22+
#
23+
# NOOP [release:do - false]
24+
#
25+
# No commands or gem pushing during a release.
26+
127
require 'rake/clean'
228

329
CLEAN.include 'derby*', 'test.db.*', '*test.sqlite3', 'test/reports'
@@ -38,7 +64,8 @@ rake = lambda { |task| ruby "-S", "rake", task }
3864

3965
desc "Build #{gem_name} gem into the pkg directory."
4066
task :build => :jar do
41-
sh("RELEASE=#{ENV['RELEASE']} gem build -V '#{gemspec_path}'") do
67+
include_jar = ENV['INCLUDE_JAR_IN_GEM'] || 'true'
68+
sh("INCLUDE_JAR_IN_GEM=#{include_jar} gem build -V '#{gemspec_path}'") do
4269
gem_path = built_gem_path.call
4370
file_name = File.basename(gem_path)
4471
FileUtils.mkdir_p(File.join(base_dir, 'pkg'))
@@ -58,7 +85,6 @@ end
5885

5986
desc "Releasing AR-JDBC gems (use NOOP=true to disable gem pushing)"
6087
task 'release:do' do
61-
ENV['RELEASE'] = 'true' # so that .gemspec is built with adapter_java.jar
6288
Rake::Task['build'].invoke
6389
Rake::Task['build:adapters'].invoke
6490

@@ -297,7 +323,7 @@ if defined? JRUBY_VERSION
297323
# class_files.gsub!('$', '\$') unless windows?
298324
# args = class_files.map { |path| [ "-C #{classes_dir}", path ] }.flatten
299325

300-
if ENV['RELEASE'] == 'true'; require 'tempfile'
326+
if ENV['INCLUDE_JAR_IN_GEM'] == 'true'; require 'tempfile'
301327
manifest = "Built-Time: #{Time.now.utc.strftime('%Y-%m-%d %H:%M:%S')}\n"
302328
manifest += "Built-JRuby: #{JRUBY_VERSION}\n"
303329
manifest += "Specification-Title: ActiveRecord-JDBC\n"

activerecord-jdbc-adapter.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Gem::Specification.new do |gem|
2727
reject { |f| f =~ /^(gemfiles)/ } # no tests - no Gemfile_s appraised ...
2828
gem.files += ['lib/arjdbc/jdbc/adapter_java.jar'] #if ENV['RELEASE'].eql?('true')
2929

30-
if ENV['RELEASE'] != 'true' # @see Rakefile
30+
if ENV['INCLUDE_JAR_IN_GEM'] != 'true' # @see Rakefile
3131
gem.extensions << 'Rakefile' # to support auto-building .jar with :git paths
3232

3333
#gem.add_runtime_dependency 'jar-dependencies', '~> 0.1' # development not enough!

0 commit comments

Comments
 (0)