jar-dependencies 0.2.6 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Mavenfile +21 -9
- data/Readme.md +55 -19
- data/lib/jar_dependencies.rb +22 -3
- data/lib/jars/attach_jars_pom.rb +24 -0
- data/lib/jars/classpath.rb +23 -3
- data/lib/jars/gemspec_artifacts.rb +9 -3
- data/lib/jars/gemspec_pom.rb +2 -23
- data/lib/jars/installer.rb +1 -1
- data/lib/jars/lock_down.rb +4 -15
- data/lib/jars/lock_down_pom.rb +15 -27
- data/lib/jars/maven_exec.rb +6 -3
- data/lib/jars/maven_factory.rb +33 -0
- data/lib/jars/output_jars_pom.rb +6 -0
- data/lib/jars/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 274254447873346a5b24169b315650e12c70dccf
|
4
|
+
data.tar.gz: e3418380915ae02feea4b997f6539b4535a02a55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4cad596f0105b5040517669ec3557c5c3b9fcaca600a42ffffd5a908446a6fe919566c652a55d82b327c780b0f6b37396484672f1531334e42b71f3136b36327
|
7
|
+
data.tar.gz: aff2bca76dddc1919217f7b2c53eef971d42b548de8ba7945635e3a340b1b5fedb99b19569f4d318c22f290e78b6e30545677622a4261ebf3c0a9cf7056a9a71
|
data/Mavenfile
CHANGED
@@ -2,8 +2,9 @@
|
|
2
2
|
|
3
3
|
gemfile
|
4
4
|
|
5
|
-
# TODO should be setup whenever a plugin uses gems
|
6
|
-
|
5
|
+
# TODO should be setup whenever a plugin uses gems by the pom-ruby-dsl
|
6
|
+
repository :id => :mavengems, :url => 'mavengem:http://rubygems.org'
|
7
|
+
extension 'de.saumya.mojo:mavengem-wagon:0.1.0'
|
7
8
|
|
8
9
|
jruby_plugin( :minitest, :minispecDirectory => "specs/*_spec.rb" ) do
|
9
10
|
execute_goals(:spec)
|
@@ -11,17 +12,21 @@ jruby_plugin( :minitest, :minispecDirectory => "specs/*_spec.rb" ) do
|
|
11
12
|
end
|
12
13
|
|
13
14
|
# retrieve the ruby-maven version
|
14
|
-
|
15
|
-
|
15
|
+
gemfile_profile = @model.profiles.detect do |p|
|
16
|
+
p.id.to_sym == :gemfile
|
17
|
+
end || @model
|
18
|
+
ruby_maven = gemfile_profile.dependencies.detect do |d|
|
19
|
+
d.artifact_id == 'ruby-maven'
|
20
|
+
end
|
16
21
|
|
17
|
-
properties( 'jruby.versions' => ['1.7.12', '1.7.
|
22
|
+
properties( 'jruby.versions' => ['1.7.12', '1.7.23', '${jruby.version}'
|
18
23
|
].join(','),
|
19
24
|
'jruby.modes' => ['1.9', '2.0', '2.2'].join(','),
|
20
25
|
# just lock the version
|
21
|
-
'bundler.version' => '1.
|
26
|
+
'bundler.version' => '1.10.6',
|
22
27
|
'ruby-maven.version' => ruby_maven.version,
|
23
|
-
'jruby.version' => '9.0.
|
24
|
-
'jruby.plugins.version' => '1.1.
|
28
|
+
'jruby.version' => '9.0.4.0',
|
29
|
+
'jruby.plugins.version' => '1.1.3',
|
25
30
|
'push.skip' => true )
|
26
31
|
|
27
32
|
plugin :invoker, '1.8' do
|
@@ -35,7 +40,8 @@ plugin :invoker, '1.8' do
|
|
35
40
|
:cloneProjectsTo => '${project.build.directory}',
|
36
41
|
:properties => { 'jar-dependencies.version' => '${project.version}',
|
37
42
|
# use an old jruby with old ruby-maven here
|
38
|
-
'jruby.version' => '1.7.20',
|
43
|
+
'jruby.old-version' => '1.7.20',
|
44
|
+
'jruby.version' => '${jruby.version}',
|
39
45
|
'jruby.plugins.version' => '${jruby.plugins.version}',
|
40
46
|
'bundler.version' => '${bundler.version}',
|
41
47
|
'ruby-maven.version' => '${ruby-maven.version}',
|
@@ -47,6 +53,12 @@ distribution_management do
|
|
47
53
|
repository :id => :ossrh, :url => 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
|
48
54
|
end
|
49
55
|
|
56
|
+
profile :id => :skip do
|
57
|
+
|
58
|
+
properties 'maven.test.skip' => true, 'invoker.skip' => true
|
59
|
+
|
60
|
+
end
|
61
|
+
|
50
62
|
profile :id => :release do
|
51
63
|
properties 'maven.test.skip' => true, 'invoker.skip' => true, 'push.skip' => false
|
52
64
|
|
data/Readme.md
CHANGED
@@ -5,36 +5,58 @@
|
|
5
5
|
|
6
6
|
add gem dependencies for jar files to ruby gems.
|
7
7
|
|
8
|
+
|
8
9
|
## getting control back over your jar ##
|
9
10
|
|
10
|
-
jar dependencies are declared in the gemspec of the gem using the same notation
|
11
|
+
jar dependencies are declared in the gemspec of the gem using the same notation
|
12
|
+
as <https://github.com/mkristian/jbundler>.
|
13
|
+
|
14
|
+
when using `require_jar` to load the jar into JRuby's classloader a version conflict
|
15
|
+
will be detected and only **ONE** jar gets loaded.
|
16
|
+
**jbundler** allows to select the version suitable for you application.
|
11
17
|
|
12
|
-
|
18
|
+
most maven-artifact do **NOT** use versions ranges but depend on a concrete version.
|
19
|
+
in such cases **jbundler** can always **overwrite** any such version.
|
13
20
|
|
14
|
-
most maven-artifact do **NOT** use versions ranges but depends pick a version. then jbundler can always **overwrite** any such version.
|
15
21
|
|
16
22
|
## vendoring your jars before packing the jar ##
|
17
23
|
|
18
|
-
add to your Rakefile
|
24
|
+
add following to your *Rakefile*:
|
19
25
|
|
20
26
|
require 'jar_installer'
|
21
27
|
task :install_jars do
|
22
28
|
Jars::JarInstaller.vendor_jars
|
23
29
|
end
|
24
30
|
|
25
|
-
which will install download the dependent jars into **JARS_HOME** and
|
31
|
+
which will install (download) the dependent jars into **JARS_HOME** and create a
|
32
|
+
file **lib/my_gem_jars.rb** which will be an enumeration of `require_jars`
|
33
|
+
statements to load all the jars.
|
34
|
+
the **vendor_jars** task will copy them into the **lib** directory of the gem.
|
26
35
|
|
27
|
-
the location where jars are cached is per default **$HOME/.m2/repository** the
|
36
|
+
the location where jars are cached is per default **$HOME/.m2/repository** the
|
37
|
+
same default as Maven uses to cache downloaded jar-artifacts.
|
38
|
+
it respects **$HOME/.m2/settings.xml** from Maven with mirror and other settings
|
39
|
+
or the environment variable **JARS_HOME**.
|
40
|
+
|
41
|
+
**IMPORTANT**: make sure that jar-dependencies is only a **development dependency**
|
42
|
+
of your gem. if it is a runtime dependency the require_jars file will be overwritten
|
43
|
+
during installation.
|
28
44
|
|
29
|
-
IMPORTANT: make sure that jar-dependencies is only a **development dependency** of your gem. if it is a runtime dependencies the require_jars file will be overwritten during installation.
|
30
45
|
|
31
46
|
## reduce the download and reuse the jars from maven local repository ##
|
32
47
|
|
33
|
-
if you do not vendor
|
48
|
+
if you do not want to vendor jars into a gem then **jar-dependency** gem can vendor
|
49
|
+
them when you install the gem. in that case do not use
|
50
|
+
`Jars::JarInstaller.install_jars` from the above rake tasks.
|
51
|
+
|
52
|
+
**NOTE**:recent JRuby comes with **jar-dependencies** as default gem, for older
|
53
|
+
versions for the feature to work you need to gem install **jar-dependencies** first
|
54
|
+
and for bundler need to use the **bundle-with-jars** command instead.
|
34
55
|
|
35
|
-
|
56
|
+
**IMPORTANT**: make sure that jar-dependencies is a **runtime dependency** of your
|
57
|
+
gem so the require_jars file will be overwritten during installation with the
|
58
|
+
"correct" versions of the jars.
|
36
59
|
|
37
|
-
IMPORTANT: make sure that jar-dependencies is a **runtime dependency** of your gem so the require_jars file will be overwritten during installation with the "correct" versions of the jars.
|
38
60
|
|
39
61
|
## for development you do not need to vendor the jars at all ##
|
40
62
|
|
@@ -42,25 +64,39 @@ just set an environment variable
|
|
42
64
|
|
43
65
|
export JARS_VENDOR=false
|
44
66
|
|
45
|
-
this tells the jar_installer not vendor any jars but only create the file with the
|
67
|
+
this tells the jar_installer not vendor any jars but only create the file with the
|
68
|
+
`require_jar` statements. this `require_jars` method will find the jar inside the
|
69
|
+
maven local repository and loads it from there.
|
70
|
+
|
46
71
|
|
47
72
|
## some drawbacks ##
|
48
73
|
|
49
|
-
|
50
|
-
|
51
|
-
|
74
|
+
* first you need to install the jar-dependency gem with its development dependencies installed (then ruby-maven gets installed as well)
|
75
|
+
* bundler does not install the jar-dependencies (unless JRuby adds the gem as default gem)
|
76
|
+
* you need ruby-maven doing the job of dependency resolution and downloading them. gems not part of <http://rubygems.org> will not work currently
|
77
|
+
|
52
78
|
|
53
79
|
## jar others then from maven-central ##
|
54
80
|
|
55
|
-
per default all jars need to come from maven-central (<search.maven.org>), in order
|
81
|
+
per default all jars need to come from maven-central (<search.maven.org>), in order
|
82
|
+
to use jars from any other repo you need to add it into your Maven *settings.xml*
|
83
|
+
and configure it in a way that works without an interactive prompt (username +
|
84
|
+
passwords needs to be part of the settings.xml file).
|
85
|
+
|
86
|
+
**NOTE:** gems depending on jars other then maven-central will **NOT** work when
|
87
|
+
they get published on rubygems.org since the user of those gems will not have the
|
88
|
+
right settings.xml to allow them to access the jar dependencies.
|
56
89
|
|
57
|
-
**NOTE:** gems depending on jars other then maven-central will **NOT** work when they get published on rubygems.org since the user of those gems will not have the right settings.xml to allow them to access the jar dependencies.
|
58
90
|
|
59
91
|
## examples ##
|
60
92
|
|
61
|
-
an [example with rspec and all](example/Readme.md) walks you through setup and
|
93
|
+
an [example with rspec and all](example/Readme.md) walks you through setup and
|
94
|
+
shows how development works and shows what happens during installation.
|
95
|
+
|
96
|
+
there are some more examples with the various [project setups for gems and application](examples/README.md).
|
97
|
+
this includes using proper Maven for the project or **ruby-maven** with rake or
|
98
|
+
the rake-compiler in conjuction with jar-dependencies.
|
62
99
|
|
63
|
-
there are some more examples with the various [project setups for gems and application](examples/README.md). this includes using proper maven for the project or ruby-maven with rake or the rake-compiler in conjuction with jar-dependencies.
|
64
100
|
|
65
101
|
# configuration #
|
66
102
|
|
@@ -98,5 +134,5 @@ or the question of how to manage jruby projects with maven [http://ruby.11.x6.na
|
|
98
134
|
|
99
135
|
or a few days ago an issue for the rake-compile [https://github.com/luislavena/rake-compiler/issues/87](https://github.com/luislavena/rake-compiler/issues/87)
|
100
136
|
|
101
|
-
with
|
137
|
+
with JRuby 9000 it is the right time to get jar dependencies "right" - the current situation is like the time before bundler for gems.
|
102
138
|
|
data/lib/jar_dependencies.rb
CHANGED
@@ -149,11 +149,25 @@ module Jars
|
|
149
149
|
( @@jars ||= {} ).clear
|
150
150
|
end
|
151
151
|
|
152
|
+
def maven_local_settings
|
153
|
+
unless instance_variable_defined?(:@_jars_maven_local_settings_)
|
154
|
+
@_jars_maven_local_settings_ = nil
|
155
|
+
end
|
156
|
+
if @_jars_maven_local_settings_.nil?
|
157
|
+
if settings = absolute( 'settings.xml' )
|
158
|
+
if File.exists?(settings)
|
159
|
+
@_jars_maven_local_settings_ = settings
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
@_jars_maven_local_settings_ || nil
|
164
|
+
end
|
165
|
+
|
152
166
|
def maven_user_settings
|
153
167
|
unless instance_variable_defined?(:@_jars_maven_user_settings_)
|
154
168
|
@_jars_maven_user_settings_ = nil
|
155
169
|
end
|
156
|
-
if
|
170
|
+
if @_jars_maven_user_settings_.nil?
|
157
171
|
if settings = absolute( to_prop( MAVEN_SETTINGS ) )
|
158
172
|
unless File.exists?(settings)
|
159
173
|
Jars.warn { "configured ENV['#{MAVEN_SETTINGS}'] = '#{settings}' not found" }
|
@@ -167,7 +181,10 @@ module Jars
|
|
167
181
|
end
|
168
182
|
@_jars_maven_user_settings_ || nil
|
169
183
|
end
|
170
|
-
|
184
|
+
|
185
|
+
def maven_settings
|
186
|
+
maven_local_settings || maven_user_settings
|
187
|
+
end
|
171
188
|
|
172
189
|
def maven_global_settings
|
173
190
|
unless instance_variable_defined?(:@_jars_maven_global_settings_)
|
@@ -186,7 +203,8 @@ module Jars
|
|
186
203
|
end
|
187
204
|
|
188
205
|
def local_maven_repo
|
189
|
-
@_local_maven_repo ||= detect_local_repository(
|
206
|
+
@_local_maven_repo ||= detect_local_repository(maven_local_settings) ||
|
207
|
+
detect_local_repository(maven_user_settings) ||
|
190
208
|
detect_local_repository(maven_global_settings) ||
|
191
209
|
File.join( user_home, '.m2', 'repository' )
|
192
210
|
end
|
@@ -226,6 +244,7 @@ module Jars
|
|
226
244
|
no_more_warnings
|
227
245
|
end
|
228
246
|
Jars.debug {
|
247
|
+
@@jars ||= {}
|
229
248
|
loaded = @@jars.collect{ |k,v| "#{k}:#{v}" }
|
230
249
|
"--- loaded jars ---\n\t#{loaded.join("\n\t")}"
|
231
250
|
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# this file is maven DSL
|
2
|
+
|
3
|
+
( 0..10000 ).each do |i|
|
4
|
+
coord = ENV_JAVA[ "jars.#{i}" ]
|
5
|
+
break unless coord
|
6
|
+
artifact = Maven::Tools::Artifact.from_coordinate( coord )
|
7
|
+
exclusions = []
|
8
|
+
( 0..10000 ).each do |j|
|
9
|
+
exclusion = ENV_JAVA[ "jars.#{i}.exclusions.#{j}" ]
|
10
|
+
break unless exclusion
|
11
|
+
exclusions << exclusion
|
12
|
+
end
|
13
|
+
scope = ENV_JAVA[ "jars.#{i}.scope" ]
|
14
|
+
artifact.scope = scope if scope
|
15
|
+
classifier = ENV_JAVA[ "jars.#{i}.classifier" ]
|
16
|
+
artifact.classifier = classifier if classifier
|
17
|
+
|
18
|
+
# declare the artifact inside the POM
|
19
|
+
dependency_artifact( artifact ) do
|
20
|
+
exclusions.each do |ex|
|
21
|
+
exclusion ex
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/jars/classpath.rb
CHANGED
@@ -6,6 +6,21 @@ module Jars
|
|
6
6
|
|
7
7
|
class Classpath
|
8
8
|
|
9
|
+
# convenient method
|
10
|
+
def self.require( scope = nil )
|
11
|
+
new.require( scope )
|
12
|
+
end
|
13
|
+
|
14
|
+
# convenient method
|
15
|
+
def self.classpath( scope = nil )
|
16
|
+
new.classpath( scope )
|
17
|
+
end
|
18
|
+
|
19
|
+
# convenient method
|
20
|
+
def self.classpath_string( scope = nil )
|
21
|
+
new.classpath_string( scope )
|
22
|
+
end
|
23
|
+
|
9
24
|
def initialize( spec = nil, deps = nil )
|
10
25
|
@spec = spec
|
11
26
|
@deps = deps
|
@@ -21,7 +36,11 @@ module Jars
|
|
21
36
|
end
|
22
37
|
|
23
38
|
def dependencies_list
|
24
|
-
if @deps
|
39
|
+
if @deps.nil?
|
40
|
+
deps = Jars.lock_path( mvn.basedir )
|
41
|
+
@deps = deps if deps && File.exist?( deps )
|
42
|
+
end
|
43
|
+
if @deps
|
25
44
|
@deps
|
26
45
|
else
|
27
46
|
resolve_dependencies
|
@@ -32,7 +51,7 @@ module Jars
|
|
32
51
|
DEPENDENCY_LIST = 'dependencies.list'
|
33
52
|
def resolve_dependencies
|
34
53
|
basedir = workdir( 'pkg' ) || workdir( 'target' ) || workdir( '' )
|
35
|
-
deps = File.join( basedir, DEPENDENCY_LIST )
|
54
|
+
deps = File.join( basedir, DEPENDENCY_LIST )
|
36
55
|
mvn.resolve_dependencies_list( deps )
|
37
56
|
deps
|
38
57
|
end
|
@@ -65,7 +84,8 @@ module Jars
|
|
65
84
|
deps = dependencies_list
|
66
85
|
Lock.new( deps ).process( scope, &block )
|
67
86
|
ensure
|
68
|
-
|
87
|
+
# just delete the temporary file if it exists
|
88
|
+
FileUtils.rm_f( DEPENDENCY_LIST )
|
69
89
|
end
|
70
90
|
private :process
|
71
91
|
|
@@ -38,7 +38,7 @@ module Jars
|
|
38
38
|
elsif arg =~ /\=/
|
39
39
|
val = arg.sub(/=\s*/, '')
|
40
40
|
# for prereleased version pick the maven version (no version range)
|
41
|
-
if val.match /[a-z]|[A-Z]/
|
41
|
+
if val.match( /[a-z]|[A-Z]/ )
|
42
42
|
[ val, val ]
|
43
43
|
else
|
44
44
|
["[#{val}", "#{val}.0.0.0.0.1)"]
|
@@ -116,7 +116,7 @@ module Jars
|
|
116
116
|
line.strip!
|
117
117
|
|
118
118
|
options = {}
|
119
|
-
line.sub!(/,\s*:exclusions\s*(:|=>)\s*(\[[
|
119
|
+
line.sub!(/,\s*:exclusions\s*(:|=>)\s*(\[[^\]]+\])/) do
|
120
120
|
options[ :exclusions ] = Exclusions.new( $2.strip )
|
121
121
|
''
|
122
122
|
end
|
@@ -124,7 +124,6 @@ module Jars
|
|
124
124
|
options[ $1.to_sym ] = $3.sub(/^:/, '')
|
125
125
|
''
|
126
126
|
end
|
127
|
-
|
128
127
|
exclusions = nil
|
129
128
|
line.sub!(/[,:]\s*\[(.+:.+,?\s*)+\]$/) do |a|
|
130
129
|
exclusions = Exclusions.new( a[1..-1].strip )
|
@@ -172,6 +171,13 @@ module Jars
|
|
172
171
|
args.join(':')
|
173
172
|
end
|
174
173
|
|
174
|
+
def to_coord_no_classifier
|
175
|
+
args = [@group_id, @artifact_id]
|
176
|
+
args << @type
|
177
|
+
args << MavenVersion.new( @version )
|
178
|
+
args.join(':')
|
179
|
+
end
|
180
|
+
|
175
181
|
def to_coord
|
176
182
|
args = [@group_id, @artifact_id]
|
177
183
|
args << @classifier if @classifier
|
data/lib/jars/gemspec_pom.rb
CHANGED
@@ -1,26 +1,5 @@
|
|
1
1
|
# this file is maven DSL and used by maven via jars/maven_exec.rb
|
2
2
|
|
3
|
-
|
3
|
+
eval( File.read( File.join( File.dirname(__FILE__), 'attach_jars_pom.rb' ) ) )
|
4
4
|
|
5
|
-
|
6
|
-
basedir( File.dirname( specfile ) )
|
7
|
-
|
8
|
-
# add jruby as provided for compilation when used vi Jars::Classpath#classpath
|
9
|
-
jar 'org.jruby:jruby-core', JRUBY_VERSION, :scope => :provided
|
10
|
-
|
11
|
-
# get ALL dependencies from the specfile
|
12
|
-
gemspec File.basename( specfile )
|
13
|
-
|
14
|
-
# we do not want those gem dependencies, each gem takes care of its
|
15
|
-
# own jar dependencies
|
16
|
-
gems = model.dependencies.select do |d|
|
17
|
-
d.group_id == 'rubygems'
|
18
|
-
end
|
19
|
-
gems.each do |d|
|
20
|
-
model.dependencies.remove( d )
|
21
|
-
end
|
22
|
-
|
23
|
-
# some output
|
24
|
-
model.dependencies.each do |d|
|
25
|
-
puts " " + d.group_id + ':' + d.artifact_id + (d.classifier ? ":" + d.classifier : "" ) + ":" + d.version unless d.artifact_id == 'jruby-core'
|
26
|
-
end
|
5
|
+
eval( File.read( File.join( File.dirname(__FILE__), 'output_jars_pom.rb' ) ) )
|
data/lib/jars/installer.rb
CHANGED
data/lib/jars/lock_down.rb
CHANGED
@@ -41,24 +41,13 @@ module Jars
|
|
41
41
|
require 'bundler'
|
42
42
|
#TODO make this group a commandline option
|
43
43
|
Bundler.setup( 'default' )
|
44
|
+
maven.property( "jars.bundler", true )
|
44
45
|
done = []
|
45
46
|
index = 0
|
47
|
+
cwd = File.expand_path( "." )
|
46
48
|
Gem.loaded_specs.each do |name, spec|
|
47
|
-
|
48
|
-
|
49
|
-
if !done.include?( a.key ) and a.scope != 'provided' and a.scope != 'test'
|
50
|
-
maven.property( "jars.#{index}", a.to_coord )
|
51
|
-
if a.exclusions
|
52
|
-
jndex = 0
|
53
|
-
a.exclusions.each do |ex|
|
54
|
-
maven.property( "jars.#{index}.exclusions.#{jndex}", ex.to_s )
|
55
|
-
end
|
56
|
-
end
|
57
|
-
maven.property( "jars.#{index}.scope", a.scope ) if a.scope
|
58
|
-
index += 1
|
59
|
-
done << a.key
|
60
|
-
end
|
61
|
-
end
|
49
|
+
# if gemspec is local then include all dependencies
|
50
|
+
maven.attach_jars( spec, cwd == spec.full_gem_path )
|
62
51
|
end
|
63
52
|
rescue Gem::LoadError => e
|
64
53
|
# not sure why to reraise the exception
|
data/lib/jars/lock_down_pom.rb
CHANGED
@@ -1,39 +1,27 @@
|
|
1
|
-
# this file is maven DSL and used by maven via jars/
|
1
|
+
# this file is maven DSL and used by maven via jars/lock_down.rb
|
2
2
|
|
3
3
|
basedir( ENV_JAVA[ "jars.basedir" ] )
|
4
4
|
|
5
|
-
(
|
6
|
-
coord = ENV_JAVA[ "jars.#{i}" ]
|
7
|
-
break unless coord
|
8
|
-
artifact = Maven::Tools::Artifact.from_coordinate( coord )
|
9
|
-
exclusions = []
|
10
|
-
( 0..10000 ).each do |j|
|
11
|
-
exclusion = ENV_JAVA[ "jars.#{i}.exclusions.#{j}" ]
|
12
|
-
break unless exclusion
|
13
|
-
exclusions << exclusion
|
14
|
-
end
|
15
|
-
scope = ENV_JAVA[ "jars.#{i}.scope" ]
|
16
|
-
artifact.scope = scope if scope
|
17
|
-
dependency_artifact( artifact ) do
|
18
|
-
exclusions.each do |ex|
|
19
|
-
exclusion ex
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
jruby_plugin :gem, ENV_JAVA[ "jruby.plugins.version" ]
|
5
|
+
eval( File.read( File.join( File.dirname(__FILE__), 'attach_jars_pom.rb' ) ) )
|
25
6
|
|
26
7
|
jfile = ENV_JAVA[ "jars.jarfile" ]
|
27
8
|
jarfile( jfile ) if jfile
|
28
9
|
|
29
|
-
|
10
|
+
# need to fix the version of this plugin for gem:jars_lock goal
|
11
|
+
jruby_plugin :gem, ENV_JAVA[ "jruby.plugins.version" ]
|
12
|
+
|
13
|
+
|
14
|
+
# if you use bundler we collect all root jar dependencies
|
15
|
+
# from each gemspec file. otherwise we need to resolve
|
16
|
+
# the gemspec artifact in the maven way
|
17
|
+
unless ENV_JAVA[ "jars.bundler" ]
|
18
|
+
|
19
|
+
gemspec rescue nil
|
20
|
+
|
21
|
+
end
|
30
22
|
|
31
23
|
properties( 'project.build.sourceEncoding' => 'utf-8' )
|
32
24
|
|
33
25
|
plugin :dependency, ENV_JAVA[ "dependency.plugin.version" ]
|
34
26
|
|
35
|
-
|
36
|
-
model.dependencies.each do |d|
|
37
|
-
puts " " + d.group_id + ':' + d.artifact_id + (d.classifier ? ":" + d.classifier : "" ) + ":" + d.version + ':' + (d.scope || 'compile')
|
38
|
-
puts " exclusions: " + d.exclusions.collect{ |e| e.group_id + ':' + e.artifact_id }.join unless d.exclusions.empty?
|
39
|
-
end
|
27
|
+
eval( File.read( File.join( File.dirname(__FILE__), 'output_jars_pom.rb' ) ) )
|
data/lib/jars/maven_exec.rb
CHANGED
@@ -35,8 +35,8 @@ module Jars
|
|
35
35
|
when String
|
36
36
|
@specfile = File.expand_path( spec )
|
37
37
|
@basedir = File.dirname( @specfile )
|
38
|
-
|
39
|
-
eval( File.read( @specfile ) )
|
38
|
+
Dir.chdir( @basedir ) do
|
39
|
+
spec = eval( File.read( @specfile ) )
|
40
40
|
end
|
41
41
|
when Gem::Specification
|
42
42
|
if File.exists?( spec.spec_file )
|
@@ -65,12 +65,15 @@ module Jars
|
|
65
65
|
factory = MavenFactory.new( @options )
|
66
66
|
maven = factory.maven_new( File.expand_path( '../gemspec_pom.rb', __FILE__ ) )
|
67
67
|
|
68
|
+
is_local_file = File.expand_path( File.dirname( @specfile ) ) == File.expand_path( Dir.pwd )
|
69
|
+
maven.attach_jars( @spec, is_local_file )
|
70
|
+
|
71
|
+
maven[ 'jars.specfile' ] = "#{@specfile}"
|
68
72
|
maven[ 'outputAbsoluteArtifactFilename' ] = 'true'
|
69
73
|
maven[ 'includeTypes' ] = 'jar'
|
70
74
|
maven[ 'outputScope' ] = 'true'
|
71
75
|
maven[ 'useRepositoryLayout' ] = 'true'
|
72
76
|
maven[ 'outputDirectory' ] = "#{Jars.home}"
|
73
|
-
maven[ 'jars.specfile' ] = "#{@specfile}"
|
74
77
|
maven[ 'outputFile' ] = "#{file}"
|
75
78
|
|
76
79
|
maven.exec( 'dependency:copy-dependencies', 'dependency:list' )
|
data/lib/jars/maven_factory.rb
CHANGED
@@ -1,8 +1,40 @@
|
|
1
1
|
require 'jar_dependencies'
|
2
|
+
require 'jars/gemspec_artifacts'
|
2
3
|
|
3
4
|
module Jars
|
4
5
|
class MavenFactory
|
5
6
|
|
7
|
+
module AttachJars
|
8
|
+
|
9
|
+
def attach_jars( spec, all_dependencies = false )
|
10
|
+
@index ||= 0
|
11
|
+
@done ||= []
|
12
|
+
|
13
|
+
deps = GemspecArtifacts.new( spec )
|
14
|
+
deps.artifacts.each do |a|
|
15
|
+
# for this gemspec we want to include all artifacts but
|
16
|
+
# for all others we want to exclude provided and test artifacts
|
17
|
+
if !@done.include?( a.key ) and (all_dependencies or (a.scope != 'provided' and a.scope != 'test'))
|
18
|
+
|
19
|
+
# ruby dsl is not working reliably for classifier
|
20
|
+
self[ "jars.#{@index}" ] = a.to_coord_no_classifier
|
21
|
+
if a.exclusions
|
22
|
+
jndex = 0
|
23
|
+
a.exclusions.each do |ex|
|
24
|
+
self[ "jars.#{@index}.exclusions.#{jndex}" ] = ex.to_s
|
25
|
+
end
|
26
|
+
end
|
27
|
+
self[ "jars.#{@index}.scope" ] = a.scope if a.scope
|
28
|
+
if a.classifier
|
29
|
+
self[ "jars.#{@index}.classifier" ] = a.classifier
|
30
|
+
end
|
31
|
+
@index += 1
|
32
|
+
@done << a.key
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
6
38
|
attr_reader :debug, :verbose
|
7
39
|
|
8
40
|
def initialize( options = nil, debug = Jars.debug?, verbose = Jars.verbose? )
|
@@ -17,6 +49,7 @@ module Jars
|
|
17
49
|
lazy_load_maven
|
18
50
|
maven = setup( Maven::Ruby::Maven.new )
|
19
51
|
|
52
|
+
maven.extend AttachJars
|
20
53
|
# TODO copy pom to tmp dir in case it is not a real file
|
21
54
|
maven.options[ '-f' ] = pom
|
22
55
|
maven
|
@@ -0,0 +1,6 @@
|
|
1
|
+
# this file is maven DSL
|
2
|
+
|
3
|
+
model.dependencies.each do |d|
|
4
|
+
puts " " + d.group_id + ':' + d.artifact_id + (d.classifier ? ":" + d.classifier : "" ) + ":" + d.version + ':' + (d.scope || 'compile')
|
5
|
+
puts " exclusions: " + d.exclusions.collect{ |e| e.group_id + ':' + e.artifact_id }.join unless d.exclusions.empty?
|
6
|
+
end
|
data/lib/jars/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jar-dependencies
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- christian meier
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -70,6 +70,7 @@ files:
|
|
70
70
|
- lib/jar_dependencies.rb
|
71
71
|
- lib/jar_install_post_install_hook.rb
|
72
72
|
- lib/jar_installer.rb
|
73
|
+
- lib/jars/attach_jars_pom.rb
|
73
74
|
- lib/jars/classpath.rb
|
74
75
|
- lib/jars/gemspec_artifacts.rb
|
75
76
|
- lib/jars/gemspec_pom.rb
|
@@ -79,6 +80,7 @@ files:
|
|
79
80
|
- lib/jars/lock_down_pom.rb
|
80
81
|
- lib/jars/maven_exec.rb
|
81
82
|
- lib/jars/maven_factory.rb
|
83
|
+
- lib/jars/output_jars_pom.rb
|
82
84
|
- lib/jars/post_install_hook.rb
|
83
85
|
- lib/jars/setup.rb
|
84
86
|
- lib/jars/version.rb
|