jbundler 0.3.0 → 0.3.1
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/Gemfile.lock +2 -2
- data/lib/commands/abstract_command.rb~ +113 -0
- data/lib/commands/install_with_jars.rb~ +22 -0
- data/lib/commands/nexus.rb~ +38 -0
- data/lib/commands/push.rb~ +38 -0
- data/lib/jars.rb~ +3 -0
- data/lib/jbundler/aether.rb +2 -2
- data/lib/jbundler.jar +0 -0
- data/lib/rubygems_plugin.rb~ +6 -0
- metadata +8 -22
- data/Test.md +0 -0
- data/lib/jbundler/aether.rb~ +0 -68
- data/lib/jbundler/classpath_file.rb~ +0 -207
- data/lib/jbundler/cli.rb~ +0 -5
- data/lib/jbundler/config.rb~ +0 -145
- data/lib/jbundler/gemfile_lock.rb~ +0 -17
- data/lib/jbundler/lazy.rb~ +0 -24
- data/lib/jbundler/maven.rb~ +0 -252
- data/lib/jbundler/maven_gemify3.rb~ +0 -337
- data/lib/jbundler/maven_util.rb~ +0 -46
- data/lib/jbundler/maven_version.rb~ +0 -4
- data/lib/jbundler/mavenfile.rb~ +0 -9
- data/lib/jbundler/pom.rb~ +0 -251
- data/lib/jbundler.rb~ +0 -2
- data/spec/aether_spec.rb~ +0 -101
- data/spec/classpath_file_spec.rb~ +0 -81
- data/spec/maven_util_spec.rb~ +0 -33
- data/spec/mavenfile_spec.rb~ +0 -40
- data/spec/pom_spec.rb~ +0 -40
- data/spec/setup.rb~ +0 -3
data/Gemfile.lock
CHANGED
@@ -0,0 +1,113 @@
|
|
1
|
+
require 'rubygems/local_remote_options'
|
2
|
+
|
3
|
+
class Gem::AbstractCommand < Gem::Command
|
4
|
+
include Gem::LocalRemoteOptions
|
5
|
+
|
6
|
+
def gemcutter_url
|
7
|
+
ENV['GEMCUTTER_URL'] || 'https://gemcutter.org'
|
8
|
+
end
|
9
|
+
|
10
|
+
def setup
|
11
|
+
use_proxy! if http_proxy
|
12
|
+
sign_in unless api_key
|
13
|
+
end
|
14
|
+
|
15
|
+
def sign_in
|
16
|
+
say "Enter your Gemcutter credentials. Don't have an account yet? Create one at http://gemcutter.org/sign_up"
|
17
|
+
|
18
|
+
email = ask("Email: ")
|
19
|
+
password = ask_for_password("Password: ")
|
20
|
+
|
21
|
+
response = make_request(:get, "api_key") do |request|
|
22
|
+
request.basic_auth email, password
|
23
|
+
end
|
24
|
+
|
25
|
+
case response
|
26
|
+
when Net::HTTPSuccess
|
27
|
+
self.api_key = response.body
|
28
|
+
say "Signed in. Your api key has been stored in ~/.gem/credentials"
|
29
|
+
else
|
30
|
+
say response.body
|
31
|
+
terminate_interaction
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def credentials_path
|
36
|
+
File.join(Gem.user_home, '.gem', 'credentials')
|
37
|
+
end
|
38
|
+
|
39
|
+
def api_key
|
40
|
+
Gem.configuration.load_file(credentials_path)[:rubygems_api_key]
|
41
|
+
end
|
42
|
+
|
43
|
+
def api_key=(api_key)
|
44
|
+
config = Gem.configuration.load_file(credentials_path).merge(:rubygems_api_key => api_key)
|
45
|
+
|
46
|
+
dirname = File.dirname(credentials_path)
|
47
|
+
Dir.mkdir(dirname) unless File.exists?(dirname)
|
48
|
+
|
49
|
+
File.open(credentials_path, 'w') do |f|
|
50
|
+
f.write config.to_yaml
|
51
|
+
end
|
52
|
+
|
53
|
+
@rubygems_api_key = api_key
|
54
|
+
end
|
55
|
+
|
56
|
+
def make_request(method, path)
|
57
|
+
require 'net/http'
|
58
|
+
require 'net/https'
|
59
|
+
|
60
|
+
url = URI.parse("#{gemcutter_url}/api/v1/#{path}")
|
61
|
+
|
62
|
+
http = proxy_class.new(url.host, url.port)
|
63
|
+
|
64
|
+
if url.scheme == 'https'
|
65
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
66
|
+
http.use_ssl = true
|
67
|
+
end
|
68
|
+
|
69
|
+
request_method =
|
70
|
+
case method
|
71
|
+
when :get
|
72
|
+
proxy_class::Get
|
73
|
+
when :post
|
74
|
+
proxy_class::Post
|
75
|
+
when :put
|
76
|
+
proxy_class::Put
|
77
|
+
when :delete
|
78
|
+
proxy_class::Delete
|
79
|
+
else
|
80
|
+
raise ArgumentError
|
81
|
+
end
|
82
|
+
|
83
|
+
request = request_method.new(url.path)
|
84
|
+
request.add_field "User-Agent", "Gemcutter/0.2.0"
|
85
|
+
|
86
|
+
yield request if block_given?
|
87
|
+
http.request(request)
|
88
|
+
end
|
89
|
+
|
90
|
+
def use_proxy!
|
91
|
+
proxy_uri = http_proxy
|
92
|
+
@proxy_class = Net::HTTP::Proxy(proxy_uri.host, proxy_uri.port, proxy_uri.user, proxy_uri.password)
|
93
|
+
end
|
94
|
+
|
95
|
+
def proxy_class
|
96
|
+
@proxy_class || Net::HTTP
|
97
|
+
end
|
98
|
+
|
99
|
+
# @return [URI, nil] the HTTP-proxy as a URI if set; +nil+ otherwise
|
100
|
+
def http_proxy
|
101
|
+
proxy = Gem.configuration[:http_proxy] || ENV['http_proxy'] || ENV['HTTP_PROXY']
|
102
|
+
return nil if proxy.nil? || proxy == :no_proxy
|
103
|
+
URI.parse(proxy)
|
104
|
+
end
|
105
|
+
|
106
|
+
def ask_for_password(message)
|
107
|
+
system "stty -echo"
|
108
|
+
password = ask(message)
|
109
|
+
system "stty echo"
|
110
|
+
ui.say("\n")
|
111
|
+
password
|
112
|
+
end
|
113
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'rubygems/commands/install_command'
|
2
|
+
class Gem::Commands::InstallCommand
|
3
|
+
|
4
|
+
unless respond_to? :execute_without_jars
|
5
|
+
alias :execute_without_jars :execute
|
6
|
+
def execute
|
7
|
+
begin
|
8
|
+
execute_without_jars
|
9
|
+
rescue Gem::SystemExitException => e
|
10
|
+
if e.exit_code == 0
|
11
|
+
puts "DO SOMETHING HERE WITH JARS"
|
12
|
+
end
|
13
|
+
raise e
|
14
|
+
end
|
15
|
+
end
|
16
|
+
alias :_s_a_y_ :say
|
17
|
+
def say( arg )
|
18
|
+
puts arg.sub( /.*\ /, '')
|
19
|
+
_s_a_y_( arg )
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
class Gem::Commands::PushCommand < Gem::AbstractCommand
|
2
|
+
|
3
|
+
def description
|
4
|
+
'Push a gem up to Nexus server'
|
5
|
+
end
|
6
|
+
|
7
|
+
def arguments
|
8
|
+
"GEM built gem to push up"
|
9
|
+
end
|
10
|
+
|
11
|
+
def usage
|
12
|
+
"#{program_name} GEM"
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize
|
16
|
+
super 'push', description
|
17
|
+
add_proxy_option
|
18
|
+
end
|
19
|
+
|
20
|
+
def execute
|
21
|
+
setup
|
22
|
+
send_gem
|
23
|
+
end
|
24
|
+
|
25
|
+
def send_gem
|
26
|
+
say "Pushing gem to Nexus..."
|
27
|
+
|
28
|
+
path = get_one_gem_name
|
29
|
+
response = make_request(:post, "gems") do |request|
|
30
|
+
request.body = Gem.read_binary(path)
|
31
|
+
request.add_field("Content-Length", request.body.size)
|
32
|
+
request.add_field("Content-Type", "application/octet-stream")
|
33
|
+
request.add_field("Authorization", api_key)
|
34
|
+
end
|
35
|
+
|
36
|
+
say response.body
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
class Gem::Commands::PushCommand < Gem::AbstractCommand
|
2
|
+
|
3
|
+
def description
|
4
|
+
'Push a gem up to Gemcutter'
|
5
|
+
end
|
6
|
+
|
7
|
+
def arguments
|
8
|
+
"GEM built gem to push up"
|
9
|
+
end
|
10
|
+
|
11
|
+
def usage
|
12
|
+
"#{program_name} GEM"
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize
|
16
|
+
super 'push', description
|
17
|
+
add_proxy_option
|
18
|
+
end
|
19
|
+
|
20
|
+
def execute
|
21
|
+
setup
|
22
|
+
send_gem
|
23
|
+
end
|
24
|
+
|
25
|
+
def send_gem
|
26
|
+
say "Pushing gem to Gemcutter..."
|
27
|
+
|
28
|
+
path = get_one_gem_name
|
29
|
+
response = make_request(:post, "gems") do |request|
|
30
|
+
request.body = Gem.read_binary(path)
|
31
|
+
request.add_field("Content-Length", request.body.size)
|
32
|
+
request.add_field("Content-Type", "application/octet-stream")
|
33
|
+
request.add_field("Authorization", api_key)
|
34
|
+
end
|
35
|
+
|
36
|
+
say response.body
|
37
|
+
end
|
38
|
+
end
|
data/lib/jars.rb~
ADDED
data/lib/jbundler/aether.rb
CHANGED
@@ -85,11 +85,11 @@ module JBundler
|
|
85
85
|
java_import 'jbundler.Aether'
|
86
86
|
end
|
87
87
|
|
88
|
-
def initialize(config = Config.new)
|
88
|
+
def initialize(config = Config.new, offline = false)
|
89
89
|
unless defined? Aether
|
90
90
|
self.class.setup_classloader
|
91
91
|
end
|
92
|
-
@aether = Aether.new(config.local_repository, config.verbose)
|
92
|
+
@aether = Aether.new(config.local_repository, config.verbose, offline)
|
93
93
|
end
|
94
94
|
|
95
95
|
def add_artifact(coordinate, extension = nil)
|
data/lib/jbundler.jar
CHANGED
Binary file
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: jbundler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.3.
|
5
|
+
version: 0.3.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Kristian Meier
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-09-24 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: ruby-maven
|
@@ -61,41 +61,27 @@ extra_rdoc_files: []
|
|
61
61
|
|
62
62
|
files:
|
63
63
|
- bin/jbundle
|
64
|
+
- lib/rubygems_plugin.rb~
|
64
65
|
- lib/jbundler.rb
|
65
|
-
- lib/
|
66
|
+
- lib/jars.rb~
|
66
67
|
- lib/jbundler.jar
|
67
|
-
- lib/
|
68
|
-
- lib/
|
68
|
+
- lib/commands/install_with_jars.rb~
|
69
|
+
- lib/commands/abstract_command.rb~
|
70
|
+
- lib/commands/push.rb~
|
71
|
+
- lib/commands/nexus.rb~
|
69
72
|
- lib/jbundler/pom.rb
|
70
|
-
- lib/jbundler/pom.rb~
|
71
|
-
- lib/jbundler/mavenfile.rb~
|
72
73
|
- lib/jbundler/cli.rb
|
73
|
-
- lib/jbundler/lazy.rb~
|
74
|
-
- lib/jbundler/maven_version.rb~
|
75
74
|
- lib/jbundler/config.rb
|
76
75
|
- lib/jbundler/classpath_file.rb
|
77
76
|
- lib/jbundler/aether.rb
|
78
|
-
- lib/jbundler/gemfile_lock.rb~
|
79
77
|
- lib/jbundler/gemfile_lock.rb
|
80
|
-
- lib/jbundler/classpath_file.rb~
|
81
|
-
- lib/jbundler/config.rb~
|
82
|
-
- lib/jbundler/aether.rb~
|
83
78
|
- lib/jbundler/lazy.rb
|
84
|
-
- lib/jbundler/maven_util.rb~
|
85
|
-
- lib/jbundler/maven.rb~
|
86
|
-
- spec/maven_util_spec.rb~
|
87
|
-
- spec/mavenfile_spec.rb~
|
88
|
-
- spec/pom_spec.rb~
|
89
|
-
- spec/classpath_file_spec.rb~
|
90
|
-
- spec/aether_spec.rb~
|
91
79
|
- spec/classpath_file_spec.rb
|
92
80
|
- spec/setup.rb
|
93
81
|
- spec/pom_spec.rb
|
94
82
|
- spec/aether_spec.rb
|
95
|
-
- spec/setup.rb~
|
96
83
|
- MIT-LICENSE
|
97
84
|
- Readme.md
|
98
|
-
- Test.md
|
99
85
|
- Gemfile
|
100
86
|
- Gemfile.lock
|
101
87
|
homepage: https://github.com/mkristian/jbundler
|
data/Test.md
DELETED
File without changes
|
data/lib/jbundler/aether.rb~
DELETED
@@ -1,68 +0,0 @@
|
|
1
|
-
require 'java'
|
2
|
-
module JBundler
|
3
|
-
|
4
|
-
class AetherRuby
|
5
|
-
|
6
|
-
def self.setup_classloader
|
7
|
-
unless defined? Aether
|
8
|
-
@maven_home = File.dirname(File.dirname(Gem.bin_path('ruby-maven',
|
9
|
-
'rmvn')))
|
10
|
-
# TODO reduce to the libs which are really needed
|
11
|
-
Dir.glob(File.join(@maven_home, 'lib', "*jar")).each {|path| require path }
|
12
|
-
require 'jbundler.jar'
|
13
|
-
java_import 'jbundler.Aether'
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def initialize(local_repo = File.join( ENV['HOME'],
|
18
|
-
".m2",
|
19
|
-
"repository"),
|
20
|
-
verbose = false)
|
21
|
-
self.class.setup_classloader
|
22
|
-
@aether = AetherRuby.new(local_repo, verbose)
|
23
|
-
end
|
24
|
-
|
25
|
-
def add_artifact(coordinate, extension = nil)
|
26
|
-
if extension
|
27
|
-
coord = coordinate.split(/:/)
|
28
|
-
coord.insert(2, extension)
|
29
|
-
@aether.add_artifact(coordinate.join(":"))
|
30
|
-
else
|
31
|
-
@aether.add_artifact(coordinate)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def add_repository(url, name = "repo_#{repos.size}")
|
36
|
-
@aether.add_repository(name, url)
|
37
|
-
end
|
38
|
-
|
39
|
-
def install(coordinate)
|
40
|
-
@aether.install(coordinate)
|
41
|
-
end
|
42
|
-
|
43
|
-
def resolve
|
44
|
-
@aether.resolve
|
45
|
-
end
|
46
|
-
|
47
|
-
def classpath
|
48
|
-
@aether.classpath
|
49
|
-
end
|
50
|
-
|
51
|
-
def dependency_map
|
52
|
-
@aether.dependency_map
|
53
|
-
end
|
54
|
-
|
55
|
-
def repositories
|
56
|
-
@aether.repositories
|
57
|
-
end
|
58
|
-
|
59
|
-
def dependency_coordinates
|
60
|
-
@aether.dependency_coordinates
|
61
|
-
end
|
62
|
-
|
63
|
-
def install(coordinate, file)
|
64
|
-
@aether.install(coordinate, file)
|
65
|
-
end
|
66
|
-
|
67
|
-
end
|
68
|
-
end
|
@@ -1,207 +0,0 @@
|
|
1
|
-
require 'uri'
|
2
|
-
require 'tempfile'
|
3
|
-
require 'fileutils'
|
4
|
-
require 'set'
|
5
|
-
require 'jbundler/gemfile_lock'
|
6
|
-
require 'jbundler/pom'
|
7
|
-
require 'java'
|
8
|
-
|
9
|
-
# A modified maven_gemify2 taken from https://github.com/ANithian/bundler/blob/a29d4550dfb2f24372bf6e60f00e633ff92d5d64/lib/bundler/maven_gemify2.rb
|
10
|
-
module JBundler
|
11
|
-
|
12
|
-
class Maven3NotFound < StandardError; end
|
13
|
-
|
14
|
-
class Maven
|
15
|
-
attr_reader :repositories
|
16
|
-
|
17
|
-
#repositories should be an array of urls
|
18
|
-
def initialize(*repositories)
|
19
|
-
maven # ensure maven initialized
|
20
|
-
@repositories = Set.new
|
21
|
-
if repositories.length > 0
|
22
|
-
@repositories.merge([repositories].flatten)
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
26
|
-
|
27
|
-
def add_repository(repository_url)
|
28
|
-
@repositories << repository_url
|
29
|
-
end
|
30
|
-
|
31
|
-
@@verbose = false
|
32
|
-
def self.verbose?
|
33
|
-
@@verbose || $DEBUG
|
34
|
-
end
|
35
|
-
def verbose?
|
36
|
-
self.class.verbose?
|
37
|
-
end
|
38
|
-
def self.verbose=(v)
|
39
|
-
@@verbose = v
|
40
|
-
end
|
41
|
-
|
42
|
-
private
|
43
|
-
def self.maven_config
|
44
|
-
@maven_config ||= Gem.configuration["maven"] || {}
|
45
|
-
end
|
46
|
-
def maven_config; self.class.maven_config; end
|
47
|
-
|
48
|
-
def self.java_imports
|
49
|
-
%w(
|
50
|
-
org.codehaus.plexus.classworlds.ClassWorld
|
51
|
-
org.codehaus.plexus.DefaultContainerConfiguration
|
52
|
-
org.codehaus.plexus.DefaultPlexusContainer
|
53
|
-
org.apache.maven.Maven
|
54
|
-
org.apache.maven.repository.RepositorySystem
|
55
|
-
org.apache.maven.execution.DefaultMavenExecutionRequest
|
56
|
-
org.apache.maven.artifact.repository.MavenArtifactRepository
|
57
|
-
org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout
|
58
|
-
org.apache.maven.artifact.repository.ArtifactRepositoryPolicy
|
59
|
-
javax.xml.stream.XMLStreamWriter
|
60
|
-
javax.xml.stream.XMLOutputFactory
|
61
|
-
javax.xml.stream.XMLStreamException
|
62
|
-
).each {|i| java_import i }
|
63
|
-
end
|
64
|
-
|
65
|
-
def self.create_maven
|
66
|
-
bin = nil
|
67
|
-
if ENV['M2_HOME'] # use M2_HOME if set
|
68
|
-
bin = File.join(ENV['M2_HOME'], "bin")
|
69
|
-
else
|
70
|
-
ENV['PATH'].split(File::PATH_SEPARATOR).detect do |path|
|
71
|
-
mvn = File.join(path, "mvn")
|
72
|
-
if File.exists?(mvn)
|
73
|
-
if File.symlink?(mvn)
|
74
|
-
link = File.readlink(mvn)
|
75
|
-
if link =~ /^\// # is absolute path
|
76
|
-
bin = File.dirname(File.expand_path(link))
|
77
|
-
else # is relative path so join with dir of the maven command
|
78
|
-
bin = File.dirname(File.expand_path(File.join(File.dirname(mvn), link)))
|
79
|
-
end
|
80
|
-
else # is no link so just expand it
|
81
|
-
bin = File.expand_path(path)
|
82
|
-
end
|
83
|
-
else
|
84
|
-
nil
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
bin = "/usr/share/maven2/bin" if bin.nil? # OK let's try debian default
|
89
|
-
if File.exists?(bin)
|
90
|
-
@mvn = File.join(bin, "mvn")
|
91
|
-
if Dir.glob(File.join(bin, "..", "lib", "maven-core-3.*jar")).size == 0
|
92
|
-
begin
|
93
|
-
gem 'ruby-maven', ">=0"
|
94
|
-
bin = File.dirname(Gem.bin_path('ruby-maven', "rmvn"))
|
95
|
-
@mvn = File.join(bin, "rmvn")
|
96
|
-
rescue LoadError
|
97
|
-
bin = nil
|
98
|
-
end
|
99
|
-
end
|
100
|
-
else
|
101
|
-
bin = nil
|
102
|
-
end
|
103
|
-
raise Maven3NotFound.new("can not find maven3 installation. install ruby-maven with\n\n\tjruby -S gem install ruby-maven\n\n") if bin.nil?
|
104
|
-
|
105
|
-
warn "Using Maven install at #{bin}" if verbose?
|
106
|
-
|
107
|
-
boot = File.join(bin, "..", "boot")
|
108
|
-
lib = File.join(bin, "..", "lib")
|
109
|
-
ext = File.join(bin, "..", "ext")
|
110
|
-
(Dir.glob(lib + "/*jar") + Dir.glob(boot + "/*jar")).each {|path| require path }
|
111
|
-
|
112
|
-
java.lang.System.setProperty("classworlds.conf", File.join(bin, "m2.conf"))
|
113
|
-
java.lang.System.setProperty("maven.home", File.join(bin, ".."))
|
114
|
-
java_imports
|
115
|
-
|
116
|
-
class_world = ClassWorld.new("plexus.core", java.lang.Thread.currentThread().getContextClassLoader());
|
117
|
-
config = DefaultContainerConfiguration.new
|
118
|
-
config.set_class_world class_world
|
119
|
-
config.set_name "ruby-tools"
|
120
|
-
container = DefaultPlexusContainer.new(config);
|
121
|
-
@@execution_request_populator = container.lookup(org.apache.maven.execution.MavenExecutionRequestPopulator.java_class)
|
122
|
-
|
123
|
-
@@settings_builder = container.lookup(org.apache.maven.settings.building.SettingsBuilder.java_class )
|
124
|
-
container.lookup(Maven.java_class)
|
125
|
-
end
|
126
|
-
|
127
|
-
def self.maven
|
128
|
-
@maven ||= create_maven
|
129
|
-
end
|
130
|
-
def maven; self.class.maven; end
|
131
|
-
|
132
|
-
def self.temp_dir
|
133
|
-
@temp_dir ||=
|
134
|
-
begin
|
135
|
-
d=Dir.mktmpdir
|
136
|
-
at_exit {FileUtils.rm_rf(d.dup)}
|
137
|
-
d
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
def temp_dir
|
142
|
-
self.class.temp_dir
|
143
|
-
end
|
144
|
-
|
145
|
-
def execute(goals, pomFile, props = {})
|
146
|
-
request = DefaultMavenExecutionRequest.new
|
147
|
-
request.set_show_errors(true)
|
148
|
-
|
149
|
-
props.each do |k,v|
|
150
|
-
request.user_properties.put(k.to_s, v.to_s)
|
151
|
-
end
|
152
|
-
request.set_goals(goals)
|
153
|
-
request.set_logging_level 0
|
154
|
-
request.setPom(java.io.File.new(pomFile))
|
155
|
-
if verbose?
|
156
|
-
active_profiles = request.getActiveProfiles.collect{ |p| p.to_s }
|
157
|
-
puts "active profiles:\n\t[#{active_profiles.join(', ')}]"
|
158
|
-
puts "maven goals:"
|
159
|
-
request.goals.each { |g| puts "\t#{g}" }
|
160
|
-
puts "system properties:"
|
161
|
-
request.getUserProperties.map.each { |k,v| puts "\t#{k} => #{v}" }
|
162
|
-
puts
|
163
|
-
end
|
164
|
-
out = java.lang.System.out
|
165
|
-
string_io = java.io.ByteArrayOutputStream.new
|
166
|
-
java.lang.System.setOut(java.io.PrintStream.new(string_io))
|
167
|
-
result = maven.execute request
|
168
|
-
java.lang.System.out = out
|
169
|
-
has_exceptions = false
|
170
|
-
result.exceptions.each do |e|
|
171
|
-
has_exceptions = true
|
172
|
-
e.print_stack_trace
|
173
|
-
string_io.write(e.get_message.to_java_string.get_bytes)
|
174
|
-
end
|
175
|
-
raise string_io.to_s if has_exceptions
|
176
|
-
string_io.to_s
|
177
|
-
end
|
178
|
-
|
179
|
-
public
|
180
|
-
|
181
|
-
def generate_classpath(mavenfile = 'Mvnfile', classpathfile = '.jbundler/classpath.rb')
|
182
|
-
|
183
|
-
#to resolve deps and generate a classpath
|
184
|
-
pomfile=File.join(temp_dir,
|
185
|
-
"pom.xml")
|
186
|
-
Pom.new(pomfile, "mavengemify", "1.0-SNAPSHOT",
|
187
|
-
File.read(mavenfile).split(/\n/) + GemfileLock.new.jar_deps)
|
188
|
-
|
189
|
-
execute(["dependency:resolve","dependency:build-classpath"],pomfile,{"mdep.outputFile" => "cp.txt","mdep.fileSeparator"=>"/"})
|
190
|
-
|
191
|
-
FileUtils.mkdir_p(File.dirname(classpathfile))
|
192
|
-
File.open(classpathfile, 'w') do |f|
|
193
|
-
f.puts "JBUNDLER_CLASSPATH = []"
|
194
|
-
path_separator = java.lang.System.getProperty("path.separator").to_s
|
195
|
-
File.read(File.join(temp_dir,"cp.txt")).each do |line|
|
196
|
-
line.split(/#{path_separator}/).each do |path|
|
197
|
-
f.puts "JBUNDLER_CLASSPATH << '#{path}'" unless path =~ /pom$/
|
198
|
-
end
|
199
|
-
end
|
200
|
-
f.puts "JBUNDLER_CLASSPATH.freeze"
|
201
|
-
f.puts "JBUNDLER_CLASSPATH.each { |c| require c }"
|
202
|
-
f.close
|
203
|
-
end
|
204
|
-
end
|
205
|
-
|
206
|
-
end
|
207
|
-
end
|