Class: RakeJava::JavacTask
- Inherits:
-
Rake::Task
- Object
- Rake::Task
- RakeJava::JavacTask
- Includes:
- RakeJavaUtil
- Defined in:
- lib/rakejava.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
Returns the value of attribute args.
-
#bootpath ⇒ Object
Returns the value of attribute bootpath.
-
#classpath ⇒ Object
Returns the value of attribute classpath.
-
#debug ⇒ Object
Returns the value of attribute debug.
-
#dest ⇒ Object
Returns the value of attribute dest.
-
#dest_ver ⇒ Object
Returns the value of attribute dest_ver.
-
#src ⇒ Object
Returns the value of attribute src.
-
#src_ver ⇒ Object
Returns the value of attribute src_ver.
Instance Method Summary collapse
- #changed_only(sources) ⇒ Object
- #execute(args = nil) ⇒ Object
-
#initialize(name, app) ⇒ JavacTask
constructor
A new instance of JavacTask.
- #src_files ⇒ Object
Methods included from RakeJavaUtil
#path_esc, #path_sep, #popd, #pushd, #pushd_stack, #separate, #space_sep
Constructor Details
#initialize(name, app) ⇒ JavacTask
Returns a new instance of JavacTask.
116 117 118 119 120 121 122 |
# File 'lib/rakejava.rb', line 116 def initialize name, app super @src = [] @srcpath = [] @bootpath = [] @classpath = [] end |
Instance Attribute Details
#args ⇒ Object
Returns the value of attribute args.
113 114 115 |
# File 'lib/rakejava.rb', line 113 def args @args end |
#bootpath ⇒ Object
Returns the value of attribute bootpath.
113 114 115 |
# File 'lib/rakejava.rb', line 113 def bootpath @bootpath end |
#classpath ⇒ Object
Returns the value of attribute classpath.
113 114 115 |
# File 'lib/rakejava.rb', line 113 def classpath @classpath end |
#debug ⇒ Object
Returns the value of attribute debug.
114 115 116 |
# File 'lib/rakejava.rb', line 114 def debug @debug end |
#dest ⇒ Object
Returns the value of attribute dest.
113 114 115 |
# File 'lib/rakejava.rb', line 113 def dest @dest end |
#dest_ver ⇒ Object
Returns the value of attribute dest_ver.
114 115 116 |
# File 'lib/rakejava.rb', line 114 def dest_ver @dest_ver end |
#src ⇒ Object
Returns the value of attribute src.
113 114 115 |
# File 'lib/rakejava.rb', line 113 def src @src end |
#src_ver ⇒ Object
Returns the value of attribute src_ver.
114 115 116 |
# File 'lib/rakejava.rb', line 114 def src_ver @src_ver end |
Instance Method Details
#changed_only(sources) ⇒ Object
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
# File 'lib/rakejava.rb', line 166 def changed_only sources # Retuns the files that have newer .java files than .class files changed = [] sources.each do |src_file| mod_time = File.mtime(src_file) base = File.basename(src_file, ".java") parent = File.dirname(src_file) classfiles = [] if @dest base_path = parent[sources.root.length+1..-1] classfiles = Dir["#{@dest}/#{base_path}/#{base}*.class"] else # Look next to it classfiles = Dir["#{parent}/#{base}*.class"] end unless classfiles.empty? classfiles.each do |classfile| if File.mtime(classfile) < mod_time changed << src_file break end end else changed << src_file end end changed end |
#execute(args = nil) ⇒ Object
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 |
# File 'lib/rakejava.rb', line 124 def execute args=nil super files = src_files unless files.empty? srcpath = @src.map { |src| src.root } cmd = "javac" cmd << " -bootclasspath #{path_sep(@bootpath)}" unless @bootpath.empty? cmd << " #{@args}" if @args cmd << " -classpath #{path_sep(@classpath)}" unless @classpath.empty? cmd << " -g" if @debug cmd << " -source #{@src_ver}" if @src_ver cmd << " -target #{@dest_ver}" if @dest_ver cmd << " -sourcepath #{path_sep(srcpath)}" if srcpath cmd << " -d #{@dest}" if @dest cmd << " #{space_sep(files)}" max_cmd_len = 500 if cmd.length < max_cmd_len puts cmd else puts cmd[0..max_cmd_len] + "..." end puts "Compiling #{files.length} file(s)" puts `#{cmd}` else puts "No files to compile" end end |
#src_files ⇒ Object
156 157 158 159 160 161 162 163 164 |
# File 'lib/rakejava.rb', line 156 def src_files files = [] @src.each do |source| files << changed_only(source) end files.flatten end |