lock_jar 0.15.11-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.codeclimate.yml +16 -0
- data/.gitignore +59 -0
- data/.rubocop.yml +31 -0
- data/.travis.yml +21 -0
- data/CHANGELOG.md +80 -0
- data/Gemfile +13 -0
- data/Guardfile +8 -0
- data/LICENSE +176 -0
- data/README.md +392 -0
- data/Rakefile +28 -0
- data/bin/lockjar +6 -0
- data/lib/lock_jar/buildr.rb +151 -0
- data/lib/lock_jar/bundler.rb +68 -0
- data/lib/lock_jar/class_loader.rb +67 -0
- data/lib/lock_jar/cli.rb +92 -0
- data/lib/lock_jar/config.rb +41 -0
- data/lib/lock_jar/domain/artifact.rb +114 -0
- data/lib/lock_jar/domain/dsl.rb +165 -0
- data/lib/lock_jar/domain/dsl_merger.rb +76 -0
- data/lib/lock_jar/domain/gem_dsl.rb +43 -0
- data/lib/lock_jar/domain/jarfile_dsl.rb +35 -0
- data/lib/lock_jar/domain/lockfile.rb +113 -0
- data/lib/lock_jar/logging.rb +14 -0
- data/lib/lock_jar/maven.rb +112 -0
- data/lib/lock_jar/registry.rb +85 -0
- data/lib/lock_jar/resolver.rb +100 -0
- data/lib/lock_jar/runtime/install.rb +28 -0
- data/lib/lock_jar/runtime/list.rb +77 -0
- data/lib/lock_jar/runtime/load.rb +53 -0
- data/lib/lock_jar/runtime/lock.rb +152 -0
- data/lib/lock_jar/runtime.rb +106 -0
- data/lib/lock_jar/version.rb +5 -0
- data/lib/lock_jar.rb +203 -0
- data/lock_jar.gemspec +36 -0
- data/spec/fixtures/Jarfile +14 -0
- data/spec/fixtures/Jarfile2 +1 -0
- data/spec/fixtures/jarfile_gem/Gemfile +4 -0
- data/spec/fixtures/jarfile_gem/Jarfile +1 -0
- data/spec/fixtures/jarfile_gem/jarfile_gem.gemspec +23 -0
- data/spec/fixtures/jarfile_gem/lib/jarfile_gem/version.rb +3 -0
- data/spec/fixtures/jarfile_gem/lib/jarfile_gem.rb +5 -0
- data/spec/fixtures/lock_jar_config.yml +4 -0
- data/spec/fixtures/naether-0.13.0.jar +0 -0
- data/spec/lock_jar/bundler_spec.rb +34 -0
- data/spec/lock_jar/class_loader_spec.rb +55 -0
- data/spec/lock_jar/cli_spec.rb +93 -0
- data/spec/lock_jar/config_spec.rb +51 -0
- data/spec/lock_jar/domain/dsl_merger_spec.rb +51 -0
- data/spec/lock_jar/domain/dsl_spec.rb +55 -0
- data/spec/lock_jar/domain/gem_dsl_spec.rb +18 -0
- data/spec/lock_jar/maven_spec.rb +21 -0
- data/spec/lock_jar/resolver_spec.rb +69 -0
- data/spec/lock_jar/runtime_spec.rb +30 -0
- data/spec/lock_jar_spec.rb +472 -0
- data/spec/pom.xml +28 -0
- data/spec/spec_helper.rb +45 -0
- data/spec/support/Jarfile +1 -0
- data/spec/support/helper.rb +52 -0
- data/spec/support/shared_examples/lockfile.rb +45 -0
- metadata +203 -0
@@ -0,0 +1,67 @@
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
+
# contributor license agreements. See the NOTICE file distributed with this
|
3
|
+
# work for additional information regarding copyright ownership. The ASF
|
4
|
+
# licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
+
# "License"); you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
+
# License for the specific language governing permissions and limitations under
|
14
|
+
# the License.
|
15
|
+
|
16
|
+
require 'lock_jar'
|
17
|
+
require 'naether'
|
18
|
+
|
19
|
+
module LockJar
|
20
|
+
#
|
21
|
+
# Create a ClassLoader populated by a lockfile
|
22
|
+
#
|
23
|
+
# @author Michael Guymon
|
24
|
+
#
|
25
|
+
class ClassLoader
|
26
|
+
# Create new instance, populating ClassLoader with lockfile
|
27
|
+
#
|
28
|
+
# @param [String] lockfile path
|
29
|
+
def initialize(lockfile)
|
30
|
+
# XXX: ensure Naether has been loaded, this should be handled less
|
31
|
+
# clumsily
|
32
|
+
LockJar::Runtime.instance.resolver(nil)
|
33
|
+
@class_loader = com.tobedevoured.naether.PathClassLoader.new(
|
34
|
+
java.lang.Thread.currentThread.getContextClassLoader())
|
35
|
+
|
36
|
+
jars = LockJar.list(lockfile, local_paths: true)
|
37
|
+
jars.each do |jar|
|
38
|
+
add_path(jar)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# Execute block
|
43
|
+
#
|
44
|
+
# @param [Block] blk
|
45
|
+
def isolate(&blk)
|
46
|
+
instance_eval(&blk)
|
47
|
+
end
|
48
|
+
|
49
|
+
# Add path to the ClassLoader
|
50
|
+
#
|
51
|
+
# @param [String] path of Jar or directory to add to ClassLoader
|
52
|
+
# @return [Boolean] if added
|
53
|
+
def add_path(path)
|
54
|
+
@class_loader.addPath(path)
|
55
|
+
end
|
56
|
+
|
57
|
+
#
|
58
|
+
# Create new instance of a Java class using the populated ClassLoader
|
59
|
+
#
|
60
|
+
# @param [String] clazz fully qualified Java class
|
61
|
+
# @param [Array] args arguments for constructing the Java class
|
62
|
+
# @return [Object]
|
63
|
+
def new_instance(clazz, *args)
|
64
|
+
@class_loader.newInstance(clazz, *args)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
data/lib/lock_jar/cli.rb
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'thor'
|
3
|
+
require 'lock_jar'
|
4
|
+
require 'lock_jar/logging'
|
5
|
+
|
6
|
+
module LockJar
|
7
|
+
#
|
8
|
+
class CLI < Thor
|
9
|
+
#
|
10
|
+
module ClassMethods
|
11
|
+
def generate_lockfile_option
|
12
|
+
method_option(
|
13
|
+
:lockfile,
|
14
|
+
aliases: '-l',
|
15
|
+
default: 'Jarfile.lock',
|
16
|
+
desc: 'Path to Jarfile.lock'
|
17
|
+
)
|
18
|
+
end
|
19
|
+
|
20
|
+
def generate_scopes_option
|
21
|
+
method_option(
|
22
|
+
:scopes,
|
23
|
+
aliases: '-s',
|
24
|
+
default: ['default'],
|
25
|
+
desc: 'Scopes to install from Jarfile.lock',
|
26
|
+
type: :array
|
27
|
+
)
|
28
|
+
end
|
29
|
+
|
30
|
+
def generate_jarfile_option
|
31
|
+
method_option(
|
32
|
+
:jarfile,
|
33
|
+
aliases: '-j',
|
34
|
+
default: 'Jarfile',
|
35
|
+
desc: 'Path to Jarfile'
|
36
|
+
)
|
37
|
+
end
|
38
|
+
|
39
|
+
def verbose_option
|
40
|
+
method_option(
|
41
|
+
:verbose,
|
42
|
+
aliases: '-v',
|
43
|
+
type: :boolean,
|
44
|
+
desc: 'Verbose output'
|
45
|
+
)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
extend(ClassMethods)
|
49
|
+
|
50
|
+
desc 'version', 'LockJar version'
|
51
|
+
def version
|
52
|
+
puts LockJar::VERSION
|
53
|
+
end
|
54
|
+
|
55
|
+
desc 'install', 'Install Jars from a Jarfile.lock'
|
56
|
+
generate_lockfile_option
|
57
|
+
generate_scopes_option
|
58
|
+
verbose_option
|
59
|
+
def install
|
60
|
+
handle_verbose(options[:verbose])
|
61
|
+
puts "Installing Jars from #{options[:lockfile]} for #{options[:scopes].inspect}"
|
62
|
+
LockJar.install(options[:lockfile], options[:scopes])
|
63
|
+
end
|
64
|
+
|
65
|
+
desc 'list', 'List Jars from a Jarfile.lock'
|
66
|
+
generate_lockfile_option
|
67
|
+
generate_scopes_option
|
68
|
+
verbose_option
|
69
|
+
def list
|
70
|
+
handle_verbose(options[:verbose])
|
71
|
+
puts "Listing Jars from #{options[:lockfile]} for #{options[:scopes].inspect}"
|
72
|
+
puts LockJar.list(options[:lockfile], options[:scopes]).inspect
|
73
|
+
end
|
74
|
+
|
75
|
+
desc 'lock', 'Lock Jars in a Jarfile.lock'
|
76
|
+
generate_jarfile_option
|
77
|
+
generate_lockfile_option
|
78
|
+
verbose_option
|
79
|
+
def lock
|
80
|
+
handle_verbose(options[:verbose])
|
81
|
+
puts "Locking #{options[:jarfile]} to #{options[:lockfile]}"
|
82
|
+
LockJar.lock(options[:jarfile], lockfile: options[:lockfile])
|
83
|
+
end
|
84
|
+
|
85
|
+
private
|
86
|
+
|
87
|
+
def handle_verbose(verbose)
|
88
|
+
LockJar::Logging.verbose! if verbose
|
89
|
+
nil
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module LockJar
|
4
|
+
# Global configuration for LockJar
|
5
|
+
class Config
|
6
|
+
CONFIG_ENV = 'LOCKJAR_CONFIG'.freeze
|
7
|
+
DEFAULT_FILENAME = '.lockjar'.freeze
|
8
|
+
|
9
|
+
attr_reader :repositories
|
10
|
+
|
11
|
+
class << self
|
12
|
+
# Load .lockjar YAML config file from ENV['LOCKJAR_CONFIG'], current_dir, or
|
13
|
+
# home dir.
|
14
|
+
def load_config_file
|
15
|
+
local_config_paths =
|
16
|
+
[Dir.pwd, Dir.home]
|
17
|
+
.map { |path| File.join(path, DEFAULT_FILENAME) }
|
18
|
+
|
19
|
+
config_path =
|
20
|
+
([ENV[CONFIG_ENV]] + local_config_paths)
|
21
|
+
.compact
|
22
|
+
.find { |path| File.exist? path }
|
23
|
+
|
24
|
+
new(YAML.load_file(config_path)) if config_path
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
#
|
29
|
+
# {
|
30
|
+
# 'repositories' => {
|
31
|
+
# ':url' => {
|
32
|
+
# 'username' => ''
|
33
|
+
# 'password' => ''
|
34
|
+
# }
|
35
|
+
# }
|
36
|
+
# }
|
37
|
+
def initialize(config)
|
38
|
+
@repositories = config['repositories'] || {}
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,114 @@
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
+
# contributor license agreements. See the NOTICE file distributed with this
|
3
|
+
# work for additional information regarding copyright ownership. The ASF
|
4
|
+
# licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
+
# "License"); you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
+
# License for the specific language governing permissions and limitations under
|
14
|
+
# the License.
|
15
|
+
|
16
|
+
require 'set'
|
17
|
+
require 'lock_jar/maven'
|
18
|
+
require 'naether/notation'
|
19
|
+
|
20
|
+
module LockJar
|
21
|
+
module Domain
|
22
|
+
#
|
23
|
+
class Artifact
|
24
|
+
include Comparable
|
25
|
+
attr_reader :type
|
26
|
+
|
27
|
+
def <=>(other)
|
28
|
+
return to_urn <=> other.to_urn if other.is_a? Artifact
|
29
|
+
|
30
|
+
to_urn <=> other.to_s
|
31
|
+
end
|
32
|
+
|
33
|
+
def resolvable?
|
34
|
+
true
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
#
|
39
|
+
class Jar < Artifact
|
40
|
+
attr_reader :notation
|
41
|
+
|
42
|
+
def initialize(notation)
|
43
|
+
@type = 'jar'
|
44
|
+
@notation = Naether::Notation.new(notation).to_notation
|
45
|
+
end
|
46
|
+
|
47
|
+
def to_urn
|
48
|
+
"jar:#{notation}"
|
49
|
+
end
|
50
|
+
|
51
|
+
def to_dep
|
52
|
+
notation
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
#
|
57
|
+
class Local < Artifact
|
58
|
+
attr_reader :path
|
59
|
+
def initialize(path)
|
60
|
+
@type = 'local'
|
61
|
+
@path = path
|
62
|
+
end
|
63
|
+
|
64
|
+
def to_urn
|
65
|
+
"local:#{path}"
|
66
|
+
end
|
67
|
+
|
68
|
+
def to_dep
|
69
|
+
path
|
70
|
+
end
|
71
|
+
|
72
|
+
def resolvable?
|
73
|
+
false
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
#
|
78
|
+
class Pom < Artifact
|
79
|
+
attr_reader :path, :scopes
|
80
|
+
|
81
|
+
def initialize(pom_path, pom_scopes = %w(compile runtime))
|
82
|
+
@type = 'pom'
|
83
|
+
@path = pom_path
|
84
|
+
@scopes = pom_scopes
|
85
|
+
end
|
86
|
+
|
87
|
+
def to_urn
|
88
|
+
"pom:#{path}"
|
89
|
+
end
|
90
|
+
|
91
|
+
def to_dep
|
92
|
+
{ path => scopes }
|
93
|
+
end
|
94
|
+
|
95
|
+
def notations
|
96
|
+
LockJar::Maven.dependencies(path, scopes)
|
97
|
+
end
|
98
|
+
|
99
|
+
def ==(other)
|
100
|
+
self.<=>(other) == 0
|
101
|
+
end
|
102
|
+
|
103
|
+
def <=>(other)
|
104
|
+
if other.is_a? Pom
|
105
|
+
return Set.new(scopes) <=> Set.new(other.scopes) if to_urn == other.to_urn
|
106
|
+
|
107
|
+
to_urn <=> other.to_urn
|
108
|
+
else
|
109
|
+
super
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
@@ -0,0 +1,165 @@
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
+
# contributor license agreements. See the NOTICE file distributed with this
|
3
|
+
# work for additional information regarding copyright ownership. The ASF
|
4
|
+
# licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
+
# "License"); you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
+
# License for the specific language governing permissions and limitations under
|
14
|
+
# the License.
|
15
|
+
|
16
|
+
require 'lock_jar/maven'
|
17
|
+
require 'lock_jar/domain/dsl_merger'
|
18
|
+
require 'lock_jar/domain/artifact'
|
19
|
+
|
20
|
+
module LockJar
|
21
|
+
module Domain
|
22
|
+
#
|
23
|
+
class Dsl
|
24
|
+
DEFAULT_GROUP = ['default'].freeze
|
25
|
+
|
26
|
+
attr_accessor :artifacts, :remote_repositories, :local_repository, :groups,
|
27
|
+
:maps, :excludes, :merged, :clear_repositories
|
28
|
+
|
29
|
+
attr_reader :file_path
|
30
|
+
|
31
|
+
class << self
|
32
|
+
def create(jarfile = nil, &blk)
|
33
|
+
builder = new
|
34
|
+
evaluate(builder, jarfile, &blk)
|
35
|
+
end
|
36
|
+
|
37
|
+
def evaluate(builder, jarfile = nil, &blk)
|
38
|
+
fail 'jarfile or block must be set' if jarfile.nil? && blk.nil?
|
39
|
+
|
40
|
+
builder.instance_eval(IO.read(jarfile.to_s), jarfile.to_s, 1) if jarfile
|
41
|
+
|
42
|
+
builder.instance_eval(&blk) if blk
|
43
|
+
|
44
|
+
builder
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def initialize
|
49
|
+
@remote_repositories = []
|
50
|
+
@artifacts = { 'default' => [] }
|
51
|
+
@group_changed = false
|
52
|
+
@present_group = 'default'
|
53
|
+
@local_repository = nil
|
54
|
+
@maps = {}
|
55
|
+
@excludes = []
|
56
|
+
@merged = []
|
57
|
+
@clear_repositories = false
|
58
|
+
end
|
59
|
+
|
60
|
+
def exclude(*notations)
|
61
|
+
@excludes += notations
|
62
|
+
end
|
63
|
+
|
64
|
+
def jar(notation, *args)
|
65
|
+
opts = {}
|
66
|
+
|
67
|
+
opts.merge!(args.last) if args.last.is_a? Hash
|
68
|
+
|
69
|
+
artifact = Jar.new(notation)
|
70
|
+
|
71
|
+
assign_groups(artifact, opts[:group])
|
72
|
+
end
|
73
|
+
|
74
|
+
def local(*args)
|
75
|
+
return if args.empty?
|
76
|
+
|
77
|
+
if File.directory?(File.expand_path(args.first))
|
78
|
+
warn(
|
79
|
+
'[DEPRECATED] `local` to set local_repository is deprecated. '\
|
80
|
+
'Please use `local_repo` instead'
|
81
|
+
)
|
82
|
+
local_repo(args.first)
|
83
|
+
else
|
84
|
+
path = args.shift
|
85
|
+
|
86
|
+
opts = {}
|
87
|
+
|
88
|
+
opts.merge!(args.last) if args.last.is_a? Hash
|
89
|
+
|
90
|
+
artifact = Local.new(path)
|
91
|
+
|
92
|
+
assign_groups(artifact, opts[:group])
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def local_repo(path)
|
97
|
+
@local_repository = path
|
98
|
+
end
|
99
|
+
|
100
|
+
alias_method :name, :local_repository
|
101
|
+
|
102
|
+
# Map a dependency to another dependency or local directory.
|
103
|
+
def map(notation, *args)
|
104
|
+
@maps[notation] = args
|
105
|
+
end
|
106
|
+
|
107
|
+
#
|
108
|
+
def pom(path, *args)
|
109
|
+
fail "#{path} is an invalid pom path" unless path =~ /\.xml$/i
|
110
|
+
|
111
|
+
opts = { scopes: %w(runtime compile) }
|
112
|
+
|
113
|
+
opts.merge!(args.last) if args.last.is_a? Hash
|
114
|
+
|
115
|
+
assign_groups(Pom.new(path, opts[:scopes]), opts[:groups])
|
116
|
+
end
|
117
|
+
|
118
|
+
def remote_repo(url, _opts = {})
|
119
|
+
@remote_repositories << url
|
120
|
+
end
|
121
|
+
alias_method :remote_repository, :remote_repo
|
122
|
+
alias_method :repository, :remote_repo
|
123
|
+
|
124
|
+
def group(*groups, &_blk)
|
125
|
+
@group_changed = true
|
126
|
+
groups.each do |group|
|
127
|
+
@present_group = group.to_s
|
128
|
+
yield
|
129
|
+
end
|
130
|
+
@group_changed = false
|
131
|
+
@present_group = 'default'
|
132
|
+
end
|
133
|
+
|
134
|
+
# @deprecated Please use {#group} instead
|
135
|
+
def scope(*scopes, &blk)
|
136
|
+
warn '[DEPRECATED] `scope` is deprecated. Please use `group` instead.'
|
137
|
+
group(*scopes, &blk)
|
138
|
+
end
|
139
|
+
|
140
|
+
def without_default_maven_repo
|
141
|
+
@clear_repositories = true
|
142
|
+
end
|
143
|
+
|
144
|
+
private
|
145
|
+
|
146
|
+
def assign_groups(artifact, groups = nil)
|
147
|
+
if groups
|
148
|
+
groups = Array(groups)
|
149
|
+
|
150
|
+
# include present group if within a group block
|
151
|
+
groups << @present_group if @group_changed
|
152
|
+
|
153
|
+
else
|
154
|
+
groups = [@present_group]
|
155
|
+
end
|
156
|
+
|
157
|
+
groups.uniq.each do |group|
|
158
|
+
group_key = group.to_s
|
159
|
+
@artifacts[group_key] = [] unless @artifacts[group_key]
|
160
|
+
@artifacts[group_key] << artifact
|
161
|
+
end if artifact
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
+
# contributor license agreements. See the NOTICE file distributed with this
|
3
|
+
# work for additional information regarding copyright ownership. The ASF
|
4
|
+
# licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
+
# "License"); you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
+
# License for the specific language governing permissions and limitations under
|
14
|
+
# the License.
|
15
|
+
|
16
|
+
module LockJar
|
17
|
+
module Domain
|
18
|
+
# Merge DSLs
|
19
|
+
class DslMerger
|
20
|
+
attr_reader :into_dsl, :from_dsl, :into_groups
|
21
|
+
|
22
|
+
# @param [LockJar::Domain::Dsl] into_dsl dsl that is merged into
|
23
|
+
# @param [LockJar::Domain::Dsl] from_dsl dsl that is merged from
|
24
|
+
# @param [String] into_group force only runtime and default groups to be
|
25
|
+
# loaded into this group
|
26
|
+
def initialize(into_dsl, from_dsl, into_groups = nil)
|
27
|
+
@into_dsl = into_dsl
|
28
|
+
@from_dsl = from_dsl
|
29
|
+
@into_groups = into_groups
|
30
|
+
end
|
31
|
+
|
32
|
+
# Merge LockJar::Domain::Dsl
|
33
|
+
# @return [LockJar::Domain::Dsl]
|
34
|
+
def merge
|
35
|
+
merged_dsl = into_dsl.dup
|
36
|
+
|
37
|
+
merged_dsl.remote_repositories = remote_repositories
|
38
|
+
|
39
|
+
merged_dsl.artifacts = artifact_groups(into_groups)
|
40
|
+
|
41
|
+
from_dsl.maps.each do |artifact, paths|
|
42
|
+
maps = into_dsl.maps[artifact] || []
|
43
|
+
merged_dsl.maps[artifact] = (maps + paths).uniq
|
44
|
+
end
|
45
|
+
|
46
|
+
from_dsl.excludes.each do |exclude|
|
47
|
+
merged_dsl.excludes << exclude unless into_dsl.excludes.include? exclude
|
48
|
+
end
|
49
|
+
|
50
|
+
merged_dsl.merged << from_dsl.file_path if from_dsl.file_path
|
51
|
+
|
52
|
+
merged_dsl
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def remote_repositories
|
58
|
+
(into_dsl.remote_repositories + from_dsl.remote_repositories).uniq
|
59
|
+
end
|
60
|
+
|
61
|
+
def artifact_groups(restrict = nil)
|
62
|
+
artifacts = Hash.new { |hash, key| hash[key] = [] }
|
63
|
+
|
64
|
+
from_dsl.artifacts.each do |group, group_artifacts|
|
65
|
+
next if restrict && !restrict.include?(group)
|
66
|
+
artifacts[group] += into_dsl.artifacts[group] || []
|
67
|
+
group_artifacts.each do |art|
|
68
|
+
artifacts[group] << art unless artifacts[group].include? art
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
artifacts
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
+
# contributor license agreements. See the NOTICE file distributed with this
|
3
|
+
# work for additional information regarding copyright ownership. The ASF
|
4
|
+
# licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
+
# "License"); you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
+
# License for the specific language governing permissions and limitations under
|
14
|
+
# the License.
|
15
|
+
|
16
|
+
require 'lock_jar/maven'
|
17
|
+
require 'lock_jar/domain/jarfile_dsl'
|
18
|
+
require 'lock_jar/domain/dsl_merger'
|
19
|
+
|
20
|
+
module LockJar
|
21
|
+
module Domain
|
22
|
+
# Jarfile found in a Gem
|
23
|
+
class GemDsl < JarfileDsl
|
24
|
+
attr_accessor :gem_dir
|
25
|
+
|
26
|
+
class << self
|
27
|
+
def create(spec, jarfile)
|
28
|
+
builder = new
|
29
|
+
builder.gem_dir = spec.gem_dir
|
30
|
+
|
31
|
+
builder.file_path = "gem:#{spec.name}:Jarfile.lock"
|
32
|
+
|
33
|
+
evaluate(builder, jarfile)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
alias_method :overriden_pom, :pom
|
38
|
+
def pom(path, *args)
|
39
|
+
overriden_pom(File.join(gem_dir, path), *args)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
+
# contributor license agreements. See the NOTICE file distributed with this
|
3
|
+
# work for additional information regarding copyright ownership. The ASF
|
4
|
+
# licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
+
# "License"); you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
+
# License for the specific language governing permissions and limitations under
|
14
|
+
# the License.
|
15
|
+
|
16
|
+
require 'lock_jar/maven'
|
17
|
+
require 'lock_jar/domain/dsl_merger'
|
18
|
+
|
19
|
+
module LockJar
|
20
|
+
module Domain
|
21
|
+
# Jarfile DSL
|
22
|
+
class JarfileDsl < Dsl
|
23
|
+
attr_accessor :file_path
|
24
|
+
|
25
|
+
class << self
|
26
|
+
def create(jarfile)
|
27
|
+
builder = new
|
28
|
+
builder.file_path = jarfile
|
29
|
+
|
30
|
+
evaluate(builder, jarfile)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|