rjack-tarpit 1.4.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. data/History.rdoc +13 -9
  2. data/Manifest.txt +39 -0
  3. data/NOTICE.txt +1 -1
  4. data/README.rdoc +85 -30
  5. data/Rakefile +11 -30
  6. data/lib/rjack-tarpit.rb +15 -456
  7. data/lib/rjack-tarpit/base.rb +22 -0
  8. data/lib/rjack-tarpit/base_strategy.rb +175 -0
  9. data/lib/rjack-tarpit/clean.rb +43 -0
  10. data/lib/rjack-tarpit/doc.rb +67 -0
  11. data/lib/rjack-tarpit/gem.rb +119 -0
  12. data/lib/rjack-tarpit/git.rb +45 -0
  13. data/lib/rjack-tarpit/line_match.rb +134 -0
  14. data/lib/rjack-tarpit/readme_parser.rb +74 -0
  15. data/lib/rjack-tarpit/spec.rb +314 -0
  16. data/lib/rjack-tarpit/test.rb +110 -0
  17. data/lib/rjack-tarpit/util.rb +37 -0
  18. data/test/jproject/History.rdoc +2 -0
  19. data/test/jproject/Manifest.static +10 -0
  20. data/test/jproject/Manifest.txt +11 -0
  21. data/test/jproject/NOTICE.txt +2 -0
  22. data/test/jproject/README.rdoc +24 -0
  23. data/test/jproject/Rakefile +7 -0
  24. data/test/jproject/jproject.gemspec +15 -0
  25. data/test/jproject/lib/jproject.rb +11 -0
  26. data/test/jproject/lib/jproject/base.rb +3 -0
  27. data/test/jproject/pom.xml +75 -0
  28. data/test/jproject/test/setup.rb +7 -0
  29. data/test/jproject/test/test_jproject.rb +14 -0
  30. data/test/setup.rb +7 -0
  31. data/test/test_projects.rb +71 -0
  32. data/test/test_readme_parser.rb +97 -0
  33. data/test/test_tarpit.rb +33 -0
  34. data/test/zookeeper/History.rdoc +2 -0
  35. data/test/zookeeper/Manifest.static +10 -0
  36. data/test/zookeeper/Manifest.txt +13 -0
  37. data/test/zookeeper/README.rdoc +23 -0
  38. data/test/zookeeper/Rakefile +7 -0
  39. data/test/zookeeper/assembly.xml +15 -0
  40. data/test/zookeeper/lib/rjack-zookeeper.rb +29 -0
  41. data/test/zookeeper/lib/rjack-zookeeper/base.rb +23 -0
  42. data/test/zookeeper/pom.xml +73 -0
  43. data/test/zookeeper/rjack-zookeeper.gemspec +18 -0
  44. data/test/zookeeper/test/setup.rb +17 -0
  45. data/test/zookeeper/{pkg/rjack-zookeeper-3.4.1.0-java/test → test}/test_zookeeper.rb +0 -0
  46. metadata +132 -66
  47. data/.gemtest +0 -0
data/History.rdoc CHANGED
@@ -1,12 +1,16 @@
1
- === 1.4.1 (2012-1-26)
2
- This is likely the last maintenance release of the TarPit 1.4.x
3
- series. Please take the time to review and upgrade to TarPit 2.x.
4
-
5
- * Narrow and fix Hoe release to version = 2.12.3. An incompatible was
6
- introduced in Hoe 2.12.5, causing loss of gem specification
7
- dependencies.
8
- * Upgrade/narrow and fix RDoc to version 3.12 for long term
9
- compatibility.
1
+ === 2.0.0 (2011-1-12)
2
+ * Major rewrite. Consumer project changes are required on upgrade!
3
+ See also updated README.
4
+ * Gem specification details are now in a separate, but highly
5
+ automated and generally improved gemspec file. This allows full
6
+ interoperability with Bundler.
7
+ * Improved ReadmeParser for spec automation.
8
+ * For Java projects, Maven is now executed in process via the
9
+ rjack-maven gem (speed improvement)
10
+ * Hoe is no longer a dependency, however many Hoe compatible tasks are
11
+ still supported.
12
+ * New default, in process Minitest launcher (speed improvement,
13
+ particularly on JRuby)
10
14
 
