maven-tools 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Mavenfile +4 -3
- data/Rakefile +33 -1
- data/lib/maven/tools/dsl.rb +32 -119
- data/lib/maven/tools/dsl/dependency_dsl.rb +9 -3
- data/lib/maven/tools/dsl/gem_support.rb +97 -0
- data/lib/maven/tools/dsl/gemspec.rb +158 -0
- data/lib/maven/tools/dsl/jarfile.rb +72 -16
- data/lib/maven/tools/dsl/jarfile_lock.rb +106 -0
- data/lib/maven/tools/dsl/profile_gemspec.rb +42 -0
- data/lib/maven/tools/dsl/project_gemspec.rb +84 -0
- data/lib/maven/tools/gemspec_dependencies.rb +1 -0
- data/lib/maven/tools/jarfile.rb +7 -4
- data/lib/maven/tools/licenses.rb +77 -0
- data/lib/maven/tools/pom.rb +3 -5
- data/lib/maven/tools/project.rb +49 -0
- data/lib/maven/tools/version.rb +1 -1
- data/lib/maven/tools/versions.rb +3 -3
- data/lib/maven/tools/visitor.rb +8 -8
- data/spec/dsl/gemspec_spec.rb +58 -0
- data/spec/dsl/gemspec_spec/jars_and_poms.gemspec +22 -0
- data/spec/dsl/gemspec_spec/jars_and_poms.xml +47 -0
- data/spec/dsl/gemspec_spec/jars_and_poms_include_jars.xml +64 -0
- data/spec/dsl/gemspec_spec/maven-tools.gemspec +422 -0
- data/spec/dsl/gemspec_spec/maven-tools.xml +44 -0
- data/spec/dsl/jarfile_lock_spec.rb +118 -0
- data/spec/dsl/profile_gemspec_spec.rb +77 -0
- data/spec/dsl/profile_gemspec_spec/jars_and_poms.gemspec +21 -0
- data/spec/dsl/profile_gemspec_spec/jars_and_poms.xml +54 -0
- data/spec/dsl/profile_gemspec_spec/jars_and_poms_include_jars.xml +71 -0
- data/spec/dsl/profile_gemspec_spec/maven-tools.gemspec +422 -0
- data/spec/dsl/profile_gemspec_spec/maven-tools.xml +51 -0
- data/spec/dsl/profile_gemspec_spec/no_gems.xml +29 -0
- data/spec/dsl/profile_gemspec_spec/snapshot.gemspec +17 -0
- data/spec/dsl/profile_gemspec_spec/snapshot.xml +29 -0
- data/spec/dsl/project_gemspec_spec.rb +97 -0
- data/spec/dsl/project_gemspec_spec/extended.gemspec +22 -0
- data/spec/dsl/project_gemspec_spec/extended.xml +86 -0
- data/spec/dsl/project_gemspec_spec/jars_and_poms.gemspec +21 -0
- data/spec/dsl/project_gemspec_spec/jars_and_poms.xml +82 -0
- data/spec/dsl/project_gemspec_spec/jars_and_poms_include_jars.xml +99 -0
- data/spec/dsl/project_gemspec_spec/maven-tools.gemspec +422 -0
- data/spec/dsl/project_gemspec_spec/maven-tools.xml +79 -0
- data/spec/dsl/project_gemspec_spec/no_gems.xml +57 -0
- data/spec/dsl/project_gemspec_spec/profile.xml +84 -0
- data/spec/dsl/project_gemspec_spec/snapshot.gemspec +17 -0
- data/spec/dsl/project_gemspec_spec/snapshot.xml +57 -0
- data/spec/gemfile/pom.xml +1 -1
- data/spec/gemfile_include_jars/pom.xml +16 -1
- data/spec/gemfile_with_access_to_model/pom.xml +1 -1
- data/spec/gemfile_with_custom_source/pom.xml +1 -1
- data/spec/gemfile_with_custom_source_and_custom_jarname/pom.xml +1 -1
- data/spec/gemfile_with_extras/pom.xml +16 -1
- data/spec/gemfile_with_groups/pom.xml +1 -1
- data/spec/gemfile_with_groups_and_lockfile/pom.xml +1 -1
- data/spec/gemfile_with_lock/pom.xml +1 -1
- data/spec/gemfile_with_path/pom.xml +2 -2
- data/spec/gemfile_with_platforms/pom.xml +1 -1
- data/spec/gemfile_with_source/pom.xml +1 -1
- data/spec/gemfile_with_source_and_custom_jarname/pom.xml +1 -1
- data/spec/gemfile_with_source_and_no_jar/pom.xml +1 -1
- data/spec/gemfile_with_test_group/pom.xml +1 -1
- data/spec/gemfile_without_gemspec/pom.xml +1 -1
- data/spec/gemspec/bouncy-castle-java.gemspec +1 -0
- data/spec/gemspec/pom.xml +18 -1
- data/spec/gemspec_in_profile/pom.xml +1 -1
- data/spec/gemspec_include_jars/pom.xml +16 -1
- data/spec/gemspec_no_rubygems_repo/pom.xml +1 -1
- data/spec/gemspec_prerelease/pom.xml +2 -2
- data/spec/gemspec_prerelease_snapshot/pom.xml +1 -1
- data/spec/gemspec_with_access_to_model/pom.xml +1 -1
- data/spec/gemspec_with_custom_source/pom.xml +1 -1
- data/spec/gemspec_with_custom_source_and_custom_jarname/pom.xml +1 -1
- data/spec/gemspec_with_extras/pom.xml +16 -1
- data/spec/gemspec_with_prereleased_dependency/pom.xml +1 -1
- data/spec/gemspec_with_prereleased_dependency_and_no_repo/pom.xml +1 -1
- data/spec/gemspec_with_source/pom.xml +1 -1
- data/spec/gemspec_with_source_and_custom_jarname/pom.xml +1 -1
- data/spec/gemspec_with_source_and_no_jar/pom.xml +1 -1
- data/spec/mavenfile/Mavenfile +1 -1
- data/spec/pom.xml +1 -1
- data/spec/pom_from_jarfile/pom.xml +0 -7
- data/spec/pom_from_jarfile_and_lock/Jarfile +3 -0
- data/spec/pom_from_jarfile_and_lock/pom.rb +5 -0
- data/spec/pom_from_jarfile_and_lock/pom.xml +37 -0
- data/spec/pom_from_jarfile_and_lock/pom2.xml +41 -0
- data/spec/pom_from_jarfile_and_skip_lock/Jarfile +3 -0
- data/spec/pom_from_jarfile_and_skip_lock/pom.rb +5 -0
- data/spec/pom_from_jarfile_and_skip_lock/pom.xml +31 -0
- data/spec/pom_from_jarfile_with_jruby/Jarfile +1 -0
- data/spec/pom_from_jarfile_with_jruby/pom.xml +0 -15
- data/spec/pom_maven_alternative_style/pom.rb +1 -1
- data/spec/pom_maven_hash_style/pom.rb +1 -1
- data/spec/pom_maven_style/pom.rb +1 -1
- metadata +79 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26c28a69e50f9e111649ce61924f54cabf6f63b7
|
4
|
+
data.tar.gz: 10cac74469e0e75b47982e9edc5c596ab40f6a5e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fbed6ef1c9355e616b061e3666641fbe47084a4bc2f10b47506de85ab25003dc6b5e1f76bfa7ef46cb81b8340570783e94aa6a34410e55220bf194ff8d10dfb8
|
7
|
+
data.tar.gz: 2fbe060c86ba0bc5866f6e1d583614ae17f43f61dd818b51925a9546cfed7becb95c9585bccf6b85594073b33f629e632f2d30d3c43deb1233f19c43999fb245
|
data/Mavenfile
CHANGED
@@ -6,13 +6,14 @@ jruby_plugin( :minitest, :minispecDirectory =>"spec/*spec.rb" ) do
|
|
6
6
|
execute_goals(:spec)
|
7
7
|
end
|
8
8
|
|
9
|
-
snapshot_repository :jruby, 'http://ci.jruby.org/snapshots/maven'
|
9
|
+
#snapshot_repository :jruby, 'http://ci.jruby.org/snapshots/maven'
|
10
10
|
|
11
11
|
# (jruby-1.6.7 produces a lot of yaml errors parsing gemspecs)
|
12
|
-
properties( 'jruby.versions' => ['1.7.
|
12
|
+
properties( #'jruby.versions' => ['1.7.16.1','9.0.0.0-SNAPSHOT'].join(','),
|
13
|
+
'jruby.versions' => ['1.7.16.1'].join(','),
|
13
14
|
'jruby.modes' => ['1.9', '2.0','2.1'].join(','),
|
14
15
|
# just lock the versions
|
15
|
-
'jruby.version' => '1.7.
|
16
|
+
'jruby.version' => '1.7.16.1',
|
16
17
|
'tesla.dump.pom' => 'pom.xml',
|
17
18
|
'tesla.dump.readonly' => true )
|
18
19
|
|
data/Rakefile
CHANGED
@@ -8,6 +8,38 @@ end
|
|
8
8
|
|
9
9
|
task :default => [ :specs ]
|
10
10
|
|
11
|
+
desc 'generate licenses data from internet'
|
12
|
+
task :licenses do
|
13
|
+
require 'open-uri'
|
14
|
+
require 'ostruct'
|
15
|
+
|
16
|
+
File.open( 'lib/maven/tools/licenses.rb', 'w' ) do |f|
|
17
|
+
url = 'http://opensource.org'
|
18
|
+
f.puts "require 'ostruct'"
|
19
|
+
f.puts 'module Maven'
|
20
|
+
f.puts ' module Tools'
|
21
|
+
f.puts ' LICENSES = {}'
|
22
|
+
|
23
|
+
open( url + '/licenses/alphabetical' ).each_line do |line|
|
24
|
+
|
25
|
+
if line =~ /.*"\/licenses\// and line =~ /<li>/
|
26
|
+
l = OpenStruct.new
|
27
|
+
line.sub!( /.*"(\/licenses\/([^"]*))">/ ) do
|
28
|
+
l.url = "http://opensource.org#{$1}"
|
29
|
+
l.short = $1.sub( /\/licenses\//, '' )
|
30
|
+
''
|
31
|
+
end
|
32
|
+
line.sub!( /\ \(.*$/, '' )
|
33
|
+
f.puts " LICENSES[ #{l.short.downcase.inspect} ] = OpenStruct.new :short => #{l.short.inspect}, :name => #{line.strip.inspect}, :url => #{l.url.inspect}"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
f.puts ' LICENSES.freeze'
|
37
|
+
f.puts ' end'
|
38
|
+
f.puts 'end'
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
11
43
|
desc 'run minispecs'
|
12
44
|
task :specs do
|
13
45
|
begin
|
@@ -19,7 +51,7 @@ task :specs do
|
|
19
51
|
$LOAD_PATH << "spec"
|
20
52
|
$LOAD_PATH << "lib"
|
21
53
|
|
22
|
-
Dir['spec
|
54
|
+
Dir['spec/**/*_spec.rb'].each { |f| require f.sub(/spec\//, '') }
|
23
55
|
end
|
24
56
|
|
25
57
|
task :headers do
|
data/lib/maven/tools/dsl.rb
CHANGED
@@ -46,6 +46,15 @@ module Maven
|
|
46
46
|
@model
|
47
47
|
end
|
48
48
|
|
49
|
+
# TODO remove me
|
50
|
+
def needs_torquebox= t
|
51
|
+
@needs_torquebox = t
|
52
|
+
end
|
53
|
+
# TODO remove me
|
54
|
+
def current
|
55
|
+
@current
|
56
|
+
end
|
57
|
+
|
49
58
|
def eval_pom( src, reference_file )
|
50
59
|
@source = reference_file || '.'
|
51
60
|
eval( src, nil, ::File.expand_path( @source ) )
|
@@ -315,29 +324,16 @@ module Maven
|
|
315
324
|
options = file
|
316
325
|
file = 'Jarfile'
|
317
326
|
end
|
318
|
-
|
319
|
-
|
327
|
+
if file.is_a?( Maven::Tools::Jarfile )
|
328
|
+
warn "DEPRECATED use filename instead"
|
329
|
+
file = jfile.file
|
320
330
|
end
|
331
|
+
dsl = Maven::Tools::DSL::Jarfile.new( @current, file, options[ :skip_lock ] )
|
321
332
|
|
322
|
-
|
323
|
-
|
324
|
-
# TODO this setup should be partly part of Jarfile
|
325
|
-
jarfile_dsl( dsl )
|
326
|
-
else
|
327
|
-
file.locked.each do |dep|
|
328
|
-
artifact( dep )
|
329
|
-
end
|
330
|
-
file.populate_unlocked do |dsl|
|
331
|
-
dsl = file.setup_locked( @current )
|
332
|
-
# TODO this setup should be partly part of Jarfile
|
333
|
-
jarfile_dsl( dsl )
|
334
|
-
dsl.parent.dependencies.each do |d|
|
335
|
-
@current.dependencies << d if d.system_path
|
336
|
-
end
|
337
|
-
end
|
338
|
-
end
|
333
|
+
# TODO this setup should be part of DSL::Jarfile
|
334
|
+
jarfile_dsl( dsl )
|
339
335
|
end
|
340
|
-
|
336
|
+
|
341
337
|
def jarfile_dsl( dsl )
|
342
338
|
dsl.repositories.each do |r|
|
343
339
|
repository r.merge( {:id => r[:name] } )
|
@@ -353,112 +349,26 @@ module Maven
|
|
353
349
|
@gemspec_args = [ name, options ]
|
354
350
|
return
|
355
351
|
end
|
356
|
-
if name.is_a? Hash
|
357
|
-
options = name
|
358
|
-
name = nil
|
359
|
-
end
|
360
|
-
if name
|
361
|
-
name = ::File.join( basedir, name )
|
362
|
-
else name
|
363
|
-
gemspecs = Dir[ ::File.join( basedir, "*.gemspec" ) ]
|
364
|
-
raise "more then one gemspec file found" if gemspecs.size > 1
|
365
|
-
raise "no gemspec file found" if gemspecs.size == 0
|
366
|
-
name = gemspecs.first
|
367
|
-
end
|
368
|
-
spec = nil
|
369
|
-
f = ::File.expand_path( name )
|
370
|
-
spec_file = ::File.read( f )
|
371
|
-
begin
|
372
|
-
spec = Gem::Specification.from_yaml( spec_file )
|
373
|
-
rescue Exception
|
374
|
-
FileUtils.cd( basedir ) do
|
375
|
-
# TODO jruby java user.dir
|
376
|
-
spec = eval( spec_file, nil, f )
|
377
|
-
end
|
378
|
-
end
|
379
|
-
|
380
|
-
self.spec( spec, name, options )
|
381
|
-
end
|
382
|
-
|
383
|
-
def spec( spec, name = nil, options = {} )
|
384
|
-
name ||= "#{spec.name}-#{spec.version}.gemspec"
|
385
|
-
|
386
|
-
@gemfile_options = nil
|
387
|
-
|
388
352
|
if @context == :project
|
389
|
-
|
390
|
-
|
391
|
-
if options[ :snapshot ] && spec.version.prerelease?
|
392
|
-
version += '-SNAPSHOT'
|
393
|
-
end
|
394
|
-
id "rubygems:#{spec.name}:#{version}"
|
395
|
-
name( spec.summary || spec.name )
|
396
|
-
description spec.description
|
397
|
-
url spec.homepage
|
398
|
-
if spec.homepage && spec.homepage.match( /github.com/ )
|
399
|
-
con = spec.homepage.sub( /http:/, 'https:' ).sub( /\/?$/, ".git" )
|
400
|
-
scm :url => spec.homepage, :connection => con
|
401
|
-
end
|
402
|
-
|
403
|
-
spec.licenses.each do |l|
|
404
|
-
license( l )
|
405
|
-
end
|
406
|
-
authors = [ spec.authors || [] ].flatten
|
407
|
-
emails = [ spec.email || [] ].flatten
|
408
|
-
authors.zip( emails ).each do |d|
|
409
|
-
developer( :name => d[0], :email => d[1] )
|
410
|
-
end
|
411
|
-
end
|
412
|
-
|
413
|
-
has_jars = setup_gem_support( options, spec )
|
414
|
-
|
415
|
-
if @context == :project and not options[ :only_metadata ]
|
416
|
-
packaging 'gem'
|
417
|
-
if has_jars
|
418
|
-
extension 'de.saumya.mojo:gem-with-jar-extension:${jruby.plugins.version}'
|
419
|
-
else
|
420
|
-
extension 'de.saumya.mojo:gem-extension:${jruby.plugins.version}'
|
421
|
-
end
|
422
|
-
end
|
423
|
-
|
424
|
-
return if options[ :only_metadata ]
|
425
|
-
|
426
|
-
config = { :gemspec => name.sub( /^#{basedir}\/?/, '' ) }
|
427
|
-
if options[ :include_jars ] || options[ 'include_jars' ]
|
428
|
-
config[ :includeDependencies ] = true
|
429
|
-
config[ :useRepositoryLayout ] = true
|
430
|
-
end
|
431
|
-
jruby_plugin!( :gem, config )
|
432
|
-
|
433
|
-
deps = nil
|
434
|
-
if @inside_gemfile.is_a? Symbol
|
435
|
-
profile! @inside_gemfile do
|
436
|
-
deps = all_deps( spec )
|
353
|
+
if @inside_gemfile.is_a? Symbol
|
354
|
+
options[ :profile ] = @inside_gemfile
|
437
355
|
end
|
356
|
+
options[ :no_gems ] = gemspec_without_gem_dependencies?
|
357
|
+
require_relative 'dsl/project_gemspec'
|
358
|
+
DSL::ProjectGemspec.new( self, name, options )
|
438
359
|
else
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
deps.java_dependency_artifacts.each do |a|
|
443
|
-
_dependency a
|
360
|
+
require_relative 'dsl/profile_gemspec'
|
361
|
+
DSL::ProfileGemspec.new( self, name, options )
|
444
362
|
end
|
445
363
|
end
|
446
364
|
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
scope :test do
|
454
|
-
deps.development.each do |d|
|
455
|
-
gem d
|
456
|
-
end
|
457
|
-
end
|
458
|
-
end
|
459
|
-
deps
|
365
|
+
# TODO remove this hack to get jar-dependencies to work
|
366
|
+
def gemspec_without_gem_dependencies?
|
367
|
+
gems = GemspecDependencies.new( Gem::Specification.new )
|
368
|
+
gems.runtime << 123
|
369
|
+
deps = gems.send( :_deps, :runtime )
|
370
|
+
deps.size == 0
|
460
371
|
end
|
461
|
-
private :all_deps
|
462
372
|
|
463
373
|
def licenses
|
464
374
|
yield
|
@@ -1309,6 +1219,9 @@ module Maven
|
|
1309
1219
|
if @context
|
1310
1220
|
m = "#{method}=".to_sym
|
1311
1221
|
if @current.respond_to? m
|
1222
|
+
if method == :properties && defined? JRUBY_VERSION
|
1223
|
+
return @current.properties = java.util.Properties.new
|
1224
|
+
end
|
1312
1225
|
#p @context
|
1313
1226
|
#p m
|
1314
1227
|
#p args
|
@@ -29,9 +29,15 @@ module Maven
|
|
29
29
|
|
30
30
|
class << self
|
31
31
|
def create( parent, type, scope, *args, &block )
|
32
|
-
|
33
|
-
|
34
|
-
|
32
|
+
if type
|
33
|
+
a = DependencyDSL.from( type, *args, &block )
|
34
|
+
a.scope = scope if scope
|
35
|
+
else
|
36
|
+
scope = args.shift
|
37
|
+
args += [nil, nil, { :scope => scope } ][ (args.size - 4 )..2 ]
|
38
|
+
a = DependencyDSL.new( *args )
|
39
|
+
end
|
40
|
+
|
35
41
|
options = process_exclusions( a.model, a.dup )
|
36
42
|
a.instance_eval &block if block
|
37
43
|
fill_options( a.model, options, :type )
|
@@ -0,0 +1,97 @@
|
|
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
|
+
module Maven
|
22
|
+
module Tools
|
23
|
+
module DSL
|
24
|
+
module GemSupport
|
25
|
+
|
26
|
+
def setup_jruby_plugins_version( project )
|
27
|
+
if not @parent.properties.key?( 'jruby.plugins.version' ) and
|
28
|
+
not project.properties.key?( 'jruby.plugins.version' )
|
29
|
+
@parent.properties( 'jruby.plugins.version' => VERSIONS[ :jruby_plugins ] )
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def setup_gem_support( project, options, spec = nil )
|
34
|
+
unless project.properties.member?( 'project.build.sourceEncoding' )
|
35
|
+
@parent.properties( 'project.build.sourceEncoding' => 'utf-8' )
|
36
|
+
end
|
37
|
+
if spec.nil?
|
38
|
+
require_path = '.'
|
39
|
+
name = ::File.basename( ::File.expand_path( '.' ) )
|
40
|
+
else
|
41
|
+
require_path = spec.require_path
|
42
|
+
name = spec.name
|
43
|
+
end
|
44
|
+
|
45
|
+
if ( nil == project.current.repositories.detect { |r| r.id == 'rubygems-releases' } && options[ :no_rubygems_repo ] != true )
|
46
|
+
|
47
|
+
@parent.repository( 'rubygems-releases',
|
48
|
+
'http://rubygems-proxy.torquebox.org/releases' )
|
49
|
+
end
|
50
|
+
@parent.needs_torquebox = true
|
51
|
+
|
52
|
+
setup_jruby_plugins_version( project )
|
53
|
+
|
54
|
+
if options.key?( :jar ) || options.key?( 'jar' )
|
55
|
+
jarpath = options[ :jar ] || options[ 'jar' ]
|
56
|
+
if jarpath
|
57
|
+
jar = ::File.basename( jarpath ).sub( /.jar$/, '' )
|
58
|
+
output = ::File.dirname( "#{require_path}/#{jarpath}" )
|
59
|
+
output.sub!( /\/$/, '' )
|
60
|
+
end
|
61
|
+
else
|
62
|
+
jar = "#{name}"
|
63
|
+
output = "#{require_path}"
|
64
|
+
end
|
65
|
+
if options.key?( :source ) || options.key?( 'source' )
|
66
|
+
source = options[ :source ] || options[ 'source' ]
|
67
|
+
@parent.build do
|
68
|
+
@parent.source_directory source
|
69
|
+
end
|
70
|
+
end
|
71
|
+
# TODO rename "no_rubygems_repo" to "no_jar_support"
|
72
|
+
if( options[ :no_rubygems_repo ] != true &&
|
73
|
+
jar &&
|
74
|
+
( source || File.exists?( File.join( project.basedir,
|
75
|
+
'src/main/java' ) ) ) )
|
76
|
+
|
77
|
+
unless spec.nil? || spec.platform.to_s.match( /java|jruby/ )
|
78
|
+
warn "gem is not a java platform gem but has a jar and source"
|
79
|
+
end
|
80
|
+
|
81
|
+
@parent.plugin( :jar, VERSIONS[ :jar_plugin ],
|
82
|
+
:outputDirectory => output,
|
83
|
+
:finalName => jar ) do
|
84
|
+
@parent.execute_goals :jar, :phase => 'prepare-package'
|
85
|
+
end
|
86
|
+
@parent.plugin( :clean, VERSIONS[ :clean_plugin ],
|
87
|
+
:filesets => [ { :directory => output,
|
88
|
+
:includes => [ "#{jar}.jar", '*/**/*.jar' ] } ] )
|
89
|
+
true
|
90
|
+
else
|
91
|
+
false
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,158 @@
|
|
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 'maven/tools/coordinate'
|
22
|
+
require 'maven/tools/versions'
|
23
|
+
require 'maven/tools/dsl/jruby_dsl'
|
24
|
+
require 'maven/tools/dsl/dependency_dsl'
|
25
|
+
module Maven
|
26
|
+
module Tools
|
27
|
+
module DSL
|
28
|
+
class Gemspec
|
29
|
+
|
30
|
+
def initialize( parent, name = nil, options = {} )
|
31
|
+
@parent = parent
|
32
|
+
case name
|
33
|
+
when Hash
|
34
|
+
options = name
|
35
|
+
name = options[ 'name' ] || options[ :name ]
|
36
|
+
when Gem::Specification
|
37
|
+
process_gem_spec( name, options )
|
38
|
+
return
|
39
|
+
end
|
40
|
+
name = find_gemspec_file( name )
|
41
|
+
spec = gem_specification( name )
|
42
|
+
name ||= "#{spec.name}-#{spec.version}.gemspec"
|
43
|
+
process( spec, name, options )
|
44
|
+
end
|
45
|
+
|
46
|
+
attr_reader :parent
|
47
|
+
|
48
|
+
def help
|
49
|
+
warn "\n# Jarfile DSL #\n"
|
50
|
+
warn self.class.help_block( :local => "path-to-local-jar", :jar => nil, :pom => nil, :repository => nil, :snapshot_repository => nil, :jruby => nil, :scope => nil)[0..-2]
|
51
|
+
end
|
52
|
+
|
53
|
+
def gem( scope, coord )
|
54
|
+
DependencyDSL.create( @parent.current, :gem, scope, coord )
|
55
|
+
end
|
56
|
+
|
57
|
+
def jar( line )
|
58
|
+
maven_dependency( "jar #{line}" )
|
59
|
+
end
|
60
|
+
|
61
|
+
def pom( line )
|
62
|
+
maven_dependency( "pom #{line}" )
|
63
|
+
end
|
64
|
+
|
65
|
+
def method_missing( m, *args )
|
66
|
+
if args.size == 1
|
67
|
+
warn "unknown declaration: #{m} " + args[0]
|
68
|
+
else
|
69
|
+
super
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
private
|
74
|
+
|
75
|
+
include Maven::Tools::Coordinate
|
76
|
+
|
77
|
+
def process_gem_spec( spec, options )
|
78
|
+
if spec.spec_file
|
79
|
+
name = File.basename( spec.spec_file )
|
80
|
+
else
|
81
|
+
name = nil
|
82
|
+
end
|
83
|
+
process( spec, name, options )
|
84
|
+
end
|
85
|
+
|
86
|
+
def find_gemspec_file( name )
|
87
|
+
if name
|
88
|
+
::File.join( @parent.basedir, name )
|
89
|
+
else
|
90
|
+
gemspecs = Dir[ ::File.join( @parent.basedir, "*.gemspec" ) ]
|
91
|
+
raise "more then one gemspec file found" if gemspecs.size > 1
|
92
|
+
raise "no gemspec file found" if gemspecs.size == 0
|
93
|
+
gemspecs.first
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def gem_specification( name )
|
98
|
+
path = File.expand_path( name )
|
99
|
+
spec_file = File.read( path )
|
100
|
+
begin
|
101
|
+
Gem::Specification.from_yaml( spec_file )
|
102
|
+
rescue Exception
|
103
|
+
FileUtils.cd( @parent.basedir ) do
|
104
|
+
return eval( spec_file, nil, path )
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def process( spec, name, options )
|
110
|
+
if name
|
111
|
+
config = { :gemspec => name.sub( /^#{@parent.basedir}\/?/, '' ) }
|
112
|
+
end
|
113
|
+
if options[ :include_jars ] || options[ 'include_jars' ]
|
114
|
+
config[ :includeDependencies ] = true
|
115
|
+
config[ :useRepositoryLayout ] = true
|
116
|
+
@parent.plugin :dependency do
|
117
|
+
@parent.execute_goal( 'copy-dependencies',
|
118
|
+
:phase => 'generate-test-resources',
|
119
|
+
:outputDirectory => spec.require_path,
|
120
|
+
:useRepositoryLayout => true )
|
121
|
+
end
|
122
|
+
end
|
123
|
+
@parent.jruby_plugin!( :gem, config )
|
124
|
+
|
125
|
+
gem_deps( spec, options ) unless options[ :no_gems ]
|
126
|
+
other_deps( spec )
|
127
|
+
end
|
128
|
+
|
129
|
+
def gem_deps( spec, options )
|
130
|
+
spec.dependencies.each do |dep|
|
131
|
+
versions = dep.requirement.requirements.collect do |req|
|
132
|
+
# use this construct to get the same result in 1.8.x and 1.9.x
|
133
|
+
req.collect{ |i| i.to_s }.join
|
134
|
+
end
|
135
|
+
scope = dep.type == :development ? :test : nil
|
136
|
+
gem( scope, "rubygems:#{dep.name}:#{to_version( *versions )}" )
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
def other_deps( spec )
|
141
|
+
spec.requirements.each do |req|
|
142
|
+
req.sub!( /#.*^/, '' )
|
143
|
+
method = req.sub(/\s.*$/, '' ).to_sym
|
144
|
+
line = req.sub(/^[^\s]*\s/, '' )
|
145
|
+
send method, line
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
def maven_dependency( line )
|
150
|
+
coord = to_split_coordinate_with_scope( line )
|
151
|
+
if coord && coord.size > 1
|
152
|
+
DependencyDSL.create( @parent.current, nil, nil, *coord )
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|