cake 0.3.11 → 0.3.12
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 +78 -50
- data/lib/bake.jar +0 -0
- data/lib/cake.jar +0 -0
- metadata +4 -4
data/bin/cake
CHANGED
@@ -15,6 +15,7 @@ if RUBY_PLATFORM =~ /(mingw|mswin)(32|64)$/
|
|
15
15
|
KILL = 'KILL'
|
16
16
|
PATH_SEP = ';'
|
17
17
|
$home = ENV['HOMEDRIVE'] + ENV['HOMEPATH']
|
18
|
+
$win = true
|
18
19
|
|
19
20
|
def daemon(cmd)
|
20
21
|
Process.create(:app_name => cmd).process_id
|
@@ -65,18 +66,53 @@ class IO
|
|
65
66
|
end
|
66
67
|
end
|
67
68
|
|
69
|
+
def add_opt!(key, *vals)
|
70
|
+
($opts[key.to_sym] ||= []).concat vals
|
71
|
+
end
|
72
|
+
|
73
|
+
def parse_opts!
|
74
|
+
ARGV.unshift('run', '--global') if ARGV.first.index('/')
|
75
|
+
ARGV.unshift('default') if ARGV.empty? or ARGV.first[0,1] == '-'
|
76
|
+
$command = ARGV.shift.to_sym
|
77
|
+
$opts = {}
|
78
|
+
ARGV.each do |opt|
|
79
|
+
case opt
|
80
|
+
when /^-(\w*)$/ then $1.split('').each {|c| add_opt!(c, '')}
|
81
|
+
when /^--?([-\w]*)=([\S]+)$/ then add_opt!($1, *$2.split(','))
|
82
|
+
when /^--?([-\w]*)$/ then add_opt!($1, "")
|
83
|
+
else add_opt!($command, opt)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
$opts.freeze
|
87
|
+
end
|
88
|
+
parse_opts!
|
89
|
+
|
68
90
|
GLOBAL_DEFAULT_PROJECT = <<END
|
69
|
-
(defproject global "0.0.0"
|
70
|
-
:description "
|
91
|
+
(defproject global "0.0.0"
|
92
|
+
:description "Don't rename this project, though you can change the version to your heart's content."
|
71
93
|
:dependencies [[clojure "1.2.0-RC2"]
|
72
94
|
[clojure-contrib "1.2.0-RC2"]])
|
95
|
+
;;--------------------
|
96
|
+
;; This is the global cake project. What does that mean?
|
97
|
+
;; 1. This project is used whenever you run cake outside a project directory.
|
98
|
+
;; 2. Any dependencies specified here will be available in the global repl.
|
99
|
+
;; 3. Any dev-dependencies specified here will be available in all projects, though you
|
100
|
+
;; must run 'cake deps --global' manually when you change this file.
|
101
|
+
;; 4. Configuration options in ~/.cake/config are used in all projects.
|
102
|
+
;;--------------------
|
73
103
|
END
|
74
104
|
|
75
105
|
def project_dir(dir)
|
106
|
+
if $opts[:project] and not $opts[:global]
|
107
|
+
project = $opts[:project].last
|
108
|
+
raise "project dir #{project} does not exist" unless File.exists?(project)
|
109
|
+
return project
|
110
|
+
end
|
111
|
+
|
76
112
|
while dir != File.dirname(dir)
|
77
113
|
return dir if ["project.clj", "tasks.clj"].any? {|file| File.exists?("#{dir}/#{file}")}
|
78
114
|
dir = File.dirname(dir)
|
79
|
-
end
|
115
|
+
end unless $opts[:global]
|
80
116
|
project_dir = "#{$home}/.cake"
|
81
117
|
project_clj = "#{project_dir}/project.clj"
|
82
118
|
FileUtils.makedirs(project_dir) unless File.exists?(project_dir)
|
@@ -86,7 +122,7 @@ end
|
|
86
122
|
|
87
123
|
def readlink(file)
|
88
124
|
File.readlink(file)
|
89
|
-
rescue NotImplementedError
|
125
|
+
rescue NotImplementedError, Errno::EINVAL
|
90
126
|
file
|
91
127
|
end
|
92
128
|
|
@@ -104,7 +140,7 @@ def get_cake(version, dest = nil, opts = {})
|
|
104
140
|
path = "#{repo}/#{jar}"
|
105
141
|
|
106
142
|
if not File.exists?(path)
|
107
|
-
log(:deps, "fetching cake libraries. this may take a moment...")
|
143
|
+
log(:deps, "fetching cake libraries. this may take a moment...") unless @logged; @logged = true
|
108
144
|
url = "#{$repo}/#{version}/#{jar}"
|
109
145
|
log(:deps, "downloading #{url}") if verbose?
|
110
146
|
FileUtils.makedirs(repo)
|
@@ -162,26 +198,6 @@ def newer?(file1, file2)
|
|
162
198
|
not File.exists?(file2) or test(?>, file1, file2)
|
163
199
|
end
|
164
200
|
|
165
|
-
def add_opt!(key, *vals)
|
166
|
-
($opts[key.to_sym] ||= []).concat vals
|
167
|
-
end
|
168
|
-
|
169
|
-
def parse_opts!
|
170
|
-
ARGV.unshift('default') if ARGV.empty? or ARGV.first[0,1] == '-'
|
171
|
-
$command = ARGV.shift.to_sym
|
172
|
-
$opts = {}
|
173
|
-
ARGV.each do |opt|
|
174
|
-
case opt
|
175
|
-
when /^-(\w*)$/ then $1.split('').each {|c| add_opt!(c, '')}
|
176
|
-
when /^--?([-\w]*)=([-,\w]+)$/ then add_opt!($1, *$2.split(','))
|
177
|
-
when /^--?([-\w]*)$/ then add_opt!($1, "")
|
178
|
-
else add_opt!($command, opt)
|
179
|
-
end
|
180
|
-
end
|
181
|
-
$opts.freeze
|
182
|
-
end
|
183
|
-
parse_opts!
|
184
|
-
|
185
201
|
def debug?
|
186
202
|
ENV['CAKE_DEBUG'] or $opts[:d] or $opts[:debug]
|
187
203
|
end
|
@@ -190,10 +206,6 @@ def verbose?
|
|
190
206
|
debug? or $opts[:v] or $opts[:verbose]
|
191
207
|
end
|
192
208
|
|
193
|
-
def config_updated?
|
194
|
-
newer?(".cake/config", ".cake/cake.pid") or (File.exists?(".cake/bake.pid") and newer?(".cake/config", ".cake/bake.pid"))
|
195
|
-
end
|
196
|
-
|
197
209
|
def restart?
|
198
210
|
$opts[:r] or $opts[:restart] or [:stop, :restart].include?($command)
|
199
211
|
end
|
@@ -209,15 +221,17 @@ def log(command, *message)
|
|
209
221
|
end
|
210
222
|
|
211
223
|
class Configuration < Hash
|
212
|
-
def initialize(
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
224
|
+
def initialize(*paths)
|
225
|
+
paths.each do |path|
|
226
|
+
File.open(path, 'r') do |file|
|
227
|
+
file.each do |line|
|
228
|
+
next if ['#', '!'].include?(line[0,1])
|
229
|
+
key, value = line.split('=', 2)
|
230
|
+
next unless key and value
|
231
|
+
self[key.strip] = value.strip
|
232
|
+
end
|
233
|
+
end if File.exists?(path)
|
234
|
+
end
|
221
235
|
end
|
222
236
|
|
223
237
|
def [](*keys)
|
@@ -231,7 +245,7 @@ class Configuration < Hash
|
|
231
245
|
end
|
232
246
|
|
233
247
|
def config
|
234
|
-
@config ||= Configuration.new(".cake/config")
|
248
|
+
@config ||= Configuration.new("#{$home}/.cake/config", ".cake/config")
|
235
249
|
end
|
236
250
|
|
237
251
|
def ps
|
@@ -278,6 +292,12 @@ class JVM
|
|
278
292
|
init
|
279
293
|
end
|
280
294
|
|
295
|
+
def with_restart
|
296
|
+
stop
|
297
|
+
yield
|
298
|
+
start
|
299
|
+
end
|
300
|
+
|
281
301
|
def reload_stale_files
|
282
302
|
stale_files = files.select {|f| stale?(f)}
|
283
303
|
|
@@ -292,7 +312,7 @@ class JVM
|
|
292
312
|
stop(:reload)
|
293
313
|
else
|
294
314
|
log(:reload, "clojure #{type} files have changed, reloading") if verbose?
|
295
|
-
with_socket(
|
315
|
+
with_socket(nil) do |socket|
|
296
316
|
stale_files = stale_files.collect {|f| %{"#{f}"} }
|
297
317
|
socket.write ":reload [#{stale_files.join(" ")}]\n"
|
298
318
|
if socket.eof?
|
@@ -334,7 +354,8 @@ class JVM
|
|
334
354
|
end
|
335
355
|
|
336
356
|
def stop(mode = :stop)
|
337
|
-
|
357
|
+
return unless running?
|
358
|
+
with_socket(nil) do |socket|
|
338
359
|
action = mode == :reload ? 'quit' : 'force-quit'
|
339
360
|
log(mode, "sending #{action} to #{type} jvm on port #{port}") if debug?
|
340
361
|
socket.write(":#{action}\n")
|
@@ -357,7 +378,7 @@ class JVM
|
|
357
378
|
end
|
358
379
|
|
359
380
|
def files
|
360
|
-
files = ["project.clj"]
|
381
|
+
files = ["project.clj", "#{$home}/.cake/config", ".cake/config"]
|
361
382
|
classpath.split(PATH_SEP).uniq.each do |path|
|
362
383
|
if path =~ /(.*)\/\*$/
|
363
384
|
files.concat Dir["#{path}.jar"] << "#{$1}/." # include the directory itself so deletions will be detected
|
@@ -440,9 +461,11 @@ private
|
|
440
461
|
result
|
441
462
|
rescue Errno::ECONNREFUSED, Errno::EBADF => e
|
442
463
|
sleep 1
|
443
|
-
|
444
|
-
|
445
|
-
|
464
|
+
if retries
|
465
|
+
retry if (retries -= 1) >= 0
|
466
|
+
log($command, "timeout while connecting to #{type} jvm")
|
467
|
+
exit
|
468
|
+
end
|
446
469
|
ensure
|
447
470
|
socket.close if socket
|
448
471
|
end
|
@@ -536,6 +559,8 @@ class Cake < JVM
|
|
536
559
|
|
537
560
|
READLINE = "READLINE__#{rand}"
|
538
561
|
def send_command(command, args = [])
|
562
|
+
with_restart { FileUtils.remove_dir("lib/dev", true) } if $win and [:deps, :clean].include?(command)
|
563
|
+
|
539
564
|
with_socket do |socket|
|
540
565
|
args = args.collect{|arg| '"' + arg.gsub('"', '\"').gsub("\n", "\\n") + '"'}
|
541
566
|
env = command == :run ? ('{' + ENV.collect {|k,v| "#{k.inspect} #{v.inspect}"}.join(' ') + '}') : 'nil'
|
@@ -622,11 +647,11 @@ else
|
|
622
647
|
end
|
623
648
|
|
624
649
|
cake = Cake.new(
|
625
|
-
[cakepath, "src", "src/clj", config['cake.claspath'], "lib/dev/*"],
|
650
|
+
[cakepath, "src", "src/clj", config['cake.claspath'], "lib/dev/*", "#{$home}/.cake/lib/dev/*"],
|
626
651
|
[config['cake.library.path'], "lib/dev/native"]
|
627
652
|
)
|
628
653
|
bake = Bake.new(
|
629
|
-
[bakepath, "src", "src/clj", "classes", "test", config['project.classpath'], "lib/*", "lib/dev/*"],
|
654
|
+
[bakepath, "src", "src/clj", "classes", "test", config['project.classpath'], "lib/*", "lib/dev/*", "#{$home}/.cake/lib/dev/*"],
|
630
655
|
[config['project.library.path'], "lib/native", "lib/dev/native"]
|
631
656
|
)
|
632
657
|
|
@@ -644,15 +669,18 @@ if $command == :kill
|
|
644
669
|
elsif $command == :ps
|
645
670
|
puts ps.sort.reverse
|
646
671
|
exit
|
647
|
-
elsif restart?
|
672
|
+
elsif restart?
|
648
673
|
cake.stop
|
649
674
|
bake.stop
|
650
675
|
exit if $command == :stop
|
651
676
|
end
|
652
677
|
|
653
678
|
cake.init
|
654
|
-
if
|
655
|
-
|
679
|
+
if [:deps, :clean].include?($command)
|
680
|
+
bake.stop
|
681
|
+
elsif File.exists?('project.clj')
|
682
|
+
if newer?('project.clj', 'pom.xml') or not bake.enabled?
|
683
|
+
bake.stop
|
656
684
|
cake.send_command(:deps)
|
657
685
|
cake.init
|
658
686
|
elsif config['swank.auto-start'] or config['swank']
|
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: 11
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 12
|
10
|
+
version: 0.3.12
|
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-12 00:00:00 -07:00
|
20
20
|
default_executable: cake
|
21
21
|
dependencies: []
|
22
22
|
|