Author: assaf
Date: Fri Feb 1 12:23:54 2008
New Revision: 617633
URL: http://svn.apache.org/viewvc?rev=617633&view=rev
Log:
Compiler now honors custom layouts
Modified:
incubator/buildr/trunk/lib/core/application.rb
incubator/buildr/trunk/lib/core/compile.rb
Modified: incubator/buildr/trunk/lib/core/application.rb
URL:
http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/core/application.rb?rev=617633&r1=617632&r2=617633&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/core/application.rb (original)
+++ incubator/buildr/trunk/lib/core/application.rb Fri Feb 1 12:23:54 2008
@@ -45,6 +45,7 @@
collect_tasks
top_level_tasks.unshift 'buildr:initialize'
end
+
def run()
times = Benchmark.measure do
standard_exception_handling do
@@ -106,11 +107,23 @@
load_imports
end
+ def collect_tasks
+ @top_level_tasks = []
+ ARGV.each do |arg|
+ if arg =~ /^(\w+)=(.*)$/
+ ENV[$1.upcase] = $2
+ else
+ @top_level_tasks << arg
+ end
+ end
+ @top_level_tasks.push("default") if @top_level_tasks.size == 0
+ end
+
def usage()
puts "Buildr #{Buildr::VERSION} #{RUBY_PLATFORM[/java/] && '(JRuby)'}"
puts
puts 'Usage:'
- puts ' buildr [-f buildfile] {options} targets...'
+ puts ' buildr [options] [tasks] [name=value]'
end
def help()
Modified: incubator/buildr/trunk/lib/core/compile.rb
URL:
http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/core/compile.rb?rev=617633&r1=617632&r2=617633&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/core/compile.rb (original)
+++ incubator/buildr/trunk/lib/core/compile.rb Fri Feb 1 12:23:54 2008
@@ -64,7 +64,8 @@
# directories. For example, Javac returns true if any of the source
directories contains
# a .java file. The default implementation looks to see if there are
any files in the
# specified path with the extension #source_ext.
- def applies_to?(paths)
+ def applies_to?(project, task)
+ paths = task.sources + Array(project.path_to(:source, task.usage,
sources.to_sym))
paths.any? { |path| !Dir["#{path}/**/*.#{source_ext}"].empty? }
end
@@ -298,7 +299,7 @@
# a specific compiler (see #using).
def compiler
unless @compiler
- candidate = Compiler.compilers.detect { |cls| cls.applies_to?(sources)
}
+ candidate = Compiler.compilers.detect { |cls| cls.applies_to?(project,
self) }
self.compiler = candidate if candidate
end
@compiler && @compiler.class.to_sym
@@ -323,6 +324,9 @@
# The project this task belongs to.
attr_reader :project
+ # The usage, one of :main or :test.
+ attr_reader :usage
+
protected
# Selects which compiler to use.
@@ -331,9 +335,9 @@
return self if cls === @compiler
raise "#{compiler} compiler already selected for this project" if
@compiler
@compiler = cls.new(project, options)
- from Array(cls.sources).map { |path| @project.path_to(:source, @usage,
path) }.
+ from Array(cls.sources).map { |path| project.path_to(:source, usage,
path) }.
select { |path| File.exist?(path) } if sources.empty?
- into @project.path_to(:target, @usage, cls.target) unless target
+ into project.path_to(:target, usage, cls.target) unless target
with Array(@compiler.dependencies)
self
end
@@ -342,8 +346,7 @@
def associate_with(project, usage) #:nodoc:
@project, @usage = project, usage
# Try to guess if we have a compiler to match source files.
- candidate = Compiler.compilers.detect { |cls|
- cls.applies_to?(Array(cls.sources).map { |path|
@project.path_to(:source, @usage, path) }) }
+ candidate = Compiler.compilers.detect { |cls| cls.applies_to?(project,
self) }
self.compiler = candidate if candidate
end