lock_jar 0.10.0 → 0.10.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +59 -59
- data/.travis.yml +8 -8
- data/CHANGELOG.md +30 -21
- data/Gemfile +13 -13
- data/Guardfile +9 -9
- data/README.md +375 -375
- data/Rakefile +24 -24
- data/bundler/Gemfile +21 -21
- data/bundler/LICENSE.txt +22 -22
- data/bundler/README.md +29 -29
- data/bundler/Rakefile +2 -2
- data/bundler/lib/lock_jar_bundler/bundler.rb +35 -35
- data/bundler/lib/lock_jar_bundler/piggy_back.rb +97 -97
- data/bundler/lib/lock_jar_bundler/version.rb +5 -5
- data/bundler/lib/lock_jar_bundler.rb +4 -4
- data/bundler/lock_jar_bundler.gemspec +24 -24
- data/bundler/spec/Jarfile +2 -2
- data/bundler/spec/dummy_gem/dummy_gem.gemspec +19 -19
- data/bundler/spec/lock_jar_bundler_spec.rb +48 -48
- data/bundler/spec/spec_helper.rb +88 -88
- data/lib/lock_jar/buildr.rb +144 -144
- data/lib/lock_jar/bundler.rb +154 -154
- data/lib/lock_jar/cli.rb +64 -64
- data/lib/lock_jar/domain/artifact.rb +123 -123
- data/lib/lock_jar/domain/dsl.rb +187 -187
- data/lib/lock_jar/domain/dsl_helper.rb +83 -83
- data/lib/lock_jar/domain/gem_dsl.rb +44 -44
- data/lib/lock_jar/domain/jarfile_dsl.rb +46 -46
- data/lib/lock_jar/domain/lockfile.rb +113 -113
- data/lib/lock_jar/maven.rb +111 -111
- data/lib/lock_jar/registry.rb +92 -92
- data/lib/lock_jar/resolver.rb +95 -95
- data/lib/lock_jar/runtime.rb +359 -355
- data/lib/lock_jar/version.rb +3 -3
- data/lib/lock_jar.rb +172 -177
- data/lock_jar.gemspec +27 -27
- data/spec/fixtures/Jarfile +13 -13
- data/spec/fixtures/Jarfile2 +1 -0
- data/spec/lock_jar/class_loader_spec.rb +57 -57
- data/spec/lock_jar/cli_spec.rb +100 -100
- data/spec/lock_jar/domain/dsl_helper_spec.rb +52 -52
- data/spec/lock_jar/domain/dsl_spec.rb +57 -57
- data/spec/lock_jar/maven_spec.rb +23 -23
- data/spec/lock_jar/resolver_spec.rb +26 -26
- data/spec/lock_jar/runtime_spec.rb +26 -26
- data/spec/lock_jar_spec.rb +372 -295
- data/spec/pom.xml +34 -34
- data/spec/spec_helper.rb +38 -38
- data/spec/support/helper.rb +44 -44
- metadata +3 -1
@@ -1,49 +1,49 @@
|
|
1
|
-
require File.expand_path(File.join(File.dirname(__FILE__),'spec_helper'))
|
2
|
-
|
3
|
-
require 'lock_jar'
|
4
|
-
require 'lock_jar_bundler'
|
5
|
-
|
6
|
-
describe LockJar::Bundler, "#bundled_jarfiles" do
|
7
|
-
it "should give a list of jarfile paths" do
|
8
|
-
jar_files = LockJar::Bundler.bundled_jarfiles([:test])
|
9
|
-
expect(jar_files).to eql [File.expand_path('spec/dummy_gem/Jarfile')]
|
10
|
-
end
|
11
|
-
|
12
|
-
it "should create a Jarfile.lock including bundler Jarfiles" do
|
13
|
-
LockJar.lock( "spec/Jarfile", :local_repo => TEST_REPO, :lockfile => "#{TEMP_DIR}/BundledJarfile.lock" )
|
14
|
-
lockfile = LockJar.read("#{TEMP_DIR}/BundledJarfile.lock")
|
15
|
-
expect(lockfile.to_hash).to eql({
|
16
|
-
"version"=>"0.10.0",
|
17
|
-
"merged" => [File.expand_path('spec/dummy_gem/Jarfile')],
|
18
|
-
"groups"=>{
|
19
|
-
"default"=>{
|
20
|
-
"dependencies"=> %w(
|
21
|
-
com.google.guava:guava:jar:14.0.1
|
22
|
-
com.metapossum:metapossum-scanner:jar:1.0.1
|
23
|
-
com.tobedevoured.command:core:jar:0.3.2
|
24
|
-
com.typesafe:config:jar:0.5.0
|
25
|
-
commons-beanutils:commons-beanutils:jar:1.8.3
|
26
|
-
commons-io:commons-io:jar:2.3
|
27
|
-
commons-lang:commons-lang:jar:2.6
|
28
|
-
commons-logging:commons-logging:jar:1.1.1
|
29
|
-
org.modeshape:modeshape-common:jar:2.8.2.Final
|
30
|
-
org.slf4j:slf4j-api:jar:1.6.6),
|
31
|
-
"artifacts"=>[
|
32
|
-
{"jar:com.tobedevoured.command:core:jar:0.3.2"=>{
|
33
|
-
"transitive"=>{
|
34
|
-
"commons-beanutils:commons-beanutils:jar:1.8.3"=>{
|
35
|
-
"commons-logging:commons-logging:jar:1.1.1"=>{}},
|
36
|
-
"com.typesafe:config:jar:0.5.0"=>{},
|
37
|
-
"com.metapossum:metapossum-scanner:jar:1.0.1"=>{
|
38
|
-
"commons-io:commons-io:jar:2.3"=>{}, "commons-lang:commons-lang:jar:2.6"=>{}},
|
39
|
-
"org.slf4j:slf4j-api:jar:1.6.6"=>{},
|
40
|
-
"org.modeshape:modeshape-common:jar:2.8.2.Final"=>{}
|
41
|
-
}
|
42
|
-
}},
|
43
|
-
{"jar:com.google.guava:guava:jar:14.0.1"=>{"transitive"=>{}}}
|
44
|
-
]
|
45
|
-
}
|
46
|
-
}
|
47
|
-
})
|
48
|
-
end
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__),'spec_helper'))
|
2
|
+
|
3
|
+
require 'lock_jar'
|
4
|
+
require 'lock_jar_bundler'
|
5
|
+
|
6
|
+
describe LockJar::Bundler, "#bundled_jarfiles" do
|
7
|
+
it "should give a list of jarfile paths" do
|
8
|
+
jar_files = LockJar::Bundler.bundled_jarfiles([:test])
|
9
|
+
expect(jar_files).to eql [File.expand_path('spec/dummy_gem/Jarfile')]
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should create a Jarfile.lock including bundler Jarfiles" do
|
13
|
+
LockJar.lock( "spec/Jarfile", :local_repo => TEST_REPO, :lockfile => "#{TEMP_DIR}/BundledJarfile.lock" )
|
14
|
+
lockfile = LockJar.read("#{TEMP_DIR}/BundledJarfile.lock")
|
15
|
+
expect(lockfile.to_hash).to eql({
|
16
|
+
"version"=>"0.10.0",
|
17
|
+
"merged" => [File.expand_path('spec/dummy_gem/Jarfile')],
|
18
|
+
"groups"=>{
|
19
|
+
"default"=>{
|
20
|
+
"dependencies"=> %w(
|
21
|
+
com.google.guava:guava:jar:14.0.1
|
22
|
+
com.metapossum:metapossum-scanner:jar:1.0.1
|
23
|
+
com.tobedevoured.command:core:jar:0.3.2
|
24
|
+
com.typesafe:config:jar:0.5.0
|
25
|
+
commons-beanutils:commons-beanutils:jar:1.8.3
|
26
|
+
commons-io:commons-io:jar:2.3
|
27
|
+
commons-lang:commons-lang:jar:2.6
|
28
|
+
commons-logging:commons-logging:jar:1.1.1
|
29
|
+
org.modeshape:modeshape-common:jar:2.8.2.Final
|
30
|
+
org.slf4j:slf4j-api:jar:1.6.6),
|
31
|
+
"artifacts"=>[
|
32
|
+
{"jar:com.tobedevoured.command:core:jar:0.3.2"=>{
|
33
|
+
"transitive"=>{
|
34
|
+
"commons-beanutils:commons-beanutils:jar:1.8.3"=>{
|
35
|
+
"commons-logging:commons-logging:jar:1.1.1"=>{}},
|
36
|
+
"com.typesafe:config:jar:0.5.0"=>{},
|
37
|
+
"com.metapossum:metapossum-scanner:jar:1.0.1"=>{
|
38
|
+
"commons-io:commons-io:jar:2.3"=>{}, "commons-lang:commons-lang:jar:2.6"=>{}},
|
39
|
+
"org.slf4j:slf4j-api:jar:1.6.6"=>{},
|
40
|
+
"org.modeshape:modeshape-common:jar:2.8.2.Final"=>{}
|
41
|
+
}
|
42
|
+
}},
|
43
|
+
{"jar:com.google.guava:guava:jar:14.0.1"=>{"transitive"=>{}}}
|
44
|
+
]
|
45
|
+
}
|
46
|
+
}
|
47
|
+
})
|
48
|
+
end
|
49
49
|
end
|
data/bundler/spec/spec_helper.rb
CHANGED
@@ -1,88 +1,88 @@
|
|
1
|
-
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
-
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
-
# The generated `.rspec` file contains `--require spec_helper` which will cause this
|
4
|
-
# file to always be loaded, without a need to explicitly require it in any files.
|
5
|
-
#
|
6
|
-
# Given that it is always loaded, you are encouraged to keep this file as
|
7
|
-
# light-weight as possible. Requiring heavyweight dependencies from this file
|
8
|
-
# will add to the boot time of your test suite on EVERY test run, even for an
|
9
|
-
# individual file that may not need all of that loaded. Instead, make a
|
10
|
-
# separate helper file that requires this one and then use it only in the specs
|
11
|
-
# that actually need it.
|
12
|
-
#
|
13
|
-
# The `.rspec` file also contains a few flags that are not defaults but that
|
14
|
-
# users commonly want.
|
15
|
-
#
|
16
|
-
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
17
|
-
|
18
|
-
require 'pry'
|
19
|
-
|
20
|
-
TEMP_DIR = File.expand_path(File.join(File.dirname(__FILE__), "..", ".spec-tmp"))
|
21
|
-
TEST_REPO = File.expand_path(File.join(TEMP_DIR, "test-repo"))
|
22
|
-
|
23
|
-
RSpec.configure do |config|
|
24
|
-
# The settings below are suggested to provide a good initial experience
|
25
|
-
# with RSpec, but feel free to customize to your heart's content.
|
26
|
-
=begin
|
27
|
-
# These two settings work together to allow you to limit a spec run
|
28
|
-
# to individual examples or groups you care about by tagging them with
|
29
|
-
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
30
|
-
# get run.
|
31
|
-
config.filter_run :focus
|
32
|
-
config.run_all_when_everything_filtered = true
|
33
|
-
|
34
|
-
# Many RSpec users commonly either run the entire suite or an individual
|
35
|
-
# file, and it's useful to allow more verbose output when running an
|
36
|
-
# individual spec file.
|
37
|
-
if config.files_to_run.one?
|
38
|
-
# Use the documentation formatter for detailed output,
|
39
|
-
# unless a formatter has already been configured
|
40
|
-
# (e.g. via a command-line flag).
|
41
|
-
config.default_formatter = 'doc'
|
42
|
-
end
|
43
|
-
|
44
|
-
# Print the 10 slowest examples and example groups at the
|
45
|
-
# end of the spec run, to help surface which specs are running
|
46
|
-
# particularly slow.
|
47
|
-
config.profile_examples = 10
|
48
|
-
|
49
|
-
# Run specs in random order to surface order dependencies. If you find an
|
50
|
-
# order dependency and want to debug it, you can fix the order by providing
|
51
|
-
# the seed, which is printed after each run.
|
52
|
-
# --seed 1234
|
53
|
-
config.order = :random
|
54
|
-
|
55
|
-
# Seed global randomization in this process using the `--seed` CLI option.
|
56
|
-
# Setting this allows you to use `--seed` to deterministically reproduce
|
57
|
-
# test failures related to randomization by passing the same `--seed` value
|
58
|
-
# as the one that triggered the failure.
|
59
|
-
Kernel.srand config.seed
|
60
|
-
|
61
|
-
# rspec-expectations config goes here. You can use an alternate
|
62
|
-
# assertion/expectation library such as wrong or the stdlib/minitest
|
63
|
-
# assertions if you prefer.
|
64
|
-
config.expect_with :rspec do |expectations|
|
65
|
-
# Enable only the newer, non-monkey-patching expect syntax.
|
66
|
-
# For more details, see:
|
67
|
-
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
68
|
-
expectations.syntax = :expect
|
69
|
-
end
|
70
|
-
|
71
|
-
# rspec-mocks config goes here. You can use an alternate test double
|
72
|
-
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
73
|
-
config.mock_with :rspec do |mocks|
|
74
|
-
# Enable only the newer, non-monkey-patching expect syntax.
|
75
|
-
# For more details, see:
|
76
|
-
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
77
|
-
mocks.syntax = :expect
|
78
|
-
|
79
|
-
# Prevents you from mocking or stubbing a method that does not exist on
|
80
|
-
# a real object. This is generally recommended.
|
81
|
-
mocks.verify_partial_doubles = true
|
82
|
-
end
|
83
|
-
=end
|
84
|
-
|
85
|
-
config.before(:suite) do
|
86
|
-
FileUtils.mkdir_p(TEST_REPO)
|
87
|
-
end
|
88
|
-
end
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause this
|
4
|
+
# file to always be loaded, without a need to explicitly require it in any files.
|
5
|
+
#
|
6
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
7
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
8
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
9
|
+
# individual file that may not need all of that loaded. Instead, make a
|
10
|
+
# separate helper file that requires this one and then use it only in the specs
|
11
|
+
# that actually need it.
|
12
|
+
#
|
13
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
14
|
+
# users commonly want.
|
15
|
+
#
|
16
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
17
|
+
|
18
|
+
require 'pry'
|
19
|
+
|
20
|
+
TEMP_DIR = File.expand_path(File.join(File.dirname(__FILE__), "..", ".spec-tmp"))
|
21
|
+
TEST_REPO = File.expand_path(File.join(TEMP_DIR, "test-repo"))
|
22
|
+
|
23
|
+
RSpec.configure do |config|
|
24
|
+
# The settings below are suggested to provide a good initial experience
|
25
|
+
# with RSpec, but feel free to customize to your heart's content.
|
26
|
+
=begin
|
27
|
+
# These two settings work together to allow you to limit a spec run
|
28
|
+
# to individual examples or groups you care about by tagging them with
|
29
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
30
|
+
# get run.
|
31
|
+
config.filter_run :focus
|
32
|
+
config.run_all_when_everything_filtered = true
|
33
|
+
|
34
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
35
|
+
# file, and it's useful to allow more verbose output when running an
|
36
|
+
# individual spec file.
|
37
|
+
if config.files_to_run.one?
|
38
|
+
# Use the documentation formatter for detailed output,
|
39
|
+
# unless a formatter has already been configured
|
40
|
+
# (e.g. via a command-line flag).
|
41
|
+
config.default_formatter = 'doc'
|
42
|
+
end
|
43
|
+
|
44
|
+
# Print the 10 slowest examples and example groups at the
|
45
|
+
# end of the spec run, to help surface which specs are running
|
46
|
+
# particularly slow.
|
47
|
+
config.profile_examples = 10
|
48
|
+
|
49
|
+
# Run specs in random order to surface order dependencies. If you find an
|
50
|
+
# order dependency and want to debug it, you can fix the order by providing
|
51
|
+
# the seed, which is printed after each run.
|
52
|
+
# --seed 1234
|
53
|
+
config.order = :random
|
54
|
+
|
55
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
56
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
57
|
+
# test failures related to randomization by passing the same `--seed` value
|
58
|
+
# as the one that triggered the failure.
|
59
|
+
Kernel.srand config.seed
|
60
|
+
|
61
|
+
# rspec-expectations config goes here. You can use an alternate
|
62
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
63
|
+
# assertions if you prefer.
|
64
|
+
config.expect_with :rspec do |expectations|
|
65
|
+
# Enable only the newer, non-monkey-patching expect syntax.
|
66
|
+
# For more details, see:
|
67
|
+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
68
|
+
expectations.syntax = :expect
|
69
|
+
end
|
70
|
+
|
71
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
72
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
73
|
+
config.mock_with :rspec do |mocks|
|
74
|
+
# Enable only the newer, non-monkey-patching expect syntax.
|
75
|
+
# For more details, see:
|
76
|
+
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
77
|
+
mocks.syntax = :expect
|
78
|
+
|
79
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
80
|
+
# a real object. This is generally recommended.
|
81
|
+
mocks.verify_partial_doubles = true
|
82
|
+
end
|
83
|
+
=end
|
84
|
+
|
85
|
+
config.before(:suite) do
|
86
|
+
FileUtils.mkdir_p(TEST_REPO)
|
87
|
+
end
|
88
|
+
end
|
data/lib/lock_jar/buildr.rb
CHANGED
@@ -1,145 +1,145 @@
|
|
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 'lock_jar/domain/dsl'
|
18
|
-
|
19
|
-
module Buildr
|
20
|
-
|
21
|
-
@@global_lockjar_dsl = nil
|
22
|
-
|
23
|
-
class << self
|
24
|
-
def project_to_lockfile( project )
|
25
|
-
"#{project.name.gsub(/:/,'-')}.lock"
|
26
|
-
end
|
27
|
-
|
28
|
-
def global_lockjar_dsl
|
29
|
-
@@global_lockjar_dsl
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def lock_jar( &blk )
|
34
|
-
@@global_lockjar_dsl = ::LockJar::Domain::Dsl.create(&blk)
|
35
|
-
end
|
36
|
-
|
37
|
-
namespace "lock_jar" do
|
38
|
-
desc "Lock dependencies for each project"
|
39
|
-
task("lock") do
|
40
|
-
projects.each do |project|
|
41
|
-
if project.lockjar_dsl
|
42
|
-
# add buildr repos
|
43
|
-
repositories.remote.each do |repo|
|
44
|
-
project.lockjar_dsl.repository repo
|
45
|
-
end
|
46
|
-
::LockJar.lock( project.lockjar_dsl, :lockfile => Buildr.project_to_lockfile(project) )
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
module LockJar
|
53
|
-
module ProjectExtension
|
54
|
-
include Extension
|
55
|
-
|
56
|
-
def lock_jar( &blk )
|
57
|
-
@lockjar_dsl = ::LockJar::Domain::Dsl.create(&blk)
|
58
|
-
|
59
|
-
unless Buildr.global_lockjar_dsl.nil?
|
60
|
-
@lockjar_dsl.merge( Buildr.global_lockjar_dsl )
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def lock_jars( *args )
|
65
|
-
lockfile = Buildr.project_to_lockfile(project)
|
66
|
-
opts = {}
|
67
|
-
groups = ['default']
|
68
|
-
|
69
|
-
args.each do |arg|
|
70
|
-
if arg.is_a?(Hash)
|
71
|
-
opts.merge!( arg )
|
72
|
-
elsif arg.is_a?( String )
|
73
|
-
lockfile = arg
|
74
|
-
elsif arg.is_a?( Array )
|
75
|
-
groups = arg
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
::LockJar.list( lockfile, groups, opts )
|
80
|
-
end
|
81
|
-
|
82
|
-
def lockjar_dsl
|
83
|
-
@lockjar_dsl || Buildr.global_lockjar_dsl
|
84
|
-
end
|
85
|
-
|
86
|
-
after_define do |project|
|
87
|
-
task :compile => 'lock_jar:compile'
|
88
|
-
task 'test:compile' => 'lock_jar:test:compile'
|
89
|
-
|
90
|
-
task 'eclipse' => 'lock_jar:eclipse'
|
91
|
-
|
92
|
-
namespace "lock_jar" do
|
93
|
-
desc "Lock dependencies to JarFile"
|
94
|
-
task("lock") do
|
95
|
-
dsl = project.lockjar_dsl
|
96
|
-
if dsl
|
97
|
-
# add buildr repos
|
98
|
-
repositories.remote do |repo|
|
99
|
-
puts repo
|
100
|
-
dsl.repository repo
|
101
|
-
end
|
102
|
-
::LockJar.lock( dsl, :lockfile => "#{project.name}.lock" )
|
103
|
-
else
|
104
|
-
# XXX: output that there were no dependencies to lock
|
105
|
-
puts "No lock_jar dependencies to lock for #{project.name}"
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
task("compile") do
|
110
|
-
if project.lockjar_dsl && !File.exists?( Buildr.project_to_lockfile(project) )
|
111
|
-
raise "#{project.name}.lock does not exist, run #{project.name}:lockjar:lock first"
|
112
|
-
end
|
113
|
-
jars = ::LockJar.list( Buildr.project_to_lockfile(project), ['default'] )
|
114
|
-
project.compile.with( jars )
|
115
|
-
end
|
116
|
-
|
117
|
-
task("test:compile") do
|
118
|
-
if project.lockjar_dsl && !File.exists?( Buildr.project_to_lockfile(project) )
|
119
|
-
raise "#{Buildr.project_to_lockfile(project)} does not exist, run #{project.name}:lockjar:lock first"
|
120
|
-
end
|
121
|
-
jars = ::LockJar.list( Buildr.project_to_lockfile(project), ['test'] )
|
122
|
-
|
123
|
-
project.test.compile.with( jars )
|
124
|
-
project.test.with( jars )
|
125
|
-
end
|
126
|
-
|
127
|
-
task("eclipse") do
|
128
|
-
if project.lockjar_dsl && !File.exists?( Buildr.project_to_lockfile(project) )
|
129
|
-
raise "#{Buildr.project_to_lockfile(project)} does not exist, run #{project.name}:lockjar:lock first"
|
130
|
-
end
|
131
|
-
jars = ::LockJar.list( Buildr.project_to_lockfile(project), ['default'] )
|
132
|
-
project.compile.with( jars )
|
133
|
-
|
134
|
-
jars = ::LockJar.list( Buildr.project_to_lockfile(project), ['test'] )
|
135
|
-
project.test.compile.with( jars )
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
class Buildr::Project
|
144
|
-
include Buildr::LockJar::ProjectExtension
|
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 'lock_jar/domain/dsl'
|
18
|
+
|
19
|
+
module Buildr
|
20
|
+
|
21
|
+
@@global_lockjar_dsl = nil
|
22
|
+
|
23
|
+
class << self
|
24
|
+
def project_to_lockfile( project )
|
25
|
+
"#{project.name.gsub(/:/,'-')}.lock"
|
26
|
+
end
|
27
|
+
|
28
|
+
def global_lockjar_dsl
|
29
|
+
@@global_lockjar_dsl
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def lock_jar( &blk )
|
34
|
+
@@global_lockjar_dsl = ::LockJar::Domain::Dsl.create(&blk)
|
35
|
+
end
|
36
|
+
|
37
|
+
namespace "lock_jar" do
|
38
|
+
desc "Lock dependencies for each project"
|
39
|
+
task("lock") do
|
40
|
+
projects.each do |project|
|
41
|
+
if project.lockjar_dsl
|
42
|
+
# add buildr repos
|
43
|
+
repositories.remote.each do |repo|
|
44
|
+
project.lockjar_dsl.repository repo
|
45
|
+
end
|
46
|
+
::LockJar.lock( project.lockjar_dsl, :lockfile => Buildr.project_to_lockfile(project) )
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
module LockJar
|
53
|
+
module ProjectExtension
|
54
|
+
include Extension
|
55
|
+
|
56
|
+
def lock_jar( &blk )
|
57
|
+
@lockjar_dsl = ::LockJar::Domain::Dsl.create(&blk)
|
58
|
+
|
59
|
+
unless Buildr.global_lockjar_dsl.nil?
|
60
|
+
@lockjar_dsl.merge( Buildr.global_lockjar_dsl )
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def lock_jars( *args )
|
65
|
+
lockfile = Buildr.project_to_lockfile(project)
|
66
|
+
opts = {}
|
67
|
+
groups = ['default']
|
68
|
+
|
69
|
+
args.each do |arg|
|
70
|
+
if arg.is_a?(Hash)
|
71
|
+
opts.merge!( arg )
|
72
|
+
elsif arg.is_a?( String )
|
73
|
+
lockfile = arg
|
74
|
+
elsif arg.is_a?( Array )
|
75
|
+
groups = arg
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
::LockJar.list( lockfile, groups, opts )
|
80
|
+
end
|
81
|
+
|
82
|
+
def lockjar_dsl
|
83
|
+
@lockjar_dsl || Buildr.global_lockjar_dsl
|
84
|
+
end
|
85
|
+
|
86
|
+
after_define do |project|
|
87
|
+
task :compile => 'lock_jar:compile'
|
88
|
+
task 'test:compile' => 'lock_jar:test:compile'
|
89
|
+
|
90
|
+
task 'eclipse' => 'lock_jar:eclipse'
|
91
|
+
|
92
|
+
namespace "lock_jar" do
|
93
|
+
desc "Lock dependencies to JarFile"
|
94
|
+
task("lock") do
|
95
|
+
dsl = project.lockjar_dsl
|
96
|
+
if dsl
|
97
|
+
# add buildr repos
|
98
|
+
repositories.remote do |repo|
|
99
|
+
puts repo
|
100
|
+
dsl.repository repo
|
101
|
+
end
|
102
|
+
::LockJar.lock( dsl, :lockfile => "#{project.name}.lock" )
|
103
|
+
else
|
104
|
+
# XXX: output that there were no dependencies to lock
|
105
|
+
puts "No lock_jar dependencies to lock for #{project.name}"
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
task("compile") do
|
110
|
+
if project.lockjar_dsl && !File.exists?( Buildr.project_to_lockfile(project) )
|
111
|
+
raise "#{project.name}.lock does not exist, run #{project.name}:lockjar:lock first"
|
112
|
+
end
|
113
|
+
jars = ::LockJar.list( Buildr.project_to_lockfile(project), ['default'] )
|
114
|
+
project.compile.with( jars )
|
115
|
+
end
|
116
|
+
|
117
|
+
task("test:compile") do
|
118
|
+
if project.lockjar_dsl && !File.exists?( Buildr.project_to_lockfile(project) )
|
119
|
+
raise "#{Buildr.project_to_lockfile(project)} does not exist, run #{project.name}:lockjar:lock first"
|
120
|
+
end
|
121
|
+
jars = ::LockJar.list( Buildr.project_to_lockfile(project), ['test'] )
|
122
|
+
|
123
|
+
project.test.compile.with( jars )
|
124
|
+
project.test.with( jars )
|
125
|
+
end
|
126
|
+
|
127
|
+
task("eclipse") do
|
128
|
+
if project.lockjar_dsl && !File.exists?( Buildr.project_to_lockfile(project) )
|
129
|
+
raise "#{Buildr.project_to_lockfile(project)} does not exist, run #{project.name}:lockjar:lock first"
|
130
|
+
end
|
131
|
+
jars = ::LockJar.list( Buildr.project_to_lockfile(project), ['default'] )
|
132
|
+
project.compile.with( jars )
|
133
|
+
|
134
|
+
jars = ::LockJar.list( Buildr.project_to_lockfile(project), ['test'] )
|
135
|
+
project.test.compile.with( jars )
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
class Buildr::Project
|
144
|
+
include Buildr::LockJar::ProjectExtension
|
145
145
|
end
|