warbler 1.4.4 → 1.4.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 98d05a82e2e4f5ccfc47ffc014a1b4baf1872510
4
- data.tar.gz: 27f3d80a4e3231a1120e72a13173ebcd2cc7ce64
3
+ metadata.gz: f191c5553256cc2b14be10dbb9e5bb4582080046
4
+ data.tar.gz: 30b9d9cbb24297872f2bc0f5ec6978f4e2bfa99d
5
5
  SHA512:
6
- metadata.gz: 1b220ad7086cb9ceef5db6e1fc80d863e150bf0e8d6e0a5aa9cfd5b26c225f0e036a73dbb6bee9c6e774535e79c0b9112fc8a1a1e054057b9059d5831f253c67
7
- data.tar.gz: 02e5f1796a08654fe5416e20a95f5e87abef27bf3d77870dbec64233e06864ed96fd9f880d0e0184d399fa962cfa49818691d524e4da0cec2e85f99a56c0408f
6
+ metadata.gz: 5e445e6ad70bcf3047e44661bfb599a43d23491bf80baae4c36f468cd49660b0dce622a01b4bd98ce7eb4e2ed758b72eac1cb4cd5b0a42a30d33599d91f56b0a
7
+ data.tar.gz: 2623d3d975d55216dcf3a8574b126ca91e745b20b870672515a34c4ffcbf46b9b0dd7ba678e215b47aaa2315c73e7c21d1c2b5b8d143c4602ab203e3a29de87b
data/History.txt CHANGED
@@ -1,3 +1,6 @@
1
+ == 1.4.5
2
+ - #282: Wrong default GEM_HOME in generated META-INF/init.rb
3
+
1
4
  == 1.4.4
2
5
  - #271: LoadError while excute rake command with runnable .war archive
3
6
  - #273: filtering support with `config.move_jars_to_webinf_lib`
