Class: Raven::JarSourceTask

Inherits:
Rake::Task
  • Object
show all
Defined in:
lib/raven/java_tasks.rb

Overview

Builds a jar file from your sources. Customized by adding directories to the source_path just like the JavacTask.

Instance Method Summary collapse

Instance Method Details

#executeObject



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
# File 'lib/raven/java_tasks.rb', line 150

def execute
  super
  # Checking if any of our prerequisites is a JavacTask, if
  # so we'll just use the build path to construct the jar.
  Raven.prereq_filter(prerequisites, :build_path) do |javac_task|
   (@source_path ||= []) << javac_task.build_path
  end
  
  # Initializing source path
  @source_path = ["src/main/java"] unless @source_path
  @source_path.flatten!
  
  latest = Time.at(0)
  @source_path.each do |dir|
    dir_latest = Raven.latest_file(dir)
    latest = dir_latest if dir_latest > latest
  end
  
  # Manifest inclusion
  mfest_param = @manifest ? "-m #{@manifest}" : ""
  
  # Building the jar from all sources
  if !File.exist?("target/#{name}") || File.stat("target/#{name}").mtime < latest
    `jar -cf target/#{name} #{mfest_param} -C #{@source_path.pop} .`
    while (p = @source_path.pop)
      `jar -uf target/#{name} -C #{p} .`
    end
  end
end

#manifest=(f) ⇒ Object



184
185
186
# File 'lib/raven/java_tasks.rb', line 184

def manifest=(f)
  @manifest = f
end

#source_pathObject



180
181
182
# File 'lib/raven/java_tasks.rb', line 180

def source_path
  @source_path ||= []
end