cake 0.3.13 → 0.4.0
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 +214 -129
- data/lib/bake.jar +0 -0
- data/lib/cake.jar +0 -0
- metadata +5 -5
data/bin/cake
CHANGED
@@ -11,10 +11,10 @@ require 'pp'
|
|
11
11
|
|
12
12
|
if RUBY_PLATFORM =~ /(mingw|mswin)(32|64)$/
|
13
13
|
require 'win32/process'
|
14
|
-
TERM =
|
14
|
+
TERM = 1
|
15
15
|
KILL = 'KILL'
|
16
16
|
PATH_SEP = ';'
|
17
|
-
$home = ENV['HOMEDRIVE'] + ENV['HOMEPATH']
|
17
|
+
$home = File.expand_path(ENV['HOMEDRIVE'] + ENV['HOMEPATH'])
|
18
18
|
$win = true
|
19
19
|
|
20
20
|
def daemon(cmd)
|
@@ -38,6 +38,90 @@ else
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
+
class IO
|
42
|
+
def gets_nonblock(delim = "\n")
|
43
|
+
line = ""
|
44
|
+
while c = read_nonblock(1)
|
45
|
+
line << c
|
46
|
+
break if c == delim
|
47
|
+
end
|
48
|
+
line
|
49
|
+
rescue Errno::EAGAIN, Errno::EWOULDBLOCK, EOFError
|
50
|
+
line
|
51
|
+
end
|
52
|
+
|
53
|
+
def eof_nonblock?
|
54
|
+
ungetc(read_nonblock(1)[0])
|
55
|
+
false
|
56
|
+
rescue Errno::EAGAIN, Errno::EWOULDBLOCK, EOFError => e
|
57
|
+
e.kind_of?(EOFError)
|
58
|
+
end
|
59
|
+
|
60
|
+
def print_flush(str)
|
61
|
+
print(str)
|
62
|
+
flush
|
63
|
+
end
|
64
|
+
|
65
|
+
def duplex(input, output, input_wait = 0, interval = 0.01)
|
66
|
+
until eof_nonblock?
|
67
|
+
while self.wait(interval)
|
68
|
+
if line = block_given? ? yield(gets_nonblock) : gets_nonblock
|
69
|
+
output.print_flush(line) if line.kind_of?(String)
|
70
|
+
else
|
71
|
+
finished = true
|
72
|
+
end
|
73
|
+
end
|
74
|
+
input_wait -= interval
|
75
|
+
return if finished
|
76
|
+
|
77
|
+
while input.ready?
|
78
|
+
return if input.eof?
|
79
|
+
write(input.gets)
|
80
|
+
end unless $win or input_wait > 0
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
class Object
|
86
|
+
# Support converting simple Ruby data structures to Clojure expressions.
|
87
|
+
def to_clj(unquote = false)
|
88
|
+
if unquote
|
89
|
+
case self
|
90
|
+
when Array : return collect {|i| i.to_clj(true)}.join(' ')
|
91
|
+
when String : return self
|
92
|
+
end
|
93
|
+
end
|
94
|
+
case self
|
95
|
+
when Hash : '{' + collect {|k,v| k.to_clj + ' ' + v.to_clj}.join(' ') + '}'
|
96
|
+
when Array : '[' + collect {|i| i.to_clj}.join(' ') + ']'
|
97
|
+
when Symbol : ":#{to_s}"
|
98
|
+
else inspect.gsub(/(\\a|\\e|\\v)/) {|c| CLJ_SUB[c]}
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
CLJ_SUB = {
|
103
|
+
'\a' => '\007',
|
104
|
+
'\e' => '\033',
|
105
|
+
'\v' => '\013',
|
106
|
+
}
|
107
|
+
|
108
|
+
define_method(:~) { Unquoted.new(self) }
|
109
|
+
end
|
110
|
+
|
111
|
+
class Unquoted
|
112
|
+
attr_reader :object
|
113
|
+
def initialize(object)
|
114
|
+
@object = object
|
115
|
+
end
|
116
|
+
|
117
|
+
def to_clj(quote = false)
|
118
|
+
object.to_clj(!quote)
|
119
|
+
end
|
120
|
+
alias to_s to_clj
|
121
|
+
|
122
|
+
define_method(:~) { @object }
|
123
|
+
end
|
124
|
+
|
41
125
|
begin
|
42
126
|
require 'readline'
|
43
127
|
rescue LoadError => e
|
@@ -45,37 +129,23 @@ rescue LoadError => e
|
|
45
129
|
HISTORY = []
|
46
130
|
attr_accessor :basic_word_break_characters, :completion_proc
|
47
131
|
def readline(prompt)
|
48
|
-
$stdout.
|
49
|
-
$stdout.flush
|
132
|
+
$stdout.print_flush(prompt)
|
50
133
|
$stdin.gets
|
51
134
|
end
|
52
135
|
extend Readline
|
53
136
|
end
|
54
137
|
end
|
55
138
|
|
56
|
-
class IO
|
57
|
-
def gets_nonblock(delim = "\n")
|
58
|
-
line = ""
|
59
|
-
while c = read_nonblock(1)
|
60
|
-
line << c
|
61
|
-
break if c == delim
|
62
|
-
end
|
63
|
-
line
|
64
|
-
rescue Errno::EAGAIN, EOFError => e
|
65
|
-
line
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
139
|
def add_opt!(key, *vals)
|
70
140
|
($opts[key.to_sym] ||= []).concat vals
|
71
141
|
end
|
72
142
|
|
73
143
|
def parse_opts!
|
74
|
-
ARGV.unshift('run'
|
75
|
-
ARGV.unshift('default')
|
76
|
-
$command = ARGV.
|
144
|
+
ARGV.unshift('run') if ARGV.any? and ARGV.first.index('/')
|
145
|
+
ARGV.unshift('default') if ARGV.empty? or ARGV.first[0,1] == '-'
|
146
|
+
$command = ARGV.first.to_sym
|
77
147
|
$opts = {}
|
78
|
-
ARGV.each do |opt|
|
148
|
+
ARGV[1..-1].each do |opt|
|
79
149
|
case opt
|
80
150
|
when /^-(\w+)$/ then $1.split('').each {|c| add_opt!(c, '')}
|
81
151
|
when /^--?([-\w]+)=([\S]+)$/ then add_opt!($1, *$2.split(','))
|
@@ -85,7 +155,6 @@ def parse_opts!
|
|
85
155
|
end
|
86
156
|
$opts.freeze
|
87
157
|
end
|
88
|
-
parse_opts!
|
89
158
|
|
90
159
|
def debug?
|
91
160
|
ENV['CAKE_DEBUG'] or $opts[:d] or $opts[:debug]
|
@@ -133,30 +202,6 @@ class Configuration < Hash
|
|
133
202
|
end
|
134
203
|
end
|
135
204
|
|
136
|
-
def config
|
137
|
-
@config ||= Configuration.new("#{$home}/.cake/config", ".cake/config")
|
138
|
-
end
|
139
|
-
|
140
|
-
if debug?
|
141
|
-
puts "opts: #{$opts.inspect}"
|
142
|
-
puts "config: #{$config.inspect}"
|
143
|
-
end
|
144
|
-
|
145
|
-
GLOBAL_DEFAULT_PROJECT = <<END
|
146
|
-
(defproject global "0.0.0"
|
147
|
-
:description "Don't rename this project, though you can change the version to your heart's content."
|
148
|
-
:dependencies [[clojure "1.2.0-RC2"]
|
149
|
-
[clojure-contrib "1.2.0-RC2"]])
|
150
|
-
;;--------------------
|
151
|
-
;; This is the global cake project. What does that mean?
|
152
|
-
;; 1. This project is used whenever you run cake outside a project directory.
|
153
|
-
;; 2. Any dependencies specified here will be available in the global repl.
|
154
|
-
;; 3. Any dev-dependencies specified here will be available in all projects, though you
|
155
|
-
;; must run 'cake deps --global' manually when you change this file.
|
156
|
-
;; 4. Configuration options in ~/.cake/config are used in all projects.
|
157
|
-
;;--------------------
|
158
|
-
END
|
159
|
-
|
160
205
|
def project_dir(dir)
|
161
206
|
if $opts[:project] and not $opts[:global]
|
162
207
|
project = $opts[:project].last
|
@@ -168,11 +213,7 @@ def project_dir(dir)
|
|
168
213
|
return dir if ["project.clj", "tasks.clj"].any? {|file| File.exists?("#{dir}/#{file}")}
|
169
214
|
dir = File.dirname(dir)
|
170
215
|
end unless $opts[:global]
|
171
|
-
|
172
|
-
project_clj = "#{project_dir}/project.clj"
|
173
|
-
FileUtils.makedirs(project_dir) unless File.exists?(project_dir)
|
174
|
-
File.open(project_clj, 'w') {|f| f.write(GLOBAL_DEFAULT_PROJECT)} unless File.exists?(project_clj)
|
175
|
-
project_dir
|
216
|
+
"#{$home}/.cake"
|
176
217
|
end
|
177
218
|
|
178
219
|
def readlink(file)
|
@@ -181,14 +222,6 @@ rescue NotImplementedError, Errno::EINVAL
|
|
181
222
|
file
|
182
223
|
end
|
183
224
|
|
184
|
-
$pwd = Dir.getwd
|
185
|
-
$bakedir = project_dir($pwd)
|
186
|
-
$cakedir = File.dirname(File.dirname(readlink(__FILE__)))
|
187
|
-
$repo = "http://clojars.org/repo/cake/cake"
|
188
|
-
$confdir = ".cake"
|
189
|
-
Dir.chdir($bakedir)
|
190
|
-
FileUtils.makedirs($confdir)
|
191
|
-
|
192
225
|
def get_cake(version, dest = nil, opts = {})
|
193
226
|
jar = version =~ /(.*)-SNAPSHOT/ ? "cake-#{$1}-#{snapshot(version)}.jar" : "cake-#{version}.jar"
|
194
227
|
repo = File.expand_path("~/.m2/repository/cake/cake/#{version}")
|
@@ -284,9 +317,13 @@ class JVM
|
|
284
317
|
end
|
285
318
|
|
286
319
|
def refresh
|
287
|
-
@pid, @port = IO.read(pidfile).split("\n").
|
320
|
+
@pid, @port, @version = IO.read(pidfile).split("\n"); @pid = @pid.to_i; @port = @port.to_i
|
288
321
|
Process.kill(0, @pid) # make sure pid is valid
|
289
322
|
TCPSocket.new("localhost", @port).close if @port # make sure jvm is running on port
|
323
|
+
|
324
|
+
return if @version == $version
|
325
|
+
Process.kill(TERM, @pid)
|
326
|
+
reset!
|
290
327
|
rescue Errno::ENOENT, Errno::ESRCH, Errno::ECONNREFUSED, Errno::EBADF, Process::Error => e
|
291
328
|
log(:start, "defunct #{type} jvm") if debug? and e.kind_of?(Errno::ECONNREFUSED)
|
292
329
|
reset! # no pidfile or invalid pid or connection refused
|
@@ -319,7 +356,8 @@ class JVM
|
|
319
356
|
log(:reload, "clojure #{type} files have changed, reloading") if verbose?
|
320
357
|
with_socket(nil) do |socket|
|
321
358
|
stale_files = stale_files.collect {|f| %{"#{f}"} }
|
322
|
-
socket.write ":reload [#{stale_files.join(" ")}]
|
359
|
+
socket.write ":reload {} [#{stale_files.join(" ")}]"
|
360
|
+
socket.close_write
|
323
361
|
if socket.eof?
|
324
362
|
FileUtils.touch(pidfile)
|
325
363
|
@load_time = Time.now
|
@@ -340,6 +378,11 @@ class JVM
|
|
340
378
|
opts
|
341
379
|
end
|
342
380
|
|
381
|
+
def vm_opts
|
382
|
+
opts = '-client'
|
383
|
+
opts << ' -d32' unless $win
|
384
|
+
end
|
385
|
+
|
343
386
|
MIN_PORT = 2**14
|
344
387
|
MAX_PORT = 2**16
|
345
388
|
|
@@ -351,8 +394,8 @@ class JVM
|
|
351
394
|
else
|
352
395
|
log(:start, "starting #{type} jvm") if verbose? or $command == :start
|
353
396
|
@port = rand(MAX_PORT - MIN_PORT) + MIN_PORT
|
354
|
-
@pid = daemon %{java -Dcake.project="#{$bakedir}" #{java_opts} clojure.main -e "(use '#{type})(start-server #{port})"}
|
355
|
-
File.open(pidfile, 'w') {|f| f.write("#{pid}\n#{port}\n") }
|
397
|
+
@pid = daemon %{java #{vm_opts} -Dcake.project="#{$bakedir}" #{java_opts} clojure.main -e "(use '#{type}.core) (start-server #{port})"}
|
398
|
+
File.open(pidfile, 'w') {|f| f.write("#{pid}\n#{port}\n#{$version}\n") }
|
356
399
|
end
|
357
400
|
rescue Errno::EADDRNOTAVAIL => e # port already in use
|
358
401
|
retry
|
@@ -363,7 +406,7 @@ class JVM
|
|
363
406
|
with_socket(nil) do |socket|
|
364
407
|
action = mode == :reload ? 'quit' : 'force-quit'
|
365
408
|
log(mode, "sending #{action} to #{type} jvm on port #{port}") if debug?
|
366
|
-
socket.write(":#{action}
|
409
|
+
socket.write(":#{action} {}")
|
367
410
|
if socket.eof?
|
368
411
|
log(mode, "#{type} jvm stopped") if restart?
|
369
412
|
reset!
|
@@ -400,7 +443,7 @@ class JVM
|
|
400
443
|
def ping
|
401
444
|
return unless enabled?
|
402
445
|
with_socket do |socket|
|
403
|
-
socket.write ":ping\n"
|
446
|
+
socket.write ":ping {}\n"
|
404
447
|
log($command, "#{type} jvm not running") unless socket.gets == "pong\n"
|
405
448
|
end
|
406
449
|
end
|
@@ -410,7 +453,7 @@ class JVM
|
|
410
453
|
load_history
|
411
454
|
loop do
|
412
455
|
with_socket do |socket|
|
413
|
-
socket.write %{:repl "#{REPL_PROMPT}"}
|
456
|
+
socket.write %{:repl #{$vars} "#{REPL_PROMPT}"}
|
414
457
|
while @ns = read_until_prompt(socket)
|
415
458
|
line = readline
|
416
459
|
return unless line
|
@@ -422,16 +465,38 @@ class JVM
|
|
422
465
|
save_history
|
423
466
|
end
|
424
467
|
|
468
|
+
def run(file = $script)
|
469
|
+
with_socket do |socket|
|
470
|
+
log(:run, "running file #{file}") if debug?
|
471
|
+
socket.write(":run #{$vars} #{file.inspect}")
|
472
|
+
socket.duplex($stdin, $stdout)
|
473
|
+
end
|
474
|
+
end
|
475
|
+
|
425
476
|
def eval(forms = $opts[:eval])
|
426
477
|
forms = forms.collect do |form|
|
427
478
|
form == '-' ? $stdin.gets(nil) : form
|
428
479
|
end.join(' ')
|
480
|
+
forms = "(doall (map println [#{forms}]))" if $opts[:p]
|
429
481
|
with_socket do |socket|
|
430
482
|
log(:eval, forms) if debug?
|
431
|
-
socket.write(
|
432
|
-
|
433
|
-
|
483
|
+
socket.write(":eval #{$vars} #{forms} :cake/EOF ")
|
484
|
+
socket.duplex($stdin, $stdout)
|
485
|
+
end
|
486
|
+
end
|
487
|
+
|
488
|
+
EOL = "EOL__#{rand}"
|
489
|
+
def filter(forms = $opts[:filter])
|
490
|
+
with_socket do |socket|
|
491
|
+
socket.write %(:filter #{$vars} "#{EOL}")
|
492
|
+
while line = $stdin.gets
|
493
|
+
socket.write [line, ~forms].to_clj
|
494
|
+
while (line = socket.gets)
|
495
|
+
break if line.start_with?(EOL)
|
496
|
+
puts line
|
497
|
+
end
|
434
498
|
end
|
499
|
+
socket.close_write
|
435
500
|
end
|
436
501
|
end
|
437
502
|
|
@@ -442,12 +507,9 @@ private
|
|
442
507
|
end
|
443
508
|
|
444
509
|
def inspect(socket)
|
445
|
-
line = socket.gets
|
446
|
-
|
510
|
+
while line = socket.gets
|
511
|
+
break if line.start_with?('reload-failed:') and not debug?
|
447
512
|
puts line
|
448
|
-
while line = socket.gets
|
449
|
-
puts line
|
450
|
-
end
|
451
513
|
end
|
452
514
|
end
|
453
515
|
|
@@ -492,40 +554,25 @@ private
|
|
492
554
|
end
|
493
555
|
end
|
494
556
|
|
495
|
-
def read_until_prompt(socket
|
557
|
+
def read_until_prompt(socket)
|
496
558
|
prompt = nil
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
$stdout.print line
|
504
|
-
$stdout.flush
|
505
|
-
end
|
559
|
+
socket.duplex($stdin, $stdout, 3) do |line|
|
560
|
+
if line =~ /^(.*)#{REPL_PROMPT}(.*)$/
|
561
|
+
prompt = $1.empty? ? $2 : "#{$1}\n#{$2}"
|
562
|
+
nil
|
563
|
+
else
|
564
|
+
line
|
506
565
|
end
|
507
|
-
break if prompt
|
508
|
-
|
509
|
-
while $stdin.ready?
|
510
|
-
socket.puts($stdin.gets)
|
511
|
-
end if read_timeout <= 0
|
512
566
|
end
|
513
567
|
prompt
|
514
568
|
end
|
515
569
|
|
516
|
-
def
|
517
|
-
return
|
570
|
+
def complete?(input)
|
571
|
+
return true if input.empty?
|
518
572
|
with_socket do |socket|
|
519
|
-
socket.write(":validate #{input.join("\n").strip}")
|
573
|
+
socket.write(":validate {} #{input.join("\n").strip}")
|
520
574
|
socket.close_write # send eof
|
521
|
-
|
522
|
-
|
523
|
-
return if results == "incomplete\n"
|
524
|
-
if results == "invalid\n"
|
525
|
-
input.join(' ').strip
|
526
|
-
else
|
527
|
-
results.strip
|
528
|
-
end
|
575
|
+
socket.gets != "incomplete\n"
|
529
576
|
end
|
530
577
|
end
|
531
578
|
|
@@ -536,9 +583,9 @@ private
|
|
536
583
|
Readline.completion_proc = method(:completions)
|
537
584
|
while line = Readline.readline(prompt)
|
538
585
|
input << line
|
539
|
-
if
|
540
|
-
Readline::HISTORY.push(
|
541
|
-
return
|
586
|
+
if complete?(input)
|
587
|
+
Readline::HISTORY.push(input.join(' '))
|
588
|
+
return input.join("\n")
|
542
589
|
end
|
543
590
|
prompt[-2] = ?*
|
544
591
|
end
|
@@ -551,7 +598,7 @@ private
|
|
551
598
|
def completions(prefix)
|
552
599
|
return [] if prefix.empty?
|
553
600
|
with_socket do |socket|
|
554
|
-
socket.write
|
601
|
+
socket.write ~[:completions, {}, ~[prefix, ~@ns]]
|
555
602
|
completions = []
|
556
603
|
while line = socket.gets
|
557
604
|
completions << line.chomp
|
@@ -565,33 +612,31 @@ class Cake < JVM
|
|
565
612
|
attr_accessor :bakeport
|
566
613
|
|
567
614
|
READLINE = "READLINE__#{rand}"
|
568
|
-
def send_command(command
|
615
|
+
def send_command(command)
|
569
616
|
with_restart { FileUtils.remove_dir("lib/dev", true) } if $win and [:deps, :clean].include?(command)
|
570
617
|
|
571
618
|
with_socket do |socket|
|
572
|
-
|
573
|
-
env = command == :run ? ('{' + ENV.collect {|k,v| "#{k.inspect} #{v.inspect}"}.join(' ') + '}') : 'nil'
|
574
|
-
cmd = %{[#{command} [#{args.join(' ')}] #{bakeport || 'nil'} "#{$pwd}" #{env}] "#{READLINE}"}
|
619
|
+
cmd = [command, bakeport, READLINE].to_clj
|
575
620
|
log(command, "sending: " + cmd) if debug?
|
576
|
-
socket.write(cmd)
|
577
|
-
|
621
|
+
socket.write("#{cmd} #{$vars}")
|
622
|
+
socket.duplex($stdin, $stdout) do |line|
|
578
623
|
if line =~ /^#{READLINE}(.*)$/
|
579
624
|
socket.write(prompt($1))
|
580
625
|
elsif line =~ /^@#{READLINE}(.*)$/
|
581
626
|
socket.write(prompt($1, :echo => false))
|
582
627
|
else
|
583
|
-
|
628
|
+
line
|
584
629
|
end
|
585
630
|
end
|
586
631
|
end
|
587
632
|
end
|
588
633
|
|
589
634
|
def files
|
590
|
-
super.concat ["
|
635
|
+
super.concat ["tasks.clj", "#{$home}/.cake/tasks.clj"]
|
591
636
|
end
|
592
637
|
|
593
638
|
def java_opts
|
594
|
-
[ENV['CAKE_JAVA_OPTS'], config['cake.java_opts'], super].compact.join(' ')
|
639
|
+
[ENV['CAKE_JAVA_OPTS'], $config['cake.java_opts'], super].compact.join(' ')
|
595
640
|
end
|
596
641
|
|
597
642
|
private
|
@@ -613,7 +658,7 @@ end
|
|
613
658
|
|
614
659
|
class Bake < JVM
|
615
660
|
def java_opts
|
616
|
-
[ENV['JAVA_OPTS'], config['project.java_opts'], super].compact.join(' ')
|
661
|
+
[ENV['JAVA_OPTS'], $config['project.java_opts'], super].compact.join(' ')
|
617
662
|
end
|
618
663
|
|
619
664
|
def enabled?
|
@@ -621,13 +666,53 @@ class Bake < JVM
|
|
621
666
|
end
|
622
667
|
end
|
623
668
|
|
669
|
+
#==================================
|
670
|
+
|
671
|
+
FileUtils.makedirs("#{$home}/.cake")
|
672
|
+
project_clj = "#{$home}/.cake/project.clj"
|
673
|
+
File.open(project_clj, 'w') do |file|
|
674
|
+
file.write <<END
|
675
|
+
(defproject global "0.0.0"
|
676
|
+
:description "Don't rename this project, though you can change the version to your heart's content."
|
677
|
+
:dependencies [[clojure "1.2.0-RC2"]
|
678
|
+
[clojure-contrib "1.2.0-RC2"]])
|
679
|
+
;;--------------------
|
680
|
+
;; This is the global cake project. What does that mean?
|
681
|
+
;; 1. This project is used whenever you run cake outside a project directory.
|
682
|
+
;; 2. Any dependencies specified here will be available in the global repl.
|
683
|
+
;; 3. Any dev-dependencies specified here will be available in all projects, though you
|
684
|
+
;; must run 'cake deps --global' manually when you change this file.
|
685
|
+
;; 4. Configuration options in ~/.cake/config are used in all projects.
|
686
|
+
;;--------------------
|
687
|
+
END
|
688
|
+
end unless File.exists?(project_clj)
|
689
|
+
|
690
|
+
parse_opts!
|
691
|
+
$script = File.expand_path($opts[:run].first) if $opts[:run]
|
692
|
+
$pwd = Dir.getwd
|
693
|
+
$bakedir = project_dir($pwd)
|
694
|
+
$cakedir = File.dirname(File.dirname(readlink(__FILE__)))
|
695
|
+
$repo = "http://clojars.org/repo/cake/cake"
|
696
|
+
$confdir = ".cake"
|
697
|
+
$config = Configuration.new("#{$home}/.cake/config", ".cake/config")
|
698
|
+
$vars = {:env => ENV.to_hash, :pwd => $pwd, :args => ARGV, :opts => $opts}.to_clj
|
699
|
+
|
700
|
+
Dir.chdir($bakedir)
|
701
|
+
FileUtils.makedirs($confdir)
|
702
|
+
|
703
|
+
if debug?
|
704
|
+
puts "config: #{$config.inspect}"
|
705
|
+
puts "vars: #{$vars}"
|
706
|
+
end
|
707
|
+
|
624
708
|
# Bootstrap cake dependencies.
|
625
709
|
lib = "#{$cakedir}/lib"
|
626
710
|
if File.exists?("#{$cakedir}/.gitignore") and File.exists?("#{$cakedir}/project.clj")
|
711
|
+
$version = IO.read("#{$cakedir}/project.clj").split("\n").first.match(/defproject cake \"(.*)\"/)[1]
|
627
712
|
if Dir["#{lib}/*.jar"].empty? or Dir["#{lib}/dev/*.jar"].empty?
|
628
713
|
# In a new git checkout, need to fetch dependencies.
|
629
714
|
begin
|
630
|
-
version =
|
715
|
+
version = $version
|
631
716
|
cakejar = get_cake(version, lib, :raise => true)
|
632
717
|
rescue OpenURI::HTTPError => e
|
633
718
|
version = current_version
|
@@ -643,26 +728,30 @@ else
|
|
643
728
|
bakejar = "#{lib}/bake.jar"
|
644
729
|
if File.exists?(cakejar) and File.exists?(bakejar)
|
645
730
|
# Inside a gem install.
|
731
|
+
$version = File.basename(File.dirname(lib)).split('-')[1]
|
646
732
|
cakepath = cakejar
|
647
733
|
bakepath = bakejar
|
648
734
|
else
|
649
735
|
# Naked script.
|
650
|
-
version = current_version
|
736
|
+
$version = current_version
|
651
737
|
cakepath = get_cake(version)
|
652
738
|
bakepath = extract(cakepath, "bake-#{version}.jar")
|
653
739
|
end
|
654
740
|
end
|
655
741
|
|
656
742
|
cake = Cake.new(
|
657
|
-
[cakepath, "src", "src/clj", config['cake.claspath'], "lib/dev/*", "#{$home}/.cake/lib/dev/*"],
|
658
|
-
[config['cake.library.path'], "lib/dev/native"]
|
743
|
+
[cakepath, "src", "src/clj", $config['cake.claspath'], "lib/dev/*", "#{$home}/.cake/lib/dev/*"],
|
744
|
+
[$config['cake.library.path'], "lib/dev/native"]
|
659
745
|
)
|
660
746
|
bake = Bake.new(
|
661
|
-
[bakepath, "src", "src/clj", "classes", "test", config['project.classpath'], "lib/*", "lib/dev/*", "#{$home}/.cake/lib/dev/*"],
|
662
|
-
[config['project.library.path'], "lib/native", "lib/dev/native"]
|
747
|
+
[bakepath, "src", "src/clj", "classes", "test", $config['project.classpath'], "lib/*", "lib/dev/*", "#{$home}/.cake/lib/dev/*"],
|
748
|
+
[$config['project.library.path'], "lib/native", "lib/dev/native"]
|
663
749
|
)
|
664
750
|
|
665
|
-
if $command == :
|
751
|
+
if $command == :default and $opts[:version]
|
752
|
+
puts "cake #{$version}"
|
753
|
+
exit
|
754
|
+
elsif $command == :kill
|
666
755
|
if $opts[:all]
|
667
756
|
ps.each do |line|
|
668
757
|
pid = line.split(' ').first.to_i
|
@@ -686,19 +775,15 @@ cake.init
|
|
686
775
|
if [:deps, :clean].include?($command)
|
687
776
|
bake.stop
|
688
777
|
elsif File.exists?('project.clj')
|
689
|
-
if
|
690
|
-
bake.stop
|
778
|
+
if not bake.enabled?
|
691
779
|
cake.send_command(:deps)
|
692
780
|
cake.init
|
693
|
-
elsif config['swank.auto-start'] or config['swank']
|
694
|
-
cake.send_command(:"swank-deps")
|
695
|
-
cake.init
|
696
781
|
end
|
697
782
|
|
698
783
|
bake.init
|
699
784
|
end
|
700
785
|
|
701
|
-
if [:repl, :eval].include?($command)
|
786
|
+
if [:repl, :eval, :filter, :run].include?($command)
|
702
787
|
if $opts[:cake] or not File.exists?('project.clj')
|
703
788
|
cake.send($command)
|
704
789
|
else
|
@@ -717,7 +802,7 @@ else
|
|
717
802
|
if $command == :autotest
|
718
803
|
cake.send_command(:autotest)
|
719
804
|
interval = $opts[:autotest].last.to_i if $opts[:autotest]
|
720
|
-
interval = interval || (config['autotest.interval'].to_i if config['autotest.interval']) || 1
|
805
|
+
interval = interval || ($config['autotest.interval'].to_i if $config['autotest.interval']) || 1
|
721
806
|
run_tests = true
|
722
807
|
ran = false
|
723
808
|
while true
|
@@ -732,6 +817,6 @@ else
|
|
732
817
|
sleep(interval)
|
733
818
|
end
|
734
819
|
else
|
735
|
-
cake.send_command($command
|
820
|
+
cake.send_command($command)
|
736
821
|
end
|
737
822
|
end
|
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: 15
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 4
|
9
|
+
- 0
|
10
|
+
version: 0.4.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-08-
|
19
|
+
date: 2010-08-18 00:00:00 -07:00
|
20
20
|
default_executable: cake
|
21
21
|
dependencies: []
|
22
22
|
|