pompompom 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.mdown +16 -18
- data/lib/pompompom/config.rb +5 -2
- data/lib/pompompom/rake.rb +35 -33
- data/lib/pompompom.rb +1 -1
- data/pompompom.gemspec +1 -1
- data/spec/pompompom/config_spec.rb +7 -2
- data/spec/pompompom/rake_spec.rb +1 -1
- metadata +3 -3
data/README.mdown
CHANGED
@@ -1,32 +1,30 @@
|
|
1
|
-
# Pom Pom Pom
|
1
|
+
# Pom Pom Pom ♫
|
2
2
|
|
3
|
-
Pom Pom Pom is a
|
3
|
+
Pom Pom Pom is a dependency manager for Maven repository artifacts.
|
4
4
|
|
5
|
-
The following code would download
|
5
|
+
The following code would download Rabbit MQ's AMQP client libraries, and Google Guice, as well as their dependencies into the directory `lib`:
|
6
6
|
|
7
|
-
|
8
|
-
dependencies = dependencies.map { |d| Dependency.parse(d) }
|
9
|
-
repositories = %w(http://repo1.maven.org/maven2)
|
10
|
-
resolver = Resolver.new(repositories)
|
11
|
-
resolver.download('lib', true, *dependencies)
|
12
|
-
|
13
|
-
There will be less verbose ways of doing this in the future. The goal is to be able to use this with rake, like this:
|
7
|
+
require 'pompompom/rake'
|
14
8
|
|
15
9
|
task :dependencies do
|
16
|
-
pompompom
|
10
|
+
pompompom 'com.rabbitmq:amqp-client:1.8.0', 'com.google.inject:guice:2.0'
|
17
11
|
end
|
18
|
-
|
19
|
-
Which would do the same as the code above.
|
20
12
|
|
21
|
-
There is a command line tool that can be used to install artifacts:
|
13
|
+
There is also a command line tool that can be used to install artifacts:
|
22
14
|
|
23
|
-
pompompom com.rabbitmq:amqp-client:1.8.0 com.google.inject:guice:2.0
|
15
|
+
$ pompompom com.rabbitmq:amqp-client:1.8.0 com.google.inject:guice:2.0
|
24
16
|
|
25
|
-
It will
|
17
|
+
It too will download the artifacts and their dependencies into `lib` (relative to the current dir).
|
18
|
+
|
19
|
+
By default Pom Pom Pom will look in the main Maven repository, but you can add more repositories by editing `~/.pompompomrc` (which is created automatically on the first run), or passing `:repositories => [repo1, repo2]` to the `pompompom` function.
|
20
|
+
|
21
|
+
By default downloaded artifacts and POM files are cached in `~/.pompompom`. You can override the cache dir by passing `:cache_dir => 'path/somewhere'`, and the target directory (where the JAR files are saved) by passing `:target_dir => 'path/somewhere'` -- or editing the corresponding keys in the config file.
|
22
|
+
|
23
|
+
Look in the `examples` directory to see a few ways to use Pom Pom Pom in a Rakefile.
|
26
24
|
|
27
|
-
## Why another dependency management tool, why not use Maven, Buildr,
|
25
|
+
## Why another dependency management tool, why not use Maven, Buildr, SBT or Ivy?
|
28
26
|
|
29
|
-
Every time I look at Maven I cringe. Buildr is almost as bad, but hides some of the complexity. Ivy is better, but still too much noisy XML.
|
27
|
+
Every time I look at Maven I cringe. Buildr is almost as bad, but hides some of the complexity. Simple Build Tool just isn't. Sure, they are all more than dependency managers, but that is part of the problem in my view. Ivy is better, but still too much noisy XML.
|
30
28
|
|
31
29
|
Pom Pom Pom is meant to do more or less what Ivy does, but in a way that doesn't make you want to tear out your eyes.
|
32
30
|
|
data/lib/pompompom/config.rb
CHANGED
@@ -23,7 +23,6 @@ module PomPomPom
|
|
23
23
|
@repositories = options[:repositories] || @repositories
|
24
24
|
@target_dir = options[:target_dir] || @target_dir
|
25
25
|
@cache_dir = options[:cache_dir] || @cache_dir
|
26
|
-
@config_file = options[:config_file] || @config_file
|
27
26
|
end
|
28
27
|
|
29
28
|
def file_exists?
|
@@ -33,7 +32,11 @@ module PomPomPom
|
|
33
32
|
def create_file!
|
34
33
|
return if file_exists?
|
35
34
|
File.open(@config_file, 'w') do |f|
|
36
|
-
f.write(YAML.dump(
|
35
|
+
f.write(YAML.dump(
|
36
|
+
'repositories' => @repositories,
|
37
|
+
'cache_dir' => @cache_dir,
|
38
|
+
'target_dir' => @target_dir
|
39
|
+
))
|
37
40
|
end
|
38
41
|
end
|
39
42
|
|
data/lib/pompompom/rake.rb
CHANGED
@@ -2,51 +2,53 @@ require 'pompompom'
|
|
2
2
|
|
3
3
|
|
4
4
|
module PomPomPom
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
5
|
+
module Rake
|
6
|
+
class SimpleLogger
|
7
|
+
def initialize(io)
|
8
|
+
@io = io
|
9
|
+
end
|
10
|
+
def info(msg)
|
11
|
+
@io.puts(msg)
|
12
|
+
end
|
11
13
|
end
|
12
|
-
end
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
15
|
+
class NullLogger
|
16
|
+
def info(msg); end
|
17
|
+
end
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
19
|
+
def pompompom(*args)
|
20
|
+
options = (Hash === args.last) ? args.pop : { }
|
21
|
+
dependencies = args.flatten
|
21
22
|
|
22
|
-
|
23
|
+
logger = NullLogger.new
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
if options[:logger]
|
26
|
+
if options[:logger].respond_to?(:info)
|
27
|
+
logger = options[:logger]
|
28
|
+
elsif options[:logger].respond_to?(:puts)
|
29
|
+
logger = SimpleLogger.new(options[:logger])
|
30
|
+
end
|
29
31
|
end
|
30
|
-
end
|
31
32
|
|
32
|
-
|
33
|
-
|
33
|
+
config = Config.new(options)
|
34
|
+
config.load!
|
34
35
|
|
35
|
-
|
36
|
-
|
36
|
+
downloader = options[:downloader]
|
37
|
+
downloader ||= CachingDownloader.new(config.cache_dir, Downloader.new)
|
37
38
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
39
|
+
resolver = Resolver.new(config.repositories, :downloader => downloader)
|
40
|
+
dependencies = dependencies.map { |d| Dependency.parse(d) }
|
41
|
+
dependencies = resolver.find_transitive_dependencies(*dependencies)
|
42
|
+
dependencies = dependencies.reject { |d| File.exists?(File.join(config.target_dir, d.jar_file_name)) }
|
42
43
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
44
|
+
unless dependencies.empty?
|
45
|
+
dependencies.each do |dependency|
|
46
|
+
logger.info("Loading #{dependency.jar_file_name}")
|
47
|
+
resolver.download!(config.target_dir, false, dependency)
|
48
|
+
end
|
47
49
|
end
|
48
50
|
end
|
49
51
|
end
|
50
52
|
end
|
51
53
|
|
52
|
-
include PomPomPom
|
54
|
+
include PomPomPom::Rake
|
data/lib/pompompom.rb
CHANGED
data/pompompom.gemspec
CHANGED
@@ -27,10 +27,12 @@ module PomPomPom
|
|
27
27
|
describe '#load!' do
|
28
28
|
it 'loads the config file' do
|
29
29
|
config_file = File.join(@tmp_dir, '.pom3rc')
|
30
|
-
File.open(config_file, 'w') { |f| f.write(YAML::dump(:repositories => %w(repo1 repo2))) }
|
30
|
+
File.open(config_file, 'w') { |f| f.write(YAML::dump(:cache_dir => 'cache', :target_dir => 'deps', :repositories => %w(repo1 repo2))) }
|
31
31
|
config = Config.new(:config_file => config_file)
|
32
32
|
config.load!
|
33
33
|
config.repositories.should == %w(repo1 repo2)
|
34
|
+
config.target_dir.should == 'deps'
|
35
|
+
config.cache_dir.should == 'cache'
|
34
36
|
end
|
35
37
|
end
|
36
38
|
|
@@ -62,7 +64,10 @@ module PomPomPom
|
|
62
64
|
|
63
65
|
it 'creates the file and puts the standard repository list in it' do
|
64
66
|
@config.create_file!
|
65
|
-
YAML.load(File.read(@config_file))
|
67
|
+
config_data = YAML.load(File.read(@config_file))
|
68
|
+
config_data['repositories'].should == %w(http://repo1.maven.org/maven2)
|
69
|
+
config_data['cache_dir'].should == File.expand_path('~/.pompompom')
|
70
|
+
config_data['target_dir'].should == 'lib'
|
66
71
|
end
|
67
72
|
|
68
73
|
it 'doesn\'t clobber existing files' do
|
data/spec/pompompom/rake_spec.rb
CHANGED
@@ -12,7 +12,7 @@ describe 'rake' do
|
|
12
12
|
@lib_dir = File.join(@tmp_dir, 'lib')
|
13
13
|
@repo_dir = File.join(@tmp_dir, 'repo')
|
14
14
|
@config_file = File.join(@tmp_dir, '.pompompomrc')
|
15
|
-
@downloader = FilesystemDownloader.new
|
15
|
+
@downloader = PomPomPom::FilesystemDownloader.new
|
16
16
|
@dependencies = %w(com.rabbitmq:amqp-client:1.8.0 com.google.inject:guice:2.0)
|
17
17
|
end
|
18
18
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pompompom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 1.1.
|
9
|
+
- 1
|
10
|
+
version: 1.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Theo Hultberg
|