lock_jar 0.3.3 → 0.4.0

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.
data/.gitignore ADDED
@@ -0,0 +1,56 @@
1
+ Gemfile.lock
2
+
3
+ .*
4
+
5
+ tmp
6
+
7
+ # rcov generated
8
+ coverage
9
+
10
+ # rdoc generated
11
+ rdoc
12
+
13
+ # yard generated
14
+ doc
15
+ .yardoc
16
+
17
+ # bundler
18
+ .bundle
19
+
20
+ # jeweler generated
21
+ pkg
22
+
23
+ # Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
24
+ #
25
+ # * Create a file at ~/.gitignore
26
+ # * Include files you want ignored
27
+ # * Run: git config --global core.excludesfile ~/.gitignore
28
+ #
29
+ # After doing this, these files will be ignored in all your git projects,
30
+ # saving you from having to 'pollute' every project you touch with them
31
+ #
32
+ # Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
33
+ #
34
+ # For MacOS:
35
+ #
36
+ #.DS_Store
37
+
38
+ # For TextMate
39
+ #*.tmproj
40
+ #tmtags
41
+
42
+ # For emacs:
43
+ #*~
44
+ #\#*
45
+ #.\#*
46
+
47
+ # For vim:
48
+ #*.swp
49
+
50
+ # For redcar:
51
+ #.redcar
52
+
53
+ # For rubinius:
54
+ #*.rbc
55
+
56
+ autotest
data/README.rdoc CHANGED
@@ -5,13 +5,15 @@ Bundler and Maven. A Jarfile ({example}[https://github.com/mguymon/lock_jar/blob
5
5
  generate a Jarfile.lock that contains all the resolved jar dependencies for scopes runtime, compile, and test.
6
6
  The Jarfile.lock can be used to populate the classpath.
7
7
 
8
+ LockJar can be used directly or integrates directly with Bundler and Buildr.
9
+
8
10
  https://github.com/mguymon/lock_jar
9
11
 
10
12
  {RDoc}[http://rubydoc.info/github/mguymon/lock_jar/master/frames]
11
13
 
12
14
  == Install
13
15
 
14
- gem install lock_jar
16
+ gem install lock_jar
15
17
 
16
18
  == Usage
17
19
 
@@ -22,12 +24,12 @@ gem install lock_jar
22
24
  A Jarfile is a simple file using a Ruby DSL for defining a project's dependencies using the following
23
25
  methods:
24
26
 
25
- * local( path ): Set the local Maven repository
26
- * repository( url ): Add url of additional remote Maven repository.
27
- * map( notation, paths ): Map local paths to a notation.
27
+ * local( path ): Set the local Maven repository, this were dependencies are downloaded to.
28
+ * repository( url ): Add additional urlr of remote Maven repository.
29
+ * map( notation, paths ): Map local compiled class paths to a notation. The map is applied when loading or listing jar. This is useful for local development that overrides an artifact. A single or Array of paths can be set.
28
30
  * exclude( excludes ): Add a artifact:group that will be excluded from resolved dependencies. A single or Array of excludes can be set.
29
31
  * jar( notations, opts = {} ): Add Jar dependency in artifact notation, artifact:group:version as the bare minimum. A single or Array of notations can be passed. Default scope is *compile*, can be specified by setting opts = { :scope => <new_scope> }
30
- * pom( pom_path, opts = {} ): Add local path to a Maven pom, default is to load dependencies for all scopes. To select the scopes to be loaded from the pom, set the opts = { :scopes => <new_scopes> }
32
+ * pom( pom_path, opts = {} ): Add a local Maven pom, default is to load dependencies for all scopes. To select the scopes to be loaded from the pom, set the opts = { :scopes => <new_scopes> }
31
33
  * scope( scopes ): Set the scope for nested jar or pom. A single or Array of scopes can be set.
32
34
 
33
35
  Example Jarfile
@@ -49,7 +51,7 @@ Example Jarfile
49
51
  ==== Resolving dependencies
50
52
 
51
53
  * LockJar.lock( *args ): Using a Jarfile, creates a lock file. Depending on the type of arg, a different configuration is set.
52
- * An arg of a String will set the Jarfile, e.g. 'Jarfile.different'. Default jarfile is *Jarfile*
54
+ * An arg of a String will set the Jarfile path, e.g. '/somewhere/Jarfile.different'. Default jarfile is *Jarfile*
53
55
  * An arg of a Hash will set the options, e.g. { :local_repo => 'path' }
54
56
  * :local_repo sets the local repo path
55
57
  * :lockfile sets the Jarfile.lock path. Default lockfile is *Jarfile.lock*.
@@ -103,12 +105,12 @@ The Jarfile.lock
103
105
  ==== Accessing Jars
104
106
 
105
107
  * LockJar.list(*args): Lists all dependencies as notations for scopes from the Jarfile.lock. Depending on the type of arg, a different configuration is set.
106
- * An arg of a String will set the Jarfile.lock, e.g. 'Better.lock'. Default lock file is *Jarfile.lock*.
108
+ * An arg of a String will set the Jarfile.lock path, e.g. 'Better.lock'. Default lock file is *Jarfile.lock*.
107
109
  * An arg of an Array will set the scopes, e.g. ['compile','test']. Defaults scopes are *compile* and *runtime*.
108
110
  * An arg of a Hash will set the options, e.g. { :local_repo => 'path' }
109
111
  * :local_repo sets the local repo path
110
- * :local_paths converts the notations to paths to jars in the local repo path
111
- * :resolve to true will make transitive dependences resolve before loading to classpath
112
+ * :local_paths converts the notations to paths of jars in the local repo
113
+ * :resolve to true will make transitive dependences resolve before returning list of jars
112
114
 
113
115
  * LockJar.load(*args): Loads all dependencies to the classpath for scopes from the Jarfile.lock. Defaults scopes are *compile* and *runtime*. Default lock file is *Jarfile.lock*.
114
116
  * An arg of a String will set the Jarfile.lock, e.g. 'Better.lock'
@@ -156,46 +158,19 @@ Since you skipped the locking part, mostly likely you will need to resolve the d
156
158
  jar 'org.eclipse.jetty:example-jetty-embedded:jar:8.1.2.v20120308'
157
159
  end
158
160
 
159
- === Bundler Integration
160
-
161
- LockJar integrates with {Bundler}[https://github.com/carlhuda/bundler/] by {modifying}[https://github.com/mguymon/lock_jar/blob/master/lib/lock_jar/bundler.rb] the Bundler
162
- DSL to include LockJar's DSL, generating a Jarfile.lock when Bundler locks, and populating the classpath when Bundler requires.
163
-
164
- ==== Example
165
-
166
- The following Gemfile with LockJar
167
-
168
- # This is what modifies Bundler to trigger LockJar
169
- require 'lock_jar/bundler'
170
-
171
- gem "naether"
172
-
173
- group :development do
174
- gem "rspec", "~> 2.9.0"
175
- end
176
-
177
- # lockjar dsl that is used to generate Jarfile.lock
178
- lock_jar do
179
- scope :test do
180
- jar 'junit:junit:jar:4.10'
181
- end
182
-
183
- pom 'spec/pom.xml', :scope => :compile
184
- end
161
+ === Command line
185
162
 
186
- Will produce a Gemfile.lock and Jarfile.lock for
163
+ There is a simple command line helper. You can lock a Jarfile with the following command
187
164
 
188
- bundle install
189
-
190
- When Bundler.setup or Bundler.require is called, the jars from the Jarfile.lock are loaded into the classpath.
165
+ lockjar lock
191
166
 
192
- require 'rubygems'
193
- require 'bundler'
167
+ or list jars in a Jarfile.lock with
168
+
169
+ lockjar list
194
170
 
195
- # This is what modifies Bundler to trigger LockJar
196
- require 'lock_jar/bundler'
171
+ === Bundler Integration
197
172
 
198
- Bundler.require
173
+ Has been deprecated to https://github.com/mguymon/lock_jar/tree/bundler_support
199
174
 
200
175
  === Buildr Integration
201
176
 
data/Rakefile CHANGED
@@ -23,6 +23,10 @@ Jeweler::Tasks.new do |gem|
23
23
  The Jarfile.lock can be used to populate the classpath"
24
24
  gem.email = "michael.guymon@gmail.com"
25
25
  gem.authors = ["Michael Guymon"]
26
+ gem.executable = "lockjar"
27
+
28
+ gem.files = `git ls-files`.split("\n") rescue ''
29
+
26
30
  # dependencies defined in Gemfile
27
31
  end
28
32
  Jeweler::RubygemsDotOrgTasks.new
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.3
1
+ 0.4.0
data/bin/lockjar ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require 'lock_jar'
4
+ require 'lock_jar/cli'
5
+
6
+ LockJar::CLI.process( ARGV )
7
+
@@ -0,0 +1,21 @@
1
+ require 'lock_jar'
2
+
3
+ module LockJar
4
+ class CLI
5
+ def self.process( args )
6
+ if args.length > 0
7
+ args.each do|arg|
8
+ if arg == "lock"
9
+ LockJar.lock
10
+ puts "Jarfile.lock created"
11
+ elsif arg == "list"
12
+ puts "Listing Jarfile.lock jars for scopes compile, runtime"
13
+ puts LockJar.list.inspect
14
+ end
15
+ end
16
+ else
17
+ puts "Arguments: lock, load, or list"
18
+ end
19
+ end
20
+ end
21
+ end
data/lock_jar.gemspec CHANGED
@@ -5,35 +5,36 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "lock_jar"
8
- s.version = "0.3.3"
8
+ s.version = "0.4.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Michael Guymon"]
12
- s.date = "2012-05-21"
12
+ s.date = "2012-08-21"
13
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
14
  s.email = "michael.guymon@gmail.com"
15
+ s.executables = ["lockjar"]
15
16
  s.extra_rdoc_files = [
16
17
  "LICENSE",
17
18
  "README.rdoc"
18
19
  ]
19
20
  s.files = [
21
+ ".gitignore",
20
22
  "Gemfile",
21
23
  "LICENSE",
22
24
  "README.rdoc",
23
25
  "Rakefile",
24
26
  "VERSION",
27
+ "bin/lockjar",
25
28
  "lib/lock_jar.rb",
26
29
  "lib/lock_jar/buildr.rb",
27
- "lib/lock_jar/bundler.rb",
30
+ "lib/lock_jar/cli.rb",
28
31
  "lib/lock_jar/dsl.rb",
29
32
  "lib/lock_jar/maven.rb",
30
33
  "lib/lock_jar/resolver.rb",
31
34
  "lib/lock_jar/runtime.rb",
32
35
  "lock_jar.gemspec",
33
- "spec/BundlerJarfile.lock",
34
36
  "spec/Jarfile",
35
- "spec/helper/bundler_helper.rb",
36
- "spec/lock_jar/bundler_spec.rb",
37
+ "spec/lock_jar/cli_spec.rb",
37
38
  "spec/lock_jar/dsl_spec.rb",
38
39
  "spec/lock_jar/maven_spec.rb",
39
40
  "spec/lock_jar/resolver_spec.rb",
data/spec/Jarfile CHANGED
@@ -2,7 +2,7 @@ local '~/.m2'
2
2
  repository 'http://repository.jboss.org/nexus/content/groups/public-jboss'
3
3
 
4
4
  jar "org.apache.mina:mina-core:2.0.4"
5
- pom 'spec/pom.xml'
5
+ pom 'pom.xml'
6
6
 
7
7
  scope 'runtime' do
8
8
  jar 'org.apache.tomcat:servlet-api:jar:6.0.35'
@@ -0,0 +1,17 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__),'../spec_helper'))
2
+ require 'lock_jar/cli'
3
+
4
+ describe LockJar::CLI do
5
+ describe "#process" do
6
+ it "should lock a Jarfile" do
7
+ Dir.chdir( 'spec' )
8
+ LockJar::CLI.process( ['lock'] )
9
+
10
+ File.exists?('Jarfile.lock').should be_true
11
+
12
+ File.delete( 'Jarfile.lock' ) if File.exists?('Jarfile.lock')
13
+
14
+ Dir.chdir( '../' )
15
+ end
16
+ end
17
+ end
@@ -6,7 +6,7 @@ describe LockJar::Dsl do
6
6
  jarfile = LockJar::Dsl.evaluate( "spec/Jarfile" )
7
7
 
8
8
  jarfile.local_repository.should eql '~/.m2'
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"]} )
9
+ jarfile.notations.should eql( {"compile"=>["org.apache.mina:mina-core:2.0.4", "pom.xml"], "runtime"=>["pom.xml", "org.apache.tomcat:servlet-api:jar:6.0.35"], "test"=>["pom.xml", "junit:junit:jar:4.10"]} )
10
10
  jarfile.repositories.should eql( ["http://repository.jboss.org/nexus/content/groups/public-jboss"] )
11
11
  end
12
12
 
@@ -8,8 +8,12 @@ describe LockJar, "#lock" do
8
8
  File.delete( 'tmp/Jarfile.lock' ) if File.exists?( 'tmp/Jarfile.lock' )
9
9
  Dir.mkdir( 'tmp' ) unless File.exists?( 'tmp' )
10
10
 
11
- LockJar.lock( "spec/Jarfile", :local_repo => 'tmp/test-repo', :lockfile => 'tmp/Jarfile.lock' )
12
- File.exists?( 'tmp/Jarfile.lock' ).should be_true
11
+ Dir.chdir( 'spec' )
12
+
13
+ LockJar.lock( "Jarfile", :local_repo => '../tmp/test-repo', :lockfile => '../tmp/Jarfile.lock' )
14
+ File.exists?( '../tmp/Jarfile.lock' ).should be_true
15
+
16
+ Dir.chdir( '../' )
13
17
  end
14
18
 
15
19
  it "should not replace dependencies with maps" do
@@ -64,10 +68,14 @@ end
64
68
 
65
69
  describe LockJar, "#list" do
66
70
  it "should list jars" do
67
- LockJar.lock( "spec/Jarfile", :local_repo => 'tmp/test-repo', :lockfile => 'tmp/Jarfile.lock' )
71
+ Dir.chdir( 'spec' )
72
+
73
+ LockJar.lock( "Jarfile", :local_repo => '../tmp/test-repo', :lockfile => '../tmp/Jarfile.lock' )
68
74
 
69
- jars = LockJar.list( 'tmp/Jarfile.lock', ['compile', 'runtime', 'bad scope'], :local_repo => 'tmp/test-repo' )
75
+ jars = LockJar.list( '../tmp/Jarfile.lock', ['compile', 'runtime', 'bad scope'], :local_repo => '../tmp/test-repo' )
70
76
  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"] )
77
+
78
+ Dir.chdir( '../' )
71
79
  end
72
80
 
73
81
  it "should replace dependencies with maps" do
@@ -101,7 +109,9 @@ describe LockJar, "#load" do
101
109
  lambda { Rjb::import('org.apache.mina.core.IoUtil') }.should raise_error
102
110
  end
103
111
 
104
- LockJar.lock( "spec/Jarfile", :local_repo => 'tmp/test-repo', :lockfile => 'tmp/Jarfile.lock' )
112
+ Dir.chdir( 'spec' )
113
+
114
+ LockJar.lock( "Jarfile", :local_repo => 'tmp/test-repo', :lockfile => 'tmp/Jarfile.lock' )
105
115
 
106
116
  jars = LockJar.load( 'tmp/Jarfile.lock', ['compile', 'runtime'], :local_repo => 'tmp/test-repo' )
107
117
  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")] )
@@ -111,6 +121,9 @@ describe LockJar, "#load" do
111
121
  else
112
122
  lambda { Rjb::import('org.apache.mina.core.IoUtil') }.should_not raise_error
113
123
  end
124
+
125
+
126
+ Dir.chdir( '../' )
114
127
  end
115
128
 
116
129
  it "by block with resolve option" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lock_jar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-21 00:00:00.000000000 Z
12
+ date: 2012-08-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: naether
@@ -96,29 +96,30 @@ description: ! "Manage Jar files for Ruby. In the spirit of Bundler, a Jarfile\n
96
96
  for scopes runtime, compile, and test.\n The Jarfile.lock can be used to populate
97
97
  the classpath"
98
98
  email: michael.guymon@gmail.com
99
- executables: []
99
+ executables:
100
+ - lockjar
100
101
  extensions: []
101
102
  extra_rdoc_files:
102
103
  - LICENSE
103
104
  - README.rdoc
104
105
  files:
106
+ - .gitignore
105
107
  - Gemfile
106
108
  - LICENSE
107
109
  - README.rdoc
108
110
  - Rakefile
109
111
  - VERSION
112
+ - bin/lockjar
110
113
  - lib/lock_jar.rb
111
114
  - lib/lock_jar/buildr.rb
112
- - lib/lock_jar/bundler.rb
115
+ - lib/lock_jar/cli.rb
113
116
  - lib/lock_jar/dsl.rb
114
117
  - lib/lock_jar/maven.rb
115
118
  - lib/lock_jar/resolver.rb
116
119
  - lib/lock_jar/runtime.rb
117
120
  - lock_jar.gemspec
118
- - spec/BundlerJarfile.lock
119
121
  - spec/Jarfile
120
- - spec/helper/bundler_helper.rb
121
- - spec/lock_jar/bundler_spec.rb
122
+ - spec/lock_jar/cli_spec.rb
122
123
  - spec/lock_jar/dsl_spec.rb
123
124
  - spec/lock_jar/maven_spec.rb
124
125
  - spec/lock_jar/resolver_spec.rb
@@ -141,7 +142,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
141
142
  version: '0'
142
143
  segments:
143
144
  - 0
144
- hash: 304515307845688125
145
+ hash: -3207062463202255767
145
146
  required_rubygems_version: !ruby/object:Gem::Requirement
146
147
  none: false
147
148
  requirements:
@@ -1,100 +0,0 @@
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 'bundler/dsl'
18
- require 'lock_jar'
19
- require 'lock_jar/dsl'
20
-
21
- module Bundler
22
- class Dsl
23
- def lock_jar(&blk)
24
- @lock_jar_blk = blk
25
- end
26
-
27
- def to_definition(lockfile, unlock)
28
- @sources << @rubygems_source unless @sources.include?(@rubygems_source)
29
- definition = LockJarDefinition.new(lockfile, @dependencies, @sources, unlock)
30
-
31
- if @lock_jar_blk
32
- definition.lock_jar = LockJar::Dsl.evaluate( nil, &@lock_jar_blk )
33
- end
34
-
35
- definition
36
- end
37
- end
38
-
39
- class Environment
40
- def lock_jar
41
- @definition.lock_jar
42
- end
43
- end
44
-
45
- class LockJarDefinition < Bundler::Definition
46
- alias :lockjar_replaced_lock :lock
47
- attr_accessor :lock_jar
48
-
49
- def lock( file )
50
-
51
- # XXX: this is call from Bundler.setup. Only should happen on install or update
52
- LockJar.lock( lock_jar )
53
-
54
- lockjar_replaced_lock( file )
55
- end
56
- end
57
-
58
- class Runtime
59
- alias :lockjar_replaced_setup :setup
60
- alias :lockjar_replaced_require :require
61
-
62
- def setup(*groups)
63
- scopes = []
64
- if groups && groups.size == 0
65
- scopes = ["compile","runtime"]
66
- else
67
- groups.each do |group|
68
- if "development" == group.to_s
69
- scopes << "compile"
70
- elsif "default" == group.to_s
71
- scopes << "compile" << "runtime"
72
- end
73
- end
74
- end
75
-
76
- LockJar.load( scopes.uniq )
77
-
78
- lockjar_replaced_setup( *groups )
79
- end
80
-
81
- def require(*groups)
82
- scopes = []
83
-
84
- if groups && groups.size == 0
85
- scopes = ["compile","runtime"]
86
- else
87
- groups.each do |group|
88
- if "development" == group.to_s
89
- scopes << "compile"
90
- elsif "default" == group.to_s
91
- scopes << "compile" << "runtime"
92
- end
93
- end
94
- end
95
- LockJar.load( scopes.uniq )
96
-
97
- lockjar_replaced_require( *groups )
98
- end
99
- end
100
- end
@@ -1,22 +0,0 @@
1
- ---
2
- scopes:
3
- compile:
4
- dependencies:
5
- - /home/zinger/devel/projects/swx/lock_jar/spec/pom.xml
6
- resolved_dependencies:
7
- - com.slackworks:modelcitizen:jar:0.2.2
8
- - commons-lang:commons-lang:jar:2.6
9
- - commons-beanutils:commons-beanutils:jar:1.8.3
10
- - commons-logging:commons-logging:jar:1.1.1
11
- - ch.qos.logback:logback-classic:jar:0.9.24
12
- - ch.qos.logback:logback-core:jar:0.9.24
13
- - org.slf4j:slf4j-api:jar:1.6.1
14
- - com.metapossum:metapossum-scanner:jar:1.0
15
- - commons-io:commons-io:jar:1.4
16
- - junit:junit:jar:4.7
17
- test:
18
- dependencies:
19
- - junit:junit:jar:4.10
20
- resolved_dependencies:
21
- - junit:junit:jar:4.10
22
- - org.hamcrest:hamcrest-core:jar:1.1
@@ -1,156 +0,0 @@
1
- # Require the correct version of popen for the current platform
2
- if RbConfig::CONFIG['host_os'] =~ /mingw|mswin/
3
- begin
4
- require 'win32/open3'
5
- rescue LoadError
6
- abort "Run `gem install win32-open3` to be able to run specs"
7
- end
8
- else
9
- require 'open3'
10
- end
11
-
12
-
13
- module BundlerHelper
14
-
15
- # Taken from Bundler spec supprt
16
- # https://github.com/carlhuda/bundler/tree/master/spec/support
17
-
18
- attr_reader :out, :err, :exitstatus
19
-
20
- def gemfile(*args)
21
- path = bundled_app("Gemfile")
22
- path = args.shift if Pathname === args.first
23
- str = args.shift || ""
24
- path.dirname.mkpath
25
- File.open(path.to_s, 'w') do |f|
26
- f.puts str
27
- end
28
- end
29
-
30
- def lockfile(*args)
31
- path = bundled_app("Gemfile.lock")
32
- path = args.shift if Pathname === args.first
33
- str = args.shift || ""
34
-
35
- # Trim the leading spaces
36
- spaces = str[/\A\s+/, 0] || ""
37
- str.gsub!(/^#{spaces}/, '')
38
-
39
- File.open(path.to_s, 'w') do |f|
40
- f.puts str
41
- end
42
- end
43
-
44
- def install_gemfile(*args)
45
- gemfile(*args)
46
- opts = args.last.is_a?(Hash) ? args.last : {}
47
- bundle :install, opts
48
- end
49
-
50
- def bundle(cmd, options = {})
51
- expect_err = options.delete(:expect_err)
52
- exitstatus = options.delete(:exitstatus)
53
- options["no-color"] = true unless options.key?("no-color") || %w(exec conf).include?(cmd.to_s[0..3])
54
-
55
- #bundle_bin = File.expand_path('../../../bin/bundle', __FILE__)
56
- bundle_bin = `which bundle`.strip
57
-
58
- requires = options.delete(:requires) || []
59
- requires << File.expand_path('../fakeweb/'+options.delete(:fakeweb)+'.rb', __FILE__) if options.key?(:fakeweb)
60
- requires << File.expand_path('../artifice/'+options.delete(:artifice)+'.rb', __FILE__) if options.key?(:artifice)
61
- requires_str = requires.map{|r| "-r#{r}"}.join(" ")
62
-
63
- env = (options.delete(:env) || {}).map{|k,v| "#{k}='#{v}' "}.join
64
- args = options.map do |k,v|
65
- v == true ? " --#{k}" : " --#{k} #{v}" if v
66
- end.join
67
-
68
- cmd = "#{env}#{Gem.ruby} -I#{lib} -I#{root} #{requires_str} #{bundle_bin} #{cmd}#{args}"
69
-
70
- #puts cmd
71
-
72
- if exitstatus
73
- sys_status(cmd)
74
- else
75
- sys_exec(cmd, expect_err){|i| yield i if block_given? }
76
- end
77
- end
78
-
79
- def root
80
- @root ||= Pathname.new(File.expand_path("../../..", __FILE__))
81
- end
82
-
83
- def bundled_app(*path)
84
- root = tmp.join("bundled_app")
85
- FileUtils.mkdir_p(root)
86
- root.join(*path)
87
- end
88
-
89
- def tmp(*path)
90
- root.join("tmp", *path)
91
- end
92
-
93
- def in_app_root(&blk)
94
- Dir.chdir(bundled_app, &blk)
95
- end
96
-
97
- def lib
98
- File.expand_path('../../../lib', __FILE__)
99
- end
100
-
101
- def sys_exec(cmd, expect_err = false)
102
- Open3.popen3(cmd.to_s) do |stdin, stdout, stderr|
103
- @in_p, @out_p, @err_p = stdin, stdout, stderr
104
-
105
- yield @in_p if block_given?
106
- @in_p.close
107
-
108
- @out = @out_p.read_available_bytes.strip
109
- @err = @err_p.read_available_bytes.strip
110
- end
111
-
112
- #puts @out
113
- puts @err unless expect_err || @err.empty? || !$show_err
114
- @out
115
- end
116
-
117
- def ruby(ruby, options = {})
118
- expect_err = options.delete(:expect_err)
119
- env = (options.delete(:env) || {}).map{|k,v| "#{k}='#{v}' "}.join
120
- ruby.gsub!(/["`\$]/) {|m| "\\#{m}" }
121
- lib_option = options[:no_lib] ? "" : " -I#{lib} -I#{root}"
122
-
123
- #puts %{#{env}#{Gem.ruby}#{lib_option} -e "#{ruby}"}
124
-
125
- sys_exec(%{#{env}#{Gem.ruby}#{lib_option} -e "#{ruby}"}, expect_err)
126
- end
127
-
128
- RSpec::Matchers.define :have_dep do |*args|
129
- dep = Bundler::Dependency.new(*args)
130
-
131
- match do |actual|
132
- actual.length == 1 && actual.all? { |d| d == dep }
133
- end
134
- end
135
- end
136
-
137
- class IO
138
- def read_available_bytes(chunk_size = 16384, select_timeout = 0.02)
139
- buffer = []
140
-
141
- return "" if closed? || eof?
142
- # IO.select cannot be used here due to the fact that it
143
- # just does not work on windows
144
- while true
145
- begin
146
- IO.select([self], nil, nil, select_timeout)
147
- break if eof? # stop raising :-(
148
- buffer << self.readpartial(chunk_size)
149
- rescue(EOFError)
150
- break
151
- end
152
- end
153
-
154
- return buffer.join
155
- end
156
- end
@@ -1,98 +0,0 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__),'../spec_helper'))
2
-
3
- require 'rubygems'
4
- require 'bundler'
5
- require 'lib/lock_jar/bundler'
6
- require 'helper/bundler_helper'
7
- require 'fileutils'
8
-
9
- describe Bundler do
10
- include BundlerHelper
11
-
12
- before(:all) do
13
- FileUtils.rm_rf( bundled_app ) if File.exists? bundled_app
14
- end
15
-
16
- before(:each) do
17
- gemfile <<-G
18
- require 'lib/lock_jar/bundler'
19
- gem "naether"
20
-
21
- lock_jar do
22
- scope :test do
23
- jar 'junit:junit:jar:4.10'
24
- end
25
-
26
- pom "#{File.join(root, 'spec', 'pom.xml')}", :scope => :development
27
- end
28
- G
29
-
30
- ENV['BUNDLE_GEMFILE'] = bundled_app("Gemfile").to_s
31
-
32
- in_app_root
33
- end
34
-
35
- after(:all) do
36
- puts "Changing pwd back to #{root}"
37
- Dir.chdir(root)
38
- end
39
-
40
- it "provides a list of the env dependencies" do
41
- dep = Bundler.load.dependencies.first
42
- dep.name.should eql("naether")
43
- (dep.requirement >= ">= 0").should be_true
44
- end
45
-
46
- it "provides a list of the jar and pom dependencies" do
47
- # XXX: In JRuby - works in autotest, fails directly from rspec. *sigh*
48
- Bundler.load.lock_jar.notations.should eql( {"compile"=>[File.expand_path(File.join(File.dirname(__FILE__), "../../spec/pom.xml"))], "runtime"=>[], "test"=>["junit:junit:jar:4.10"]} )
49
- end
50
-
51
- it "should create Jarfile.lock with bundle install" do
52
- File.delete( bundled_app("Jarfile.lock") ) if File.exists? bundled_app("Jarfile.lock")
53
- install_gemfile <<-G
54
- require 'lock_jar/bundler'
55
- gem "naether"
56
-
57
- lock_jar do
58
- scope :test do
59
- jar 'junit:junit:jar:4.10'
60
- end
61
-
62
- pom "#{File.join(root, 'spec', 'pom.xml')}", :scope => :development
63
- end
64
-
65
- G
66
- File.exists?( bundled_app("Jarfile.lock") ).should be_true
67
-
68
- LockJar.read( File.join(root,'spec', 'BundlerJarfile.lock') ).should eql( LockJar.read( bundled_app("Jarfile.lock") ) )
69
- end
70
-
71
- it "should create Jarfile.lock with bundle update" do
72
- File.delete( bundled_app("Jarfile.lock") ) if File.exists? bundled_app("Jarfile.lock")
73
- bundle "update"
74
- File.exists?( bundled_app("Jarfile.lock") ).should be_true
75
-
76
- LockJar.read( File.join(root,'spec', 'BundlerJarfile.lock') ).should eql( LockJar.read( bundled_app("Jarfile.lock") ) )
77
- end
78
-
79
- it "should load Jarfile.lock with Bundle.setup" do
80
- LockJar.list( :resolve => true, :local_repo => tmp('test-repo') ) # ensure jars are already downloaded
81
-
82
- ruby <<-RUBY
83
- require 'rubygems'
84
- require 'bundler'
85
- require 'lib/lock_jar/bundler'
86
- require 'naether/java'
87
-
88
- LockJar.config( :local_repo => '#{tmp('test-repo')}' )
89
-
90
- Bundler.setup
91
-
92
- puts Naether::Java.create('com.slackworks.modelcitizen.ModelFactory').getClass().toString()
93
- RUBY
94
- #err.should eq("") # 1.9.3 has a IConv error that outputs to std err
95
- out.should match("class com.slackworks.modelcitizen.ModelFactory")
96
- end
97
-
98
- end