jbundler 0.7.4 → 0.8.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -3
- data/Gemfile.lock~ +46 -0
- data/Readme.md +15 -103
- data/bin/jbundle +41 -60
- data/lib/jbundler/executor.rb +107 -0
- data/lib/jbundler/pom.rb +27 -145
- data/lib/jbundler.rb +5 -47
- metadata +29 -74
- data/lib/jbundler/aether.rb +0 -139
- data/lib/jbundler/classpath_file.rb +0 -115
- data/lib/jbundler/cli.rb +0 -171
- data/lib/jbundler/config.rb +0 -191
- data/lib/jbundler/configurator.rb +0 -27
- data/lib/jbundler/context.rb +0 -34
- data/lib/jbundler/dependency_pom.rb +0 -29
- data/lib/jbundler/executable.rb +0 -41
- data/lib/jbundler/executable_pom.rb +0 -105
- data/lib/jbundler/gemfile_lock.rb +0 -69
- data/lib/jbundler/jarfile_lock.rb +0 -67
- data/lib/jbundler/jruby_complete.rb +0 -44
- data/lib/jbundler/jruby_complete_pom.rb +0 -31
- data/lib/jbundler/lazy.rb +0 -102
- data/lib/jbundler/lock_down.rb +0 -166
- data/lib/jbundler/pom_runner.rb +0 -71
- data/lib/jbundler/show.rb +0 -53
- data/lib/jbundler/tree.rb +0 -31
- data/lib/jbundler/vendor.rb +0 -52
- data/lib/jbundler.jar +0 -0
- data/spec/aether_spec.rb +0 -98
- data/spec/classpath_file_spec.rb +0 -138
- data/spec/config_spec.rb +0 -180
- data/spec/pom_spec.rb +0 -30
- data/spec/project/Settings.xml +0 -0
- data/spec/project/settings.xml +0 -0
- data/spec/setup.rb +0 -16
- data/spec/vendor_spec.rb +0 -60
data/lib/jbundler/config.rb
DELETED
@@ -1,191 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Copyright (C) 2013 Christian Meier
|
3
|
-
#
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
5
|
-
# this software and associated documentation files (the "Software"), to deal in
|
6
|
-
# the Software without restriction, including without limitation the rights to
|
7
|
-
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
8
|
-
# the Software, and to permit persons to whom the Software is furnished to do so,
|
9
|
-
# subject to the following conditions:
|
10
|
-
#
|
11
|
-
# The above copyright notice and this permission notice shall be included in all
|
12
|
-
# copies or substantial portions of the Software.
|
13
|
-
#
|
14
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
16
|
-
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
17
|
-
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
18
|
-
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
19
|
-
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
20
|
-
#
|
21
|
-
require 'yaml'
|
22
|
-
require 'jar_dependencies'
|
23
|
-
|
24
|
-
module JBundler
|
25
|
-
|
26
|
-
# allow yaml config in $HOME/.jbundlerrc and $PWD/.jbundlerrc
|
27
|
-
class Config
|
28
|
-
|
29
|
-
RC_FILE = '.jbundlerrc'
|
30
|
-
|
31
|
-
attr_accessor :verbose, :local_repository, :jarfile, :gemfile, :skip, :settings, :offline, :work_dir, :vendor_dir, :basedir
|
32
|
-
|
33
|
-
def initialize
|
34
|
-
if ENV.has_key? 'HOME'
|
35
|
-
homefile = File.join(ENV['HOME'], RC_FILE)
|
36
|
-
home_config = YAML.load_file(homefile) if File.exists?(homefile)
|
37
|
-
else
|
38
|
-
home_config = nil
|
39
|
-
end
|
40
|
-
@config = (home_config || {})
|
41
|
-
@basedir = find_basedir( File.expand_path( '.' ) )
|
42
|
-
@basedir ||= File.expand_path( '.' )
|
43
|
-
file = join_basedir( RC_FILE )
|
44
|
-
pwd_config = YAML.load_file(file) if File.exists?(file)
|
45
|
-
@config.merge!(pwd_config || {})
|
46
|
-
end
|
47
|
-
|
48
|
-
def join_basedir( path )
|
49
|
-
if @basedir
|
50
|
-
File.join( @basedir, path )
|
51
|
-
else
|
52
|
-
path
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
def find_basedir( dir )
|
57
|
-
f = File.join( dir, RC_FILE )
|
58
|
-
return dir if File.exists?( f )
|
59
|
-
f = File.join( dir, _jarfile )
|
60
|
-
return dir if File.exists?( f )
|
61
|
-
f = File.join( dir, _gemfile )
|
62
|
-
return dir if File.exists?( f )
|
63
|
-
parent = File.dirname( dir )
|
64
|
-
if dir != ENV['HOME'] && dir != parent
|
65
|
-
find_basedir( parent )
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
def absolute( file )
|
70
|
-
if file.nil? || file == File.expand_path( file )
|
71
|
-
file
|
72
|
-
else
|
73
|
-
File.join( @basedir, file )
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def _jbundler_env( key )
|
78
|
-
ENV[ key.upcase.gsub( /[.]/, '_' ) ] ||
|
79
|
-
@config[ key.downcase.sub(/^j?bundle_/, '' ).sub( /[.]/, '_' ) ]
|
80
|
-
end
|
81
|
-
private :_jbundler_env
|
82
|
-
|
83
|
-
if defined? JRUBY_VERSION
|
84
|
-
def jbundler_env( key )
|
85
|
-
java.lang.System.getProperty( key.downcase.gsub( /_/, '.' ) ) ||
|
86
|
-
_jbundler_env( key )
|
87
|
-
end
|
88
|
-
else
|
89
|
-
alias :jbundler_env :_jbundler_env
|
90
|
-
end
|
91
|
-
private :jbundler_env
|
92
|
-
|
93
|
-
def skip
|
94
|
-
skip = jbundler_env('JBUNDLE_SKIP')
|
95
|
-
# defaults to false
|
96
|
-
@skip ||= skip && skip != 'false'
|
97
|
-
end
|
98
|
-
|
99
|
-
def verbose
|
100
|
-
verbose = jbundler_env('JBUNDLE_VERBOSE')
|
101
|
-
# defaults to false
|
102
|
-
@verbose ||= verbose && verbose != 'false'
|
103
|
-
end
|
104
|
-
|
105
|
-
def jarfile
|
106
|
-
@jarfile ||= absolute( _jarfile )
|
107
|
-
end
|
108
|
-
|
109
|
-
def _jarfile
|
110
|
-
jbundler_env('JBUNDLE_JARFILE') || 'Jarfile'
|
111
|
-
end
|
112
|
-
private :_jarfile
|
113
|
-
|
114
|
-
def jarfile_lock
|
115
|
-
"#{jarfile}.lock"
|
116
|
-
end
|
117
|
-
|
118
|
-
def gemfile
|
119
|
-
@gemfile ||= absolute( _gemfile )
|
120
|
-
end
|
121
|
-
|
122
|
-
def _gemfile
|
123
|
-
jbundler_env('BUNDLE_GEMFILE') || 'Gemfile'
|
124
|
-
end
|
125
|
-
private :_gemfile
|
126
|
-
|
127
|
-
def gemfile_lock
|
128
|
-
"#{gemfile}.lock"
|
129
|
-
end
|
130
|
-
|
131
|
-
def classpath_file
|
132
|
-
absolute( jbundler_env('JBUNDLE_CLASSPATH_FILE') ||
|
133
|
-
'.jbundler/classpath.rb' )
|
134
|
-
end
|
135
|
-
|
136
|
-
def local_repository
|
137
|
-
# use maven default local repo as default
|
138
|
-
local_maven_repository = absolute( jbundler_env('JBUNDLE_LOCAL_REPOSITORY') )
|
139
|
-
if local_maven_repository
|
140
|
-
warn "JBUNDLE_LOCAL_REPOSITORY environment or jbundle.local.repository' system property is deprecated use JARS_HOME or jars.home instead"
|
141
|
-
ENV[ Jars::HOME ] ||= local_maven_repository
|
142
|
-
else
|
143
|
-
# first load the right settings
|
144
|
-
self.settings
|
145
|
-
Jars.home
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
def settings
|
150
|
-
settings = absolute( jbundler_env('JBUNDLE_SETTINGS') )
|
151
|
-
if settings
|
152
|
-
warn "JBUNDLE_SETTINGS environment or jbundle.settings' system property is deprecated use JARS_MAVEN_SETTINGS or jars.maven.settings instead"
|
153
|
-
ENV[ Jars::MAVEN_SETTINGS ] ||= settings
|
154
|
-
end
|
155
|
-
Jars.maven_settings
|
156
|
-
end
|
157
|
-
|
158
|
-
def offline
|
159
|
-
@offline ||= jbundler_env('JBUNDLE_OFFLINE')
|
160
|
-
@offline == 'true' || @offline == true
|
161
|
-
end
|
162
|
-
|
163
|
-
def proxy
|
164
|
-
@proxy ||= jbundler_env('JBUNDLE_PROXY')
|
165
|
-
if @proxy
|
166
|
-
warn 'proxy config is deprecated, use settings.xml instead'
|
167
|
-
end
|
168
|
-
@proxy
|
169
|
-
end
|
170
|
-
|
171
|
-
def mirror
|
172
|
-
@mirror ||= jbundler_env('JBUNDLE_MIRROR')
|
173
|
-
# nice to have no leading slash
|
174
|
-
@mirror = @mirror.sub( /\/$/, '' ) if @mirror
|
175
|
-
if @mirror
|
176
|
-
warn 'mirror config is deprecated, use settings.xml instead'
|
177
|
-
end
|
178
|
-
@mirror
|
179
|
-
end
|
180
|
-
|
181
|
-
def work_dir
|
182
|
-
@work_dir ||= absolute( jbundler_env('JBUNDLE_WORK_DIR') || 'pkg' )
|
183
|
-
end
|
184
|
-
|
185
|
-
def vendor_dir
|
186
|
-
@vendor_dir ||= absolute( jbundler_env('JBUNDLE_VENDOR_DIR') ||
|
187
|
-
File.join( 'vendor', 'jars' ) )
|
188
|
-
end
|
189
|
-
|
190
|
-
end
|
191
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'jbundler/configurator'
|
2
|
-
module JBundler
|
3
|
-
class Configurator
|
4
|
-
|
5
|
-
attr_accessor :groups, :bootstrap, :verbose, :compile, :work_dir
|
6
|
-
|
7
|
-
def initialize( config )
|
8
|
-
@config = config
|
9
|
-
end
|
10
|
-
|
11
|
-
def configure( maven )
|
12
|
-
maven.property( 'jbundler.basedir', @config.basedir )
|
13
|
-
maven.property( 'jbundler.jarfile', @config.jarfile )
|
14
|
-
maven.property( 'jbundler.gemfile', @config.gemfile )
|
15
|
-
maven.property( 'jbundler.workdir', work_dir )
|
16
|
-
maven.property( 'jbundler.groups', @groups )
|
17
|
-
maven.property( 'jbundler.bootstrap', @bootstrap )
|
18
|
-
maven.property( 'maven.repo.local', @config.local_repository ) if @config.local_repository
|
19
|
-
maven.options[ '-s' ] = @config.settings if @config.settings
|
20
|
-
maven.options[ '-o' ] = nil if @config.offline
|
21
|
-
end
|
22
|
-
|
23
|
-
def work_dir
|
24
|
-
@work_dir ||= File.expand_path( @config.work_dir )
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
data/lib/jbundler/context.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'maven/tools/jarfile'
|
2
|
-
require 'jbundler/classpath_file'
|
3
|
-
require 'jbundler/vendor'
|
4
|
-
require 'jbundler/gemfile_lock'
|
5
|
-
require 'jbundler/aether'
|
6
|
-
|
7
|
-
module JBundler
|
8
|
-
|
9
|
-
class Context
|
10
|
-
|
11
|
-
attr_reader :config
|
12
|
-
|
13
|
-
def initialize
|
14
|
-
@config = JBundler::Config.new
|
15
|
-
end
|
16
|
-
|
17
|
-
def jarfile
|
18
|
-
@jarfile ||= Maven::Tools::Jarfile.new( @config.jarfile )
|
19
|
-
end
|
20
|
-
|
21
|
-
def vendor
|
22
|
-
@vendor ||= JBundler::Vendor.new( @config.vendor_dir )
|
23
|
-
end
|
24
|
-
|
25
|
-
def classpath
|
26
|
-
@classpath ||= JBundler::ClasspathFile.new( @config.classpath_file )
|
27
|
-
end
|
28
|
-
|
29
|
-
def gemfile_lock
|
30
|
-
@gemfile_lock ||= JBundler::GemfileLock.new( jarfile,
|
31
|
-
@config.gemfile_lock )
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
bdir = java.lang.System.getProperty( "jbundler.basedir" )
|
2
|
-
jfile = java.lang.System.getProperty( "jbundler.jarfile" )
|
3
|
-
gfile = java.lang.System.getProperty( "jbundler.gemfile" )
|
4
|
-
jworkdir = java.lang.System.getProperty( "jbundler.workdir" )
|
5
|
-
|
6
|
-
basedir( bdir )
|
7
|
-
if basedir != bdir
|
8
|
-
# older maven-tools needs this
|
9
|
-
self.instance_variable_set( :@basedir, bdir )
|
10
|
-
end
|
11
|
-
|
12
|
-
( 0..(java.lang.System.getProperty( "jbundler.jars.size" ).to_i - 1) ).each do |i|
|
13
|
-
dependency_artifact Maven::Tools::Artifact.from_coordinate( java.lang.System.getProperty( "jbundler.jars.#{i}" ).to_s )
|
14
|
-
end
|
15
|
-
|
16
|
-
jarfile( jfile )
|
17
|
-
|
18
|
-
build do
|
19
|
-
directory = jworkdir
|
20
|
-
end
|
21
|
-
|
22
|
-
properties( 'project.build.sourceEncoding' => 'utf-8',
|
23
|
-
'tesla.dump.readOnly' => true,
|
24
|
-
'tesla.dump.pom' => 'tree.pom.xml' )
|
25
|
-
|
26
|
-
plugin( :dependency, '2.8',
|
27
|
-
:includeTypes => 'jar',
|
28
|
-
:outputAbsoluteArtifactFilename => true,
|
29
|
-
:outputFile => java.lang.System.getProperty( "jbundler.outputFile" ) )
|
data/lib/jbundler/executable.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
require 'maven/ruby/maven'
|
2
|
-
require 'fileutils'
|
3
|
-
module JBundler
|
4
|
-
class Executable
|
5
|
-
|
6
|
-
class Filter
|
7
|
-
|
8
|
-
def initialize(a)
|
9
|
-
@a = a
|
10
|
-
end
|
11
|
-
def method_missing(m, *args, &b)
|
12
|
-
args[ 0 ].sub!(/^.* - /, '' )
|
13
|
-
@a.send(m,*args, &b)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def initialize( bootstrap, config, compile, verbose, *groups )
|
18
|
-
raise "file not found: #{bootstrap}" unless File.exists?( bootstrap )
|
19
|
-
@config = Configurator.new( config )
|
20
|
-
@config.bootstrap = bootstrap
|
21
|
-
@config.compile = compile
|
22
|
-
@config.verbose = verbose
|
23
|
-
@config.groups = groups.join( ',' )
|
24
|
-
end
|
25
|
-
|
26
|
-
def packit
|
27
|
-
m = Maven::Ruby::Maven.new
|
28
|
-
m.options[ '-f' ] = File.join( File.dirname( __FILE__ ),
|
29
|
-
'executable_pom.rb' )
|
30
|
-
@config.configure( m )
|
31
|
-
m.verbose = @config.verbose
|
32
|
-
m.package( '-P', @config.compile ? :compile : :no_compile )
|
33
|
-
|
34
|
-
puts
|
35
|
-
puts 'now you can execute your jar like this'
|
36
|
-
puts
|
37
|
-
puts "\tjava -jar #{File.basename( File.expand_path( '.' ) )}_exec.jar"
|
38
|
-
puts
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
@@ -1,105 +0,0 @@
|
|
1
|
-
begin
|
2
|
-
groups = java.lang.System.getProperty( "jbundler.groups" ) || ''
|
3
|
-
require 'bundler'
|
4
|
-
Bundler.setup( *groups.split( /,/ ) )
|
5
|
-
rescue LoadError
|
6
|
-
# ignore- bundler is optional
|
7
|
-
end
|
8
|
-
|
9
|
-
jfile = ::Maven::Tools::Jarfile.new( java.lang.System.getProperty( "jbundler.jarfile" ) )
|
10
|
-
|
11
|
-
workdir = java.lang.System.getProperty( "jbundler.workdir" )
|
12
|
-
jworkdir = File.join( workdir, 'executable' )
|
13
|
-
FileUtils.rm_rf( jworkdir )
|
14
|
-
FileUtils.mkdir_p( jworkdir )
|
15
|
-
|
16
|
-
BOOTSTRAP = 'jar-bootstrap.rb' unless defined? BOOTSTRAP
|
17
|
-
|
18
|
-
FileUtils.cp( java.lang.System.getProperty( 'jbundler.bootstrap'),
|
19
|
-
File.join( jworkdir, BOOTSTRAP ) )
|
20
|
-
|
21
|
-
def jruby_home( path )
|
22
|
-
File.join( 'META-INF/jruby.home/lib/ruby/gems/shared', path )
|
23
|
-
end
|
24
|
-
|
25
|
-
jfile.locked.each do |dep|
|
26
|
-
artifact( dep )
|
27
|
-
end
|
28
|
-
|
29
|
-
build.directory = jworkdir
|
30
|
-
resource do
|
31
|
-
directory jworkdir
|
32
|
-
includes [ BOOTSTRAP ]
|
33
|
-
end
|
34
|
-
Gem.loaded_specs.values.each do |s|
|
35
|
-
resource do
|
36
|
-
directory s.full_gem_path
|
37
|
-
target_path File.join( jruby_home( 'gems' ),
|
38
|
-
File.basename( s.full_gem_path ) )
|
39
|
-
if s.full_gem_path == File.expand_path( '.' )
|
40
|
-
excludes [ "**/#{workdir}/**" ]
|
41
|
-
end
|
42
|
-
end
|
43
|
-
resource do
|
44
|
-
directory File.dirname( s.loaded_from )
|
45
|
-
includes [ File.basename( s.loaded_from ) ]
|
46
|
-
target_path jruby_home( 'specifications' )
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
properties( 'maven.test.skip' => true,
|
51
|
-
'tesla.dump.pom' => 'pom.xml',
|
52
|
-
'project.build.sourceEncoding' => 'utf-8' )
|
53
|
-
|
54
|
-
jfile.populate_unlocked do |dsl|
|
55
|
-
|
56
|
-
setup_jruby( dsl.jruby || JRUBY_VERSION, :compile )
|
57
|
-
dsl.artifacts.select do |a|
|
58
|
-
a[ :scope ] == :provided
|
59
|
-
end.each do |a|
|
60
|
-
a[ :scope ] = :compile
|
61
|
-
artifact( a )
|
62
|
-
end
|
63
|
-
local = dsl.artifacts.select do |a|
|
64
|
-
a[ :system_path ]
|
65
|
-
end
|
66
|
-
|
67
|
-
# setup a localrepo for the local jars if needed
|
68
|
-
if local
|
69
|
-
localrepo = File.join( jworkdir, 'localrepo' )
|
70
|
-
repository( "file:#{localrepo}", :id => 'localrepo' )
|
71
|
-
local.each do |a|
|
72
|
-
file = "#{localrepo}/#{a[ :group_id ].gsub( /\./, File::SEPARATOR)}/#{a[ :artifact_id ]}/#{a[ :version ]}/#{a[ :artifact_id ]}-#{a[ :version ]}.#{a[ :type ]}"
|
73
|
-
FileUtils.mkdir_p( File.dirname( file ) )
|
74
|
-
FileUtils.cp( a.delete( :system_path ), file )
|
75
|
-
a.delete( :scope )
|
76
|
-
jar a
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
profile :compile do
|
82
|
-
|
83
|
-
properties 'jruby.plugins.version' => Maven::Tools::VERSIONS[ :jruby_plugins ]
|
84
|
-
plugin( 'de.saumya.mojo:jruby-maven-plugin', '${jruby.plugins.version}' ) do
|
85
|
-
execute_goal( :compile,
|
86
|
-
:rubySourceDirectory => 'lib',
|
87
|
-
:jrubycVerbose => @verbose)
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
profile :no_compile do
|
92
|
-
build do
|
93
|
-
resource do
|
94
|
-
directory '${basedir}/lib'
|
95
|
-
includes [ '**/*.rb' ]
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
plugin( :shade, '2.1',
|
101
|
-
:outputFile => "${user.dir}/#{File.basename( File.expand_path( '.' ) )}_exec.jar",
|
102
|
-
:transformers => [ { '@implementation' => 'org.apache.maven.plugins.shade.resource.ManifestResourceTransformer',
|
103
|
-
:mainClass => 'org.jruby.JarBootstrapMain' } ] ) do
|
104
|
-
execute_goals( 'shade', :phase => 'package' )
|
105
|
-
end
|
@@ -1,69 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Copyright (C) 2013 Christian Meier
|
3
|
-
#
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
5
|
-
# this software and associated documentation files (the "Software"), to deal in
|
6
|
-
# the Software without restriction, including without limitation the rights to
|
7
|
-
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
8
|
-
# the Software, and to permit persons to whom the Software is furnished to do so,
|
9
|
-
# subject to the following conditions:
|
10
|
-
#
|
11
|
-
# The above copyright notice and this permission notice shall be included in all
|
12
|
-
# copies or substantial portions of the Software.
|
13
|
-
#
|
14
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
16
|
-
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
17
|
-
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
18
|
-
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
19
|
-
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
20
|
-
#
|
21
|
-
require 'rubygems'
|
22
|
-
require 'jbundler/pom'
|
23
|
-
require 'bundler'
|
24
|
-
|
25
|
-
module JBundler
|
26
|
-
|
27
|
-
class GemfileLock
|
28
|
-
|
29
|
-
def initialize(jarfile, lockfile = 'Gemfile.lock')
|
30
|
-
@jarfile = jarfile
|
31
|
-
@lockfile = lockfile if File.exists?(lockfile)
|
32
|
-
end
|
33
|
-
|
34
|
-
def exists?
|
35
|
-
!@lockfile.nil?
|
36
|
-
end
|
37
|
-
|
38
|
-
def newer?( mtime )
|
39
|
-
exists? && ( self.mtime > mtime )
|
40
|
-
end
|
41
|
-
|
42
|
-
def mtime
|
43
|
-
File.mtime(@lockfile) if @lockfile
|
44
|
-
end
|
45
|
-
|
46
|
-
def populate_dependencies(aether)
|
47
|
-
if @lockfile
|
48
|
-
# assuming we run in Bundler context here
|
49
|
-
# since we have a Gemfile.lock :)
|
50
|
-
Bundler.load.specs.each do |spec|
|
51
|
-
jars = []
|
52
|
-
spec.requirements.each do |rr|
|
53
|
-
rr.split(/\n/).each do |r|
|
54
|
-
jars << r if r =~ /^\s*(jar|pom)\s/
|
55
|
-
end
|
56
|
-
end
|
57
|
-
unless jars.empty?
|
58
|
-
pom = Pom.new(spec.name, spec.version, jars, "pom")
|
59
|
-
aether.install(pom.coordinate, pom.file)
|
60
|
-
unless @jarfile.locked?(pom.coordinate)
|
61
|
-
aether.add_artifact(pom.coordinate)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
end
|
@@ -1,67 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Copyright (C) 2014 Christian Meier
|
3
|
-
#
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
5
|
-
# this software and associated documentation files (the "Software"), to deal in
|
6
|
-
# the Software without restriction, including without limitation the rights to
|
7
|
-
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
8
|
-
# the Software, and to permit persons to whom the Software is furnished to do so,
|
9
|
-
# subject to the following conditions:
|
10
|
-
#
|
11
|
-
# The above copyright notice and this permission notice shall be included in all
|
12
|
-
# copies or substantial portions of the Software.
|
13
|
-
#
|
14
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
16
|
-
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
17
|
-
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
18
|
-
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
19
|
-
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
20
|
-
#
|
21
|
-
require 'jar_dependencies'
|
22
|
-
require 'maven/tools/dsl/jarfile_lock'
|
23
|
-
module JBundler
|
24
|
-
class JarfileLock < Maven::Tools::DSL::JarfileLock
|
25
|
-
|
26
|
-
def require( scope = :runtime )
|
27
|
-
coordinates( scope ).each do |coord|
|
28
|
-
Jars.require_jar( coord.split( /:/ ) )
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def classpath( scope = :runtime )
|
33
|
-
coordinates( scope ).collect do |coord|
|
34
|
-
path_to_jar( coord.split( /:/ ) )
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def downloaded?
|
39
|
-
classpath.member?( nil ) == false &&
|
40
|
-
classpath( :test ).member?( nil ) == false
|
41
|
-
end
|
42
|
-
|
43
|
-
private
|
44
|
-
|
45
|
-
# TODO should move into jar-dependencies
|
46
|
-
def to_path( group_id, artifact_id, *classifier_version )
|
47
|
-
version = classifier_version[ -1 ]
|
48
|
-
classifier = classifier_version[ -2 ]
|
49
|
-
|
50
|
-
jar = to_jar( group_id, artifact_id, version, classifier )
|
51
|
-
( [ Jars.home ] + $LOAD_PATH ).each do |path|
|
52
|
-
if File.exists?( f = File.join( path, jar ) )
|
53
|
-
return f
|
54
|
-
end
|
55
|
-
end
|
56
|
-
nil
|
57
|
-
end
|
58
|
-
|
59
|
-
# TODO this is copy and paste from jar-dependncies
|
60
|
-
def to_jar( group_id, artifact_id, version, classifier )
|
61
|
-
file = "#{group_id.gsub( /\./, '/' )}/#{artifact_id}/#{version}/#{artifact_id}-#{version}"
|
62
|
-
file << "-#{classifier}" if classifier
|
63
|
-
file << '.jar'
|
64
|
-
file
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
require 'jbundler/pom_runner'
|
2
|
-
require 'fileutils'
|
3
|
-
module JBundler
|
4
|
-
class JRubyComplete < PomRunner
|
5
|
-
|
6
|
-
def initialize( config, options )
|
7
|
-
super options
|
8
|
-
work_dir = File.expand_path( config.work_dir )
|
9
|
-
maven.property( 'jbundler.workdir', work_dir )
|
10
|
-
maven.property( 'jbundler.basedir', config.basedir )
|
11
|
-
maven.property( 'jbundler.jarfile', config.jarfile )
|
12
|
-
maven.property( 'jbundler.gemfile', config.gemfile )
|
13
|
-
@tree = File.join( work_dir, 'tree.txt' )
|
14
|
-
maven.property( 'jbundler.outputFile', @tree )
|
15
|
-
end
|
16
|
-
|
17
|
-
def pom_file
|
18
|
-
File.join( File.dirname( __FILE__ ), 'jruby_complete_pom.rb' )
|
19
|
-
end
|
20
|
-
|
21
|
-
def show_versions
|
22
|
-
puts '...'
|
23
|
-
|
24
|
-
FileUtils.rm_f( @tree )
|
25
|
-
|
26
|
-
exec( 'dependency:tree' )
|
27
|
-
|
28
|
-
if File.exists?( @tree )
|
29
|
-
puts File.read( @tree )
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def packit
|
34
|
-
puts '...'
|
35
|
-
exec( :package )
|
36
|
-
|
37
|
-
puts
|
38
|
-
puts 'now you can use jruby like this'
|
39
|
-
puts
|
40
|
-
puts "\tjava -jar jruby_complete_custom.jar"
|
41
|
-
puts
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
jfile = ::Maven::Tools::Jarfile.new( java.lang.System.getProperty( "jbundler.jarfile" ) )
|
2
|
-
workdir = java.lang.System.getProperty( "jbundler.workdir" )
|
3
|
-
jworkdir = File.join( workdir, 'jruby_complete' )
|
4
|
-
FileUtils.mkdir_p( jworkdir )
|
5
|
-
|
6
|
-
build.directory = jworkdir
|
7
|
-
|
8
|
-
properties( 'maven.test.skip' => true,
|
9
|
-
'project.build.sourceEncoding' => 'utf-8' )
|
10
|
-
|
11
|
-
jfile.populate_unlocked do |dsl|
|
12
|
-
setup_jruby( dsl.jruby || JRUBY_VERSION, :compile )
|
13
|
-
dsl.artifacts.select do |a|
|
14
|
-
a[ :scope ] == :provided
|
15
|
-
end.each do |a|
|
16
|
-
a[ :scope ] = :compile
|
17
|
-
artifact( a )
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
plugin( :shade, '2.1',
|
22
|
-
:outputFile => "${user.dir}/jruby-complete-custom.jar",
|
23
|
-
:transformers => [ { '@implementation' => 'org.apache.maven.plugins.shade.resource.ManifestResourceTransformer',
|
24
|
-
:mainClass => 'org.jruby.Main' } ] ) do
|
25
|
-
execute_goals( 'shade', :phase => 'package' )
|
26
|
-
end
|
27
|
-
|
28
|
-
plugin( :dependency, '2.8',
|
29
|
-
:includeTypes => 'jar',
|
30
|
-
:outputAbsoluteArtifactFilename => true,
|
31
|
-
:outputFile => java.lang.System.getProperty( "jbundler.outputFile" ) )
|