lock_jar 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +11 -0
- data/Gemfile.lock +30 -0
- data/LICENSE +176 -0
- data/README.rdoc +169 -0
- data/Rakefile +38 -0
- data/VERSION +1 -0
- data/lib/lock_jar/buildr.rb +104 -0
- data/lib/lock_jar/dsl.rb +108 -0
- data/lib/lock_jar/resolver.rb +71 -0
- data/lib/lock_jar/runtime.rb +93 -0
- data/lib/lock_jar.rb +36 -0
- data/lock_jar.gemspec +65 -0
- data/spec/Jarfile +12 -0
- data/spec/lock_jar/dsl_spec.rb +79 -0
- data/spec/lock_jar/resolver_spec.rb +19 -0
- data/spec/lock_jar_spec.rb +38 -0
- data/spec/pom.xml +23 -0
- metadata +146 -0
data/Gemfile
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
gem "naether", "~> 0.6.0"
|
4
|
+
|
5
|
+
# Add dependencies to develop your gem here.
|
6
|
+
# Include everything needed to run rake, tests, features, etc.
|
7
|
+
group :development do
|
8
|
+
gem "rspec", ">= 0"
|
9
|
+
gem "bundler", "> 1.0.0"
|
10
|
+
gem "jeweler", "~> 1.6.4"
|
11
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
diff-lcs (1.1.3)
|
5
|
+
git (1.2.5)
|
6
|
+
jeweler (1.6.4)
|
7
|
+
bundler (~> 1.0)
|
8
|
+
git (>= 1.2.5)
|
9
|
+
rake
|
10
|
+
naether (0.6.0)
|
11
|
+
rjb (= 1.3.3)
|
12
|
+
rake (0.9.2.2)
|
13
|
+
rjb (1.3.3)
|
14
|
+
rspec (2.9.0)
|
15
|
+
rspec-core (~> 2.9.0)
|
16
|
+
rspec-expectations (~> 2.9.0)
|
17
|
+
rspec-mocks (~> 2.9.0)
|
18
|
+
rspec-core (2.9.0)
|
19
|
+
rspec-expectations (2.9.1)
|
20
|
+
diff-lcs (~> 1.1.3)
|
21
|
+
rspec-mocks (2.9.0)
|
22
|
+
|
23
|
+
PLATFORMS
|
24
|
+
ruby
|
25
|
+
|
26
|
+
DEPENDENCIES
|
27
|
+
bundler (> 1.0.0)
|
28
|
+
jeweler (~> 1.6.4)
|
29
|
+
naether (~> 0.6.0)
|
30
|
+
rspec
|
data/LICENSE
ADDED
@@ -0,0 +1,176 @@
|
|
1
|
+
Apache License
|
2
|
+
Version 2.0, January 2004
|
3
|
+
http://www.apache.org/licenses/
|
4
|
+
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6
|
+
|
7
|
+
1. Definitions.
|
8
|
+
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
11
|
+
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13
|
+
the copyright owner that is granting the License.
|
14
|
+
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
16
|
+
other entities that control, are controlled by, or are under common
|
17
|
+
control with that entity. For the purposes of this definition,
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
19
|
+
direction or management of such entity, whether by contract or
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22
|
+
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24
|
+
exercising permissions granted by this License.
|
25
|
+
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
27
|
+
including but not limited to software source code, documentation
|
28
|
+
source, and configuration files.
|
29
|
+
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
31
|
+
transformation or translation of a Source form, including but
|
32
|
+
not limited to compiled object code, generated documentation,
|
33
|
+
and conversions to other media types.
|
34
|
+
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
36
|
+
Object form, made available under the License, as indicated by a
|
37
|
+
copyright notice that is included in or attached to the work
|
38
|
+
(an example is provided in the Appendix below).
|
39
|
+
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46
|
+
the Work and Derivative Works thereof.
|
47
|
+
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
49
|
+
the original version of the Work and any modifications or additions
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
61
|
+
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
64
|
+
subsequently incorporated within the Work.
|
65
|
+
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
72
|
+
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78
|
+
where such license applies only to those patent claims licensable
|
79
|
+
by such Contributor that are necessarily infringed by their
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
82
|
+
institute patent litigation against any entity (including a
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
85
|
+
or contributory patent infringement, then any patent licenses
|
86
|
+
granted to You under this License for that Work shall terminate
|
87
|
+
as of the date such litigation is filed.
|
88
|
+
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
91
|
+
modifications, and in Source or Object form, provided that You
|
92
|
+
meet the following conditions:
|
93
|
+
|
94
|
+
(a) You must give any other recipients of the Work or
|
95
|
+
Derivative Works a copy of this License; and
|
96
|
+
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
98
|
+
stating that You changed the files; and
|
99
|
+
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
102
|
+
attribution notices from the Source form of the Work,
|
103
|
+
excluding those notices that do not pertain to any part of
|
104
|
+
the Derivative Works; and
|
105
|
+
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
108
|
+
include a readable copy of the attribution notices contained
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
111
|
+
of the following places: within a NOTICE text file distributed
|
112
|
+
as part of the Derivative Works; within the Source form or
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
114
|
+
within a display generated by the Derivative Works, if and
|
115
|
+
wherever such third-party notices normally appear. The contents
|
116
|
+
of the NOTICE file are for informational purposes only and
|
117
|
+
do not modify the License. You may add Your own attribution
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
120
|
+
that such additional attribution notices cannot be construed
|
121
|
+
as modifying the License.
|
122
|
+
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
124
|
+
may provide additional or different license terms and conditions
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
128
|
+
the conditions stated in this License.
|
129
|
+
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
133
|
+
this License, without any additional terms or conditions.
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135
|
+
the terms of any separate license agreement you may have executed
|
136
|
+
with Licensor regarding such Contributions.
|
137
|
+
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
140
|
+
except as required for reasonable and customary use in describing the
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
142
|
+
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
152
|
+
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
158
|
+
incidental, or consequential damages of any character arising as a
|
159
|
+
result of this License or out of the use or inability to use the
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
162
|
+
other commercial damages or losses), even if such Contributor
|
163
|
+
has been advised of the possibility of such damages.
|
164
|
+
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168
|
+
or other liability obligations and/or rights consistent with this
|
169
|
+
License. However, in accepting such obligations, You may act only
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
174
|
+
of your accepting any such warranty or additional liability.
|
175
|
+
|
176
|
+
END OF TERMS AND CONDITIONS
|
data/README.rdoc
ADDED
@@ -0,0 +1,169 @@
|
|
1
|
+
= LockJar
|
2
|
+
|
3
|
+
LockJar manages Java Jars for Ruby. A Jarfile ({example}[https://github.com/mguymon/lock_jar/blob/master/spec/Jarfile])
|
4
|
+
is used to generate a Jarfile.lock that contains all the resolved jar dependencies for scopes runtime, compile, and test. The Jarfile.lock can be used to populate
|
5
|
+
the classpath.
|
6
|
+
|
7
|
+
https://github.com/mguymon/lock_jar
|
8
|
+
|
9
|
+
== Install
|
10
|
+
|
11
|
+
gem install lock_jar
|
12
|
+
|
13
|
+
== Usage
|
14
|
+
|
15
|
+
=== Using a Jarfile
|
16
|
+
|
17
|
+
==== Jarfile
|
18
|
+
A Jarfile is a simple Ruby DSL for defining a project's Jar dependencies using the following
|
19
|
+
methods:
|
20
|
+
|
21
|
+
* repository: url of additional Maven repository to use.
|
22
|
+
* jar: artifact notation of Jar dependency
|
23
|
+
* pom: local path to a Maven pom
|
24
|
+
* scope: set the scope for a jar or pom declaration. Default scope is compile
|
25
|
+
|
26
|
+
Example Jarfile
|
27
|
+
|
28
|
+
repository 'http://repository.jboss.org/nexus/content/groups/public-jboss'
|
29
|
+
|
30
|
+
// Default scope is compile
|
31
|
+
jar "org.apache.mina:mina-core:2.0.4"
|
32
|
+
|
33
|
+
scope 'runtime' do
|
34
|
+
jar 'org.apache.tomcat:servlet-api:jar:6.0.35'
|
35
|
+
end
|
36
|
+
|
37
|
+
scope 'test' do
|
38
|
+
jar 'junit:junit:jar:4.10'
|
39
|
+
end
|
40
|
+
|
41
|
+
==== Resolving dependencies
|
42
|
+
|
43
|
+
When the Jarfile is locked, the transitive dependencies for the Jars and Pom are resolved and saved to the Jarfile.lock file.
|
44
|
+
|
45
|
+
Example of locking
|
46
|
+
|
47
|
+
require 'lock_jar'
|
48
|
+
|
49
|
+
LockJar.lock
|
50
|
+
|
51
|
+
|
52
|
+
==== Jarfile.lock
|
53
|
+
|
54
|
+
The Jarfile.lock generated is a YAML file containing the scoped dependencies, their resolved dependencies, and
|
55
|
+
the additional Maven repositories.
|
56
|
+
|
57
|
+
The Jarfile.lock
|
58
|
+
|
59
|
+
---
|
60
|
+
scopes:
|
61
|
+
compile:
|
62
|
+
dependencies:
|
63
|
+
- org.apache.mina:mina-core:2.0.4
|
64
|
+
resolved_dependencies:
|
65
|
+
- org.apache.mina:mina-core:jar:2.0.4
|
66
|
+
- org.slf4j:slf4j-api:jar:1.6.1
|
67
|
+
- com.slackworks:modelcitizen:jar:0.2.2
|
68
|
+
- commons-lang:commons-lang:jar:2.6
|
69
|
+
- commons-beanutils:commons-beanutils:jar:1.8.3
|
70
|
+
- commons-logging:commons-logging:jar:1.1.1
|
71
|
+
- ch.qos.logback:logback-classic:jar:0.9.24
|
72
|
+
- ch.qos.logback:logback-core:jar:0.9.24
|
73
|
+
- com.metapossum:metapossum-scanner:jar:1.0
|
74
|
+
- commons-io:commons-io:jar:1.4
|
75
|
+
- junit:junit:jar:4.7
|
76
|
+
runtime:
|
77
|
+
dependencies:
|
78
|
+
- org.apache.tomcat:servlet-api:jar:6.0.35
|
79
|
+
resolved_dependencies:
|
80
|
+
- org.apache.tomcat:servlet-api:jar:6.0.35
|
81
|
+
test:
|
82
|
+
dependencies:
|
83
|
+
- junit:junit:jar:4.10
|
84
|
+
resolved_dependencies:
|
85
|
+
- junit:junit:jar:4.10
|
86
|
+
- org.hamcrest:hamcrest-core:jar:1.1
|
87
|
+
repositories:
|
88
|
+
- http://repository.jboss.org/nexus/content/groups/public-jboss
|
89
|
+
|
90
|
+
==== Accessing Jars
|
91
|
+
|
92
|
+
Once a Jarfile.lock is generated, you can list all resolved jars by
|
93
|
+
|
94
|
+
require 'lock_jars'
|
95
|
+
|
96
|
+
jars = LockJar.list
|
97
|
+
|
98
|
+
or directly load all Jars into the classpath
|
99
|
+
|
100
|
+
require 'lock_jars'
|
101
|
+
|
102
|
+
jars = LockJar.load
|
103
|
+
|
104
|
+
=== Buildr Integration
|
105
|
+
|
106
|
+
LockJar integrates with {Buildr}[http://buildr.apache.org/] using an {Addon}[https://github.com/mguymon/lock_jar/blob/master/lib/lock_jar/buildr.rb].
|
107
|
+
This allows the Jarfile to be defined directly into a buildfile. A global app LockJar definition can be set and
|
108
|
+
is inherited to all projects. Each project may have its own LockJar definition. A lock file is generated per project based
|
109
|
+
on the project name.
|
110
|
+
|
111
|
+
The resolved dependencies are automatically added to the classpath for compiling and testing.
|
112
|
+
|
113
|
+
==== Example
|
114
|
+
|
115
|
+
Sample buildfile with LockJar
|
116
|
+
|
117
|
+
require 'lock_jar/buildr'
|
118
|
+
|
119
|
+
# app definition, inherited into all projects
|
120
|
+
lock_jar do
|
121
|
+
repository 'http://repository.jboss.org/nexus/content/groups/public-jboss'
|
122
|
+
|
123
|
+
scope 'test' do
|
124
|
+
jar 'junit:junit:jar:4.10'
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
define 'app' do
|
129
|
+
|
130
|
+
def 'project1' do
|
131
|
+
lock_jar do
|
132
|
+
jar "org.apache.mina:mina-core:2.0.4"
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
def 'project2' do
|
137
|
+
lock_jar do
|
138
|
+
pom 'pom.xml'
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
end
|
143
|
+
|
144
|
+
Generated lock files
|
145
|
+
|
146
|
+
* project1.lock - contains junit and mina jars.
|
147
|
+
* project2.lock - contains junit and pom.xml jars.
|
148
|
+
|
149
|
+
=== About
|
150
|
+
|
151
|
+
Power by {Naether}[https://github.com/mguymon/naether] to create a frankenstein of Bundler and Maven.
|
152
|
+
|
153
|
+
== License
|
154
|
+
|
155
|
+
Licensed to the Apache Software Foundation (ASF) under one or more
|
156
|
+
contributor license agreements. See the NOTICE file distributed with this
|
157
|
+
work for additional information regarding copyright ownership. The ASF
|
158
|
+
licenses this file to you under the Apache License, Version 2.0 (the
|
159
|
+
"License"); you may not use this file except in compliance with the License.
|
160
|
+
You may obtain a copy of the License at
|
161
|
+
|
162
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
163
|
+
|
164
|
+
Unless required by applicable law or agreed to in writing, software
|
165
|
+
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
166
|
+
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
167
|
+
License for the specific language governing permissions and limitations under
|
168
|
+
the License.
|
169
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "lock_jar"
|
18
|
+
gem.homepage = "http://github.com/mguymon/lockjar"
|
19
|
+
gem.license = "Apache"
|
20
|
+
gem.summary = "Manage Jar files for Ruby"
|
21
|
+
gem.description = "Manage Jar files for Ruby. In the spirit of Bundler, a Jarfile
|
22
|
+
is used to generate a Jarfile.lock that contains all the resolved jar dependencies for scopes runtime, compile, and test.
|
23
|
+
The Jarfile.lock can be used to populate the classpath"
|
24
|
+
gem.email = "michael.guymon@gmail.com"
|
25
|
+
gem.authors = ["Michael Guymon"]
|
26
|
+
# dependencies defined in Gemfile
|
27
|
+
end
|
28
|
+
Jeweler::RubygemsDotOrgTasks.new
|
29
|
+
|
30
|
+
require 'rake/rdoctask'
|
31
|
+
Rake::RDocTask.new do |rdoc|
|
32
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
33
|
+
|
34
|
+
rdoc.rdoc_dir = 'rdoc'
|
35
|
+
rdoc.title = "lockjar #{version}"
|
36
|
+
rdoc.rdoc_files.include('README*')
|
37
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
38
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
@@ -0,0 +1,104 @@
|
|
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/dsl'
|
18
|
+
|
19
|
+
module Buildr
|
20
|
+
|
21
|
+
attr_reader :global_lockjar_dsl
|
22
|
+
|
23
|
+
class << self
|
24
|
+
def project_to_lockfile( project )
|
25
|
+
"#{project.name.gsub(/:/,'-')}.lock"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def lock_jar( &blk )
|
30
|
+
@global_lockjar_dsl = ::LockJar::Dsl.evaluate(&blk)
|
31
|
+
end
|
32
|
+
|
33
|
+
namespace "lock_jar" do
|
34
|
+
desc "Lock dependencies for each project"
|
35
|
+
task("lock") do
|
36
|
+
projects.each do |project|
|
37
|
+
if project.lockjar_dsl
|
38
|
+
::LockJar.lock( project.lockjar_dsl, :lockfile => Buildr.project_to_lockfile(project) )
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
module LockJar
|
45
|
+
module ProjectExtension
|
46
|
+
include Extension
|
47
|
+
|
48
|
+
def lock_jar( &blk )
|
49
|
+
@lockjar_dsl = ::LockJar::Dsl.evaluate(&blk)
|
50
|
+
if global_lockjar_dsl
|
51
|
+
@lockjar_dsl.merge( global_lockjar_dsl )
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def lock_jars( scope = ['compile','runtime'])
|
56
|
+
::LockJar.list( Buildr.project_to_lockfile(project), scope )
|
57
|
+
end
|
58
|
+
|
59
|
+
def lockjar_dsl
|
60
|
+
@lockjar_dsl || global_lockjar_dsl
|
61
|
+
end
|
62
|
+
|
63
|
+
after_define do |project|
|
64
|
+
task :compile => 'lock_jar:compile'
|
65
|
+
task 'test:compile' => 'lock_jar:test:compile'
|
66
|
+
|
67
|
+
namespace "lock_jar" do
|
68
|
+
desc "Lock dependencies to JarFile"
|
69
|
+
task("lock") do
|
70
|
+
dsl = project.lockjar_dsl
|
71
|
+
if dsl
|
72
|
+
::LockJar.lock( dsl, :lockfile => "#{project.name}.lock" )
|
73
|
+
else
|
74
|
+
# XXX: output that there were not dependencies to lock
|
75
|
+
puts "No lock_jar dependencies to lock for #{project.name}"
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
task("compile") do
|
80
|
+
if project.lockjar_dsl && !File.exists?( Buildr.project_to_lockfile(project) )
|
81
|
+
raise "#{project.name}.lock does not exist, run #{project.name}:lockjar:lock first"
|
82
|
+
end
|
83
|
+
jars = ::LockJar.list( Buildr.project_to_lockfile(project), ['compile', 'runtime'] )
|
84
|
+
project.compile.with( jars )
|
85
|
+
end
|
86
|
+
|
87
|
+
task("test:compile") do
|
88
|
+
if project.lockjar_dsl && !File.exists?( Buildr.project_to_lockfile(project) )
|
89
|
+
raise "#{Buildr.project_to_lockfile(project)} does not exist, run #{project.name}:lockjar:lock first"
|
90
|
+
end
|
91
|
+
jars = ::LockJar.list( Buildr.project_to_lockfile(project), ['compile', 'test', 'runtime'] )
|
92
|
+
|
93
|
+
project.test.compile.with( jars )
|
94
|
+
project.test.with( jars )
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
class Buildr::Project
|
103
|
+
include Buildr::LockJar::ProjectExtension
|
104
|
+
end
|
data/lib/lock_jar/dsl.rb
ADDED
@@ -0,0 +1,108 @@
|
|
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
|
+
class Dsl
|
18
|
+
|
19
|
+
attr_reader :notations
|
20
|
+
attr_reader :repositories
|
21
|
+
attr_reader :scopes
|
22
|
+
|
23
|
+
class << self
|
24
|
+
|
25
|
+
def evaluate(jarfile = nil, &blk)
|
26
|
+
if jarfile.nil? && blk.nil?
|
27
|
+
raise "jarfile or block must be set"
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
builder = new
|
32
|
+
|
33
|
+
if jarfile
|
34
|
+
builder.instance_eval(builder.read_file(jarfile.to_s), jarfile.to_s, 1)
|
35
|
+
end
|
36
|
+
|
37
|
+
if blk
|
38
|
+
builder.instance_eval(&blk)
|
39
|
+
end
|
40
|
+
|
41
|
+
builder
|
42
|
+
end
|
43
|
+
|
44
|
+
def scopes
|
45
|
+
['compile', 'runtime', 'test']
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def initialize
|
50
|
+
|
51
|
+
@repositories = []
|
52
|
+
@notations = {}
|
53
|
+
|
54
|
+
@scope_changed = false
|
55
|
+
|
56
|
+
LockJar::Dsl.scopes.each do |scope|
|
57
|
+
@notations[scope] = []
|
58
|
+
end
|
59
|
+
|
60
|
+
@present_scope = 'compile'
|
61
|
+
end
|
62
|
+
|
63
|
+
def jar(notation, *args)
|
64
|
+
if notation
|
65
|
+
@notations[@present_scope] << notation
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
# Pom default to all scopes, unless nested in a scope
|
70
|
+
def pom(path, *args)
|
71
|
+
if @scope_changed
|
72
|
+
@notations[@present_scope] << path
|
73
|
+
else
|
74
|
+
LockJar::Dsl.scopes.each do |scope|
|
75
|
+
@notations[scope] << path
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def repository( url, opts = {} )
|
81
|
+
@repositories << url
|
82
|
+
end
|
83
|
+
|
84
|
+
def scope(*scopes, &blk)
|
85
|
+
@scope_changed = true
|
86
|
+
scopes.each do |scope|
|
87
|
+
@present_scope = scope.to_s
|
88
|
+
yield
|
89
|
+
end
|
90
|
+
@scope_changed = false
|
91
|
+
@present_scope = 'compile'
|
92
|
+
end
|
93
|
+
|
94
|
+
def read_file(file)
|
95
|
+
File.open(file, "rb") { |f| f.read }
|
96
|
+
end
|
97
|
+
|
98
|
+
def merge( dsl )
|
99
|
+
@repositories = (@repositories + dsl.repositories).uniq
|
100
|
+
|
101
|
+
dsl.notations.each do |scope, notations|
|
102
|
+
@notations[scope] = (@notations[scope] + notations).uniq
|
103
|
+
end
|
104
|
+
|
105
|
+
self
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,71 @@
|
|
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 'rubygems'
|
17
|
+
require 'naether'
|
18
|
+
require 'tmpdir'
|
19
|
+
|
20
|
+
module LockJar
|
21
|
+
class Resolver
|
22
|
+
|
23
|
+
attr_reader :naether
|
24
|
+
|
25
|
+
def initialize( opts = {} )
|
26
|
+
local_repo = opts[:local_repo]
|
27
|
+
|
28
|
+
# Bootstrap Naether
|
29
|
+
jars = []
|
30
|
+
deps = Naether::Bootstrap.check_local_repo_for_deps( local_repo )
|
31
|
+
if deps[:missing].size > 0
|
32
|
+
Dir.mktmpdir do |dir|
|
33
|
+
deps = Naether::Bootstrap.download_dependencies( dir, deps.merge( :local_repo => local_repo ) )
|
34
|
+
if deps[:downloaded].size > 0
|
35
|
+
Naether::Bootstrap.install_dependencies_to_local_repo( dir, :local_repo => local_repo )
|
36
|
+
jars = deps[:downloaded].map{ |jar| jar.values[0] }
|
37
|
+
else
|
38
|
+
# XXX: download failed?
|
39
|
+
end
|
40
|
+
end
|
41
|
+
else
|
42
|
+
jars = deps[:exists].map{ |jar| jar.values[0] }
|
43
|
+
end
|
44
|
+
|
45
|
+
jars << Naether::JAR_PATH
|
46
|
+
@naether = Naether.create_from_jars( jars )
|
47
|
+
|
48
|
+
@naether.local_repo_path = opts[:local_repo] if opts[:local_repo]
|
49
|
+
|
50
|
+
|
51
|
+
@naether.clear_remote_repositories if opts[:offline]
|
52
|
+
end
|
53
|
+
|
54
|
+
def add_remote_repository( repo )
|
55
|
+
@naether.add_remote_repository( repo )
|
56
|
+
end
|
57
|
+
|
58
|
+
def resolve( dependencies )
|
59
|
+
@naether.dependencies = dependencies
|
60
|
+
@naether.resolve_dependencies
|
61
|
+
@naether.dependenciesNotation
|
62
|
+
end
|
63
|
+
|
64
|
+
def load_jars_to_classpath( notations )
|
65
|
+
jars = @naether.to_local_paths( notations )
|
66
|
+
Naether::Java.load_jars( jars )
|
67
|
+
|
68
|
+
jars
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,93 @@
|
|
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 "yaml"
|
17
|
+
require 'rubygems'
|
18
|
+
require 'lock_jar/resolver'
|
19
|
+
require 'lock_jar/dsl'
|
20
|
+
require 'lock_jar/runtime'
|
21
|
+
|
22
|
+
module LockJar
|
23
|
+
class Runtime
|
24
|
+
def initialize( opts = {} )
|
25
|
+
@resolver = LockJar::Resolver.new( opts )
|
26
|
+
end
|
27
|
+
|
28
|
+
def lock( jarfile = "Jarfile", opts = {} )
|
29
|
+
lock_jar_file = nil
|
30
|
+
|
31
|
+
if jarfile.is_a? LockJar::Dsl
|
32
|
+
lock_jar_file = jarfile
|
33
|
+
else
|
34
|
+
lock_jar_file = LockJar::Dsl.evaluate( jarfile )
|
35
|
+
end
|
36
|
+
|
37
|
+
lock_jar_file.repositories.each do |repo|
|
38
|
+
@resolver.add_remote_repository( repo )
|
39
|
+
end
|
40
|
+
|
41
|
+
lock_data = { 'scopes' => {} }
|
42
|
+
|
43
|
+
if lock_jar_file.repositories.size > 0
|
44
|
+
lock_data['repositories'] = lock_jar_file.repositories
|
45
|
+
end
|
46
|
+
|
47
|
+
lock_jar_file.notations.each do |scope, notations|
|
48
|
+
|
49
|
+
dependencies = []
|
50
|
+
notations.each do |notation|
|
51
|
+
dependencies << {notation => scope}
|
52
|
+
end
|
53
|
+
|
54
|
+
resolved_notations = @resolver.resolve( dependencies )
|
55
|
+
lock_data['scopes'][scope] = {
|
56
|
+
'dependencies' => notations,
|
57
|
+
'resolved_dependencies' => resolved_notations }
|
58
|
+
end
|
59
|
+
|
60
|
+
File.open( opts[:lockfile] || "Jarfile.lock", "w") do |f|
|
61
|
+
f.write( lock_data.to_yaml )
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def list( jarfile_lock = "Jarfile.lock", scopes = ['compile', 'runtime'] )
|
66
|
+
lock_data = YAML.load_file( jarfile_lock )
|
67
|
+
|
68
|
+
dependencies = []
|
69
|
+
|
70
|
+
scopes.each do |scope|
|
71
|
+
if lock_data['scopes'][scope]
|
72
|
+
dependencies += lock_data['scopes'][scope]['resolved_dependencies']
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
dependencies
|
77
|
+
end
|
78
|
+
|
79
|
+
def load( jarfile_lock = "Jarfile.lock", scopes = ['compile', 'runtime'] )
|
80
|
+
lock_data = YAML.load_file( jarfile_lock )
|
81
|
+
|
82
|
+
dependencies = []
|
83
|
+
|
84
|
+
scopes.each do |scope|
|
85
|
+
if lock_data['scopes'][scope]
|
86
|
+
dependencies += lock_data['scopes'][scope]['resolved_dependencies']
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
@resolver.load_jars_to_classpath( dependencies )
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
data/lib/lock_jar.rb
ADDED
@@ -0,0 +1,36 @@
|
|
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 "yaml"
|
17
|
+
require 'rubygems'
|
18
|
+
require 'lock_jar/resolver'
|
19
|
+
require 'lock_jar/dsl'
|
20
|
+
require 'lock_jar/runtime'
|
21
|
+
|
22
|
+
module LockJar
|
23
|
+
|
24
|
+
def self.lock( jarfile = 'Jarfile', opts = {} )
|
25
|
+
Runtime.new( opts ).lock( jarfile, opts )
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.list( lockfile = 'Jarfile.lock', scopes = ['compile', 'runtime'], opts = {} )
|
29
|
+
Runtime.new( opts ).list( lockfile, scopes )
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.load( lockfile = 'Jarfile.lock', scopes = ['compile', 'runtime'], opts = {} )
|
33
|
+
Runtime.new( opts ).load( lockfile, scopes )
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
data/lock_jar.gemspec
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "lock_jar"
|
8
|
+
s.version = "0.0.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Michael Guymon"]
|
12
|
+
s.date = "2012-04-16"
|
13
|
+
s.description = "Manage Jar files for Ruby. In the spirit of Bundler, a Jarfile\n is used to generate a Jarfile.lock that contains all the resolved jar dependencies for scopes runtime, compile, and test.\n The Jarfile.lock can be used to populate the classpath"
|
14
|
+
s.email = "michael.guymon@gmail.com"
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
"Gemfile",
|
21
|
+
"Gemfile.lock",
|
22
|
+
"LICENSE",
|
23
|
+
"README.rdoc",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"lib/lock_jar.rb",
|
27
|
+
"lib/lock_jar/buildr.rb",
|
28
|
+
"lib/lock_jar/dsl.rb",
|
29
|
+
"lib/lock_jar/resolver.rb",
|
30
|
+
"lib/lock_jar/runtime.rb",
|
31
|
+
"lock_jar.gemspec",
|
32
|
+
"spec/Jarfile",
|
33
|
+
"spec/lock_jar/dsl_spec.rb",
|
34
|
+
"spec/lock_jar/resolver_spec.rb",
|
35
|
+
"spec/lock_jar_spec.rb",
|
36
|
+
"spec/pom.xml"
|
37
|
+
]
|
38
|
+
s.homepage = "http://github.com/mguymon/lockjar"
|
39
|
+
s.licenses = ["Apache"]
|
40
|
+
s.require_paths = ["lib"]
|
41
|
+
s.rubygems_version = "1.8.12"
|
42
|
+
s.summary = "Manage Jar files for Ruby"
|
43
|
+
|
44
|
+
if s.respond_to? :specification_version then
|
45
|
+
s.specification_version = 3
|
46
|
+
|
47
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
48
|
+
s.add_runtime_dependency(%q<naether>, ["~> 0.6.0"])
|
49
|
+
s.add_development_dependency(%q<rspec>, [">= 0"])
|
50
|
+
s.add_development_dependency(%q<bundler>, ["> 1.0.0"])
|
51
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
|
52
|
+
else
|
53
|
+
s.add_dependency(%q<naether>, ["~> 0.6.0"])
|
54
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
55
|
+
s.add_dependency(%q<bundler>, ["> 1.0.0"])
|
56
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
57
|
+
end
|
58
|
+
else
|
59
|
+
s.add_dependency(%q<naether>, ["~> 0.6.0"])
|
60
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
61
|
+
s.add_dependency(%q<bundler>, ["> 1.0.0"])
|
62
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
data/spec/Jarfile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
repository 'http://repository.jboss.org/nexus/content/groups/public-jboss'
|
2
|
+
|
3
|
+
jar "org.apache.mina:mina-core:2.0.4"
|
4
|
+
pom 'spec/pom.xml'
|
5
|
+
|
6
|
+
scope 'runtime' do
|
7
|
+
jar 'org.apache.tomcat:servlet-api:jar:6.0.35'
|
8
|
+
end
|
9
|
+
|
10
|
+
scope 'test' do
|
11
|
+
jar 'junit:junit:jar:4.10'
|
12
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'lib/lock_jar/dsl'
|
3
|
+
|
4
|
+
describe LockJar::Dsl do
|
5
|
+
context "Instance" do
|
6
|
+
it "should load a Jarfile" do
|
7
|
+
jarfile = LockJar::Dsl.evaluate( "spec/Jarfile" )
|
8
|
+
|
9
|
+
jarfile.notations.should eql( {"compile"=>["org.apache.mina:mina-core:2.0.4", "spec/pom.xml"], "runtime"=>["spec/pom.xml", "org.apache.tomcat:servlet-api:jar:6.0.35"], "test"=>["spec/pom.xml", "junit:junit:jar:4.10"]} )
|
10
|
+
jarfile.repositories.should eql( ["http://repository.jboss.org/nexus/content/groups/public-jboss"] )
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should load a block" do
|
14
|
+
block = LockJar::Dsl.evaluate do
|
15
|
+
repository 'http://repository.jboss.org/nexus/content/groups/public-jboss'
|
16
|
+
|
17
|
+
jar "org.apache.mina:mina-core:2.0.4"
|
18
|
+
pom 'spec/pom.xml'
|
19
|
+
|
20
|
+
scope 'runtime' do
|
21
|
+
jar 'org.apache.tomcat:servlet-api:jar:6.0.35'
|
22
|
+
end
|
23
|
+
|
24
|
+
scope 'test' do
|
25
|
+
jar 'junit:junit:jar:4.10'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
block.notations.should eql( {"compile"=>["org.apache.mina:mina-core:2.0.4", "spec/pom.xml"], "runtime"=>["spec/pom.xml", "org.apache.tomcat:servlet-api:jar:6.0.35"], "test"=>["spec/pom.xml", "junit:junit:jar:4.10"]} )
|
30
|
+
block.repositories.should eql( ["http://repository.jboss.org/nexus/content/groups/public-jboss"] )
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should raise an error without arguments" do
|
35
|
+
lambda { LockJar::Dsl.evaluate }.should raise_error
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should merge dsl" do
|
39
|
+
block1 = LockJar::Dsl.evaluate do
|
40
|
+
repository 'http://repository.jboss.org/nexus/content/groups/public-jboss'
|
41
|
+
|
42
|
+
jar "org.apache.mina:mina-core:2.0.4"
|
43
|
+
pom 'spec/pom.xml'
|
44
|
+
|
45
|
+
scope 'runtime' do
|
46
|
+
jar 'org.apache.tomcat:servlet-api:jar:6.0.35'
|
47
|
+
end
|
48
|
+
|
49
|
+
scope 'test' do
|
50
|
+
jar 'junit:junit:jar:4.10'
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
block2 = LockJar::Dsl.evaluate do
|
55
|
+
repository 'http://repository.jboss.org/nexus/content/groups/public-jboss'
|
56
|
+
repository 'http://new-repo'
|
57
|
+
|
58
|
+
jar "org.apache.mina:mina-core:2.0.4"
|
59
|
+
jar "compile-jar"
|
60
|
+
|
61
|
+
scope 'runtime' do
|
62
|
+
jar 'runtime-jar'
|
63
|
+
pom 'runtime-pom'
|
64
|
+
end
|
65
|
+
|
66
|
+
scope 'test' do
|
67
|
+
jar 'test-jar'
|
68
|
+
pom 'test-pom'
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
dsl = block1.merge( block2 )
|
73
|
+
|
74
|
+
dsl.notations.should eql( {"compile"=>["org.apache.mina:mina-core:2.0.4", "spec/pom.xml", "compile-jar"], "runtime"=>["spec/pom.xml", "org.apache.tomcat:servlet-api:jar:6.0.35", "runtime-jar", "runtime-pom"], "test"=>["spec/pom.xml", "junit:junit:jar:4.10", "test-jar", "test-pom"]} )
|
75
|
+
dsl.repositories.should eql( ["http://repository.jboss.org/nexus/content/groups/public-jboss", 'http://new-repo'] )
|
76
|
+
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'lib/lock_jar/resolver'
|
3
|
+
require 'fileutils'
|
4
|
+
require 'naether'
|
5
|
+
|
6
|
+
describe LockJar::Resolver do
|
7
|
+
context "Instance" do
|
8
|
+
it "should bootstrap naether" do
|
9
|
+
FileUtils.mkdir_p( 'tmp/test-repo' )
|
10
|
+
resolver = LockJar::Resolver.new( :local_repo => 'tmp/test-repo' )
|
11
|
+
|
12
|
+
deps = Naether::Bootstrap.check_local_repo_for_deps( 'tmp/test-repo' )
|
13
|
+
deps[:missing].should eql([])
|
14
|
+
deps[:exists].each do |dep|
|
15
|
+
dep.values[0].should match /.+#{File::SEPARATOR}tmp#{File::SEPARATOR}test-repo#{File::SEPARATOR}.+/
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'lib/lock_jar'
|
3
|
+
require 'naether'
|
4
|
+
|
5
|
+
describe LockJar do
|
6
|
+
context "Module" do
|
7
|
+
it "should create a lock file" do
|
8
|
+
File.delete( 'tmp/Jarfile.lock' ) if File.exists?( 'tmp/Jarfile.lock' )
|
9
|
+
Dir.mkdir( 'tmp' ) unless File.exists?( 'tmp' )
|
10
|
+
|
11
|
+
LockJar.lock( "spec/Jarfile", :local_repo => 'tmp/test-repo', :lockfile => 'tmp/Jarfile.lock' )
|
12
|
+
File.exists?( 'tmp/Jarfile.lock' ).should be_true
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should list jars" do
|
16
|
+
jars = LockJar.list( 'tmp/Jarfile.lock', ['compile', 'runtime', 'bad scope'], :local_repo => 'tmp/test-repo' )
|
17
|
+
jars.should eql( ["org.apache.mina:mina-core:jar:2.0.4", "org.slf4j:slf4j-api:jar:1.6.1", "com.slackworks:modelcitizen:jar:0.2.2", "commons-lang:commons-lang:jar:2.6", "commons-beanutils:commons-beanutils:jar:1.8.3", "commons-logging:commons-logging:jar:1.1.1", "ch.qos.logback:logback-classic:jar:0.9.24", "ch.qos.logback:logback-core:jar:0.9.24", "com.metapossum:metapossum-scanner:jar:1.0", "commons-io:commons-io:jar:1.4", "junit:junit:jar:4.7", "org.apache.tomcat:servlet-api:jar:6.0.35"] )
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should load jars" do
|
21
|
+
if Naether.platform == 'java'
|
22
|
+
lambda { include_class 'org.apache.mina.core.IoUtil' }.should raise_error
|
23
|
+
else
|
24
|
+
lambda { Rjb::import('org.apache.mina.core.IoUtil') }.should raise_error
|
25
|
+
end
|
26
|
+
|
27
|
+
jars = LockJar.load( 'tmp/Jarfile.lock', ['compile', 'runtime'], :local_repo => 'tmp/test-repo' )
|
28
|
+
|
29
|
+
jars.should eql( [File.expand_path("tmp/test-repo/org/apache/mina/mina-core/2.0.4/mina-core-2.0.4.jar"), File.expand_path("tmp/test-repo/org/slf4j/slf4j-api/1.6.1/slf4j-api-1.6.1.jar"), File.expand_path("tmp/test-repo/com/slackworks/modelcitizen/0.2.2/modelcitizen-0.2.2.jar"), File.expand_path("tmp/test-repo/commons-lang/commons-lang/2.6/commons-lang-2.6.jar"), File.expand_path("tmp/test-repo/commons-beanutils/commons-beanutils/1.8.3/commons-beanutils-1.8.3.jar"), File.expand_path("tmp/test-repo/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar"), File.expand_path("tmp/test-repo/ch/qos/logback/logback-classic/0.9.24/logback-classic-0.9.24.jar"), File.expand_path("tmp/test-repo/ch/qos/logback/logback-core/0.9.24/logback-core-0.9.24.jar"), File.expand_path("tmp/test-repo/com/metapossum/metapossum-scanner/1.0/metapossum-scanner-1.0.jar"), File.expand_path("tmp/test-repo/commons-io/commons-io/1.4/commons-io-1.4.jar"), File.expand_path("tmp/test-repo/junit/junit/4.7/junit-4.7.jar"), File.expand_path("tmp/test-repo/org/apache/tomcat/servlet-api/6.0.35/servlet-api-6.0.35.jar")] )
|
30
|
+
|
31
|
+
if Naether.platform == 'java'
|
32
|
+
lambda { include_class 'org.apache.mina.core.IoUtil' }.should_not raise_error
|
33
|
+
else
|
34
|
+
lambda { Rjb::import('org.apache.mina.core.IoUtil') }.should_not raise_error
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/spec/pom.xml
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/
|
3
|
+
2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 h
|
4
|
+
ttp://maven.apache.org/maven-v4_0_0.xsd ">
|
5
|
+
<modelVersion>4.0.0</modelVersion>
|
6
|
+
<groupId>lockjar</groupId>
|
7
|
+
<artifactId>test</artifactId>
|
8
|
+
<version>3</version>
|
9
|
+
<packaging>jar</packaging>
|
10
|
+
<dependencies>
|
11
|
+
<dependency>
|
12
|
+
<groupId>com.slackworks</groupId>
|
13
|
+
<artifactId>modelcitizen</artifactId>
|
14
|
+
<version>0.2.2</version>
|
15
|
+
</dependency>
|
16
|
+
<dependency>
|
17
|
+
<groupId>junit</groupId>
|
18
|
+
<artifactId>junit</artifactId>
|
19
|
+
<version>4.8.2</version>
|
20
|
+
<scope>test</scope>
|
21
|
+
</dependency>
|
22
|
+
</dependencies>
|
23
|
+
</project>
|
metadata
ADDED
@@ -0,0 +1,146 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lock_jar
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Michael Guymon
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2012-04-16 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
prerelease: false
|
22
|
+
type: :runtime
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ~>
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 7
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
- 6
|
32
|
+
- 0
|
33
|
+
version: 0.6.0
|
34
|
+
version_requirements: *id001
|
35
|
+
name: naether
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
prerelease: false
|
38
|
+
type: :development
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: 3
|
45
|
+
segments:
|
46
|
+
- 0
|
47
|
+
version: "0"
|
48
|
+
version_requirements: *id002
|
49
|
+
name: rspec
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
prerelease: false
|
52
|
+
type: :development
|
53
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ">"
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
hash: 23
|
59
|
+
segments:
|
60
|
+
- 1
|
61
|
+
- 0
|
62
|
+
- 0
|
63
|
+
version: 1.0.0
|
64
|
+
version_requirements: *id003
|
65
|
+
name: bundler
|
66
|
+
- !ruby/object:Gem::Dependency
|
67
|
+
prerelease: false
|
68
|
+
type: :development
|
69
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
|
+
requirements:
|
72
|
+
- - ~>
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
hash: 7
|
75
|
+
segments:
|
76
|
+
- 1
|
77
|
+
- 6
|
78
|
+
- 4
|
79
|
+
version: 1.6.4
|
80
|
+
version_requirements: *id004
|
81
|
+
name: jeweler
|
82
|
+
description: |-
|
83
|
+
Manage Jar files for Ruby. In the spirit of Bundler, a Jarfile
|
84
|
+
is used to generate a Jarfile.lock that contains all the resolved jar dependencies for scopes runtime, compile, and test.
|
85
|
+
The Jarfile.lock can be used to populate the classpath
|
86
|
+
email: michael.guymon@gmail.com
|
87
|
+
executables: []
|
88
|
+
|
89
|
+
extensions: []
|
90
|
+
|
91
|
+
extra_rdoc_files:
|
92
|
+
- LICENSE
|
93
|
+
- README.rdoc
|
94
|
+
files:
|
95
|
+
- Gemfile
|
96
|
+
- Gemfile.lock
|
97
|
+
- LICENSE
|
98
|
+
- README.rdoc
|
99
|
+
- Rakefile
|
100
|
+
- VERSION
|
101
|
+
- lib/lock_jar.rb
|
102
|
+
- lib/lock_jar/buildr.rb
|
103
|
+
- lib/lock_jar/dsl.rb
|
104
|
+
- lib/lock_jar/resolver.rb
|
105
|
+
- lib/lock_jar/runtime.rb
|
106
|
+
- lock_jar.gemspec
|
107
|
+
- spec/Jarfile
|
108
|
+
- spec/lock_jar/dsl_spec.rb
|
109
|
+
- spec/lock_jar/resolver_spec.rb
|
110
|
+
- spec/lock_jar_spec.rb
|
111
|
+
- spec/pom.xml
|
112
|
+
homepage: http://github.com/mguymon/lockjar
|
113
|
+
licenses:
|
114
|
+
- Apache
|
115
|
+
post_install_message:
|
116
|
+
rdoc_options: []
|
117
|
+
|
118
|
+
require_paths:
|
119
|
+
- lib
|
120
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
hash: 3
|
126
|
+
segments:
|
127
|
+
- 0
|
128
|
+
version: "0"
|
129
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
|
+
none: false
|
131
|
+
requirements:
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
hash: 3
|
135
|
+
segments:
|
136
|
+
- 0
|
137
|
+
version: "0"
|
138
|
+
requirements: []
|
139
|
+
|
140
|
+
rubyforge_project:
|
141
|
+
rubygems_version: 1.8.12
|
142
|
+
signing_key:
|
143
|
+
specification_version: 3
|
144
|
+
summary: Manage Jar files for Ruby
|
145
|
+
test_files: []
|
146
|
+
|