cake 0.3.6 → 0.3.8
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/bin/cake +64 -33
- data/lib/bake.jar +0 -0
- data/lib/cake.jar +0 -0
- metadata +4 -4
data/bin/cake
CHANGED
@@ -7,6 +7,30 @@ require 'socket'
|
|
7
7
|
require 'timeout'
|
8
8
|
require 'fileutils'
|
9
9
|
|
10
|
+
if RUBY_PLATFORM =~ /(mingw|mswin)32$/
|
11
|
+
require 'win32/process'
|
12
|
+
PATH_SEP = ';'
|
13
|
+
$home = ENV['HOMEDRIVE'] + ENV['HOMEPATH']
|
14
|
+
|
15
|
+
def daemon(cmd)
|
16
|
+
Process.create(:app_name => cmd).process_id
|
17
|
+
end
|
18
|
+
else
|
19
|
+
PATH_SEP = ':'
|
20
|
+
$home = File.expand_path("~")
|
21
|
+
|
22
|
+
class Process::Error; end
|
23
|
+
def daemon(cmd)
|
24
|
+
puts cmd if debug?
|
25
|
+
pid = fork do
|
26
|
+
Process.setsid
|
27
|
+
exec(cmd)
|
28
|
+
end
|
29
|
+
Process.detach(pid)
|
30
|
+
pid
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
10
34
|
begin
|
11
35
|
require 'readline'
|
12
36
|
rescue LoadError => e
|
@@ -35,19 +59,34 @@ class IO
|
|
35
59
|
end
|
36
60
|
end
|
37
61
|
|
62
|
+
GLOBAL_DEFAULT_PROJECT = <<END
|
63
|
+
(defproject global "0.0.0"
|
64
|
+
:description "This is the global cake project. It is used whenever you run cake outside a project directory"
|
65
|
+
:dependencies [[clojure "1.2.0-RC2"]
|
66
|
+
[clojure-contrib "1.2.0-RC2"]])
|
67
|
+
END
|
68
|
+
|
38
69
|
def project_dir(dir)
|
39
|
-
while dir !=
|
40
|
-
return dir if ["
|
70
|
+
while dir != File.dirname(dir)
|
71
|
+
return dir if ["project.clj", "tasks.clj"].any? {|file| File.exists?("#{dir}/#{file}")}
|
41
72
|
dir = File.dirname(dir)
|
42
73
|
end
|
43
|
-
|
74
|
+
project_dir = "#{$home}/.cake"
|
75
|
+
project_clj = "#{project_dir}/project.clj"
|
76
|
+
FileUtils.makedirs(project_dir) unless File.exists?(project_dir)
|
77
|
+
File.open(project_clj, 'w') {|f| f.write(GLOBAL_DEFAULT_PROJECT)} unless File.exists?(project_clj)
|
78
|
+
project_dir
|
79
|
+
end
|
80
|
+
|
81
|
+
def readlink(file)
|
82
|
+
File.readlink(file)
|
83
|
+
rescue NotImplementedError
|
84
|
+
file
|
44
85
|
end
|
45
86
|
|
46
|
-
PATH_SEP = ':'
|
47
|
-
file = File.readlink(__FILE__) rescue __FILE__
|
48
87
|
$pwd = Dir.getwd
|
49
88
|
$bakedir = project_dir($pwd)
|
50
|
-
$cakedir = File.dirname(File.dirname(
|
89
|
+
$cakedir = File.dirname(File.dirname(readlink(__FILE__)))
|
51
90
|
$repo = "http://clojars.org/repo/cake/cake"
|
52
91
|
$confdir = ".cake"
|
53
92
|
Dir.chdir($bakedir)
|
@@ -104,7 +143,7 @@ end
|
|
104
143
|
def extract(jar, file, dest = File.dirname(jar))
|
105
144
|
if not File.exists?("#{dest}/#{file}")
|
106
145
|
log(:deps, "extracting #{file} from #{jar}") if verbose?
|
107
|
-
ret = system
|
146
|
+
ret = system "jar xf #{jar} #{file}"
|
108
147
|
raise "cannot find jar command" unless ret
|
109
148
|
FileUtils.makedirs(dest)
|
110
149
|
FileUtils.move(file, dest)
|
@@ -219,7 +258,7 @@ class JVM
|
|
219
258
|
@pid, @port = IO.read(pidfile).split("\n").map {|l| l.to_i}
|
220
259
|
Process.kill(0, @pid) # make sure pid is valid
|
221
260
|
TCPSocket.new("localhost", @port).close if @port # make sure jvm is running on port
|
222
|
-
rescue Errno::ENOENT, Errno::ESRCH, Errno::ECONNREFUSED => e
|
261
|
+
rescue Errno::ENOENT, Errno::ESRCH, Errno::ECONNREFUSED, Errno::EBADF, Process::Error => e
|
223
262
|
log(:start, "defunct #{type} jvm") if debug? and e.kind_of?(Errno::ECONNREFUSED)
|
224
263
|
reset! # no pidfile or invalid pid or connection refused
|
225
264
|
end
|
@@ -250,7 +289,7 @@ class JVM
|
|
250
289
|
FileUtils.touch(pidfile)
|
251
290
|
@load_time = Time.now
|
252
291
|
else
|
253
|
-
inspect(socket)
|
292
|
+
inspect(socket)
|
254
293
|
log(:reload, "unable to reload all #{type} files, restarting") if verbose?
|
255
294
|
stop(:reload)
|
256
295
|
end
|
@@ -261,12 +300,12 @@ class JVM
|
|
261
300
|
end
|
262
301
|
|
263
302
|
def java_opts
|
264
|
-
opts =
|
265
|
-
opts <<
|
303
|
+
opts = %{-cp "#{classpath}" -Djava.library.path="#{libpath}"}
|
304
|
+
opts << %{ -Djava.home="#{ENV['JAVA_HOME']}" -Djava.ext.dirs="#{ENV['JAVA_HOME']}/lib"} if ENV['JAVA_HOME']
|
266
305
|
opts
|
267
306
|
end
|
268
307
|
|
269
|
-
MIN_PORT = 2**
|
308
|
+
MIN_PORT = 2**14
|
270
309
|
MAX_PORT = 2**16
|
271
310
|
|
272
311
|
def start
|
@@ -277,7 +316,7 @@ class JVM
|
|
277
316
|
else
|
278
317
|
log(:start, "starting #{type} jvm") if verbose? or $command == :start
|
279
318
|
@port = rand(MAX_PORT - MIN_PORT) + MIN_PORT
|
280
|
-
@pid = daemon %{
|
319
|
+
@pid = daemon %{java -Dcake.project="#{$bakedir}" #{java_opts} clojure.main -e "(use '#{type})(start-server #{port})"}
|
281
320
|
File.open(pidfile, 'w') {|f| f.write("#{pid}\n#{port}\n") }
|
282
321
|
end
|
283
322
|
rescue Errno::EADDRNOTAVAIL => e # port already in use
|
@@ -361,14 +400,16 @@ class JVM
|
|
361
400
|
private
|
362
401
|
|
363
402
|
def make_path(paths)
|
364
|
-
paths.flatten.compact.
|
365
|
-
path[0,1] == '/' ? path : "#{$bakedir}/#{path}"
|
366
|
-
end.join(PATH_SEP)
|
403
|
+
paths.flatten.compact.join(PATH_SEP)
|
367
404
|
end
|
368
405
|
|
369
406
|
def inspect(socket)
|
370
|
-
|
407
|
+
line = socket.gets
|
408
|
+
if debug? or not line.start_with?('reload-failed:')
|
371
409
|
puts line
|
410
|
+
while line = socket.gets
|
411
|
+
puts line
|
412
|
+
end
|
372
413
|
end
|
373
414
|
end
|
374
415
|
|
@@ -382,22 +423,12 @@ private
|
|
382
423
|
File.exists?(file) and File.mtime(file) > load_time
|
383
424
|
end
|
384
425
|
|
385
|
-
def daemon(cmd)
|
386
|
-
puts cmd if debug?
|
387
|
-
pid = fork do
|
388
|
-
Process.setsid
|
389
|
-
exec(cmd)
|
390
|
-
end
|
391
|
-
Process.detach(pid)
|
392
|
-
pid
|
393
|
-
end
|
394
|
-
|
395
426
|
def with_socket(retries = 20)
|
396
427
|
return unless port
|
397
428
|
socket = TCPSocket.new("localhost", port)
|
398
429
|
result = yield(socket)
|
399
430
|
result
|
400
|
-
rescue Errno::ECONNREFUSED => e
|
431
|
+
rescue Errno::ECONNREFUSED, Errno::EBADF => e
|
401
432
|
sleep 1
|
402
433
|
retry if (retries -= 1) >= 0
|
403
434
|
log($command, "timeout while connecting to #{type} jvm")
|
@@ -498,7 +529,7 @@ class Cake < JVM
|
|
498
529
|
end
|
499
530
|
|
500
531
|
def files
|
501
|
-
super.concat ["build.clj", "
|
532
|
+
super.concat ["build.clj", "#{$home}/.cake/tasks.clj"]
|
502
533
|
end
|
503
534
|
|
504
535
|
def java_opts
|
@@ -596,7 +627,7 @@ end
|
|
596
627
|
cake.init
|
597
628
|
if not [:deps, :clean].include?($command) and File.exists?('project.clj')
|
598
629
|
if newer?('project.clj', 'pom.xml')
|
599
|
-
cake.send_command(:deps)
|
630
|
+
cake.send_command(:deps)
|
600
631
|
cake.init
|
601
632
|
elsif config['swank.auto-start'] or config['swank']
|
602
633
|
cake.send_command(:"swank-deps")
|
@@ -607,10 +638,10 @@ if not [:deps, :clean].include?($command) and File.exists?('project.clj')
|
|
607
638
|
end
|
608
639
|
|
609
640
|
if [:repl, :eval].include?($command)
|
610
|
-
if File.exists?('project.clj')
|
611
|
-
bake.send($command)
|
612
|
-
else
|
641
|
+
if $opts[:cake] or not File.exists?('project.clj')
|
613
642
|
cake.send($command)
|
643
|
+
else
|
644
|
+
bake.send($command)
|
614
645
|
end
|
615
646
|
elsif [:start, :reload, :restart].include?($command)
|
616
647
|
if $opts[:l] or $opts[:log]
|
data/lib/bake.jar
CHANGED
Binary file
|
data/lib/cake.jar
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cake
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 3
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 8
|
10
|
+
version: 0.3.8
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Justin Balthrop
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-08-
|
19
|
+
date: 2010-08-09 00:00:00 -07:00
|
20
20
|
default_executable: cake
|
21
21
|
dependencies: []
|
22
22
|
|