data/README.rdoc CHANGED
@@ -1,4 +1,4 @@
1
- = Warbler {<img src="https://travis-ci.org/jruby/warbler.png" />}[https://travis-ci.org/jruby/warbler]
1
+ = Warbler {<img src="https://badge.fury.io/rb/warbler.svg" alt="Gem Version" />}[http://badge.fury.io/rb/warbler] {<img src="https://travis-ci.org/jruby/warbler.png" />}[https://travis-ci.org/jruby/warbler]
2
2
 
3
3
  Warbler is a gem to make a Java jar or war file out of any Ruby, Rails or Rack
4
4
  application. Warbler provides a minimal, flexible, Ruby-like way to bundle up
data/ext/JarMain.java CHANGED
@@ -25,15 +25,15 @@ import java.util.jar.JarEntry;
25
25
  import java.util.jar.JarFile;
26
26
 
27
27
  public class JarMain implements Runnable {
28
-
28
+
29
29
  static final String MAIN = "/" + JarMain.class.getName().replace('.', '/') + ".class";
30
30
 
31
31
  final boolean debug = isDebug();
32
-
32
+
33
33
  protected final String[] args;
34
34
  protected final String archive;
35
35
  private final String path;
36
-
36
+
37
37
  protected File extractRoot;
38
38
 
39
39
  protected URLClassLoader classLoader;
@@ -43,15 +43,15 @@ public class JarMain implements Runnable {
43
43
  URL mainClass = getClass().getResource(MAIN);
44
44
  try {
45
45
  this.path = mainClass.toURI().getSchemeSpecificPart();
46
- }
46
+ }
47
47
  catch (URISyntaxException e) {
48
48
  throw new RuntimeException(e);
49
49
  }
50
50
  archive = this.path.replace("!" + MAIN, "").replace("file:", "");
51
-
51
+
52
52
  Runtime.getRuntime().addShutdownHook(new Thread(this));
53
53
  }
54
-
54
+
55
55
  protected URL[] extractArchive() throws Exception {
56
56
  final JarFile jarFile = new JarFile(archive);
57
57
  try {
@@ -65,12 +65,12 @@ public class JarMain implements Runnable {
65
65
  extractRoot = File.createTempFile("jruby", "extract");
66
66
  extractRoot.delete(); extractRoot.mkdirs();
67
67
 
68
- final List<URL> urls = new ArrayList<URL>();
68
+ final List<URL> urls = new ArrayList<URL>(jarNames.size());
69
69
  for (Map.Entry<String, JarEntry> e : jarNames.entrySet()) {
70
70
  URL entryURL = extractEntry(e.getValue(), e.getKey());
71
71
  if (entryURL != null) urls.add( entryURL );
72
72
  }
73
- return (URL[]) urls.toArray(new URL[urls.size()]);
73
+ return urls.toArray(new URL[urls.size()]);
74
74
  }
75
75
  finally {
76
76
  jarFile.close();
@@ -84,18 +84,18 @@ public class JarMain implements Runnable {
84
84
  }
85
85
  return null; // do not extract entry
86
86
  }
87
-
87
+
88
88
  protected URL extractEntry(final JarEntry entry, final String path) throws Exception {
89
89
  final File file = new File(extractRoot, path);
90
90
  if ( entry.isDirectory() ) {
91
- file.mkdirs();
91
+ file.mkdirs();
92
92
  return null;
93
93
  }
94
94
  final String entryPath = entryPath(entry.getName());
95
95
  final InputStream entryStream;
96
96
  try {
97
97
  entryStream = new URI("jar", entryPath, null).toURL().openStream();
98
- }
98
+ }
99
99
  catch (IllegalArgumentException e) {
100
100
  // TODO gems '%' file name "encoding" ?!
101
101
  debug("failed to open jar:" + entryPath + " skipping entry: " + entry.getName(), e);
@@ -110,7 +110,7 @@ public class JarMain implements Runnable {
110
110
  while ((bytesRead = entryStream.read(buf)) != -1) {
111
111
  outStream.write(buf, 0, bytesRead);
112
112
  }
113
- }
113
+ }
114
114
  finally {
115
115
  entryStream.close();
116
116
  outStream.close();
@@ -135,7 +135,7 @@ public class JarMain implements Runnable {
135
135
  invokeMethod(scriptingContainer, "setClassLoader", new Class[] { ClassLoader.class }, classLoader);
136
136
  return scriptingContainer;
137
137
  }
138
-
138
+
139
139
  protected int launchJRuby(final URL[] jars) throws Exception {
140
140
  final Object scriptingContainer = newScriptingContainer(jars);
141
141
  debug("invoking " + archive + " with: " + Arrays.deepToString(args));
@@ -144,7 +144,7 @@ public class JarMain implements Runnable {
144
144
  }
145
145
 
146
146
  protected String launchScript() {
147
- return
147
+ return
148
148
  "begin\n" +
149
149
  " require 'META-INF/init.rb'\n" +
150
150
  " require 'META-INF/main.rb'\n" +
@@ -153,7 +153,7 @@ public class JarMain implements Runnable {
153
153
  " e.status\n" +
154
154
  "end";
155
155
  }
156
-
156
+
157
157
  protected int start() throws Exception {
158
158
  final URL[] jars = extractArchive();
159
159
  return launchJRuby(jars);
@@ -168,10 +168,23 @@ public class JarMain implements Runnable {
168
168
  if (debug && t != null) t.printStackTrace(System.out);
169
169
  }
170
170
 
171
+ protected static void debug(Throwable t) {
172
+ if (isDebug()) t.printStackTrace(System.out);
173
+ }
174
+
171
175
  protected void warn(String msg) {
172
176
  System.out.println("WARNING: " + msg);
173
177
  }
174
-
178
+
179
+ protected static void error(Throwable t) {
180
+ error(t.toString(), t);
181
+ }
182
+
183
+ protected static void error(String msg, Throwable t) {
184
+ System.err.println("ERROR: " + msg);
185
+ debug(t);
186
+ }
187
+
175
188
  protected void delete(File f) {
176
189
  try {
177
190
  if (f.isDirectory() && !isSymlink(f)) {
@@ -181,22 +194,19 @@ public class JarMain implements Runnable {
181
194
  }
182
195
  }
183
196
  f.delete();
184
- } catch (IOException e) {
185
- System.err.println("error: " + e.toString());
186
197
  }
198
+ catch (IOException e) { error(e); }
187
199
  }
188
200
 
189
201
  protected boolean isSymlink(File file) throws IOException {
190
- if (file == null)
191
- throw new NullPointerException("File must not be null");
192
- File canon;
193
- if (file.getParent() == null) {
194
- canon = file;
195
- } else {
196
- File canonDir = file.getParentFile().getCanonicalFile();
197
- canon = new File(canonDir, file.getName());
198
- }
199
- return !canon.getCanonicalFile().equals(canon.getAbsoluteFile());
202
+ if (file == null) throw new NullPointerException("File must not be null");
203
+ final File canonical;
204
+ if ( file.getParent() == null ) canonical = file;
205
+ else {
206
+ File parentDir = file.getParentFile().getCanonicalFile();
207
+ canonical = new File(parentDir, file.getName());
208
+ }
209
+ return ! canonical.getCanonicalFile().equals( canonical.getAbsoluteFile() );
200
210
  }
201
211
 
202
212
  public void run() {
@@ -204,10 +214,8 @@ public class JarMain implements Runnable {
204
214
  try {
205
215
  invokeMethod(classLoader, "close");
206
216
  }
207
- catch(NoSuchMethodException e) { } // We're not being run on Java >= 7
208
- catch(Exception e) {
209
- System.err.println("error: " + e.toString());
210
- }
217
+ catch (NoSuchMethodException e) { } // We're not being run on Java >= 7
218
+ catch (Exception e) { error(e); }
211
219
 
212
220
  if ( extractRoot != null ) delete(extractRoot);
213
221
  }
@@ -219,29 +227,27 @@ public class JarMain implements Runnable {
219
227
  protected static void doStart(final JarMain main) {
220
228
  try {
221
229
  int exit = main.start();
222
- if(isSystemExitEnabled()) System.exit(exit);
223
- } catch (Exception e) {
224
- System.err.println("error: " + e.toString());
230
+ if (isSystemExitEnabled()) System.exit(exit);
231
+ }
232
+ catch (Exception e) {
225
233
  Throwable t = e;
226
- while (t.getCause() != null && t.getCause() != t) {
234
+ while ( t.getCause() != null && t.getCause() != t ) {
227
235
  t = t.getCause();
228
236
  }
229
- if (isDebug()) {
230
- t.printStackTrace();
231
- }
237
+ error(e.toString(), t);
232
238
  System.exit(1);
233
239
  }
234
240
  }
235
-
236
- protected static Object invokeMethod(final Object self, final String name, final Object... args)
241
+
242
+ protected static Object invokeMethod(final Object self, final String name, final Object... args)
237
243
  throws NoSuchMethodException, IllegalAccessException, Exception {
238
-
244
+
239
245
  final Class[] signature = new Class[args.length];
240
246
  for ( int i = 0; i < args.length; i++ ) signature[i] = args[i].getClass();
241
247
  return invokeMethod(self, name, signature, args);
242
248
  }
243
249
 
244
- protected static Object invokeMethod(final Object self, final String name, final Class[] signature, final Object... args)
250
+ protected static Object invokeMethod(final Object self, final String name, final Class[] signature, final Object... args)
245
251
  throws NoSuchMethodException, IllegalAccessException, Exception {
246
252
  Method method = self.getClass().getDeclaredMethod(name, signature);
247
253
  try {
@@ -255,7 +261,7 @@ public class JarMain implements Runnable {
255
261
  throw e;
256
262
  }
257
263
  }
258
-
264
+
259
265
  static boolean isDebug() {
260
266
  return Boolean.getBoolean("warbler.debug");
261
267
  }
data/ext/WarblerJar.java CHANGED
@@ -37,8 +37,9 @@ public class WarblerJar {
37
37
  }
38
38
 
39
39
  @JRubyMethod
40
- public static IRubyObject create_jar(ThreadContext context, IRubyObject recv, IRubyObject jar_path, IRubyObject entries) {
41
- final Ruby runtime = recv.getRuntime();
40
+ public static IRubyObject create_jar(ThreadContext context, IRubyObject self,
41
+ IRubyObject jar_path, IRubyObject entries) {
42
+ final Ruby runtime = context.runtime;
42
43
 
43
44
  if (!(entries instanceof RubyHash)) {
44
45
  throw runtime.newArgumentError("expected a hash for the second argument");
@@ -56,7 +57,7 @@ public class WarblerJar {
56
57
  }
57
58
  } catch (IOException e) {
58
59
  if (runtime.isDebug()) {
59
- e.printStackTrace();
60
+ e.printStackTrace(runtime.getOut());
60
61
  }
61
62
  throw runtime.newIOErrorFromException(e);
62
63
  }
@@ -65,8 +66,9 @@ public class WarblerJar {
65
66
  }
66
67
 
67
68
  @JRubyMethod
68
- public static IRubyObject entry_in_jar(ThreadContext context, IRubyObject recv, IRubyObject jar_path, IRubyObject entry) {
69
- final Ruby runtime = recv.getRuntime();
69
+ public static IRubyObject entry_in_jar(ThreadContext context, IRubyObject self,
70
+ IRubyObject jar_path, IRubyObject entry) {
71
+ final Ruby runtime = context.runtime;
70
72
  try {
71
73
  InputStream entryStream = getStream(jar_path.convertToString().getUnicodeValue(),
72
74
  entry.convertToString().getUnicodeValue());
@@ -84,7 +86,7 @@ public class WarblerJar {
84
86
  }
85
87
  } catch (IOException e) {
86
88
  if (runtime.isDebug()) {
87
- e.printStackTrace();
89
+ e.printStackTrace(runtime.getOut());
88
90
  }
89
91
  throw runtime.newIOErrorFromException(e);
90
92
  }
@@ -120,7 +122,7 @@ public class WarblerJar {
120
122
  try {
121
123
  zip.putNextEntry(new ZipEntry(entryName));
122
124
  byte[] buf = new byte[16384];
123
- int bytesRead = -1;
125
+ int bytesRead;
124
126
  while ((bytesRead = inFile.read(buf)) != -1) {
125
127
  zip.write(buf, 0, bytesRead);
126
128
  }
@@ -181,7 +183,7 @@ public class WarblerJar {
181
183
  entry = trimTrailingSlashes(entry);
182
184
 
183
185
  ZipInputStream jstream = new ZipInputStream(jar);
184
- ZipEntry zentry = null;
186
+ ZipEntry zentry;
185
187
  while ((zentry = jstream.getNextEntry()) != null) {
186
188
  if (trimTrailingSlashes(zentry.getName()).equals(entry)) {
187
189
  return jstream;
data/integration/pom.xml CHANGED
@@ -20,7 +20,7 @@
20
20
  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
21
21
  <jruby.version>1.7.13</jruby.version>
22
22
  <!-- prereleased gems ARE snapshots -->
23
- <warbler.version>1.4.4-SNAPSHOT</warbler.version>
23
+ <warbler.version>1.4.5.dev-SNAPSHOT</warbler.version>
24
24
  <gem.home>${session.executionRootDirectory}/target/rubygems</gem.home>
25
25
  <gem.path>${session.executionRootDirectory}/target/rubygems</gem.path>
26
26
  </properties>
@@ -1,3 +1,3 @@
1
- ENV['RACK_ENV'] = '<%= (params = config.webxml.context_params; params['rack.env']) %>'
1
+ ENV['RACK_ENV'] ||= '<%= (params = config.webxml.context_params; params['rack.env']) %>'
2
2
 
3
3
  $LOAD_PATH.unshift $servlet_context.getRealPath('/WEB-INF') if $servlet_context
@@ -1,8 +1,8 @@
1
1
  <% assignment_operator = config.override_gem_home ? "=" : "||=" %>
2
2
  if $servlet_context.nil?
3
- ENV['GEM_HOME'] <%= assignment_operator %> File.expand_path('../../WEB-INF', __FILE__)
3
+ ENV['GEM_HOME'] <%= assignment_operator %> File.expand_path(File.join('..', '..', '<%= config.gem_path %>'), __FILE__)
4
4
  <% if config.bundler && config.bundler[:gemfile_path] %>
5
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../<%= config.bundler[:gemfile_path] %>', __FILE__)
5
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path(File.join('..', '..', '<%= config.bundler[:gemfile_path] %>'), __FILE__)
6
6
  <% end %>
7
7
  else
8
8
  ENV['GEM_HOME'] <%= assignment_operator %> $servlet_context.getRealPath('<%= config.gem_path %>')
@@ -6,6 +6,7 @@
6
6
  #++
7
7
 
8
8
  require 'stringio'
9
+ require 'tsort'
9
10
 
10
11
  module Warbler
11
12
  # Traits are project configuration characteristics that correspond
@@ -21,7 +22,7 @@ module Warbler
21
22
  end
22
23
 
23
24
  def auto_detect_traits
24
- Traits.constants.map {|t| Traits.const_get(t)}.select {|tc| tc.detect? }.sort
25
+ TraitsDependencyArray.new(Traits.constants.map {|t| Traits.const_get(t)}).tsort.select {|tc| tc.detect? }
25
26
  end
26
27
 
27
28
  def before_configure
@@ -49,12 +50,8 @@ module Warbler
49
50
  # Each trait class includes this module to receive shared functionality.
50
51
  module Trait
51
52
  module ClassMethods
52
- def <=>(o)
53
- requires?(o) ? 1 : (o.requires?(self) ? -1 : 0)
54
- end
55
-
56
- def requires?(t)
57
- false
53
+ def requirements
54
+ []
58
55
  end
59
56
  end
60
57
 
@@ -103,6 +100,16 @@ module Warbler
103
100
  FileList[JRubyJars.core_jar_path, JRubyJars.stdlib_jar_path]
104
101
  end
105
102
  end
103
+
104
+ class TraitsDependencyArray < Array
105
+ include TSort
106
+
107
+ alias tsort_each_node each
108
+ def tsort_each_child(node, &block)
109
+ node.requirements.each(&block)
110
+ end
111
+ end
112
+
106
113
  end
107
114
 
108
115
  require 'warbler/traits/jar'
@@ -17,8 +17,8 @@ module Warbler
17
17
  File.exist?(ENV['BUNDLE_GEMFILE'] || "Gemfile")
18
18
  end
19
19
 
20
- def self.requires?(trait)
21
- trait == Traits::War || trait == Traits::Jar
20
+ def self.requirements
21
+ [ Traits::War, Traits::Jar ]
22
22
  end
23
23
 
24
24
  def before_configure
@@ -17,8 +17,8 @@ module Warbler
17
17
  File.exist?(ENV['JBUNDLE_JARFILE'] || "Jarfile")
18
18
  end
19
19
 
20
- def self.requires?(trait)
21
- trait == Traits::War || trait == Traits::Jar
20
+ def self.requirements
21
+ [ Traits::War, Traits::Jar ]
22
22
  end
23
23
 
24
24
  def before_configure
@@ -15,8 +15,8 @@ module Warbler
15
15
  File.exist?("config/init.rb")
16
16
  end
17
17
 
18
- def self.requires?(trait)
19
- trait == Traits::War
18
+ def self.requirements
19
+ [ Traits::War ]
20
20
  end
21
21
 
22
22
  def before_configure
@@ -15,8 +15,8 @@ module Warbler
15
15
  !Rails.detect? && (File.exist?("config.ru") || !Dir['*/config.ru'].empty?)
16
16
  end
17
17
 
18
- def self.requires?(trait)
19
- trait == Traits::War
18
+ def self.requirements
19
+ [ Traits::War ]
20
20
  end
21
21
 
22
22
  def before_configure
@@ -15,8 +15,8 @@ module Warbler
15
15
  File.exist?("config/environment.rb")
16
16
  end
17
17
 
18
- def self.requires?(trait)
19
- trait == Traits::War
18
+ def self.requirements
19
+ [ Traits::War ]
20
20
  end
21
21
 
22
22
  def before_configure
@@ -6,5 +6,5 @@
6
6
  #++
7
7
 
8
8
  module Warbler
9
- VERSION = "1.4.4"
9
+ VERSION = "1.4.5"
10
10
  end
@@ -1,12 +1,13 @@
1
1
  module Warbler
2
2
  class WebServer
3
3
  class Artifact < Struct.new(:repo, :group_id, :artifact_id, :version)
4
+
4
5
  def path_fragment
5
6
  @path_fragment ||= "#{group_id.gsub('.', '/')}/#{artifact_id}/#{version}/#{artifact_id}-#{version}.jar"
6
7
  end
7
8
 
8
9
  def cached_path
9
- @cached_path ||= File.expand_path("~/.m2/repository/#{path_fragment}")
10
+ @cached_path ||= File.join(local_repository, path_fragment)
10
11
  end
11
12
 
12
13
  def download_url
@@ -33,6 +34,47 @@ module Warbler
33
34
  end
34
35
  cached_path
35
36
  end
37
+
38
+ @@local_repository = nil
39
+
40
+ def local_repository
41
+ @@local_repository ||= begin
42
+ m2_home = File.join(user_home, '.m2')
43
+ if File.exist?(settings = File.join(m2_home, 'settings.xml'))
44
+ local_repo = detect_local_repository(settings)
45
+ end
46
+ if local_repo.nil? && mvn_home = ENV['M2_HOME'] || ENV['MAVEN_HOME']
47
+ if File.exist?(settings = File.join(mvn_home, 'conf/settings.xml'))
48
+ local_repo = detect_local_repository(settings)
49
+ end
50
+ end
51
+ local_repo || File.join(m2_home, 'repository')
52
+ end
53
+ end
54
+
55
+ private
56
+
57
+ def user_home
58
+ ENV[ 'HOME' ] || begin
59
+ user_home = Dir.home if Dir.respond_to?(:home)
60
+ unless user_home
61
+ user_home = ENV_JAVA[ 'user.home' ] if Object.const_defined?(:ENV_JAVA)
62
+ end
63
+ user_home
64
+ end
65
+ end
66
+
67
+ def detect_local_repository(settings); require 'rexml/document'
68
+ doc = REXML::Document.new( File.read( settings ) )
69
+ if local_repo = doc.root.elements['localRepository']
70
+ if ( local_repo = local_repo.first )
71
+ local_repo = local_repo.value
72
+ local_repo = nil if local_repo.empty?
73
+ end
74
+ end
75
+ local_repo
76
+ end
77
+
36
78
  end
37
79
 
38
80
  def add(jar)
@@ -90,9 +132,9 @@ PROPS
90
132
  end
91
133
  end
92
134
 
93
- WEB_SERVERS = Hash.new {|h,k| h["jenkins-ci.winstone"] }
94
- WEB_SERVERS.update({ "winstone" => WinstoneServer.new,
95
- "jenkins-ci.winstone" => JenkinsWinstoneServer.new,
96
- "jetty" => JettyServer.new
97
- })
135
+ WEB_SERVERS = Hash.new { |hash,_| hash['jetty'] }
136
+ WEB_SERVERS['winstone'] = WinstoneServer.new
137
+ WEB_SERVERS['jenkins-ci.winstone'] = JenkinsWinstoneServer.new,
138
+ WEB_SERVERS['jetty'] = JettyServer.new
139
+
98
140
  end
data/pom.xml CHANGED
@@ -4,7 +4,7 @@
4
4
  <modelVersion>4.0.0</modelVersion>
5
5
  <groupId>rubygems</groupId>
6
6
  <artifactId>warbler</artifactId>
7
- <version>1.4.4-SNAPSHOT</version>
7
+ <version>1.4.5.dev-SNAPSHOT</version>
8
8
  <packaging>gem</packaging>
9
9
  <name>Warbler chirpily constructs .war files of your Rails applications.</name>
10
10
  <description>Warbler is a gem to make a Java jar or war file out of any Ruby,
@@ -0,0 +1,25 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <settings>
3
+ <profiles>
4
+ <profile>
5
+ <id>codehaus</id>
6
+ <activation>
7
+ <activeByDefault>false</activeByDefault>
8
+ </activation>
9
+ <pluginRepositories>
10
+ <pluginRepository>
11
+ <id>codehaus</id>
12
+ <name>Codehaus Repository</name>
13
+ <releases>
14
+ <enabled>true</enabled>
15
+ </releases>
16
+ <snapshots>
17
+ <enabled>false</enabled>
18
+ </snapshots>
19
+ <url>http://repository.codehaus.org</url>
20
+ </pluginRepository>
21
+ </pluginRepositories>
22
+ </profile>
23
+ </profiles>
24
+ <localRepository>/usr/local/maven/repo</localRepository>
25
+ </settings>
@@ -9,9 +9,13 @@ require File.expand_path('../../spec_helper', __FILE__)
9
9
 
10
10
  describe Warbler::Traits do
11
11
  it "are ordered by fewer dependencies first" do
12
- traits = [Warbler::Traits::War, Warbler::Traits::Bundler, Warbler::Traits::Rails]
13
- result = traits.shuffle.sort
14
- result.index(Warbler::Traits::War).should < result.index(Warbler::Traits::Bundler)
15
- result.index(Warbler::Traits::War).should < result.index(Warbler::Traits::Rails)
12
+ traits = Warbler::TraitsDependencyArray.new( Warbler::Traits.constants.map {|t| Warbler::Traits.const_get(t)})
13
+ result = traits.shuffle!.tsort
14
+
15
+ result.each do |trait|
16
+ trait.requirements.each do |requirement|
17
+ result.index(requirement).should < result.index(trait)
18
+ end
19
+ end
16
20
  end
17
21
  end
@@ -0,0 +1,41 @@
1
+ require File.expand_path('../../spec_helper', __FILE__)
2
+
3
+ class Warbler::WebServer::Artifact
4
+ def self.reset_local_repository
5
+ @@local_repository = nil
6
+ end
7
+ end
8
+
9
+ describe Warbler::WebServer::Artifact do
10
+
11
+ @@_env = ENV.dup
12
+
13
+ after(:all) { ENV.clear; ENV.update @@_env }
14
+
15
+ before do
16
+ Warbler::WebServer::Artifact.reset_local_repository
17
+ end
18
+
19
+ after(:all) do
20
+ Warbler::WebServer::Artifact.reset_local_repository
21
+ end
22
+
23
+ let(:sample_artifact) do
24
+ Warbler::WebServer::Artifact.new("http://repo.jenkins-ci.org/public",
25
+ "org.jenkins-ci", "winstone", "0.9.10-jenkins-43"
26
+ )
27
+ end
28
+
29
+ it "uses default (maven) local repository" do
30
+ ENV['HOME'] = '/home/borg'
31
+ ENV.delete('M2_HOME'); ENV.delete('MAVEN_HOME')
32
+ expect( sample_artifact.local_repository ).to eql "/home/borg/.m2/repository"
33
+ end
34
+
35
+ it "detects a custom maven repository setting" do
36
+ ENV['HOME'] = '/home/borg'
37
+ ENV['M2_HOME'] = File.expand_path('../m2_home', File.dirname(__FILE__))
38
+ expect( sample_artifact.local_repository ).to eql '/usr/local/maven/repo'
39
+ end
40
+
41
+ end
data/warble.rb CHANGED
@@ -80,6 +80,12 @@ Warbler::Config.new do |config|
80
80
  # of the project directory.
81
81
  # config.jar_name = "mywar"
82
82
 
83
+ # File extension for the archive. Defaults to either 'jar' or 'war'.
84
+ # config.jar_extension = "jar"
85
+
86
+ # Destionation for the created archive. Defaults to project's root directory.
87
+ # config.autodeploy_dir = "dist/"
88
+
83
89
  # Name of the MANIFEST.MF template for the war file. Defaults to a simple
84
90
  # MANIFEST.MF that contains the version of Warbler used to create the war file.
85
91
  # config.manifest_file = "config/MANIFEST.MF"
data/warbler.gemspec CHANGED
@@ -25,7 +25,7 @@ bundle up all of your application files for deployment to a Java environment.}
25
25
  gem.add_runtime_dependency 'rake', [">= 0.9.6"]
26
26
  # restrict it for maven not to find jruby-9000.dev
27
27
  gem.add_runtime_dependency 'jruby-jars', [">= 1.5.6", '< 2.0']
28
- gem.add_runtime_dependency 'jruby-rack', [">= 1.0.0"]
28
+ gem.add_runtime_dependency 'jruby-rack', [">= 1.1.1", '< 1.3']
29
29
  gem.add_runtime_dependency 'rubyzip', [">= 0.9", "< 1.2"]
30
30
  gem.add_development_dependency 'jbundler', "~> 0.5.5"
31
31
  gem.add_development_dependency 'ruby-maven', '~> 3.1.1.0'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: warbler
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.4
4
+ version: 1.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Sieger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-22 00:00:00.000000000 Z
11
+ date: 2015-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -50,12 +50,18 @@ dependencies:
50
50
  requirements:
51
51
  - - '>='
52
52
  - !ruby/object:Gem::Version
53
- version: 1.0.0
53
+ version: 1.1.1
54
+ - - <
55
+ - !ruby/object:Gem::Version
56
+ version: '1.3'
54
57
  requirement: !ruby/object:Gem::Requirement
55
58
  requirements:
56
59
  - - '>='
57
60
  - !ruby/object:Gem::Version
58
- version: 1.0.0
61
+ version: 1.1.1
62
+ - - <
63
+ - !ruby/object:Gem::Version
64
+ version: '1.3'
59
65
  prerelease: false
60
66
  type: :runtime
61
67
  - !ruby/object:Gem::Dependency
@@ -278,6 +284,7 @@ files:
278
284
  - pom.xml
279
285
  - spec/drb_default_id_conv.rb
280
286
  - spec/drb_helper.rb
287
+ - spec/m2_home/conf/settings.xml
281
288
  - spec/sample_bundler/.bundle/config
282
289
  - spec/sample_bundler/Gemfile
283
290
  - spec/sample_bundler/Gemfile.lock
@@ -358,6 +365,7 @@ files:
358
365
  - spec/warbler/task_spec.rb
359
366
  - spec/warbler/traits_spec.rb
360
367
  - spec/warbler/war_spec.rb
368
+ - spec/warbler/web_server_spec.rb
361
369
  - warble.rb
362
370
  - warbler.gemspec
363
371
  - web.xml.erb
@@ -386,7 +394,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
386
394
  version: '0'
387
395
  requirements: []
388
396
  rubyforge_project:
389
- rubygems_version: 2.2.2
397
+ rubygems_version: 2.1.9
390
398
  signing_key:
391
399
  specification_version: 4
392
400
  summary: Warbler chirpily constructs .war files of your Rails applications.
@@ -475,6 +483,7 @@ test_files:
475
483
  - integration/simple_rack_test/src/test/java/org/jruby/warbler/AppTestIT.java
476
484
  - spec/drb_default_id_conv.rb
477
485
  - spec/drb_helper.rb
486
+ - spec/m2_home/conf/settings.xml
478
487
  - spec/sample_bundler/.bundle/config
479
488
  - spec/sample_bundler/Gemfile
480
489
  - spec/sample_bundler/Gemfile.lock
@@ -555,3 +564,4 @@ test_files:
555
564
  - spec/warbler/task_spec.rb
556
565
  - spec/warbler/traits_spec.rb
557
566
  - spec/warbler/war_spec.rb
567
+ - spec/warbler/web_server_spec.rb