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.
- data/History.rdoc +13 -9
- data/Manifest.txt +39 -0
- data/NOTICE.txt +1 -1
- data/README.rdoc +85 -30
- data/Rakefile +11 -30
- data/lib/rjack-tarpit.rb +15 -456
- data/lib/rjack-tarpit/base.rb +22 -0
- data/lib/rjack-tarpit/base_strategy.rb +175 -0
- data/lib/rjack-tarpit/clean.rb +43 -0
- data/lib/rjack-tarpit/doc.rb +67 -0
- data/lib/rjack-tarpit/gem.rb +119 -0
- data/lib/rjack-tarpit/git.rb +45 -0
- data/lib/rjack-tarpit/line_match.rb +134 -0
- data/lib/rjack-tarpit/readme_parser.rb +74 -0
- data/lib/rjack-tarpit/spec.rb +314 -0
- data/lib/rjack-tarpit/test.rb +110 -0
- data/lib/rjack-tarpit/util.rb +37 -0
- data/test/jproject/History.rdoc +2 -0
- data/test/jproject/Manifest.static +10 -0
- data/test/jproject/Manifest.txt +11 -0
- data/test/jproject/NOTICE.txt +2 -0
- data/test/jproject/README.rdoc +24 -0
- data/test/jproject/Rakefile +7 -0
- data/test/jproject/jproject.gemspec +15 -0
- data/test/jproject/lib/jproject.rb +11 -0
- data/test/jproject/lib/jproject/base.rb +3 -0
- data/test/jproject/pom.xml +75 -0
- data/test/jproject/test/setup.rb +7 -0
- data/test/jproject/test/test_jproject.rb +14 -0
- data/test/setup.rb +7 -0
- data/test/test_projects.rb +71 -0
- data/test/test_readme_parser.rb +97 -0
- data/test/test_tarpit.rb +33 -0
- data/test/zookeeper/History.rdoc +2 -0
- data/test/zookeeper/Manifest.static +10 -0
- data/test/zookeeper/Manifest.txt +13 -0
- data/test/zookeeper/README.rdoc +23 -0
- data/test/zookeeper/Rakefile +7 -0
- data/test/zookeeper/assembly.xml +15 -0
- data/test/zookeeper/lib/rjack-zookeeper.rb +29 -0
- data/test/zookeeper/lib/rjack-zookeeper/base.rb +23 -0
- data/test/zookeeper/pom.xml +73 -0
- data/test/zookeeper/rjack-zookeeper.gemspec +18 -0
- data/test/zookeeper/test/setup.rb +17 -0
- data/test/zookeeper/{pkg/rjack-zookeeper-3.4.1.0-java/test → test}/test_zookeeper.rb +0 -0
- metadata +132 -66
- data/.gemtest +0 -0
@@ -0,0 +1,22 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2009-2012 David Kellum
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you
|
5
|
+
# may not use this file except in compliance with the License. You
|
6
|
+
# may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
13
|
+
# implied. See the License for the specific language governing
|
14
|
+
# permissions and limitations under the License.
|
15
|
+
#++
|
16
|
+
|
17
|
+
module RJack
|
18
|
+
module TarPit
|
19
|
+
MINOR_VERSION = '2.0'
|
20
|
+
VERSION = MINOR_VERSION + '.0'
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,175 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2009-2012 David Kellum
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you
|
5
|
+
# may not use this file except in compliance with the License. You
|
6
|
+
# may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
13
|
+
# implied. See the License for the specific language governing
|
14
|
+
# permissions and limitations under the License.
|
15
|
+
#++
|
16
|
+
|
17
|
+
require 'rjack-tarpit/base'
|
18
|
+
require 'rjack-tarpit/util'
|
19
|
+
require 'rjack-tarpit/spec'
|
20
|
+
|
21
|
+
require 'rjack-tarpit/test'
|
22
|
+
require 'rjack-tarpit/gem'
|
23
|
+
require 'rjack-tarpit/clean'
|
24
|
+
require 'rjack-tarpit/line_match'
|
25
|
+
require 'rjack-tarpit/doc'
|
26
|
+
require 'rjack-tarpit/git'
|
27
|
+
|
28
|
+
module RJack::TarPit
|
29
|
+
|
30
|
+
# Base class for Rake task generation.
|
31
|
+
class BaseStrategy
|
32
|
+
|
33
|
+
#For rack ~> 0.9.0
|
34
|
+
include Rake::DSL if defined?( Rake::DSL )
|
35
|
+
|
36
|
+
include TestTaskDefiner
|
37
|
+
include GemTaskDefiner
|
38
|
+
include CleanTaskDefiner
|
39
|
+
include LineMatchTaskDefiner
|
40
|
+
include DocTaskDefiner
|
41
|
+
include GitTaskDefiner
|
42
|
+
|
43
|
+
include Util
|
44
|
+
|
45
|
+
# The augmented Gem::Specification as constructed.
|
46
|
+
attr_reader :spec
|
47
|
+
|
48
|
+
# See TarPit.new
|
49
|
+
def initialize( spec )
|
50
|
+
@defines = [ :define_maven_tasks ]
|
51
|
+
super()
|
52
|
+
|
53
|
+
@spec = spec
|
54
|
+
|
55
|
+
@install_request = Rake.application.top_level_tasks.include?( "install" )
|
56
|
+
end
|
57
|
+
|
58
|
+
def add_define_hook( sym )
|
59
|
+
@defines << sym
|
60
|
+
end
|
61
|
+
|
62
|
+
# Define rake tasks (given settings)
|
63
|
+
def define_tasks
|
64
|
+
@defines.each { |sym| send( sym ) }
|
65
|
+
end
|
66
|
+
|
67
|
+
# Define maven tasks based on spec strategy and other details.
|
68
|
+
def define_maven_tasks
|
69
|
+
from_assembly = ( spec.maven_strategy == :jars_from_assembly )
|
70
|
+
do_maven = from_assembly || spec.jars.size > 0
|
71
|
+
|
72
|
+
define_maven_package_task if do_maven
|
73
|
+
|
74
|
+
if do_maven || spec.generated_files
|
75
|
+
define_manifest_task
|
76
|
+
task( :manifest => [ MVN_STATE_FILE ] ) if from_assembly
|
77
|
+
end
|
78
|
+
|
79
|
+
define_post_maven_tasks if do_maven
|
80
|
+
end
|
81
|
+
|
82
|
+
# Define task for dynamically generating Manifest.txt
|
83
|
+
def define_manifest_task
|
84
|
+
|
85
|
+
if File.exist?( 'Manifest.static' )
|
86
|
+
file 'Manifest.txt' => [ 'Manifest.static' ]
|
87
|
+
end
|
88
|
+
|
89
|
+
gf = clean_list( spec.generated_files ).sort
|
90
|
+
[ :gem, :test ].each { |t| task t => gf }
|
91
|
+
|
92
|
+
unless gf.empty?
|
93
|
+
task :gen_clean do
|
94
|
+
rm_f gf
|
95
|
+
end
|
96
|
+
task :clean => :gen_clean
|
97
|
+
end
|
98
|
+
|
99
|
+
desc "Force update of Manifest.txt"
|
100
|
+
task :manifest do
|
101
|
+
spec.generate_manifest
|
102
|
+
end
|
103
|
+
|
104
|
+
mtask = file 'Manifest.txt' do
|
105
|
+
spec.generate_manifest
|
106
|
+
end
|
107
|
+
|
108
|
+
mtask
|
109
|
+
end
|
110
|
+
|
111
|
+
# File touched to record the time of last successful 'mvn
|
112
|
+
# package' run.
|
113
|
+
MVN_STATE_FILE = 'target/.tarpit'
|
114
|
+
MVN_STATE_FILE_INSTALL = 'target/.tarpit-install'
|
115
|
+
|
116
|
+
# Define a file task tracking calls to "mvn package"
|
117
|
+
def define_maven_package_task
|
118
|
+
[ MVN_STATE_FILE, MVN_STATE_FILE_INSTALL ].each do |sf|
|
119
|
+
file sf => maven_dependencies do
|
120
|
+
run_maven
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
task :install => MVN_STATE_FILE_INSTALL
|
125
|
+
end
|
126
|
+
|
127
|
+
# Run Maven mvn package or install and touch state files.
|
128
|
+
def run_maven
|
129
|
+
# Delay till now, in case we were not running on jvm
|
130
|
+
require 'rjack-maven'
|
131
|
+
|
132
|
+
target = @install_request ? 'install' : 'package'
|
133
|
+
|
134
|
+
status = RJack::Maven.launch( [ target ] )
|
135
|
+
unless status == 0
|
136
|
+
raise "TARPIT: Maven #{target} failed (exit code: #{status})"
|
137
|
+
end
|
138
|
+
|
139
|
+
touch( MVN_STATE_FILE )
|
140
|
+
touch( MVN_STATE_FILE_INSTALL ) if @install_request
|
141
|
+
end
|
142
|
+
|
143
|
+
# Define file tasks for all jar symlinks and other misc. maven
|
144
|
+
# associated tasks like :mvn_clean.
|
145
|
+
def define_post_maven_tasks
|
146
|
+
jfrom = spec.jar_from
|
147
|
+
spec.jars.each do |jar|
|
148
|
+
from = File.join( jfrom, jar )
|
149
|
+
dest = File.join( spec.jar_dest, jar )
|
150
|
+
file from => [ MVN_STATE_FILE ]
|
151
|
+
file dest => [ from ] do
|
152
|
+
ln( from, dest, :force => true )
|
153
|
+
end
|
154
|
+
[ :gem, :test ].each { |t| task t => [ dest ] }
|
155
|
+
end
|
156
|
+
|
157
|
+
task :mvn_clean do
|
158
|
+
spec.remove_dest_jars
|
159
|
+
rm_rf 'target' if File.directory?( 'target' )
|
160
|
+
end
|
161
|
+
task :clean => :mvn_clean
|
162
|
+
end
|
163
|
+
|
164
|
+
# Dependencies on "mvn package" including pom.xml, any assembly.xml,
|
165
|
+
# all files under the "src" directory.
|
166
|
+
def maven_dependencies
|
167
|
+
deps = [ 'pom.xml' ]
|
168
|
+
deps << 'assembly.xml' if File.exist?( 'assembly.xml' )
|
169
|
+
deps += FileList[ "src/**/*" ].exclude { |f| ! File.file?( f ) }
|
170
|
+
deps
|
171
|
+
end
|
172
|
+
|
173
|
+
end
|
174
|
+
|
175
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2009-2012 David Kellum
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you
|
5
|
+
# may not use this file except in compliance with the License. You may
|
6
|
+
# obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
13
|
+
# implied. See the License for the specific language governing
|
14
|
+
# permissions and limitations under the License.
|
15
|
+
#++
|
16
|
+
|
17
|
+
module RJack::TarPit
|
18
|
+
|
19
|
+
module CleanTaskDefiner
|
20
|
+
|
21
|
+
# An array of file patterns to delete on clean.
|
22
|
+
attr_accessor :clean_globs
|
23
|
+
|
24
|
+
def initialize
|
25
|
+
super
|
26
|
+
|
27
|
+
@clean_globs ||= %w[ .source_index **/*~ **/.*~ ]
|
28
|
+
|
29
|
+
add_define_hook( :define_clean_tasks )
|
30
|
+
end
|
31
|
+
|
32
|
+
def define_clean_tasks
|
33
|
+
desc 'Clean up (common backup file patterns)'
|
34
|
+
task :clean do
|
35
|
+
globs = clean_globs + [ 'pkg', rdoc_dir ]
|
36
|
+
files = globs.map { |p| Dir[ p ] }.flatten
|
37
|
+
rm_rf( files, :verbose => true ) unless files.empty?
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2009-2012 David Kellum
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you
|
5
|
+
# may not use this file except in compliance with the License. You may
|
6
|
+
# obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
13
|
+
# implied. See the License for the specific language governing
|
14
|
+
# permissions and limitations under the License.
|
15
|
+
#++
|
16
|
+
|
17
|
+
module RJack::TarPit
|
18
|
+
|
19
|
+
module DocTaskDefiner
|
20
|
+
|
21
|
+
# Local destination directory for RDoc generated files.
|
22
|
+
# (default: doc)
|
23
|
+
attr_accessor :rdoc_dir
|
24
|
+
|
25
|
+
# Remote destinations array for publish_rdoc. (default: [])
|
26
|
+
attr_accessor :rdoc_destinations
|
27
|
+
|
28
|
+
# Rsync flags for publish_rdoc. (default: %w[ -a -u -i ])
|
29
|
+
attr_accessor :publish_rdoc_rsync_flags
|
30
|
+
|
31
|
+
def initialize
|
32
|
+
super
|
33
|
+
|
34
|
+
@rdoc_dir = 'doc'
|
35
|
+
@rdoc_destinations = []
|
36
|
+
@publish_rdoc_rsync_flags = %w[ -a -u -i ]
|
37
|
+
|
38
|
+
add_define_hook( :define_doc_tasks )
|
39
|
+
end
|
40
|
+
|
41
|
+
def define_doc_tasks
|
42
|
+
require 'rdoc/task'
|
43
|
+
|
44
|
+
RDoc::Task.new( :rdoc ) do |t|
|
45
|
+
t.rdoc_dir = rdoc_dir
|
46
|
+
t.rdoc_files += spec.require_paths
|
47
|
+
t.rdoc_files += spec.extra_rdoc_files
|
48
|
+
t.options = spec.rdoc_options
|
49
|
+
end
|
50
|
+
|
51
|
+
unless rdoc_destinations.empty?
|
52
|
+
desc "Publish rdoc to #{ rdoc_destinations.join( ', ' ) }"
|
53
|
+
task :publish_rdoc => [ :docs ] do
|
54
|
+
rdoc_destinations.each do |dest|
|
55
|
+
sh( *[ 'rsync', publish_rdoc_rsync_flags,
|
56
|
+
rdoc_dir + '/', dest ].flatten )
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
desc "Alias rdoc task"
|
62
|
+
task :docs => [ :rdoc ]
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
@@ -0,0 +1,119 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2009-2012 David Kellum
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you
|
5
|
+
# may not use this file except in compliance with the License. You may
|
6
|
+
# obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
13
|
+
# implied. See the License for the specific language governing
|
14
|
+
# permissions and limitations under the License.
|
15
|
+
#++
|
16
|
+
|
17
|
+
require 'rubygems/package_task'
|
18
|
+
|
19
|
+
module RJack::TarPit
|
20
|
+
|
21
|
+
module GemTaskDefiner
|
22
|
+
|
23
|
+
# Should package create a tarball? (default: false)
|
24
|
+
attr_accessor :need_tar
|
25
|
+
|
26
|
+
# Should package create a zipfile? (default: false)
|
27
|
+
attr_accessor :need_zip
|
28
|
+
|
29
|
+
def initialize
|
30
|
+
super
|
31
|
+
|
32
|
+
@need_tar = false
|
33
|
+
@need_zip = false
|
34
|
+
|
35
|
+
add_define_hook( :define_gem_tasks )
|
36
|
+
end
|
37
|
+
|
38
|
+
def define_gem_tasks
|
39
|
+
|
40
|
+
Gem::PackageTask.new( spec ) do |pkg|
|
41
|
+
pkg.need_tar = @need_tar
|
42
|
+
pkg.need_zip = @need_zip
|
43
|
+
end
|
44
|
+
|
45
|
+
desc 'Dump plain ruby Gem::Specification'
|
46
|
+
task :debug_gem do
|
47
|
+
puts spec.to_ruby
|
48
|
+
end
|
49
|
+
|
50
|
+
desc "gem push (gemcutter)"
|
51
|
+
task :push => [ :gem ] do
|
52
|
+
require 'rubygems'
|
53
|
+
require 'rubygems/command_manager'
|
54
|
+
cm = Gem::CommandManager.instance
|
55
|
+
cm.run( gem_config( 'push', '-V', gem_file ) )
|
56
|
+
end
|
57
|
+
|
58
|
+
desc "gem(+maven) install"
|
59
|
+
task :install => [ :gem ] do
|
60
|
+
require 'rubygems'
|
61
|
+
require 'rubygems/command_manager'
|
62
|
+
cm = Gem::CommandManager.instance
|
63
|
+
begin
|
64
|
+
cm.run( gem_config( 'install', '--local', '-V', gem_file ) )
|
65
|
+
rescue Gem::SystemExitException => x
|
66
|
+
raise "Install failed (#{x.exit_code})" if x.exit_code != 0
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
desc "gem install missing/all dev dependencies"
|
71
|
+
task( :install_deps, :force ) do |t,args|
|
72
|
+
require 'rubygems'
|
73
|
+
require 'rubygems/command_manager'
|
74
|
+
force = ( args[:force] == 'force' )
|
75
|
+
( @spec.extra_deps + @spec.extra_dev_deps ).each do |dep|
|
76
|
+
if force
|
77
|
+
gem_install_dep( dep )
|
78
|
+
else
|
79
|
+
begin
|
80
|
+
gem( *dep )
|
81
|
+
rescue Gem::LoadError => e
|
82
|
+
puts "Gem dep: " + e.to_s
|
83
|
+
gem_install_dep( dep )
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def gem_install_dep( dep )
|
91
|
+
puts "Install: " + dep.inspect
|
92
|
+
cm = Gem::CommandManager.instance
|
93
|
+
c = [ 'install', '--remote', '-V', dep.first ]
|
94
|
+
c += dep[1..-1].map { |r| [ '-v', r ] }.flatten
|
95
|
+
cm.run( gem_config( *c ) )
|
96
|
+
rescue Gem::SystemExitException => x
|
97
|
+
raise "Install failed (#{x.exit_code})" if x.exit_code != 0
|
98
|
+
end
|
99
|
+
|
100
|
+
def gem_file
|
101
|
+
parts = [ spec.name, spec.version ]
|
102
|
+
p = spec.platform
|
103
|
+
parts << 'java' if p.respond_to?( :os ) && p.os == 'java'
|
104
|
+
|
105
|
+
"pkg/#{ parts.join( '-' ) }.gem"
|
106
|
+
end
|
107
|
+
|
108
|
+
def gem_config( command, *args )
|
109
|
+
cargs = [ 'gem', command ].map do |cmd|
|
110
|
+
conf = Gem.configuration[ cmd ]
|
111
|
+
conf.is_a?( String ) ? conf.split( ' ' ) : Array( conf )
|
112
|
+
end
|
113
|
+
cargs.flatten!
|
114
|
+
[ command ] + cargs + args
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|
118
|
+
|
119
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2009-2012 David Kellum
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you
|
5
|
+
# may not use this file except in compliance with the License. You may
|
6
|
+
# obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
13
|
+
# implied. See the License for the specific language governing
|
14
|
+
# permissions and limitations under the License.
|
15
|
+
#++
|
16
|
+
|
17
|
+
module RJack::TarPit
|
18
|
+
|
19
|
+
module GitTaskDefiner
|
20
|
+
|
21
|
+
def initialize
|
22
|
+
super
|
23
|
+
|
24
|
+
add_define_hook( :define_git_tasks )
|
25
|
+
end
|
26
|
+
|
27
|
+
# Define git based :tag task
|
28
|
+
def define_git_tasks
|
29
|
+
desc "git tag current version"
|
30
|
+
task :tag do
|
31
|
+
tag = [ spec.name, spec.version ].join( '-' )
|
32
|
+
dname = Rake.original_dir
|
33
|
+
dname = '.' if Dir.getwd == dname
|
34
|
+
delta = `git status --porcelain -- #{dname} 2>&1`.split(/^/)
|
35
|
+
if delta.length > 0
|
36
|
+
puts delta
|
37
|
+
raise "Commit these changes before tagging"
|
38
|
+
end
|
39
|
+
sh %{git tag -s -f -m "tag [#{tag}]" "#{tag}"}
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|