cake 0.4.18 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/cake +44 -69
- data/lib/bake.jar +0 -0
- data/lib/cake.jar +0 -0
- data/lib/clojure.jar +0 -0
- metadata +5 -5
data/bin/cake
CHANGED
@@ -35,6 +35,10 @@ else
|
|
35
35
|
def daemon(cmd)
|
36
36
|
puts cmd if debug?
|
37
37
|
pid = fork do
|
38
|
+
if not $stdin.tty?
|
39
|
+
$stdout.close
|
40
|
+
$stderr.close
|
41
|
+
end
|
38
42
|
Process.setsid
|
39
43
|
exec(cmd)
|
40
44
|
end
|
@@ -132,6 +136,7 @@ end
|
|
132
136
|
|
133
137
|
begin
|
134
138
|
require 'readline'
|
139
|
+
$libedit = true unless Readline.respond_to?(:emacs_editing_mode)
|
135
140
|
rescue LoadError
|
136
141
|
$no_readline = true
|
137
142
|
module Readline
|
@@ -235,7 +240,6 @@ end
|
|
235
240
|
|
236
241
|
def download(url, path, opts = {})
|
237
242
|
file = File.basename(url)
|
238
|
-
path = "#{path}/#{file}" if File.directory?(path)
|
239
243
|
|
240
244
|
if opts[:force] or not File.exists?(path)
|
241
245
|
FileUtils.makedirs(File.dirname(path))
|
@@ -260,14 +264,14 @@ end
|
|
260
264
|
|
261
265
|
def get_cake(opts = {})
|
262
266
|
version = cake_version(opts[:version] || :current)
|
263
|
-
download("#{$github}/jars/cake-#{version}.jar", "#{$m2}/cake/cake/#{snapshot(version)}", opts)
|
267
|
+
download("#{$github}/jars/cake-#{version}.jar", "#{$m2}/cake/cake/#{snapshot(version)}/cake-#{version}.jar", opts)
|
264
268
|
end
|
265
269
|
|
266
270
|
def get_clojure(opts = {})
|
267
271
|
version = opts[:version] || "1.2.0"
|
268
272
|
repo = opts[:repo] || "http://build.clojure.org/releases"
|
269
273
|
path = "org/clojure/clojure/#{version}"
|
270
|
-
download("#{repo}/#{path}/clojure-#{version}.jar", "#{$m2}/#{path}", opts)
|
274
|
+
download("#{repo}/#{path}/clojure-#{version}.jar", "#{$m2}/#{path}/clojure-#{version}.jar", opts)
|
271
275
|
end
|
272
276
|
|
273
277
|
def progress_bar(label, ch = '=', bg = '', width = 77, out = $stdout, progress = 0, total = nil)
|
@@ -327,13 +331,13 @@ class JVM
|
|
327
331
|
end
|
328
332
|
|
329
333
|
def init
|
330
|
-
|
334
|
+
reload_stale_files if enabled? and running?
|
331
335
|
start
|
332
|
-
stale
|
333
336
|
end
|
334
337
|
|
335
338
|
def refresh
|
336
339
|
@pid, @port, @version = IO.read(pidfile).split("\n"); @pid = @pid.to_i; @port = @port.to_i
|
340
|
+
|
337
341
|
Process.kill(0, @pid) # make sure pid is valid
|
338
342
|
TCPSocket.new("localhost", @port).close if @port # make sure jvm is running on port
|
339
343
|
|
@@ -341,7 +345,7 @@ class JVM
|
|
341
345
|
rescue Errno::ENOENT, Errno::ESRCH, Errno::ECONNREFUSED, Errno::EBADF, Process::Error => e
|
342
346
|
if e.kind_of?(Errno::ECONNREFUSED)
|
343
347
|
log(:start, "defunct #{type} jvm") if debug?
|
344
|
-
kill
|
348
|
+
kill(true)
|
345
349
|
end
|
346
350
|
reset! # no pidfile or invalid pid or connection refused
|
347
351
|
end
|
@@ -358,34 +362,17 @@ class JVM
|
|
358
362
|
end
|
359
363
|
|
360
364
|
def reload_stale_files
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
log(:reload, "the following #{type} files have changed: #{stale_files.join(', ')}") if debug?
|
368
|
-
|
369
|
-
if stale_files.any? {|f| File.extname(f) != ".clj"}
|
370
|
-
log(:reload, "non-clojure #{type} files have changed, restarting") if verbose?
|
371
|
-
stop(:reload)
|
365
|
+
with_socket(nil) do |socket|
|
366
|
+
socket.write ":reload {}"
|
367
|
+
socket.close_write
|
368
|
+
if socket.eof?
|
369
|
+
FileUtils.touch(pidfile)
|
370
|
+
@load_time = Time.now
|
372
371
|
else
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
socket.write ":reload {} [#{stale_files.join(" ")}]"
|
377
|
-
socket.close_write
|
378
|
-
if socket.eof?
|
379
|
-
FileUtils.touch(pidfile)
|
380
|
-
@load_time = Time.now
|
381
|
-
else
|
382
|
-
inspect(socket)
|
383
|
-
log(:reload, "unable to reload all #{type} files, restarting") if verbose?
|
384
|
-
stop(:reload)
|
385
|
-
end
|
386
|
-
end
|
372
|
+
inspect(socket) if debug?
|
373
|
+
log(:reload, "unable to reload all #{type} files, restarting") if verbose?
|
374
|
+
stop(:reload)
|
387
375
|
end
|
388
|
-
true
|
389
376
|
end
|
390
377
|
end
|
391
378
|
|
@@ -438,9 +425,9 @@ class JVM
|
|
438
425
|
end || (log(mode, "#{type} jvm not running") if $command == :stop)
|
439
426
|
end
|
440
427
|
|
441
|
-
def kill
|
428
|
+
def kill(force = $opts[:"9"])
|
442
429
|
if pid
|
443
|
-
signal =
|
430
|
+
signal = force ? KILL : TERM
|
444
431
|
log(:kill, "sending #{signal} signal to #{type} jvm") if debug?
|
445
432
|
Process.kill(signal, pid)
|
446
433
|
reset!
|
@@ -449,21 +436,6 @@ class JVM
|
|
449
436
|
end
|
450
437
|
end
|
451
438
|
|
452
|
-
def files
|
453
|
-
files = ["project.clj", "#{$home}/.cake/config", ".cake/config"]
|
454
|
-
classpath.split(PATH_SEP).uniq.each do |path|
|
455
|
-
if path =~ /(.*)\/\*$/
|
456
|
-
files.concat Dir["#{path}.jar"] << "#{$1}/." # include the directory itself so deletions will be detected
|
457
|
-
else
|
458
|
-
Find.find(path) do |f|
|
459
|
-
Find.prune if f == "#{$bakedir}/src/jvm"
|
460
|
-
files << f if f =~ /\.(clj|class|jar)$/ and File.exists?(f) and not File.directory?(f)
|
461
|
-
end if File.exists?(path)
|
462
|
-
end
|
463
|
-
end
|
464
|
-
files
|
465
|
-
end
|
466
|
-
|
467
439
|
def ping
|
468
440
|
return unless enabled?
|
469
441
|
with_socket do |socket|
|
@@ -518,7 +490,7 @@ class JVM
|
|
518
490
|
while line = $stdin.gets
|
519
491
|
socket.write [line.chomp, ~forms].to_clj
|
520
492
|
while (line = socket.gets)
|
521
|
-
break if line.
|
493
|
+
break if line.index(EOL) == 0
|
522
494
|
puts line
|
523
495
|
end
|
524
496
|
end
|
@@ -534,7 +506,7 @@ private
|
|
534
506
|
|
535
507
|
def inspect(socket)
|
536
508
|
while line = socket.gets
|
537
|
-
break if line.
|
509
|
+
break if line.index('reload-failed:') == 0 and not debug?
|
538
510
|
puts line
|
539
511
|
end
|
540
512
|
end
|
@@ -561,7 +533,7 @@ private
|
|
561
533
|
log :cake, "connection to #{type} jvm is taking a long time...",
|
562
534
|
"you can use ^C to abort and use 'cake kill' or 'cake kill -9' to force the jvm to restart"
|
563
535
|
end
|
564
|
-
retry
|
536
|
+
retry unless retries < -$timeout
|
565
537
|
end
|
566
538
|
ensure
|
567
539
|
socket.close if socket
|
@@ -661,13 +633,9 @@ class Cake < JVM
|
|
661
633
|
end
|
662
634
|
end
|
663
635
|
|
664
|
-
def files
|
665
|
-
super.concat ["tasks.clj", "#{$home}/.cake/tasks.clj"]
|
666
|
-
end
|
667
|
-
|
668
636
|
def java_opts
|
669
637
|
# bootclasspath = %{-Xbootclasspath/a:"#{$clojure}"}
|
670
|
-
[ENV['CAKE_JAVA_OPTS'], $config['cake.java_opts'], super].compact.join(' ')
|
638
|
+
["-Xms16M -Xmx64M", ENV['CAKE_JAVA_OPTS'], $config['cake.java_opts'], super].compact.join(' ')
|
671
639
|
end
|
672
640
|
|
673
641
|
private
|
@@ -692,17 +660,17 @@ end
|
|
692
660
|
|
693
661
|
class Bake < JVM
|
694
662
|
def java_opts
|
695
|
-
[ENV['JAVA_OPTS'], $config['project.java_opts'], super].compact.join(' ')
|
663
|
+
["-Xms128M -Xmx256M", ENV['JAVA_OPTS'], $config['project.java_opts'], super].compact.join(' ')
|
696
664
|
end
|
697
665
|
|
698
666
|
def enabled?
|
699
|
-
Dir['lib/*.jar'].any?
|
667
|
+
Dir['lib/*.jar'].any? or Dir['classes/**/*.class'].any?
|
700
668
|
end
|
701
669
|
end
|
702
670
|
|
703
671
|
def initialize_cake_dirs
|
704
|
-
FileUtils.makedirs("#{$bakedir}/.cake")
|
705
|
-
FileUtils.makedirs("#{$home}/.cake")
|
672
|
+
FileUtils.makedirs("#{$bakedir}/.cake/run")
|
673
|
+
FileUtils.makedirs("#{$home}/.cake/run")
|
706
674
|
project_clj = "#{$home}/.cake/project.clj"
|
707
675
|
File.open(project_clj, 'w') do |file|
|
708
676
|
file.write <<END
|
@@ -720,6 +688,12 @@ def initialize_cake_dirs
|
|
720
688
|
;;--------------------
|
721
689
|
END
|
722
690
|
end unless File.exists?(project_clj)
|
691
|
+
|
692
|
+
# Enable paren matching if using readline and .inputrc doesn't exist.
|
693
|
+
inputrc = "#{$home}/.inputrc"
|
694
|
+
File.open(inputrc, 'w') do |file|
|
695
|
+
file.write "set blink-matching-paren on\n"
|
696
|
+
end unless $no_readline or $libedit or File.exists?(inputrc)
|
723
697
|
end
|
724
698
|
|
725
699
|
#==================================
|
@@ -728,11 +702,11 @@ parse_opts!
|
|
728
702
|
$script = File.expand_path($opts[:run].first) if $opts[:run]
|
729
703
|
$pwd = Dir.getwd
|
730
704
|
$bakedir = project_dir($pwd)
|
731
|
-
$cakedir = File.dirname(File.dirname(readlink(__FILE__)))
|
705
|
+
$cakedir = File.expand_path(File.dirname(File.dirname(readlink(__FILE__))))
|
732
706
|
$github = "http://github.com/ninjudd/cake-standalone/raw/master"
|
733
707
|
$m2 = "#{$home}/.m2/repository"
|
734
708
|
$config = Configuration.new("#{$home}/.cake/config", ".cake/config")
|
735
|
-
$vars = {:
|
709
|
+
$vars = {:shellenv => ENV.to_hash, :pwd => $pwd, :args => ARGV, :opts => $opts, :script => $0}.to_clj
|
736
710
|
$timeout = ($config['connect.timeout'] || 20).to_i
|
737
711
|
|
738
712
|
initialize_cake_dirs
|
@@ -760,14 +734,15 @@ if File.exists?("#{$cakedir}/.gitignore") and File.exists?(project)
|
|
760
734
|
# Force new cake libs if cake's project.clj has changed.
|
761
735
|
FileUtils.remove_dir(lib, true) if newer?(project, lib) and not $config['cake.disable-auto-deps']
|
762
736
|
|
763
|
-
if Dir["#{lib}/*.jar"].empty?
|
737
|
+
if Dir["#{lib}/*.jar"].empty? or Dir["#{lib}/dev/*.jar"].empty?
|
764
738
|
# In a new git checkout, need to fetch dependencies.
|
765
739
|
cakejar = get_cake(:version => $version, :dest => lib) rescue get_cake(:version => :current, :dest => lib)
|
740
|
+
extract(cakejar, "bake.jar", "#{lib}/dev")
|
766
741
|
end
|
767
742
|
$clojure = get_clojure(:dest => lib)
|
768
743
|
|
769
|
-
cakepath = ["#{$cakedir}/src", "#{lib}/*"]
|
770
|
-
bakepath = ["#{$cakedir}/bake"]
|
744
|
+
cakepath = ["#{$cakedir}/src", "#{lib}/*", "#{lib}/dev/*"]
|
745
|
+
bakepath = ["#{$cakedir}/bake", "#{lib}/dev/*"]
|
771
746
|
else
|
772
747
|
cakejar = "#{lib}/cake.jar"
|
773
748
|
bakejar = "#{lib}/bake.jar"
|
@@ -815,15 +790,15 @@ cake = Cake.new(
|
|
815
790
|
[$config['cake.library.path'], "lib/dev/native"]
|
816
791
|
)
|
817
792
|
bake = Bake.new(
|
818
|
-
[bakepath, "src", "src/clj", "classes", "resources", "dev", "test", $config['project.classpath'], $opts[:cp], "lib/*", "lib/dev/*", "#{$home}/.cake/lib/dev/*"],
|
793
|
+
[bakepath, "src", "src/clj", "classes", "resources", "dev", "test", "test/classes", $config['project.classpath'], $opts[:cp], "lib/*", "lib/dev/*", "#{$home}/.cake/lib/dev/*"],
|
819
794
|
[$config['project.library.path'], "lib/native", "lib/dev/native"]
|
820
795
|
)
|
821
796
|
|
822
797
|
if $command == :default and $opts[:version]
|
823
798
|
puts "cake #{$version}"
|
824
799
|
exit
|
825
|
-
elsif $command == :kill
|
826
|
-
if $opts[:all] or $opts[:kill] == ['all']
|
800
|
+
elsif $command == :killall or $command == :kill
|
801
|
+
if $opts[:all] or $opts[:kill] == ['all'] or $command == :killall
|
827
802
|
puts "'cake kill --all' is deprecated, in the future use 'cake kill all' instead" if $opts[:all]
|
828
803
|
num = ps.each do |line|
|
829
804
|
pid = line.split(' ').first.to_i
|
data/lib/bake.jar
CHANGED
Binary file
|
data/lib/cake.jar
CHANGED
Binary file
|
data/lib/clojure.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: 11
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 5
|
9
|
+
- 0
|
10
|
+
version: 0.5.0
|
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-
|
19
|
+
date: 2010-10-13 00:00:00 -07:00
|
20
20
|
default_executable: cake
|
21
21
|
dependencies: []
|
22
22
|
|