11
15
  === 1.4.0 (2011-9-21)
12
16
  * Update/broaden to rdoc ~> 3.6
data/Manifest.txt CHANGED
@@ -3,4 +3,43 @@ Manifest.txt
3
3
  NOTICE.txt
4
4
  README.rdoc
5
5
  Rakefile
6
+ lib/rjack-tarpit/base.rb
6
7
  lib/rjack-tarpit.rb
8
+ lib/rjack-tarpit/base_strategy.rb
9
+ lib/rjack-tarpit/clean.rb
10
+ lib/rjack-tarpit/doc.rb
11
+ lib/rjack-tarpit/gem.rb
12
+ lib/rjack-tarpit/git.rb
13
+ lib/rjack-tarpit/line_match.rb
14
+ lib/rjack-tarpit/readme_parser.rb
15
+ lib/rjack-tarpit/spec.rb
16
+ lib/rjack-tarpit/test.rb
17
+ lib/rjack-tarpit/util.rb
18
+ test/setup.rb
19
+ test/test_projects.rb
20
+ test/test_readme_parser.rb
21
+ test/test_tarpit.rb
22
+ test/jproject/History.rdoc
23
+ test/jproject/Manifest.static
24
+ test/jproject/Manifest.txt
25
+ test/jproject/NOTICE.txt
26
+ test/jproject/README.rdoc
27
+ test/jproject/Rakefile
28
+ test/jproject/jproject.gemspec
29
+ test/jproject/pom.xml
30
+ test/jproject/lib/jproject/base.rb
31
+ test/jproject/lib/jproject.rb
32
+ test/jproject/test/setup.rb
33
+ test/jproject/test/test_jproject.rb
34
+ test/zookeeper/History.rdoc
35
+ test/zookeeper/Manifest.static
36
+ test/zookeeper/Manifest.txt
37
+ test/zookeeper/README.rdoc
38
+ test/zookeeper/Rakefile
39
+ test/zookeeper/assembly.xml
40
+ test/zookeeper/pom.xml
41
+ test/zookeeper/rjack-zookeeper.gemspec
42
+ test/zookeeper/lib/rjack-zookeeper/base.rb
43
+ test/zookeeper/lib/rjack-zookeeper.rb
44
+ test/zookeeper/test/setup.rb
45
+ test/zookeeper/test/test_zookeeper.rb
data/NOTICE.txt CHANGED
@@ -1,2 +1,2 @@
1
1
  rjack-tarpit
2
- Copyright (c) 2009-2011 David Kellum
2
+ Copyright (c) 2009-2012 David Kellum
data/README.rdoc CHANGED
@@ -6,55 +6,110 @@
6
6
 
7
7
  == Description
8
8
 
