naether 0.6.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -1,14 +1,23 @@
1
1
  = Naether
2
2
 
3
- Naether is a Java Dependency Resolver using Maven's {Aether}[https://github.com/sonatype/sonatype-aether]
3
+ Naether is a Java Dependency Resolver using Maven's {Aether}[https://github.com/sonatype/sonatype-aether]
4
+ that can be used by Ruby or Java.
4
5
 
5
6
  https://github.com/mguymon/naether
6
7
 
7
-
8
8
  === Install
9
9
 
10
- gem install naether
10
+ ==== Ruby
11
+
12
+ gem install naether
13
+
14
+ ==== Java
11
15
 
16
+ <dependency>
17
+ <groupId>com.slackworks</groupId>
18
+ <artifactId>naether</artifactId>
19
+ <version>0.7.0</version>
20
+ </dependency>
12
21
 
13
22
  === About
14
23
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.1
1
+ 0.7.0
data/lib/naether.rb CHANGED
@@ -51,18 +51,13 @@ class Naether
51
51
 
52
52
  Naether.new
53
53
  end
54
+
54
55
  end
55
56
 
56
57
  # Create new instance. Naether.create_from_paths and Naether.create_from_jars should be
57
58
  # used instead of Naether.new to ensure the dependencies for Naether are set into the classpath
58
- def initialize()
59
-
60
- if Naether.platform == 'java'
61
- @resolver = com.slackworks.naether.Naether.new
62
- else
63
- naetherClass = Rjb::import('com.slackworks.naether.Naether')
64
- @resolver = naetherClass.new
65
- end
59
+ def initialize
60
+ @resolver = Naether::Java.create('com.slackworks.naether.Naether')
66
61
  end
67
62
 
68
63
  # Clear all remote repositories
@@ -94,6 +89,39 @@ class Naether
94
89
  @resolver.setLocalRepoPath( path )
95
90
  end
96
91
 
92
+ def add_build_artifact( notation, path, pom = nil )
93
+ @resolver.addBuildArtifact(notation, path, pom )
94
+ end
95
+
96
+ def build_artifacts=( artifacts )
97
+ @resolver.clearBuildArtifacts()
98
+
99
+ unless artifacts.is_a? Array
100
+ artifacts = [artifacts]
101
+ end
102
+
103
+ artifacts.each do |artifact|
104
+ # Hash of notation => path or notation => { :path =>, :pom => }
105
+ if artifact.is_a? Hash
106
+
107
+ notation, opts = artifact.shift
108
+
109
+ if opts.is_a? Hash
110
+ @resolver.add_build_artifact( notation, opts[:path], opts[:pom] )
111
+ else
112
+ @resolver.add_build_artifact( notation, opts )
113
+ end
114
+
115
+ else
116
+ raise "invalid build_artifacts format"
117
+ end
118
+ end
119
+ end
120
+
121
+ def build_artifacts
122
+ Naether::Java.convert_to_ruby_array( @resolver.getBuildArtifacts() )
123
+ end
124
+
97
125
  # Add a dependency in the notation: groupId:artifactId:type:version
98
126
  def add_notation_dependency( notation, scope='compile' )
99
127
  @resolver.addDependency( notation, scope )
@@ -328,4 +356,8 @@ class Naether
328
356
  @project_instance.writePom( file_path )
329
357
 
330
358
  end
359
+
360
+ def set_log_level( level )
361
+ Naether::Java.java_class('com.slackworks.naether.LogUtil').changeLevel( 'com.slackworks', level )
362
+ end
331
363
  end
@@ -105,7 +105,7 @@ class Naether
105
105
  local_repo = local_repo || ENV['M2_REPO'] || File.expand_path('~/.m2/repository')
106
106
  local_repo = File.expand_path(local_repo)
107
107
 
108
- puts "Checking #{local_repo} for jars to bootstrap Naether"
108
+ #puts "Checking #{local_repo} for jars to bootstrap Naether"
109
109
 
110
110
  deps = {:exists => [], :missing => [] }
111
111
 
data/lib/naether/java.rb CHANGED
@@ -27,7 +27,6 @@ class Naether
27
27
  instance.java.loaded_jars
28
28
  end
29
29
 
30
-
31
30
  # Loads all jars from the array of paths
32
31
  def self.load_jars_dir(paths)
33
32
  unless paths.is_a? Array
@@ -48,12 +47,22 @@ class Naether
48
47
  instance.java.load_jars(jars)
49
48
  end
50
49
 
51
- def self.set_log_level( level )
52
- instance.java.set_log_level( level )
50
+ # Paths loaded
51
+ def self.loaded_paths
52
+ instance.java.loaded_paths
53
53
  end
54
54
 
55
- def self.create( java_class, *args )
56
- instance.java.create( java_class, *args )
55
+ # Load paths for the runtime platform
56
+ def self.load_paths(paths)
57
+ instance.java.load_paths(paths)
58
+ end
59
+
60
+ def self.create( target_class, *args )
61
+ instance.java.create( target_class, *args )
62
+ end
63
+
64
+ def self.java_class( target_class )
65
+ instance.java.java_class( target_class )
57
66
  end
