-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRakefile
More file actions
179 lines (157 loc) · 5.88 KB
/
Copy pathRakefile
File metadata and controls
179 lines (157 loc) · 5.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
require 'rake/clean'
require 'ant'
CLEAN.include 'dist', 'build', 'src/**/rb' # Clean all compiled Ruby sources
CLOBBER.include 'doc'
desc "Migrates an existing website folder into a gh-pages branch, and links back as submodule"
task :migrate_website do
current_branch = `git branch | grep "^*" | sed -e "s/* //"`.strip
repo = `git config --list | grep "^remote.origin.url" | sed -e "s/remote.origin.url=//"`.strip
website_folder = ENV['WEBSITE_PATH'] || 'website'
tmp_folder = "/tmp/gh-pages-website"
puts "Moving #{website_folder} folder to branch gh-pages."
puts "Working in #{current_branch} branch of #{repo}:"
commands = <<-CMD.gsub(/^ /, '')
rm -rf #{tmp_folder}
mv #{website_folder} #{tmp_folder}
git commit -a -m "temporarily removing #{website_folder} whilst moving to gh-pages branch"
git symbolic-ref HEAD refs/heads/gh-pages
rm .git/index
git clean -fdx
cp -R #{tmp_folder}/* .
git add .
git commit -a -m 'Import original #{website_folder} folder from #{current_branch} branch'
git push origin gh-pages
git checkout #{current_branch}
git submodule add -b gh-pages #{repo} #{website_folder}
git commit -a -m "migrated #{website_folder} -> gh-pages branch, and replaced with submodule link"
git push
CMD
commands.split(/\n/).each { |cmd| sh cmd }
end
namespace :ant do
md_dir = "#{ENV["HOME"]}/.moneydance" # Moneydance user directory
features = "#{md_dir}/fmodules/" # Features directory
src = "src" # Java sources directory
lib = "lib" # Ruby sources directory
jars = "jars" # Jar dependensies directory
doc = "doc" # Javadocs directory
misc = "misc" # Misc files directory
dist = "dist" # Final product directory
build = "build" # Class files directory
build_compiler = "classic"
build_compiler_fulldepend = "true"
privkeyfile = "#{misc}/priv_key"
pubkeyfile = "#{misc}/pub_key"
privkeyid = "99"
debug = "on"
optimize = "off"
# TODO: OSX-specific, need to generalize
md_command = "/Applications/Moneydance.app/Contents/MacOS/JavaApplicationStub " +
"-invoke_and_quit moneydance:fmodule:ruby:irb" #runfile?=networth.py"
tail_command = "iterm tail -f #{md_dir}/errlog.txt"
def fileset_with src, build
fileset :dir => src, :includes =>
"com/moneydance/modules/features/ruby/meta_info.dict,
com/moneydance/modules/features/ruby/*.gif,
com/moneydance/modules/features/ruby/*.jpg,
com/moneydance/modules/features/ruby/*.jpeg"
fileset :dir => build, :includes => "com/moneydance/modules/features/ruby/**"
end
def classpath_with jars
classpath do
fileset :dir => jars, :includes => "*.jar"
end
end
directory doc
directory build
directory dist
desc 'Build the documentation'
task :javadoc => doc do
ant.javadoc :sourcefiles => FileList["#{src}/**/*.java"], :destdir => doc do
classpath_with jars
end
end
desc 'Compile Ruby sources'
task :compile_ruby => [:clean, build] do
sh "jrubyc -t #{src} --java #{lib}/**/*.rb"
end
desc 'Compile Java sources'
task :compile_java => [:clean, build] do
puts "Compiling in #{src}"
ant.javac :srcdir => src, :destdir => build, :target =>"1.6",
:debug => debug, :optimize => optimize,
:includes => "com/moneydance/modules/features/ruby/**" do
classpath_with jars
end
end
desc 'Compile all sources'
task :compile => [:compile_ruby, :compile_java]
desc 'Default jar method'
task :jar => 'jar:update'
namespace :jar do
desc 'Build jar bundle (jruby-complete is bundled into jar with your code)'
task :bundle => [:compile, dist] do
ant.jar :destfile => "#{dist}/ruby.mxt" do
fileset_with src, build
zipfileset :src => "jars/jruby-complete.jar"
end
end
desc 'Update jruby-complete jar (your code is mixed into jruby-complete)'
task :update => [:compile, dist] do
ant.copy :file => "jars/jruby-complete.jar", :tofile => "#{dist}/jruby-complete.jar"
ant.jar :destfile => "#{dist}/jruby-complete.jar", :update => true do
fileset_with src, build
end
ant.move :file => "#{dist}/jruby-complete.jar", :tofile => "#{dist}/ruby.mxt"
end
# Fails with NoClassDefFoundError
desc 'Separate jar (jruby-complete and your code as two separate jars)'
task :separate => [:compile, dist] do
ant.jar :destfile => "#{dist}/ruby.mxt" do
# ant.jar :destfile => "#{dist}/ruby.mxt", :manifest => "small.manifest" do
fileset_with src, build
end
ant.copy :file => "jars/jruby-complete.jar", :tofile => "#{dist}/jruby-complete.jar"
end
# Fails on load with NullPointerException
desc 'Extract and repack jruby-complete with your code (via shell commands, not ant)'
task :repack => [:compile, dist] do
# Extract jruby-complete so we can combine it with the app
Dir.chdir(build) do
sh 'jar -xf ../jars/jruby-complete.jar'
end
sh "jar -cfm #{dist}/ruby.mxt #{misc}/small.manifest -C #{build} ."
end
end
desc 'Sign jar package'
task :sign => :jar do
ant.java :newenvironment => "true",
:classname => "com.moneydance.admin.KeyAdmin" do
classpath_with jars
arg :value => "signextjar"
arg :value => privkeyfile
arg :value => privkeyid
arg :value => "ruby"
arg :line => "#{dist}/ruby.mxt"
end
ant.move :file => "s-ruby.mxt", :tofile => "#{dist}/ruby.mxt"
end
desc 'Load extension package into Moneydance'
task :load => :jar do
ant.copy :file => "#{dist}/ruby.mxt", :tofile => "#{features}/ruby.mxt"
sh "#{md_command}"
end
desc 'Start tracking Moneydance errors'
task :tail do
sh "#{tail_command}"
end
desc 'Generate keys'
task :genkeys do
ant.java :classname => "com.moneydance.admin.KeyAdmin" do
classpath_with jars
arg :value => "genkey"
arg :value => privkeyfile
arg :value => pubkeyfile
end
end
end