9
- TarPit provides the glue for an unholy union of build tools. Namely:
9
+ TarPit provides the glue for an unholy union of build tools. TarPit
10
+ includes general automation for any rubygems project. It originally
11
+ used and remains heavily influenced by
12
+ Hoe[http://seattlerb.rubyforge.org/hoe/] (e.g. Manifest.txt.)
13
+ However, it fully supports use of Bundler[http://gembundler.com/]. The
14
+ gemspec benefits from sensible automation but remains in
15
+ a <project>.gemspec per Bundler's requirements.
16
+
17
+ For java platform projects, TarPit offers Maven integration via the
18
+ rjack-maven[http://rjack.rubyforge.org/maven] gem. Maven
19
+ package/install is run as needed, and jars are linked to the gem lib
20
+ directory for inclusion, with semi-automatic Manifest.txt production.
21
+ No need to bloat your git repo by checking in every version of every
22
+ jar for all time. The standard Maven layout and configuration
23
+ (i.e. src, target, pom.xml, assembly.xml) is otherwise retained for
24
+ complete java tool set compatibility. Use Maven only for what is it
25
+ good at: java compilation with dependencies. Use Rake for everything
26
+ else.
27
+
28
+ === Features
29
+
30
+ * In Rake/JVM process Maven execution via rjack-maven (speed)
31
+ * Default, in Rake process
32
+ Minitest[http://docs.seattlerb.org/minitest/] launcher (speed)
33
+ * Manifest.txt for gem file contents, derived from Manifest.static
34
+ plus jars in Java projects
35
+ * ReadmeParser for default specification url, summary, description
36
+ values
37
+ * Specification name defaults from <name>.gemspec
38
+ * LineMatchTaskDefiner defines check_(history|init)_(version|date)
39
+ tasks where appropriate to avoid missing history or version updates
40
+ on release
41
+
42
+ === Java strategies
43
+
44
+ Java projects require different strategies for integrating Maven,
45
+ specified via +s.maven_strategy=+ and summarized below:
46
+
47
+ +:no_assembly+ :: pom.xml builds a single jar, default same name and
48
+ same version as gem project (SpecHelper.default_jar)
49
+ or specified via +s.jars=+.
50
+
51
+ +:jars_from_assembly+ :: assembly.xml defines the jars at Maven
52
+ package time. Changes to this set of jars
53
+ must be incorporated by explicitly running
54
+ the `rake manifest` task.
55
+
56
+ Default :: No java, or use assembly for multiple jars but specify
57
+ +s.jars=+ when they can be computed, for example from
58
+ common version number or other gem data. This avoids the
59
+ need for the `rake manifest` step of +:jars_from_assembly+.
60
+
61
+ Assemblies are built and located with the pom version number. This
62
+ defaults to gem project version, but can be fixed
63
+ (i.e. s.assembly_version='1.0') to avoid a separate version to bump,
64
+ where the project will not export the pom, for example when the
65
+ project is re-packaging upstream jars as a gem.
10
66
 
11
- * Rake[http://github.com/jimweirich/rake] with
12
- Hoe[http://seattlerb.rubyforge.org/hoe/] for gem publishing
13
- * Maven[http://maven.apache.org/] for Java builds with dependencies.
67
+ == Synopsis
14
68
 
15
- In particular, it runs "mvn package" when needed, links jars to the
16
- gem lib directory, and provides (semi-)automatic Manifest.txt
17
- generation with these jar files without offending Hoe.
69
+ Sample gemspec for a gem including a single jar, built from java
70
+ source with maven (see also included test/jproject):
18
71
 
19
- * The Maven pom.xml (and assembly.xml if needed) must be managed
20
- independently.
21
- * A Manifest.static file holds the static elements of the manifest.
72
+ gem 'rjack-tarpit', '~> 2.0'
73
+ require 'rjack-tarpit/spec'
22
74
 
23
- == Synopsis
75
+ RJack::TarPit.specify do |s|
76
+ require 'jproject/base'
77
+
78
+ s.version = JProject::VERSION
79
+
80
+ s.add_developer 'David Kellum', 'dek-oss@gravitext.com'
24
81
 
25
- Rakefile example for a gem including a single jar, built from java
26
- source with maven:
82
+ s.maven_strategy = :no_assembly
27
83
 
28
- # -*- ruby -*-
29
- $LOAD_PATH << './lib'
30
- require 'mygem/version'
84
+ s.depend 'rjack-slf4j', '~> 1.6.4'
85
+ s.depend 'minitest', '~> 2.3', :dev
86
+ end
87
+
88
+ And the associated Rakefile (assuming use of Bundler):
31
89
 
32
90
  require 'rubygems'
33
- gem 'rjack-tarpit', '~> 1.4.1'
91
+ require 'bundler/setup'
34
92
  require 'rjack-tarpit'
35
93
 
36
- t = RJack::TarPit.new( 'mygem', MyGem::VERSION, :java_platform )
94
+ RJack::TarPit.new( "jproject" ).define_tasks
37
95
 
38
- t.specify do |h|
39
- h.developer( "David Kellum", "dek-oss@gravitext.com" )
40
- h.extra_deps += [ [ 'rjack-slf4j', '~> 1.6.2' ],
41
- [ 'rjack-logback, '~> 1.2' ] ]
42
- end
96
+ And a Bundler Gemfile:
43
97
 
44
- file 'Manifest.txt' => [ 'lib/mygem/version.rb' ]
98
+ source :rubygems
99
+ gemspec
45
100
 
46
- t.define_tasks
101
+ Java projects should provide a Manifest.static. Jars or other
102
+ generated files will be added to this to produce Manifest.txt for use
103
+ as the gemspec's files.
47
104
 
48
105
  == Dependencies
49
106
 
50
- Besides the explicit gem dependencies, TarPit requires:
51
-
52
- * rake 0.8.7+ (bundled with JRuby 1.3+)
53
- * Apache Maven 2+ ('mvn' command on path)
107
+ See the gem dependencies. The rjack-maven gem is only a dependency on
108
+ the java platform.
54
109
 
55
110
  == License
56
111
 
57
- Copyright (c) 2009-2011 David Kellum
112
+ Copyright (c) 2009-2012 David Kellum
58
113
 
59
114
  Licensed under the Apache License, Version 2.0 (the "License"); you
60
115
  may not use this file except in compliance with the License. You
data/Rakefile CHANGED
@@ -1,40 +1,21 @@
1
1
  # -*- ruby -*-
2
2
 
3
- $LOAD_PATH << './lib'
4
3
  require 'rubygems'
5
-
6
- tarpit_deps = [ [ 'rdoc', '= 3.12' ],
7
- [ 'hoe', '= 2.12.3' ] ]
8
-
9
- # gem them here, so we can build tarpit with tarpit_deps
10
- tarpit_deps.each { |dep| gem( *dep ) }
4
+ require 'bundler/setup'
11
5
 
12
6
  require 'rjack-tarpit'
13
7
 
14
- include RJack
8
+ RJack::TarPit.new( 'rjack-tarpit' ) do |tp|
15
9
 
16
- t = TarPit.new( 'rjack-tarpit', TarPit::VERSION )
10
+ tp.rdoc_destinations <<
11
+ 'dekellum@rubyforge.org:/var/www/gforge-projects/rjack/tarpit'
17
12
 
18
- t.specify do |h|
19
- h.developer( 'David Kellum', 'dek-oss@gravitext.com' )
20
- h.extra_deps += tarpit_deps
21
- h.rdoc_locations << "dekellum@rubyforge.org:/var/www/gforge-projects/rjack/tarpit"
22
- end
13
+ desc "Check that README sample has latest version"
14
+ task :check_sample_version do
15
+ tp.test_line_match( 'README.rdoc',
16
+ /^\s*gem.+rjack-tarpit/,
17
+ /#{ RJack::TarPit::MINOR_VERSION }/ )
18
+ end
19
+ [ :gem, :tag, :push ].each { |t| task t => :check_sample_version }
23
20
 
24
- task :check_history_version do
25
- t.test_line_match( 'History.rdoc', /^==/, / #{ t.version } / )
26
- end
27
- task :check_sample_version do
28
- t.test_line_match( 'README.rdoc', /^\s*gem.+#{ t.name }/, /#{ t.version }/ )
29
21
  end
30
- task :check_history_date do
31
- t.test_line_match( 'History.rdoc', /^==/, /\([0-9\-]+\)$/ )
32
- end
33
-
34
- task :gem => [ :check_history_version, :check_sample_version ]
35
- task :tag => [ :check_history_version, :check_sample_version, :check_history_date ]
36
- task :push => [ :check_history_version, :check_sample_version, :check_history_date ]
37
-
38
- task :test #noop
39
-
40
- t.define_tasks
data/lib/rjack-tarpit.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2009-2011 David Kellum
2
+ # Copyright (c) 2009-2012 David Kellum
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you
5
5
  # may not use this file except in compliance with the License. You
@@ -14,468 +14,27 @@
14
14
  # permissions and limitations under the License.
15
15
  #++
16
16
 
17
- require 'hoe'
17
+ require 'rjack-tarpit/base'
18
+ require 'rjack-tarpit/spec'
19
+ require 'rjack-tarpit/base_strategy'
18
20
 
19
- module RJack
21
+ module RJack::TarPit
20
22
 
21
- # Provides glue for Rake, Hoe, and Maven by generating tasks.
22
- module TarPit
23
- # Module version
24
- VERSION = '1.4.1'
23
+ # New task generator given name matching <name>.gemspec in the
24
+ # current directory. If block is given, yields self (err, actually
25
+ # the BaseStrategy) to block and calls define_tasks upon exit.
26
+ def self.new( name )
25
27
 
26
- # Construct new task generator by gem name, version, and flags. A descendant
27
- # of BaseStrategy is returned.
28
- # ==== flags
29
- # :jars_from_assembly:: jars will be found in assembly rather then
30
- # set in Rakefile.
31
- # :no_assembly:: One jar created from source, jars=[default_jar],
32
- # no assembly setup in maven.
33
- # :java_platform:: Set gem specification platform to java.
34
- def self.new( name, version, *flags )
35
- if flags.include?( :jars_from_assembly )
36
- JarsFromAssembly.new( name, version, flags )
37
- else
38
- BaseStrategy.new( name, version, flags )
39
- end
40
- end
41
-
42
- # Base strategy implementation where jars are known by the
43
- # Rakefile (not :jars_from_assembly)
44
- class BaseStrategy
45
-
46
- #For rack ~> 0.9.0
47
- include Rake::DSL if defined?( Rake::DSL )
48
-
49
- # Name of gem as constructed.
50
- attr_reader :name
51
- # Version of gem as constructed.
52
- attr_reader :version
53
-
54
- # The set of jar file names (without path) to include. May be
55
- # lazily computed by other strategies.
56
- attr_accessor :jars
57
-
58
- # Destination path for any jars [Default: lib/name]
59
- attr_accessor :jar_dest
60
-
61
- # Any additional generated files to be included [Default: nil]
62
- attr_accessor :generated_files
63
-
64
- # Use rdoc --diagram (requires http://graphiz.org 'dot' in PATH)
65
- attr_accessor :rdoc_diagram
66
-
67
- # The name of the assembly [Default: name]
68
- attr_writer :assembly_name
69
-
70
- # The version of the assembly, which might be static
71
- # (i.e. "1.0") if the pom is not shared (dependency jars only)
72
- # [Default: version]
73
- attr_writer :assembly_version
74
-
75
- # See TarPit.new
76
- def initialize( name, version, flags )
77
- @name = name
78
- @version = version
79
- @flags = flags
80
- @jars = [ default_jar ] if @flags.include?( :no_assembly )
81
- @jar_dest = File.join( 'lib', @name )
82
- @hoe_specifier = :unset
83
- @rdoc_diagram = false
84
- @spec = nil
85
-
86
- @install_request =
87
- Rake.application.top_level_tasks.include?( "install" )
88
- end
89
-
90
- # Return a default jar name built from name and version
91
- def default_jar
92
- "#{name}-#{version}.jar"
93
- end
94
-
95
- # Specify gem project details, yielding Hoe instance to block
96
- # after setting various defaults. Thus all Hoe.spec setters are
97
- # valid in this block. The actual Hoe construction and execution
98
- # of block is deferred to define_tasks.
99
- def specify( &block )
100
- @hoe_specifier = block
101
- end
102
-
103
- # Define all tasks based on provided details. In this strategy,
104
- # the Manifest.txt task will be invoked prior to calling
105
- # Hoe.spec, thus any additional Manifest.txt dependencies
106
- # should be specified prior to this call.
107
- def define_tasks
108
- define_maven_package_task if jars
109
-
110
- if jars || generated_files
111
- mtask = define_manifest_task
112
-
113
- # The manifest needs to run before hoe_specify
114
- mtask.invoke
115
- end
116
-
117
- define_post_maven_tasks if jars
118
-
119
- hoe_specify
120
-
121
- define_git_tag
122
- define_gem_tasks
123
- end
124
-
125
- # Test that all specified files have at least one line matching
126
- # line_regex, and that first line additionally matches (optional)
127
- # pass_line_regex.
128
- # ==== Parameters
129
- # files<Array(~)>:: List of files to test
130
- # line_regex<Regexp>:: Test first matching line
131
- # pass_line_regex:: Further test on match line (default: match all)
132
- # ==== Raises
133
- # RuntimeError:: on test failure.
134
- def test_line_match( files, line_regex, pass_line_regex = // )
135
- Array( files ).each do |mfile|
136
- found = false
137
- open( mfile ) do |mf|
138
- num = 0
139
- mf.each do |line|
140
- num += 1
141
- if line =~ line_regex
142
- found = true
143
- unless line =~ pass_line_regex
144
- raise( "%s:%d: %s !~ %s" %
145
- [ mfile, num, line.strip, pass_line_regex.inspect ] )
146
- end
147
- break
148
- end
149
- end
150
- end
151
- unless found
152
- raise "#{mfile}: #{line_regex.inspect} not found"
153
- end
154
- end
155
- end
156
-
157
- # Define task for dynamically generating Manifest.txt, by
158
- # appending array returned by the given block to specified files, or
159
- # contents of Manifest.static.
160
- def define_manifest_task
161
-
162
- if File.exist?( 'Manifest.static' )
163
- file 'Manifest.txt' => [ 'Manifest.static' ]
164
- end
165
-
166
- gf = clean_list( generated_files ).sort
167
- [ :gem, :test ].each { |t| task t => gf }
168
-
169
- unless gf.empty?
170
- task :gen_clean do
171
- rm_f gf
172
- end
173
- task :clean => :gen_clean
174
- end
175
-
176
- desc "Force update of Manifest.txt"
177
- task :manifest do
178
- generate_manifest
179
- end
180
-
181
- mtask = file 'Manifest.txt' do
182
- generate_manifest
183
- end
184
-
185
- mtask
186
- end
187
-
188
- # File touched to record the time of last successful 'mvn
189
- # package' run.
190
- MVN_STATE_FILE = 'target/.tarpit'
191
- MVN_STATE_FILE_INSTALL = 'target/.tarpit-install'
192
-
193
- # Define a file task tracking calls to "mvn package"
194
- def define_maven_package_task
195
- [ MVN_STATE_FILE, MVN_STATE_FILE_INSTALL ].each do |sf|
196
- file sf => maven_dependencies do
197
- run_maven
198
- end
199
- end
200
-
201
- task :install => MVN_STATE_FILE_INSTALL
202
- end
203
-
204
- # Run Maven mvn package or install and touch state files.
205
- def run_maven
206
- mvn = [ 'mvn', @install_request ? 'install' : 'package' ].join( ' ' )
207
- sh( mvn ) do |ok,res|
208
- if ok
209
- touch( MVN_STATE_FILE )
210
- touch( MVN_STATE_FILE_INSTALL ) if @install_request
211
- else
212
- raise "TARPIT: '#{mvn}' failed."
213
- end
214
- end
215
- end
216
-
217
- # Define file tasks for all jar symlinks and other misc. maven
218
- # associated tasks like :mvn_clean.
219
- def define_post_maven_tasks
220
- jfrom = jar_from
221
- jars.each do |jar|
222
- from = File.join( jfrom, jar )
223
- dest = File.join( jar_dest, jar )
224
- file from => [ MVN_STATE_FILE ]
225
- file dest => [ from ] do
226
- ln( from, dest, :force => true )
227
- end
228
- [ :gem, :test ].each { |t| task t => [ dest ] }
229
- end
230
-
231
- task :mvn_clean do
232
- remove_dest_jars
233
- sh 'mvn clean'
234
- end
235
- task :clean => :mvn_clean
236
- end
237
-
238
- # Dependencies on "mvn package" including pom.xml, any assembly.xml,
239
- # all files under the "src" directory.
240
- def maven_dependencies
241
- deps = [ 'pom.xml' ]
242
- deps << 'assembly.xml' if File.exist?( 'assembly.xml' )
243
- deps += FileList[ "src/**/*" ].exclude { |f| ! File.file?( f ) }
244
- deps
245
- end
246
-
247
- # Define git based :tag task
248
- def define_git_tag
249
- desc "git tag current version"
250
- task :tag do
251
- tag = [ name, version ].join( '-' )
252
- dname = Rake.original_dir
253
- dname = '.' if Dir.getwd == dname
254
- delta = `git status --porcelain -- #{dname} 2>&1`.split(/^/)
255
- if delta.length > 0
256
- puts delta
257
- raise "Commit these changes before tagging"
258
- end
259
- sh %{git tag -s -f -m "tag [#{tag}]" "#{tag}"}
260
- end
261
- end
262
-
263
- # Define gem push and install tasks
264
- def define_gem_tasks
265
- desc "gem push (gemcutter)"
266
- task :push => [ :gem ] do
267
- require 'rubygems'
268
- require 'rubygems/command_manager'
269
- cm = Gem::CommandManager.instance
270
- cm.run( gem_config( 'push', '-V', gem_file ) )
271
- end
272
-
273
- desc "gem(+maven) install"
274
- task :install => [ :gem ] do
275
- require 'rubygems'
276
- require 'rubygems/command_manager'
277
- cm = Gem::CommandManager.instance
278
- begin
279
- cm.run( gem_config( 'install', '--local', '-V', gem_file ) )
280
- rescue Gem::SystemExitException => x
281
- raise "Install failed (#{x.exit_code})" if x.exit_code != 0
282
- end
283
- end
28
+ load( "#{name}.gemspec", true )
284
29
 
285
- desc "gem install missing/all dev dependencies"
286
- task( :install_deps, :force ) do |t,args|
287
- require 'rubygems'
288
- require 'rubygems/command_manager'
289
- force = ( args[:force] == 'force' )
290
- ( @spec.extra_deps + @spec.extra_dev_deps ).each do |dep|
291
- if force
292
- gem_install_dep( dep )
293
- else
294
- begin
295
- gem( *dep )
296
- rescue Gem::LoadError => e
297
- puts "Gem dep: " + e.to_s
298
- gem_install_dep( dep )
299
- end
300
- end
301
- end
302
- end
303
- end
304
-
305
- def gem_install_dep( dep )
306
- puts "Install: " + dep.inspect
307
- cm = Gem::CommandManager.instance
308
- c = [ 'install', '--remote', '-V', dep.first ]
309
- c += dep[1..-1].map { |r| [ '-v', r ] }.flatten
310
- cm.run( gem_config( *c ) )
311
- rescue Gem::SystemExitException => x
312
- raise "Install failed (#{x.exit_code})" if x.exit_code != 0
313
- end
314
-
315
- def gem_file
316
- parts = [ name, version ]
317
- if @spec
318
- pform = @spec.spec_extras[ :platform ]
319
- parts << 'java' if ( pform && pform.os == 'java' )
320
- end
321
-
322
- "pkg/#{ parts.join( '-' ) }.gem"
323
- end
324
-
325
- def gem_config( command, *args )
326
- cargs = [ 'gem', command ].map do |cmd|
327
- conf = Gem.configuration[ cmd ]
328
- conf.is_a?( String ) ? conf.split( ' ' ) : Array( conf )
329
- end
330
- cargs.flatten!
331
- [ command ] + cargs + args
332
- end
333
-
334
- # Setup Hoe via Hoe.spec
335
- def hoe_specify
336
-
337
- unless @rdoc_diagram
338
- # Silly Hoe sets up DOT with rdoc unless this is set.
339
- ENV['NODOT'] = "no thanks"
340
- end
341
-
342
- unless @hoe_specifier == :unset
343
- tp = self
344
- outer = @hoe_specifier
345
- jplat = @flags.include?( :java_platform )
346
- @spec = Hoe.spec( @name ) do |h|
347
-
348
- h.version = tp.version
349
- h.readme_file = 'README.rdoc' if File.exist?( 'README.rdoc' )
350
- h.history_file = 'History.rdoc' if File.exist?( 'History.rdoc' )
351
- h.extra_rdoc_files = FileList[ '*.rdoc' ]
352
-
353
- h.spec_extras[ :platform ] = Gem::Platform.new( "java" ) if jplat
354
-
355
- outer.call( h )
356
- end
357
- end
358
- end
359
-
360
- # Generate Manifest.txt
361
- def generate_manifest
362
- unless @generated_manifest #only once
363
- remove_dest_jars
364
-
365
- m = []
366
- if File.exist?( 'Manifest.static' )
367
- m += read_file_list( 'Manifest.static' )
368
- end
369
- m += clean_list( generated_files ).sort
370
- m += dest_jars
371
-
372
- puts "TARPIT: Updating Manifest.txt"
373
- open( 'Manifest.txt', 'w' ) { |out| out.puts m }
374
- @generated_manifest = true
375
- end
376
- end
377
-
378
- # Remove jars in jar_dest by wildcard expression
379
- def remove_dest_jars
380
- jars = FileList[ File.join( jar_dest, "*.jar" ) ].sort
381
- rm_f jars unless jars.empty?
382
- end
383
-
384
- # The list of jars in jar_dest path, used during manifest generation
385
- def dest_jars
386
- clean_list( jars ).sort.map { |j| File.join( jar_dest, j ) }
387
- end
388
-
389
- # The target/assembly path from which jars are linked
390
- def jar_from
391
- dirs = [ 'target' ]
392
-
393
- unless @flags.include?( :no_assembly )
394
- dirs << [ @assembly_name || name,
395
- @assembly_version || version,
396
- 'bin.dir' ].join('-')
397
- end
398
-
399
- File.join( dirs )
400
- end
401
-
402
- # Read a list of files and return a cleaned list.
403
- def read_file_list( sfile )
404
- clean_list( open( sfile ) { |f| f.readlines } )
405
- end
406
-
407
- # Cleanup a list of files
408
- def clean_list( l )
409
- l = Array( l ).compact
410
- l.map! { |f| f.strip }
411
- l.map! { |f| f.empty? ? nil : f }
412
- l.compact!
413
- l
414
- end
415
-
416
- end
417
-
418
- # Strategy in which the jars are inferred only by inspecting the
419
- # the completed maven assembly. The :manifest task is thus
420
- # dependent on 'mvn package'. Manifest changes need to be manually
421
- # incorporated by explicitly running "jrake manifest"
422
- class JarsFromAssembly < BaseStrategy
423
-
424
- # Define all tasks based on provided details. Don't invoke
425
- # Manifest.txt before Hoe, just use whats already in place.
426
- def define_tasks
427
- define_maven_package_task
428
-
429
- mtask = define_manifest_task
430
-
431
- task :manifest => [ MVN_STATE_FILE ]
432
-
433
- define_post_maven_tasks
434
-
435
- hoe_specify
436
-
437
- define_git_tag
438
- define_gem_tasks
439
- end
440
-
441
- # For manifest, map destination jars from available jars in
442
- # (jar_from) target/assembly. These are available since mvn
443
- # package will be run first for the :manifest target.
444
- def dest_jars
445
- jars = FileList[ File.join( jar_from, "*.jar" ) ]
446
- jars = jars.map { |j| File.basename( j ) }.sort
447
- jars.map { |j| File.join( jar_dest, j ) }
448
- end
449
-
450
- # Extract jar files from saved Manifest state, since
451
- # neither from or dest jars may be available at call time.
452
- def jars
453
- unless @jars
454
- files = read_file_list( 'Manifest.txt' ).select { |f| f =~ /\.jar$/ }
455
- @jars = files.map { |f| File.basename( f ) }
456
- end
457
- @jars
458
- end
30
+ tp = BaseStrategy.new( last_spec )
459
31
 
32
+ if block_given?
33
+ yield tp
34
+ tp.define_tasks
460
35
  end
461
36
 
37
+ tp
462
38
  end
463
39
 
464
40
  end
465
-
466
- # Replace special Hoe development dependency with rjack-tarpit (which
467
- # itself depends on a constrained version of Hoe.)
468
- class Hoe
469
- # FIXME: Adjust Hoe for rack ~> 0.9.0 until we can update to a hoe
470
- # that includes Rake::DSL itself.
471
- include Rake::DSL if defined?( Rake::DSL )
472
-
473
- def add_dependencies
474
- self.extra_deps = normalize_deps extra_deps
475
- self.extra_dev_deps = normalize_deps extra_dev_deps
476
-
477
- unless name == 'rjack-tarpit'
478
- extra_dev_deps << [ 'rjack-tarpit', "~> #{ RJack::TarPit::VERSION }" ]
479
- end
480
- end
481
- end