pompompom 2.0.0.b0-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/bin/pombundle ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $: << File.expand_path('../../lib', __FILE__)
4
+
5
+ require 'bundler'
6
+ require 'pompompom/bundler'
7
+
8
+ load ENV['PATH'].split(File::PATH_SEPARATOR).map { |path| File.join(path, 'bundle') }.find { |path| File.exists?(path) }
data/bin/pompompom ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ $: << File.expand_path('../../lib', __FILE__)
5
+
6
+ require 'pompompom'
7
+
8
+
9
+ PomPomPom::Runner.run(*ARGV)
data/lib/ivy.rb ADDED
@@ -0,0 +1,13 @@
1
+ # encoding: utf-8
2
+
3
+ require 'ivy-jars'
4
+
5
+
6
+ module Ivy
7
+ import 'org.apache.ivy.Ivy'
8
+ import 'org.apache.ivy.core.module.id.ModuleRevisionId'
9
+ import 'org.apache.ivy.core.install.InstallOptions'
10
+ import 'org.apache.ivy.plugins.resolver.FileSystemResolver'
11
+ import 'org.apache.ivy.plugins.resolver.IBiblioResolver'
12
+ end
13
+
data/lib/pompompom.rb ADDED
@@ -0,0 +1,73 @@
1
+ # encoding: utf-8
2
+
3
+ require 'yaml'
4
+ require 'ivy'
5
+
6
+
7
+ module PomPomPom
8
+ class Runner
9
+ def self.run(*args)
10
+ new.run(*args)
11
+ end
12
+
13
+ def initialize(configuration={})
14
+ @configuration = load_configuration(configuration)
15
+ @installer = Installer.new(@configuration)
16
+ end
17
+
18
+ def run(*coordinates)
19
+ all_coordinates(coordinates).each do |coordinate|
20
+ @installer.install(coordinate)
21
+ end
22
+ end
23
+
24
+ private
25
+
26
+ def load_configuration(extra_config)
27
+ repositories = {}
28
+ dependencies = []
29
+ destination = 'lib/ext'
30
+ if File.exists?('.pompompom')
31
+ c = YAML.load(File.read('.pompompom'))
32
+ repositories = c['repositories'] if c['repositories']
33
+ dependencies = c['dependencies'] if c['dependencies']
34
+ destination = c['destination'] if c['destination']
35
+ end
36
+ destination = extra_config[:destination] if extra_config[:destination]
37
+ {
38
+ :repositories => create_repositories(repositories.merge(extra_config[:repositories])),
39
+ :dependencies => (dependencies + extra_config[:dependencies]).uniq,
40
+ :install_pattern => File.expand_path("#{destination}/[artifact]-[revision]-[type].[ext]")
41
+ }
42
+ end
43
+
44
+ def all_coordinates(extra_coordinates)
45
+ create_coordinates(@configuration[:dependencies] + extra_coordinates)
46
+ end
47
+
48
+ def create_coordinates(coordinates)
49
+ coordinates.map do |coordinate|
50
+ case coordinate
51
+ when MavenCoordinate
52
+ coordinate
53
+ when Array
54
+ MavenCoordinate.new(*coordinate)
55
+ when /^[^:]+:[^:]+:[^:]+$/ # TODO: also /^[^#]+#[^;];.+$/
56
+ MavenCoordinate.parse(coordinate)
57
+ else
58
+ raise ArgumentError, %("#{coordinate}" could not be converted to a Maven coordinate)
59
+ end
60
+ end.compact
61
+ end
62
+
63
+ def create_repositories(repos)
64
+ repos.map do |name, url|
65
+ MavenRepository.new(name, url)
66
+ end
67
+ end
68
+ end
69
+ end
70
+
71
+ require 'pompompom/maven_repository'
72
+ require 'pompompom/maven_coordinate'
73
+ require 'pompompom/installer'
@@ -0,0 +1,110 @@
1
+ # encoding: utf-8
2
+
3
+ require 'pompompom'
4
+
5
+
6
+ module PomPomPom
7
+ class MavenCoordinateAdapter
8
+ attr_reader :coordinate
9
+
10
+ def initialize(coordinate)
11
+ @coordinate = coordinate
12
+ end
13
+
14
+ begin :bundler_compatibility
15
+ def source
16
+ nil
17
+ end
18
+
19
+ def name
20
+ @name ||= "#@coordinate.group_id:#@coordinate.artifact_id"
21
+ end
22
+
23
+ def gem_platforms(valid_platforms)
24
+ if valid_platforms.include?(Gem::Platform::JAVA)
25
+ [Gem::Platform::JAVA]
26
+ else
27
+ []
28
+ end
29
+ end
30
+
31
+ def requirement
32
+ Gem::Requirement.create([])
33
+ end
34
+ end
35
+ end
36
+
37
+ class MavenRepositoryAdapter
38
+ attr_reader :repository
39
+
40
+ def initialize(repository)
41
+ @repository = repository
42
+ end
43
+
44
+ begin :bundler_compatibility
45
+ def specs
46
+ Bundler::Index.new
47
+ end
48
+
49
+ def to_lock
50
+ ''
51
+ end
52
+ end
53
+ end
54
+
55
+ class ArtifactInstaller
56
+ def initialize(*args)
57
+ @root, @definition = args
58
+ repositories = @definition.mvn_sources.map(&:repository)
59
+ @installer = PomPomPom::Installer.new(:repositories => repositories)
60
+ end
61
+
62
+ def run(options)
63
+ coordinates = @definition.mvn_dependencies.map(&:coordinate)
64
+ coordinates.each do |coordinate|
65
+ @installer.install(coordinate)
66
+ end
67
+ end
68
+ end
69
+ end
70
+
71
+ module Bundler
72
+ class Dsl
73
+ def mvn(group, artifact, version)
74
+ @dependencies << PomPomPom::MavenCoordinateAdapter.new(PomPomPom::MavenCoordinate.new(group, artifact, version))
75
+ end
76
+
77
+ def mvn_source(url, options={})
78
+ @sources << PomPomPom::MavenRepositoryAdapter.new(PomPomPom::MavenRepository.new(options[:name], url))
79
+ end
80
+ end
81
+
82
+ class Definition
83
+ def dependencies
84
+ @dependencies.reject { |d| d.is_a?(PomPomPom::MavenCoordinateAdapter) }
85
+ end
86
+
87
+ def mvn_dependencies
88
+ @dependencies.select { |d| d.is_a?(PomPomPom::MavenCoordinateAdapter) }
89
+ end
90
+
91
+ def sources
92
+ @sources.reject { |d| d.is_a?(PomPomPom::MavenRepositoryAdapter) }
93
+ end
94
+
95
+ def mvn_sources
96
+ @sources.select { |d| d.is_a?(PomPomPom::MavenRepositoryAdapter) }
97
+ end
98
+ end
99
+
100
+ class Installer
101
+ class << self
102
+ alias_method :_original_install, :install
103
+
104
+ def install(root, definition, options={})
105
+ _original_install(root, definition, options)
106
+ PomPomPom::ArtifactInstaller.new(root, definition).run(options)
107
+ end
108
+ end
109
+ end
110
+ end
@@ -0,0 +1,64 @@
1
+ # encoding: utf-8
2
+
3
+ require 'yaml'
4
+ require 'ivy'
5
+
6
+
7
+ module PomPomPom
8
+ class Installer
9
+ def initialize(configuration={})
10
+ @configuration = configuration
11
+ end
12
+
13
+ def install(coordinate)
14
+ ivy.install(
15
+ coordinate.to_ivy_module_id,
16
+ ivy.settings.default_resolver.name,
17
+ INSTALL_RESOLVER_NAME,
18
+ install_options
19
+ )
20
+ end
21
+
22
+ private
23
+
24
+ INSTALL_RESOLVER_NAME = 'install'.freeze
25
+
26
+ def ivy
27
+ @ivy ||= begin
28
+ ivy = Ivy::Ivy.new_instance
29
+ ivy.configure_default
30
+ ivy.settings.add_resolver(create_install_resolver)
31
+ repositories.each do |repository|
32
+ resolver = repository.to_ivy_resolver
33
+ resolver.settings = ivy.settings
34
+ ivy.settings.default_resolver.add(resolver)
35
+ end
36
+ ivy
37
+ end
38
+ end
39
+
40
+ def create_install_resolver
41
+ install_resolver = Ivy::FileSystemResolver.new
42
+ install_resolver.name = INSTALL_RESOLVER_NAME
43
+ install_resolver.add_ivy_pattern(install_pattern)
44
+ install_resolver.add_artifact_pattern(install_pattern)
45
+ install_resolver
46
+ end
47
+
48
+ def install_options
49
+ @install_options ||= begin
50
+ install_options = Ivy::InstallOptions.new
51
+ install_options.set_overwrite(true)
52
+ install_options
53
+ end
54
+ end
55
+
56
+ def install_pattern
57
+ @configuration[:install_pattern]
58
+ end
59
+
60
+ def repositories
61
+ @configuration[:repositories]
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,48 @@
1
+ # encoding: utf-8
2
+
3
+ module PomPomPom
4
+ class MavenCoordinate
5
+ def self.parse(str)
6
+ new(*str.split(':'))
7
+ end
8
+
9
+ attr_reader :group_id, :artifact_id, :version
10
+
11
+ def initialize(*args)
12
+ @group_id, @artifact_id, @version = args
13
+ end
14
+
15
+ begin :conversions
16
+ def to_s
17
+ "#{group_id}:#{artifact_id}:#{version}"
18
+ end
19
+
20
+ def to_ivy_module_id
21
+ Ivy::ModuleRevisionId.new_instance(group_id, artifact_id, version)
22
+ end
23
+ end
24
+
25
+ begin :comparisons
26
+ def <=>(other)
27
+ d = self.group_id <=> other.group_id
28
+ return d unless d == 0
29
+ d = self.artifact_id <=> other.artifact_id
30
+ return d unless d == 0
31
+ d = self.version <=> other.version
32
+ return d
33
+ end
34
+
35
+ def eql?(other)
36
+ (self <=> other) == 0
37
+ end
38
+
39
+ def hash
40
+ @hash ||= begin
41
+ h = 0
42
+ [group_id, artifact_id, version].each { |p| h = (h & 33554431) * 31 ^ p.hash }
43
+ h
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,21 @@
1
+ # encoding: utf-8
2
+
3
+ module PomPomPom
4
+ class MavenRepository
5
+ attr_reader :name, :url
6
+
7
+ def initialize(name, url)
8
+ @url = url
9
+ @name = name
10
+ @name = @url[%r{^https?://([^:/]+).*$}, 1] unless @name
11
+ end
12
+
13
+ def to_ivy_resolver
14
+ resolver = Ivy::IBiblioResolver.new
15
+ resolver.name = @name
16
+ resolver.root = @url
17
+ resolver.set_m2compatible(true)
18
+ resolver
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,3 @@
1
+ module PomPomPom
2
+ VERSION = '2.0.0.b0'
3
+ end
metadata ADDED
@@ -0,0 +1,73 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pompompom
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: 6
5
+ version: 2.0.0.b0
6
+ platform: java
7
+ authors:
8
+ - Theo Hultberg
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2012-06-10 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: ivy-jars
17
+ prerelease: false
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 2.2.0
24
+ type: :runtime
25
+ version_requirements: *id001
26
+ description: Painless JAR dependency management for JRuby
27
+ email:
28
+ - theo@iconara.net
29
+ executables:
30
+ - pompompom
31
+ extensions: []
32
+
33
+ extra_rdoc_files: []
34
+
35
+ files:
36
+ - lib/ivy.rb
37
+ - lib/pompompom/bundler.rb
38
+ - lib/pompompom/installer.rb
39
+ - lib/pompompom/maven_coordinate.rb
40
+ - lib/pompompom/maven_repository.rb
41
+ - lib/pompompom/version.rb
42
+ - lib/pompompom.rb
43
+ - bin/pombundle
44
+ - bin/pompompom
45
+ homepage: http://github.com/iconara/pompompom
46
+ licenses: []
47
+
48
+ post_install_message:
49
+ rdoc_options: []
50
+
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: "0"
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ">"
63
+ - !ruby/object:Gem::Version
64
+ version: 1.3.1
65
+ requirements: []
66
+
67
+ rubyforge_project: pompompom
68
+ rubygems_version: 1.8.11
69
+ signing_key:
70
+ specification_version: 3
71
+ summary: Dependency manager for JRuby
72
+ test_files: []
73
+