warbler 2.0.5 → 2.1.1
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.
- checksums.yaml +5 -5
- data/{History.txt → CHANGELOG.md} +72 -43
- data/Gemfile +6 -10
- data/LICENSE.txt +4 -5
- data/Mavenfile +28 -11
- data/README.rdoc +74 -28
- data/Rakefile +19 -38
- data/ext/JarMain.java +106 -98
- data/ext/WarMain.java +59 -73
- data/lib/warbler/bundler_helper.rb +1 -8
- data/lib/warbler/config.rb +7 -9
- data/lib/warbler/gems.rb +3 -9
- data/lib/warbler/jar.rb +9 -13
- data/lib/warbler/task.rb +10 -7
- data/lib/warbler/templates/bundler.erb +0 -15
- data/lib/warbler/templates/jar.erb +2 -0
- data/lib/warbler/templates/rack.erb +2 -2
- data/lib/warbler/templates/war.erb +2 -5
- data/lib/warbler/traits/bundler.rb +2 -17
- data/lib/warbler/traits/gemspec.rb +6 -2
- data/lib/warbler/traits/jar.rb +5 -1
- data/lib/warbler/traits/jbundler.rb +3 -2
- data/lib/warbler/traits/nogemspec.rb +5 -1
- data/lib/warbler/traits/rack.rb +5 -1
- data/lib/warbler/traits/rails.rb +4 -0
- data/lib/warbler/traits/war.rb +30 -31
- data/lib/warbler/traits.rb +29 -5
- data/lib/warbler/version.rb +1 -1
- data/lib/warbler/web_server.rb +7 -5
- data/lib/warbler/zip_support.rb +1 -1
- data/lib/warbler_jar.jar +0 -0
- data/warble.rb +29 -6
- data/warbler.gemspec +19 -7
- data/web.xml.erb +0 -19
- metadata +121 -39
- data/lib/warbler/war.rb +0 -8
- data/pom.xml +0 -190
data/ext/WarMain.java
CHANGED
|
@@ -5,38 +5,39 @@
|
|
|
5
5
|
* See the file LICENSE.txt for details.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import java.lang.reflect.Method;
|
|
9
|
-
import java.io.InputStream;
|
|
10
8
|
import java.io.ByteArrayInputStream;
|
|
11
|
-
import java.io.SequenceInputStream;
|
|
12
9
|
import java.io.File;
|
|
13
10
|
import java.io.FileNotFoundException;
|
|
14
11
|
import java.io.FileOutputStream;
|
|
12
|
+
import java.io.IOException;
|
|
13
|
+
import java.io.InputStream;
|
|
14
|
+
import java.io.SequenceInputStream;
|
|
15
|
+
import java.lang.reflect.Method;
|
|
15
16
|
import java.net.URI;
|
|
16
|
-
import java.net.URLClassLoader;
|
|
17
17
|
import java.net.URL;
|
|
18
|
+
import java.net.URLClassLoader;
|
|
18
19
|
import java.util.Arrays;
|
|
19
20
|
import java.util.List;
|
|
20
|
-
import java.util.Properties;
|
|
21
21
|
import java.util.Map;
|
|
22
|
+
import java.util.Properties;
|
|
22
23
|
import java.util.jar.JarEntry;
|
|
23
24
|
|
|
24
25
|
/**
|
|
25
26
|
* Used as a Main-Class in the manifest for a .war file, so that you can run
|
|
26
27
|
* a .war file with <tt>java -jar</tt>.
|
|
27
|
-
*
|
|
28
|
+
* <p/>
|
|
28
29
|
* WarMain can be used with different web server libraries. WarMain expects
|
|
29
30
|
* to have two files present in the .war file,
|
|
30
31
|
* <tt>WEB-INF/webserver.properties</tt> and <tt>WEB-INF/webserver.jar</tt>.
|
|
31
|
-
*
|
|
32
|
+
* <p/>
|
|
32
33
|
* When WarMain starts up, it extracts the webserver jar to a temporary
|
|
33
34
|
* directory, and creates a temporary work directory for the webapp. Both
|
|
34
35
|
* are deleted on exit.
|
|
35
|
-
*
|
|
36
|
+
* <p/>
|
|
36
37
|
* It then reads webserver.properties into a java.util.Properties object,
|
|
37
38
|
* creates a URL classloader holding the jar, and loads and invokes the
|
|
38
39
|
* <tt>main</tt> method of the main class mentioned in the properties.
|
|
39
|
-
*
|
|
40
|
+
* <p/>
|
|
40
41
|
* An example webserver.properties follows for Jetty. The <tt>args</tt>
|
|
41
42
|
* property indicates the names and ordering of other properties to be used
|
|
42
43
|
* as command-line arguments. The special tokens <tt>{{warfile}}</tt> and
|
|
@@ -63,10 +64,11 @@ import java.util.jar.JarEntry;
|
|
|
63
64
|
*/
|
|
64
65
|
public class WarMain extends JarMain {
|
|
65
66
|
|
|
66
|
-
static final String MAIN = '/' + WarMain.class.getName().replace('.', '/') + ".class";
|
|
67
67
|
static final String WEBSERVER_PROPERTIES = "/WEB-INF/webserver.properties";
|
|
68
68
|
static final String WEBSERVER_JAR = "/WEB-INF/webserver.jar";
|
|
69
69
|
static final String WEBSERVER_CONFIG = "/WEB-INF/webserver.xml";
|
|
70
|
+
static final String WEB_INF = "WEB-INF";
|
|
71
|
+
static final String META_INF = "META-INF";
|
|
70
72
|
|
|
71
73
|
/**
|
|
72
74
|
* jruby arguments, consider the following command :
|
|
@@ -83,8 +85,6 @@ public class WarMain extends JarMain {
|
|
|
83
85
|
private final String executable;
|
|
84
86
|
private final String[] executableArgv;
|
|
85
87
|
|
|
86
|
-
private File webroot;
|
|
87
|
-
|
|
88
88
|
WarMain(final String[] args) {
|
|
89
89
|
super(args);
|
|
90
90
|
final List<String> argsList = Arrays.asList(args);
|
|
@@ -113,36 +113,40 @@ public class WarMain extends JarMain {
|
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
private
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
116
|
+
private void launchWebServer() throws Exception {
|
|
117
|
+
File webroot = createWebRoot();
|
|
118
|
+
File jarFile = extractWebServerJar();
|
|
119
|
+
|
|
120
|
+
doLaunchWebServer(jarFile, webroot);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
private File createWebRoot() throws IOException {
|
|
124
|
+
File warblerRoot = File.createTempFile("warbler", "webroot");
|
|
125
|
+
warblerRoot.delete();
|
|
126
|
+
warblerRoot.mkdirs();
|
|
127
|
+
closeables.add(() -> deleteAll(warblerRoot));
|
|
128
|
+
|
|
129
|
+
File webroot = new File(warblerRoot, new File(archive).getName());
|
|
130
|
+
debug("webroot directory is " + webroot.getPath());
|
|
131
|
+
return webroot;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
private File extractWebServerJar() throws Exception {
|
|
123
135
|
File jarFile = File.createTempFile("webserver", ".jar");
|
|
124
136
|
jarFile.deleteOnExit();
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
while ((bytesRead = jarStream.read(buf)) != -1) {
|
|
130
|
-
outStream.write(buf, 0, bytesRead);
|
|
131
|
-
}
|
|
132
|
-
} finally {
|
|
133
|
-
jarStream.close();
|
|
134
|
-
outStream.close();
|
|
135
|
-
}
|
|
137
|
+
|
|
138
|
+
transferAndClose(
|
|
139
|
+
() -> new URI("jar", entryPath(WEBSERVER_JAR), null).toURL().openStream(),
|
|
140
|
+
() -> new FileOutputStream(jarFile));
|
|
136
141
|
debug("webserver.jar extracted to " + jarFile.getPath());
|
|
137
|
-
return jarFile
|
|
142
|
+
return jarFile;
|
|
138
143
|
}
|
|
139
144
|
|
|
140
|
-
private Properties getWebserverProperties() throws Exception {
|
|
145
|
+
private Properties getWebserverProperties(File webRoot) throws Exception {
|
|
141
146
|
Properties props = new Properties();
|
|
142
|
-
try {
|
|
143
|
-
InputStream is = getClass().getResourceAsStream(WEBSERVER_PROPERTIES);
|
|
147
|
+
try (InputStream is = getClass().getResourceAsStream(WEBSERVER_PROPERTIES)) {
|
|
144
148
|
if ( is != null ) props.load(is);
|
|
145
|
-
} catch (Exception
|
|
149
|
+
} catch (Exception ignore) { }
|
|
146
150
|
|
|
147
151
|
String port = getSystemProperty("warbler.port", getENV("PORT"));
|
|
148
152
|
port = port == null ? "8080" : port;
|
|
@@ -150,13 +154,13 @@ public class WarMain extends JarMain {
|
|
|
150
154
|
String webserverConfig = getSystemProperty("warbler.webserver_config", getENV("WARBLER_WEBSERVER_CONFIG"));
|
|
151
155
|
String embeddedWebserverConfig = new URI("jar", entryPath(WEBSERVER_CONFIG), null).toURL().toString();
|
|
152
156
|
webserverConfig = webserverConfig == null ? embeddedWebserverConfig : webserverConfig;
|
|
153
|
-
for ( Map.Entry entry : props.entrySet() ) {
|
|
157
|
+
for ( Map.Entry<Object, Object> entry : props.entrySet() ) {
|
|
154
158
|
String val = (String) entry.getValue();
|
|
155
159
|
val = val.replace("{{warfile}}", archive).
|
|
156
160
|
replace("{{port}}", port).
|
|
157
161
|
replace("{{host}}", host).
|
|
158
162
|
replace("{{config}}", webserverConfig).
|
|
159
|
-
replace("{{webroot}}",
|
|
163
|
+
replace("{{webroot}}", webRoot.getAbsolutePath());
|
|
160
164
|
entry.setValue(val);
|
|
161
165
|
}
|
|
162
166
|
|
|
@@ -170,10 +174,11 @@ public class WarMain extends JarMain {
|
|
|
170
174
|
return props;
|
|
171
175
|
}
|
|
172
176
|
|
|
173
|
-
|
|
174
|
-
|
|
177
|
+
|
|
178
|
+
private void doLaunchWebServer(File jar, File webRoot) throws Exception {
|
|
179
|
+
URLClassLoader loader = new URLClassLoader(new URL[] {jar.toURI().toURL()});
|
|
175
180
|
Thread.currentThread().setContextClassLoader(loader);
|
|
176
|
-
Properties props = getWebserverProperties();
|
|
181
|
+
Properties props = getWebserverProperties(webRoot);
|
|
177
182
|
String mainClass = props.getProperty("mainclass");
|
|
178
183
|
if (mainClass == null) {
|
|
179
184
|
throw new IllegalArgumentException("unknown webserver main class ("
|
|
@@ -181,7 +186,7 @@ public class WarMain extends JarMain {
|
|
|
181
186
|
+ " is missing 'mainclass' property)");
|
|
182
187
|
}
|
|
183
188
|
Class<?> klass = Class.forName(mainClass, true, loader);
|
|
184
|
-
Method main = klass.getDeclaredMethod("main",
|
|
189
|
+
Method main = klass.getDeclaredMethod("main", String[].class);
|
|
185
190
|
String[] newArgs = launchWebServerArguments(props);
|
|
186
191
|
debug("invoking webserver with: " + Arrays.deepToString(newArgs));
|
|
187
192
|
main.invoke(null, new Object[] { newArgs });
|
|
@@ -208,21 +213,24 @@ public class WarMain extends JarMain {
|
|
|
208
213
|
@Override
|
|
209
214
|
protected String getExtractEntryPath(final JarEntry entry) {
|
|
210
215
|
final String name = entry.getName();
|
|
211
|
-
final String
|
|
212
|
-
if ( name.startsWith(
|
|
216
|
+
final String res;
|
|
217
|
+
if ( name.startsWith(WEB_INF) ) {
|
|
213
218
|
// WEB-INF/app/controllers/application_controller.rb ->
|
|
214
219
|
// app/controllers/application_controller.rb
|
|
215
|
-
|
|
216
|
-
}
|
|
217
|
-
|
|
220
|
+
res = name.substring(WEB_INF.length());
|
|
221
|
+
} else if (name.startsWith(META_INF)) {
|
|
222
|
+
// Keep them where they are.
|
|
223
|
+
res = name;
|
|
224
|
+
} else {
|
|
218
225
|
// 404.html -> public/404.html
|
|
219
|
-
|
|
226
|
+
// javascripts -> public/javascripts
|
|
227
|
+
res = "/public/" + name;
|
|
220
228
|
}
|
|
221
|
-
return
|
|
229
|
+
return res;
|
|
222
230
|
}
|
|
223
231
|
|
|
224
232
|
@Override
|
|
225
|
-
protected URL extractEntry(final JarEntry entry,
|
|
233
|
+
protected URL extractEntry(final JarEntry entry, String path) throws Exception {
|
|
226
234
|
// always extract but only return class-path entry URLs :
|
|
227
235
|
final URL entryURL = super.extractEntry(entry, path);
|
|
228
236
|
return path.endsWith(".jar") && path.startsWith("/lib/") ? entryURL : null;
|
|
@@ -251,7 +259,7 @@ public class WarMain extends JarMain {
|
|
|
251
259
|
|
|
252
260
|
invokeMethod(rubyInstanceConfig, "processArguments", (Object) arguments);
|
|
253
261
|
|
|
254
|
-
Object runtime = invokeMethod(
|
|
262
|
+
Object runtime = invokeMethod(provider, "getRuntime");
|
|
255
263
|
|
|
256
264
|
debug("loading resource: " + executablePath);
|
|
257
265
|
Object executableInput =
|
|
@@ -267,21 +275,6 @@ public class WarMain extends JarMain {
|
|
|
267
275
|
return ( outcome instanceof Number ) ? ( (Number) outcome ).intValue() : 0;
|
|
268
276
|
}
|
|
269
277
|
|
|
270
|
-
@Deprecated
|
|
271
|
-
protected String locateExecutable(final Object scriptingContainer) throws Exception {
|
|
272
|
-
if ( executable == null ) {
|
|
273
|
-
throw new IllegalStateException("no executable");
|
|
274
|
-
}
|
|
275
|
-
final File exec = new File(extractRoot, executable);
|
|
276
|
-
if ( exec.exists() ) {
|
|
277
|
-
return exec.getAbsolutePath();
|
|
278
|
-
}
|
|
279
|
-
else {
|
|
280
|
-
final String script = locateExecutableScript(executable, executableScriptEnvPrefix());
|
|
281
|
-
return (String) invokeMethod(scriptingContainer, "runScriptlet", script);
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
|
|
285
278
|
protected String locateExecutable(final Object scriptingContainer, final CharSequence envPreScript)
|
|
286
279
|
throws Exception {
|
|
287
280
|
if ( executable == null ) {
|
|
@@ -341,8 +334,7 @@ public class WarMain extends JarMain {
|
|
|
341
334
|
protected int start() throws Exception {
|
|
342
335
|
if ( executable == null ) {
|
|
343
336
|
try {
|
|
344
|
-
|
|
345
|
-
launchWebServer(server);
|
|
337
|
+
launchWebServer();
|
|
346
338
|
}
|
|
347
339
|
catch (FileNotFoundException e) {
|
|
348
340
|
final String msg = e.getMessage();
|
|
@@ -357,12 +349,6 @@ public class WarMain extends JarMain {
|
|
|
357
349
|
return super.start();
|
|
358
350
|
}
|
|
359
351
|
|
|
360
|
-
@Override
|
|
361
|
-
public void run() {
|
|
362
|
-
super.run();
|
|
363
|
-
if ( webroot != null ) delete(webroot.getParentFile());
|
|
364
|
-
}
|
|
365
|
-
|
|
366
352
|
public static void main(String[] args) {
|
|
367
353
|
doStart(new WarMain(args));
|
|
368
354
|
}
|
|
@@ -7,14 +7,7 @@
|
|
|
7
7
|
module Warbler
|
|
8
8
|
module BundlerHelper
|
|
9
9
|
def to_spec(spec)
|
|
10
|
-
|
|
11
|
-
# thus a `spec.respond_to?(:to_spec) ? spec.to_spec : spec` won't do :
|
|
12
|
-
if ::Bundler.const_defined?(:StubSpecification) # since Bundler 1.10.1
|
|
13
|
-
spec = spec.to_spec if spec.is_a?(::Bundler::StubSpecification)
|
|
14
|
-
else
|
|
15
|
-
spec = spec.to_spec if spec.respond_to?(:to_spec)
|
|
16
|
-
end
|
|
17
|
-
spec
|
|
10
|
+
spec.respond_to?(:to_spec) ? spec.to_spec : spec
|
|
18
11
|
end
|
|
19
12
|
module_function :to_spec
|
|
20
13
|
end
|
data/lib/warbler/config.rb
CHANGED
|
@@ -15,8 +15,8 @@ module Warbler
|
|
|
15
15
|
include RakeHelper
|
|
16
16
|
|
|
17
17
|
TOP_DIRS = %w(app db config lib log script vendor)
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
CONFIG_DIR = "config"
|
|
19
|
+
FILE = "#{CONFIG_DIR}/warble.rb"
|
|
20
20
|
|
|
21
21
|
include Traits
|
|
22
22
|
|
|
@@ -29,11 +29,8 @@ module Warbler
|
|
|
29
29
|
|
|
30
30
|
# Traits: an array of trait classes corresponding to
|
|
31
31
|
# characteristics of the project that are either auto-detected or
|
|
32
|
-
#
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
# Deprecated: No longer has any effect.
|
|
36
|
-
attr_accessor :staging_dir
|
|
32
|
+
# forced enabled during `Config.new(forced_traits: [...]) do |config|`
|
|
33
|
+
attr_reader :traits
|
|
37
34
|
|
|
38
35
|
# Directory where the war file will be written. Can be used to direct
|
|
39
36
|
# Warbler to place your war file directly in your application server's
|
|
@@ -185,8 +182,9 @@ module Warbler
|
|
|
185
182
|
attr_reader :warbler_templates
|
|
186
183
|
attr_reader :warbler_scripts
|
|
187
184
|
|
|
188
|
-
|
|
189
|
-
|
|
185
|
+
# @param forced_traits [Array<Class>, nil] optional array of Warbler::Trait types to force rather than auto-detecting them
|
|
186
|
+
def initialize(warbler_home = WARBLER_HOME, forced_traits: nil)
|
|
187
|
+
super(forced_traits)
|
|
190
188
|
|
|
191
189
|
@warbler_home = warbler_home
|
|
192
190
|
@warbler_templates = "#{WARBLER_HOME}/lib/warbler/templates"
|
data/lib/warbler/gems.rb
CHANGED
|
@@ -51,11 +51,8 @@ module Warbler
|
|
|
51
51
|
|
|
52
52
|
# Add a single gem to WEB-INF/gems
|
|
53
53
|
def find_single_gem_files(gem_dependencies, gem_pattern, version = nil)
|
|
54
|
-
gem_spec_class = Gem::Specification
|
|
55
|
-
gem_spec_class = Gem::BasicSpecification if Gem.const_defined?(:BasicSpecification)
|
|
56
|
-
# Gem::Specification < Gem::BasicSpecification (since RGs 2.1)
|
|
57
54
|
case gem_pattern
|
|
58
|
-
when
|
|
55
|
+
when Gem::Specification
|
|
59
56
|
return BundlerHelper.to_spec(gem_pattern)
|
|
60
57
|
when Gem::Dependency
|
|
61
58
|
gem = gem_pattern
|
|
@@ -63,12 +60,9 @@ module Warbler
|
|
|
63
60
|
gem = Gem::Dependency.new(gem_pattern, Gem::Requirement.create(version))
|
|
64
61
|
end
|
|
65
62
|
# skip development dependencies
|
|
66
|
-
return nil if gem.
|
|
63
|
+
return nil if gem.type != :runtime
|
|
67
64
|
|
|
68
|
-
|
|
69
|
-
matched = gem.respond_to?(:to_spec) ? [ gem.to_spec ] : Gem.source_index.search(gem)
|
|
70
|
-
fail "gem '#{gem}' not installed" if matched.empty?
|
|
71
|
-
spec = matched.last
|
|
65
|
+
spec = gem.to_spec
|
|
72
66
|
return spec unless gem_dependencies
|
|
73
67
|
[spec] + spec.dependencies.map { |dependent_gem| find_single_gem_files(gem_dependencies, dependent_gem) }
|
|
74
68
|
end
|
data/lib/warbler/jar.rb
CHANGED
|
@@ -70,8 +70,6 @@ module Warbler
|
|
|
70
70
|
end
|
|
71
71
|
@compiled = true
|
|
72
72
|
end
|
|
73
|
-
# @deprecated only due compatibility
|
|
74
|
-
alias_method :run_javac, :run_jrubyc
|
|
75
73
|
|
|
76
74
|
def sh_jrubyc(cmd)
|
|
77
75
|
sh(cmd) do |ok, res|
|
|
@@ -88,7 +86,7 @@ module Warbler
|
|
|
88
86
|
private :jrubyc_options
|
|
89
87
|
|
|
90
88
|
def java_version(config)
|
|
91
|
-
config.bytecode_version ? "-
|
|
89
|
+
config.bytecode_version ? "-Djruby.bytecode.version=#{config.bytecode_version}" : ''
|
|
92
90
|
end
|
|
93
91
|
|
|
94
92
|
def replace_compiled_ruby_files(config, compiled_ruby_files)
|
|
@@ -178,6 +176,7 @@ module Warbler
|
|
|
178
176
|
|
|
179
177
|
# Invoke a hook to allow the project traits to add or modify the archive contents.
|
|
180
178
|
def apply_traits(config)
|
|
179
|
+
puts "Applying traits #{config.traits}" unless silent?
|
|
181
180
|
config.update_archive(self)
|
|
182
181
|
end
|
|
183
182
|
|
|
@@ -234,6 +233,11 @@ module Warbler
|
|
|
234
233
|
next if config.gem_excludes && config.gem_excludes.any? {|rx| f =~ rx }
|
|
235
234
|
@files[apply_pathmaps(config, File.join(spec.full_name, f), :gems)] = src
|
|
236
235
|
end
|
|
236
|
+
if File.exist?(spec.gem_build_complete_path)
|
|
237
|
+
base_dir = Pathname.new(spec.base_dir)
|
|
238
|
+
gem_build_complete_path = Pathname.new(spec.gem_build_complete_path)
|
|
239
|
+
@files[File.join(config.relative_gem_path, gem_build_complete_path.relative_path_from(base_dir))] = spec.gem_build_complete_path
|
|
240
|
+
end
|
|
237
241
|
end
|
|
238
242
|
|
|
239
243
|
# Add all application directories and files to the archive.
|
|
@@ -280,7 +284,7 @@ module Warbler
|
|
|
280
284
|
|
|
281
285
|
def expand_erb(file, config)
|
|
282
286
|
require 'erb'
|
|
283
|
-
erb = ERB.new(File.read(file),
|
|
287
|
+
erb = ERB.new(File.read(file), trim_mode: '-')
|
|
284
288
|
StringIO.new(erb.result(erb_binding(config)))
|
|
285
289
|
end
|
|
286
290
|
|
|
@@ -330,14 +334,6 @@ module Warbler
|
|
|
330
334
|
|
|
331
335
|
# Java-boosted jar creation for JRuby; replaces #create_jar and
|
|
332
336
|
# #entry_in_jar with Java version
|
|
333
|
-
require 'warbler_jar' if defined?(JRUBY_VERSION)
|
|
334
|
-
end
|
|
335
|
-
|
|
336
|
-
# Warbler::War is Deprecated. Please use Warbler::Jar.
|
|
337
|
-
class War < Jar
|
|
338
|
-
def initialize(*)
|
|
339
|
-
super
|
|
340
|
-
warn "Warbler::War is deprecated. Please replace all occurrences with Warbler::Jar."
|
|
341
|
-
end
|
|
337
|
+
require 'warbler_jar' if defined?(JRUBY_VERSION)
|
|
342
338
|
end
|
|
343
339
|
end
|
data/lib/warbler/task.rb
CHANGED
|
@@ -42,7 +42,7 @@ module Warbler
|
|
|
42
42
|
|
|
43
43
|
def initialize(name = nil, config = nil)
|
|
44
44
|
@config = config
|
|
45
|
-
if @config.nil? && File.
|
|
45
|
+
if @config.nil? && File.exist?(Config::FILE)
|
|
46
46
|
@config = eval(File.read(Config::FILE), binding, Config::FILE, 0)
|
|
47
47
|
end
|
|
48
48
|
@config ||= Config.new
|
|
@@ -148,15 +148,18 @@ module Warbler
|
|
|
148
148
|
|
|
149
149
|
def define_config_task
|
|
150
150
|
task "config" do
|
|
151
|
-
if File.
|
|
151
|
+
if File.exist?(Warbler::Config::FILE) && ENV["FORCE"].nil?
|
|
152
152
|
puts "There's another bird sitting on my favorite branch"
|
|
153
153
|
puts "(file '#{Warbler::Config::FILE}' already exists. Pass argument FORCE=1 to override)"
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
154
|
+
next
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
if !File.directory?(Warbler::Config::CONFIG_DIR)
|
|
158
|
+
puts "config dir is missing, creating it"
|
|
159
|
+
mkdir_p Warbler::Config::CONFIG_DIR
|
|
159
160
|
end
|
|
161
|
+
|
|
162
|
+
cp "#{Warbler::WARBLER_HOME}/warble.rb", Warbler::Config::FILE
|
|
160
163
|
end
|
|
161
164
|
end
|
|
162
165
|
|
|
@@ -2,18 +2,3 @@ ENV['BUNDLE_WITHOUT'] = '<%= config.bundle_without.join(':') %>'
|
|
|
2
2
|
<% if config.bundler[:frozen] -%>
|
|
3
3
|
ENV['BUNDLE_FROZEN'] = '1'
|
|
4
4
|
<% end -%>
|
|
5
|
-
|
|
6
|
-
module Bundler
|
|
7
|
-
module Patch
|
|
8
|
-
def clean_load_path
|
|
9
|
-
# nothing to be done for embedded JRuby
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
module SharedHelpers
|
|
13
|
-
def included(bundler)
|
|
14
|
-
bundler.send :include, Patch
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
require 'bundler/shared_helpers'
|
|
@@ -9,3 +9,5 @@ ENV['GEM_PATH'] = nil # RGs sets Gem.paths.path = Gem.default_path + [ GEM_HOME
|
|
|
9
9
|
<% if config.bundler && config.bundler[:gemfile_path] -%>
|
|
10
10
|
ENV['BUNDLE_GEMFILE'] = File.expand_path(File.join('..', '..', '<%= config.bundler[:gemfile_path] %>'), __FILE__)
|
|
11
11
|
<% end -%>
|
|
12
|
+
<%# Ensure any cached paths are cleared; otherwise behaviour can be indeterminate if the paths have already been read %>
|
|
13
|
+
# Gem.clear_paths
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
<% if (params = config.webxml.context_params) && params['rack.env'] -%>
|
|
2
|
-
ENV['RACK_ENV'] ||= '<%= params['rack.env'] %>'
|
|
1
|
+
<% if ((params = config.webxml.context_params) && params['rack.env']) || ENV_JAVA['RACK_ENV'] -%>
|
|
2
|
+
ENV['RACK_ENV'] ||= ENV_JAVA['RACK_ENV'] || '<%= params['rack.env'] %>'
|
|
3
3
|
<% end -%>
|
|
4
4
|
|
|
5
5
|
$LOAD_PATH.unshift $servlet_context.getRealPath('/WEB-INF') if $servlet_context
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
if $servlet_context.nil?
|
|
2
2
|
ENV['GEM_HOME'] <%= config.override_gem_home ? '=' : '||=' %> File.expand_path(File.join('..', '..', '<%= config.gem_path %>'), __FILE__)
|
|
3
|
-
<% if config.override_gem_home -%>
|
|
4
|
-
<% # GEM_HOME/GEM_PATH are set as .war gets extracted (on java -jar ...)
|
|
5
|
-
# ... thus setting `ENV['GEM_PATH'] = nil` would cause a boot failure
|
|
6
|
-
-%>
|
|
7
|
-
<% end -%>
|
|
8
3
|
<% if config.bundler && config.bundler[:gemfile_path] -%>
|
|
9
4
|
ENV['BUNDLE_GEMFILE'] ||= File.expand_path(File.join('..', '..', '<%= config.bundler[:gemfile_path] %>'), __FILE__)
|
|
10
5
|
<% end -%>
|
|
@@ -17,3 +12,5 @@ else
|
|
|
17
12
|
ENV['BUNDLE_GEMFILE'] ||= $servlet_context.getRealPath('/<%= config.bundler[:gemfile_path] %>')
|
|
18
13
|
<% end -%>
|
|
19
14
|
end
|
|
15
|
+
<%# Ensure any cached paths are cleared; otherwise behaviour can be indeterminate if the paths have already been read %>
|
|
16
|
+
Gem.clear_paths
|
|
@@ -38,22 +38,6 @@ module Warbler
|
|
|
38
38
|
|
|
39
39
|
bundler_specs.each do |spec|
|
|
40
40
|
spec = to_spec(spec)
|
|
41
|
-
# Bundler HAX -- fixup bad #loaded_from attribute in fake
|
|
42
|
-
# bundler gemspec from bundler/source.rb
|
|
43
|
-
if spec.name == 'bundler'
|
|
44
|
-
full_gem_path = Pathname.new(spec.full_gem_path)
|
|
45
|
-
while ! full_gem_path.join('bundler.gemspec').exist?
|
|
46
|
-
full_gem_path = full_gem_path.dirname
|
|
47
|
-
# if at top of the path, meaning we cannot find bundler.gemspec, abort.
|
|
48
|
-
if full_gem_path.to_s =~ /^[\.\/]$/
|
|
49
|
-
warn("Unable to detect bundler spec under '#{spec.full_gem_path}'' and its sub-dirs")
|
|
50
|
-
exit
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
spec.loaded_from = full_gem_path.join('bundler.gemspec').to_s
|
|
55
|
-
spec.full_gem_path = full_gem_path.to_s
|
|
56
|
-
end
|
|
57
41
|
|
|
58
42
|
case spec.source
|
|
59
43
|
when ::Bundler::Source::Git
|
|
@@ -143,7 +127,8 @@ module Warbler
|
|
|
143
127
|
bundle_without = config.bundle_without.map { |s| s.to_sym }
|
|
144
128
|
definition = ::Bundler.definition
|
|
145
129
|
all = definition.specs.to_a
|
|
146
|
-
|
|
130
|
+
requested_groups = definition.groups - bundle_without
|
|
131
|
+
requested = requested_groups.empty? ? [] : definition.specs_for(requested_groups).to_a
|
|
147
132
|
excluded_git_specs = (all - requested).select { |spec| ::Bundler::Source::Git === spec.source }
|
|
148
133
|
excluded_git_specs.each { |spec| spec.groups << :warbler_excluded }
|
|
149
134
|
requested + excluded_git_specs
|
|
@@ -18,6 +18,10 @@ module Warbler
|
|
|
18
18
|
!Dir['*.gemspec'].empty?
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
+
def self.conflicts
|
|
22
|
+
[ Traits::NoGemspec ]
|
|
23
|
+
end
|
|
24
|
+
|
|
21
25
|
def before_configure; require 'yaml'
|
|
22
26
|
@spec_file = Dir['*.gemspec'].first
|
|
23
27
|
@spec = File.open(@spec_file) { |f| Gem::Specification.from_yaml(f) } rescue Gem::Specification.load(@spec_file)
|
|
@@ -56,9 +60,9 @@ module Warbler
|
|
|
56
60
|
if ! @spec.executables.empty?
|
|
57
61
|
exe_script = @spec.executables.first
|
|
58
62
|
exe_path = File.join(@spec.bindir, exe_script) # bin/script
|
|
59
|
-
if File.
|
|
63
|
+
if File.exist?(exe_path)
|
|
60
64
|
exe_path
|
|
61
|
-
elsif File.
|
|
65
|
+
elsif File.exist?("bin/#{exe_script}") # compatibility
|
|
62
66
|
"bin/#{exe_script}" # ... should probably remove this
|
|
63
67
|
else
|
|
64
68
|
raise "no `#{exe_script}` executable script found"
|
data/lib/warbler/traits/jar.rb
CHANGED
|
@@ -23,6 +23,7 @@ module Warbler
|
|
|
23
23
|
|
|
24
24
|
def before_configure
|
|
25
25
|
config.jbundler = true
|
|
26
|
+
warn "JBundler support is deprecated due to the EOL of JBundler. See https://github.com/jruby/warbler/issues/481 for discussion on replacement with jar-dependencies."
|
|
26
27
|
end
|
|
27
28
|
|
|
28
29
|
def after_configure
|
|
@@ -32,10 +33,10 @@ module Warbler
|
|
|
32
33
|
def add_jbundler_jars
|
|
33
34
|
require 'jbundler/config'
|
|
34
35
|
classpath = ::JBundler::Config.new.classpath_file
|
|
35
|
-
if File.
|
|
36
|
+
if File.exist?( classpath )
|
|
36
37
|
require File.expand_path( classpath )
|
|
37
38
|
else
|
|
38
|
-
raise '
|
|
39
|
+
raise 'JBundler support needs JRuby to create a local config: jruby -S jbundle install'
|
|
39
40
|
end
|
|
40
41
|
# use only the jars from jbundler and jruby
|
|
41
42
|
config.java_libs += jruby_jars
|
data/lib/warbler/traits/rack.rb
CHANGED
|
@@ -12,7 +12,11 @@ module Warbler
|
|
|
12
12
|
include Trait
|
|
13
13
|
|
|
14
14
|
def self.detect?
|
|
15
|
-
|
|
15
|
+
(File.exist?("config.ru") || !Dir['*/config.ru'].empty?) && !detect_any_conflicts?
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def self.conflicts
|
|
19
|
+
[ Traits::Rails ]
|
|
16
20
|
end
|
|
17
21
|
|
|
18
22
|
def self.requirements
|