58
67
 
59
68
  def self.convert_to_ruby_array( java_array, to_string = false )
@@ -70,25 +79,44 @@ class Naether
70
79
  class JRuby
71
80
  include Singleton
72
81
 
73
- attr_reader :loaded_jars
82
+ attr_reader :loaded_jars, :loaded_paths
74
83
 
75
84
  def initialize
76
85
  require 'java'
77
86
 
78
87
  @loaded_jars = []
88
+ @loaded_paths = []
79
89
  end
80
90
 
81
- def create( java_class, *args )
82
- java_class = eval(java_class)
91
+ def create( target_class, *args )
92
+ java_class = java_class(target_class)
83
93
  java_class.new( *args )
84
94
  end
85
95
 
86
- def set_log_level( level )
87
- com.slackworks.naether.LogUtil.changeLevel( 'com.slackworks', level )
96
+ def java_class( target_class )
97
+ eval(target_class)
98
+ end
99
+
100
+ def load_paths(paths)
101
+ load_paths = []
102
+ unless paths.is_a? Array
103
+ paths = [paths]
104
+ end
105
+
106
+ paths.each do |path|
107
+ expanded_path = File.expand_path(path)
108
+ if !@loaded_paths.include? expanded_path
109
+ $CLASSPATH << expanded_path
110
+ load_paths << expanded_path
111
+ @loaded_paths << expanded_path
112
+ end
113
+ end
114
+
115
+ load_paths
88
116
  end
89
117
 
90
118
  def load_jars(jars)
91
- loaded_jars = []
119
+ load_jars = []
92
120
  unless jars.is_a? Array
93
121
  jars = [jars]
94
122
  end
@@ -97,12 +125,12 @@ class Naether
97
125
  expanded_jar = File.expand_path(jar)
98
126
  if !@loaded_jars.include? expanded_jar
99
127
  require expanded_jar
100
- loaded_jars << expanded_jar
128
+ load_jars << expanded_jar
101
129
  @loaded_jars << expanded_jar
102
130
  end
103
131
  end
104
132
 
105
- loaded_jars
133
+ load_jars
106
134
  end
107
135
 
108
136
  def convert_to_ruby_array( java_array, to_string = false )
@@ -121,7 +149,7 @@ class Naether
121
149
  class Ruby
122
150
  include Singleton
123
151
 
124
- attr_reader :loaded_jars
152
+ attr_reader :loaded_jars, :loaded_paths
125
153
 
126
154
  def initialize()
127
155
  require 'rjb'
@@ -131,15 +159,35 @@ class Naether
131
159
  Rjb::load("", java_opts)
132
160
 
133
161
  @loaded_jars = []
162
+ @loaded_paths = []
134
163
  end
135
164
 
136
- def create( java_class, *args )
137
- java_class = Rjb::import(java_class)
138
- java_class.new( *args )
165
+ def create( target_class, *args )
166
+ target_class = java_class(target_class)
167
+ target_class.new( *args )
139
168
  end
140
169
 
141
- def set_log_level( level )
142
- Rjb::import('com.slackworks.naether.LogUtil').changeLevel( 'com.slackworks', level )
170
+ def java_class( target_class )
171
+ Rjb::import( target_class )
172
+ end
173
+
174
+ def load_paths(paths)
175
+ loadable_paths = []
176
+ unless paths.is_a? Array
177
+ paths = [paths]
178
+ end
179
+
180
+ paths.each do |path|
181
+ expanded_path = File.expand_path(path)
182
+ if !@loaded_paths.include? expanded_path
183
+ @loaded_paths << expanded_path
184
+ loadable_paths << expanded_path
185
+ end
186
+ end
187
+
188
+ Rjb::load(loadable_paths.join(File::PATH_SEPARATOR))
189
+
190
+ loadable_paths
143
191
  end
144
192
 
145
193
  def load_jars(jars)
data/naether-0.7.0.jar ADDED
Binary file
data/pom.xml CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  <groupId>com.slackworks</groupId>
6
6
  <artifactId>naether</artifactId>
7
- <version>0.6.1</version>
7
+ <version>0.7.0</version>
8
8
  <packaging>jar</packaging>
9
9
  <name>naether</name>
10
10
  <url>https://github.com/mguymon/naether</url>
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: naether
3
3
  version: !ruby/object:Gem::Version
4
- hash: 5
4
+ hash: 3
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 6
9
- - 1
10
- version: 0.6.1
8
+ - 7
9
+ - 0
10
+ version: 0.7.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Michael Guymon
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-04-17 00:00:00 Z
18
+ date: 2012-05-02 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  prerelease: false
@@ -98,7 +98,7 @@ files:
98
98
  - lib/naether.rb
99
99
  - lib/naether/bootstrap.rb
100
100
  - lib/naether/java.rb
101
- - naether-0.6.1.jar
101
+ - naether-0.7.0.jar
102
102
  - pom.xml
103
103
  homepage: http://github.com/mguymon/naether
104
104
  licenses:
data/naether-0.6.1.jar DELETED
Binary file