You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildr.apache.org by as...@apache.org on 2008/01/02 07:30:19 UTC
svn commit: r608023 - in /incubator/buildr/trunk: ./ lib/ lib/buildr/
lib/core/ lib/ide/ lib/java/ spec/
Author: assaf
Date: Tue Jan 1 22:30:09 2008
New Revision: 608023
URL: http://svn.apache.org/viewvc?rev=608023&view=rev
Log:
Added: Layout class for controlling the project layout. Also cleaned up places where paths were used instead of path names.
Modified:
incubator/buildr/trunk/CHANGELOG
incubator/buildr/trunk/Rakefile
incubator/buildr/trunk/lib/buildr.rb
incubator/buildr/trunk/lib/buildr/antlr.rb
incubator/buildr/trunk/lib/buildr/cobertura.rb
incubator/buildr/trunk/lib/buildr/hibernate.rb
incubator/buildr/trunk/lib/buildr/javacc.rb
incubator/buildr/trunk/lib/buildr/openjpa.rb
incubator/buildr/trunk/lib/buildr/xmlbeans.rb
incubator/buildr/trunk/lib/core/build.rb
incubator/buildr/trunk/lib/core/compile.rb
incubator/buildr/trunk/lib/core/project.rb
incubator/buildr/trunk/lib/core/test.rb
incubator/buildr/trunk/lib/ide/eclipse.rb
incubator/buildr/trunk/lib/ide/idea.rb
incubator/buildr/trunk/lib/java/compilers.rb
incubator/buildr/trunk/lib/java/packaging.rb
incubator/buildr/trunk/spec/build_spec.rb
incubator/buildr/trunk/spec/compile_spec.rb
incubator/buildr/trunk/spec/project_spec.rb
incubator/buildr/trunk/spec/sandbox.rb
Modified: incubator/buildr/trunk/CHANGELOG
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/CHANGELOG?rev=608023&r1=608022&r2=608023&view=diff
==============================================================================
--- incubator/buildr/trunk/CHANGELOG (original)
+++ incubator/buildr/trunk/CHANGELOG Tue Jan 1 22:30:09 2008
@@ -1,6 +1,7 @@
1.3.0 (Pending)
* Added: Mechanism to simplify creating extensions (see Extension module).
* Added: To run all test cases 'rake spec'. Test coverage reports will show up in html/coverage. To run failing tests against, 'rake failing'.
+* Added: Layout class for controlling the project layout. Also cleaned up places where paths were used instead of path names.
* Changed: Upgraded to Rake 0.8 and RSpec 1.1.
* Changed: Resources are now copied to target/resources instead of target/classes, and target/test/resources instead of target/test-resources.
* Changed: Test cases are not compiled into target/test/classes instead of target/test-classes.
Modified: incubator/buildr/trunk/Rakefile
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/Rakefile?rev=608023&r1=608022&r2=608023&view=diff
==============================================================================
--- incubator/buildr/trunk/Rakefile (original)
+++ incubator/buildr/trunk/Rakefile Tue Jan 1 22:30:09 2008
@@ -28,17 +28,17 @@
spec.executables = ['buildr']
# Tested against these dependencies.
- spec.add_dependency 'rake', '= 0.8.0'
- spec.add_dependency 'facets', '= 1.8.54'
- spec.add_dependency 'builder', '= 2.1.2'
- spec.add_dependency 'net-ssh', '= 1.1.2'
- spec.add_dependency 'net-sftp', '= 1.1.0'
- spec.add_dependency 'rubyzip', '= 0.9.1'
- spec.add_dependency 'highline', '= 1.4.0'
- spec.add_dependency 'Antwrap', '= 0.6.0'
- spec.add_dependency 'rspec', '= 1.1.1'
- spec.add_dependency 'xml-simple', '= 1.0.11'
- spec.add_dependency 'archive-tar-minitar', '= 0.5.1'
+ spec.add_dependency 'rake', '~> 0.8'
+ spec.add_dependency 'facets', '~> 2.2'
+ spec.add_dependency 'builder', '~> 2.1'
+ spec.add_dependency 'net-ssh', '~> 1.1'
+ spec.add_dependency 'net-sftp', '~> 1.1'
+ spec.add_dependency 'rubyzip', '~> 0.9'
+ spec.add_dependency 'highline', '~> 1.4'
+ spec.add_dependency 'Antwrap', '~> 0.6'
+ spec.add_dependency 'rspec', '~> 1.1'
+ spec.add_dependency 'xml-simple', '~> 1.0'
+ spec.add_dependency 'archive-tar-minitar', '~> 0.5'
spec.platform = platform
@@ -46,7 +46,7 @@
end
end
-spec = specify(Gem::Platform::RUBY) { |spec| spec.add_dependency 'rjb', '>= 1.0.11' }
+spec = specify(Gem::Platform::RUBY) { |spec| spec.add_dependency 'rjb', '~> 1.1' }
jruby_spec = specify('java')
package = Rake::GemPackageTask.new(spec) do |pkg|
pkg.need_tar = true
Modified: incubator/buildr/trunk/lib/buildr.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr.rb?rev=608023&r1=608022&r2=608023&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/buildr.rb (original)
+++ incubator/buildr/trunk/lib/buildr.rb Tue Jan 1 22:30:09 2008
@@ -14,7 +14,6 @@
# What it says.
require 'facet/kernel/__DIR__'
require 'facet/module/alias_method_chain'
-require 'facet/module/memoize'
require 'facet/array/head'
require 'facet/string/starts_with'
require 'facet/openobject'
Modified: incubator/buildr/trunk/lib/buildr/antlr.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/antlr.rb?rev=608023&r1=608022&r2=608023&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/buildr/antlr.rb (original)
+++ incubator/buildr/trunk/lib/buildr/antlr.rb Tue Jan 1 22:30:09 2008
@@ -37,7 +37,7 @@
else
in_package = []; token = nil
end
- file(path_to(:target, "generated/antlr")=>args.flatten) do |task|
+ file(path_to(:target, :generated, :antlr)=>args.flatten) do |task|
args = {:output=>File.join(task.name, in_package)}
args.merge!({:token=>File.join(task.name, token)}) if token
ANTLR.antlr task.prerequisites, args
Modified: incubator/buildr/trunk/lib/buildr/cobertura.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/cobertura.rb?rev=608023&r1=608022&r2=608023&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/buildr/cobertura.rb (original)
+++ incubator/buildr/trunk/lib/buildr/cobertura.rb Tue Jan 1 22:30:09 2008
@@ -30,7 +30,7 @@
unless project.compile.sources.empty?
# Instrumented bytecode goes in a different directory. This task creates before running the test
# cases and monitors for changes in the generate bytecode.
- instrumented = project.file(project.path_to(:target, "instrumented")=>project.compile.target) do |task|
+ instrumented = project.file(project.path_to(:target, :instrumented, :classes)=>project.compile.target) do |task|
Buildr.ant "cobertura" do |ant|
ant.taskdef :classpath=>requires.join(File::PATH_SEPARATOR), :resource=>"tasks.properties"
ant.send "cobertura-instrument", :todir=>task.to_s, :datafile=>data_file do
Modified: incubator/buildr/trunk/lib/buildr/hibernate.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/hibernate.rb?rev=608023&r1=608022&r2=608023&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/buildr/hibernate.rb (original)
+++ incubator/buildr/trunk/lib/buildr/hibernate.rb Tue Jan 1 22:30:09 2008
@@ -101,7 +101,7 @@
# hibernate_schemaexport "derby.sql" do |task, ant|
# ant.schemaexport :properties=>"derby.properties", :output=>task.name,
# :delimiter=>";", :drop=>"no", :create=>"yes" do
- # fileset(:dir=>path_to(:java_src_dir)) { include :name=>"**/*.hbm.xml" } }
+ # fileset(:dir=>compile.sources.first) { include :name=>"**/*.hbm.xml" } }
# end
# end
def hibernate_schemaexport(args, &block)
Modified: incubator/buildr/trunk/lib/buildr/javacc.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/javacc.rb?rev=608023&r1=608022&r2=608023&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/buildr/javacc.rb (original)
+++ incubator/buildr/trunk/lib/buildr/javacc.rb Tue Jan 1 22:30:09 2008
@@ -44,7 +44,7 @@
else
in_package = []
end
- file(path_to(:target, "generated/javacc")=>args.flatten) do |task|
+ file(path_to(:target, :generated, :javacc)=>args.flatten) do |task|
JavaCC.javacc task.prerequisites, :output=>File.join(task.name, in_package)
end
end
@@ -57,7 +57,7 @@
else
in_package = []
end
- file(path_to(:target, "generated/jjtree")=>args.flatten) do |task|
+ file(path_to(:target, :generated, :jjtree)=>args.flatten) do |task|
JavaCC.jjtree task.prerequisites, :output=>File.join(task.name, in_package), :build_node_files=>build_node_files
end
end
Modified: incubator/buildr/trunk/lib/buildr/openjpa.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/openjpa.rb?rev=608023&r1=608022&r2=608023&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/buildr/openjpa.rb (original)
+++ incubator/buildr/trunk/lib/buildr/openjpa.rb Tue Jan 1 22:30:09 2008
@@ -61,7 +61,7 @@
def open_jpa_enhance(options = nil)
jpa_options = { :output=>compile.target, :classpath=>compile.classpath,
- :properties=>path_to("src/main/resources/META-INF/persistence.xml") }
+ :properties=>path_to(:source, :main, :resources, 'META-INF/persistence.xml') }
OpenJPA.enhance jpa_options.merge(options || {})
end
Modified: incubator/buildr/trunk/lib/buildr/xmlbeans.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/xmlbeans.rb?rev=608023&r1=608022&r2=608023&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/buildr/xmlbeans.rb (original)
+++ incubator/buildr/trunk/lib/buildr/xmlbeans.rb Tue Jan 1 22:30:09 2008
@@ -42,7 +42,7 @@
# (the last FileList is there to deal with things like *.xsdconfig).
files = args.flatten.map { |file| File.directory?(file) ? FileList["#{file}/*.xsd"] : FileList[file] }.flatten
# Generate sources and add them to the compile task.
- generated = file(path_to(:target, "generated/xmlbeans")=>files) do |task|
+ generated = file(path_to(:target, :generated, :xmlbeans)=>files) do |task|
XMLBeans.compile args.flatten, :output=>task.name,
:javasource=>compile.options.source, :xsb=>compile.target
end
Modified: incubator/buildr/trunk/lib/core/build.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/core/build.rb?rev=608023&r1=608022&r2=608023&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/core/build.rb (original)
+++ incubator/buildr/trunk/lib/core/build.rb Tue Jan 1 22:30:09 2008
@@ -55,26 +55,28 @@
end
- # The target directory. By default, it's the "target" directory inside the project. Various tasks
- # use it to determine where to place files, e.g. when compiling or packaging. The clean task
- # nukes it.
- def target()
- @target ||= _("target")
+ # *Deprecated:* Use +path_to(:target)+ instead.
+ def target
+ warn_deprecated 'Use path_to(:target) instead'
+ layout.expand(:target)
end
+ # *Deprecated:* Use Layout instead.
def target=(dir)
- @target = _(dir)
+ warn_deprecated 'Use Layout instead'
+ layout[:target] = _(dir)
end
- # The reports directory. By default, it's the "reports" directory inside the project. Various tasks
- # use it to determine where to place reports, e.g. when running test cases or code analysis.
- # The clean task nukes it.
+ # *Deprecated:* Use +path_to(:reports)+ instead.
def reports()
- @reports ||= _("reports")
+ warn_deprecated 'Use path_to(:reports) instead'
+ layout.expand(:reports)
end
+ # *Deprecated:* Use Layout instead.
def reports=(dir)
- @reports = _(dir)
+ warn_deprecated 'Use Layout instead'
+ layout[:reports] = _(dir)
end
# :call-seq:
Modified: incubator/buildr/trunk/lib/core/compile.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/core/compile.rb?rev=608023&r1=608022&r2=608023&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/core/compile.rb (original)
+++ incubator/buildr/trunk/lib/core/compile.rb Tue Jan 1 22:30:09 2008
@@ -93,6 +93,37 @@
end
end
+ private
+
+ # Use this to copy options used by this compiler from the parent, for example,
+ # if this task is 'foo:bar:compile', copy options set in the parent task 'foo:compile'.
+ #
+ # For example:
+ # def configure(task, source, target)
+ # super
+ # update_options_from_parent! task, OPTIONS
+ # . . .
+ # end
+ def update_options_from_parent!(task, supported)
+ parent = Project.task_in_parent_project(task.name)
+ if parent.respond_to?(:options)
+ missing = supported.flatten - task.options.to_hash.keys
+ task.options.merge( missing.inject({}) { |hash, key| hash.update(key=>parent.options[key]) } )
+ end
+ end
+
+ # Use this to complain about CompileTask options not supported by this compiler.
+ #
+ # For example:
+ # def compile(files, task)
+ # check_options task, OPTIONS
+ # . . .
+ # end
+ def check_options(task, supported)
+ unsupported = task.options.to_hash.keys - supported.flatten
+ raise ArgumentError, "No such option: #{unsupported.join(' ')}" unless unsupported.empty?
+ end
+
end
end
@@ -117,27 +148,10 @@
# only need to set options and dependencies. See Project#compile.
class CompileTask < Rake::Task
- module OpenStructExtension #:nodoc:
-
- def [](key)
- @table[key]
- end
-
- def []=(key, value)
- @table[key] = value
- end
-
- def clear
- @table.clear
- end
-
- end
-
def initialize(*args) #:nodoc:
super
parent = Project.task_in_parent_project(name)
- @options = parent && parent.respond_to?(:options) && parent.options.clone || OpenStruct.new
- @options.extend OpenStructExtension
+ @options = OpenObject.new#(parent.respond_to?(:options) && parent.options)
@sources = []
@dependencies = []
@@ -387,12 +401,12 @@
before_define do |project|
resources = ResourcesTask.define_task('resources')
- project.path_to('src/main/resources').tap { |dir| resources.from dir if File.exist?(dir) }
- resources.filter.into project.path_to(:target, 'resources')
+ project.path_to(:source, :main, :resources).tap { |dir| resources.from dir if File.exist?(dir) }
+ resources.filter.into project.path_to(:target, :main, :resources)
resources.filter.using Buildr.profile
compile = CompileTask.define_task('compile'=>resources)
- compile.send :associate, project.path_to('src/main'), project.path_to(:target)
+ compile.send :associate, project.path_to(:source, :main), project.path_to(:target, :main)
project.recursive_task('compile')
end
Modified: incubator/buildr/trunk/lib/core/project.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/core/project.rb?rev=608023&r1=608022&r2=608023&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/core/project.rb (original)
+++ incubator/buildr/trunk/lib/core/project.rb Tue Jan 1 22:30:09 2008
@@ -26,6 +26,92 @@
end
+ # Symbolic mapping for directory layout. Used for both the default and custom layouts.
+ #
+ # For example, the default layout maps [:source, :main, :java] to 'src/main/java', and
+ # [:target, :main, :classes] to 'target/classes'. You can use this to change the layout
+ # of your projects.
+ #
+ # To map [:source, :main] into the 'sources' directory:
+ # my_layout = Layout.new
+ # my_layout[:source, :main] = 'sources'
+ #
+ # define 'foo', :layout=>my_layout do
+ # ...
+ # end
+ #
+ # To map [:source, :main, :java] to 'java/main':
+ # class MainLast < Layout
+ # def expand(*args)
+ # if args[0..1] == [:source, :main]
+ # super args[2], :main, *args[3,]
+ # else
+ # super
+ # end
+ # end
+ # end
+ #
+ # define 'foo', :layout=>MainLast do
+ # ...
+ # end
+ class Layout
+
+ class << self
+
+ # Default layout used by new projects.
+ attr_accessor :default
+
+ end
+
+ def initialize #:nodoc:
+ @mapping = {}
+ end
+
+ # Expands list of symbols and path names into a full path, for example:
+ # puts default.expand(:source, :main, :java)
+ # => "src/main/java"
+ def expand(*args)
+ return '' if args.empty?
+ @mapping[args] ||= File.join(*[expand(*args[0..-2]), args.last.to_s].reject(&:empty?)) if args.size > 1
+ return @mapping[args] || args.first.to_s
+ end
+
+ # Resolves a list of symbols into a path.
+ def [](*args)
+ @mapping[args.map(&:to_sym)]
+ end
+
+ # Specifies the path resolved from a list of symbols.
+ def []=(*args)
+ @mapping[args[0...-1].map(&:to_sym)] = args.last
+ end
+
+ def initialize_copy(copy)
+ copy.instance_variable_set :@mapping, @mapping.clone
+ end
+
+ # Default layout has the following properties:
+ # * :source maps to the 'src' directory.
+ # * Anything under :source maps verbatim (e.g. :source, :main becomes 'src/main')
+ # * :target maps to the 'target' directory.
+ # * :target, :main maps to the 'target' directory as well.
+ # * Anything under :target, :main maps verbatim (e.g. :target, :main, :classes becomes 'target/classes')
+ # * Anything else under :target also maps verbatim (e.g. :target, :test becomes 'target/test')
+ class Default < Layout
+
+ def initialize
+ super
+ self[:source] = 'src'
+ self[:target, :main] = 'target'
+ end
+
+ end
+
+ self.default = Default.new
+
+ end
+
+
# A project definition is where you define all the tasks associated with
# the project you're building.
#
@@ -71,7 +157,12 @@
# | |__resources <-- Resources to copy (tests)
# |__target <-- Packages created here
# | |__classes <-- Generated when compiling
- # | |__test-classes <-- Generated when compiling tests
+ # | |__resources <-- Copied (and filtered) from resources
+ # | |__test/classes <-- Generated when compiling tests
+ # | |__test/resources <-- Copied (and filtered) from resources
+ # |__reports <-- Test, coverage and other reports
+ #
+ # You can change the project layout by passing a new Layout to the project definition.
#
# You can only define a project once using #define. Afterwards, you can obtain the project
# definition using #project. The order in which you define projects is not important,
@@ -136,7 +227,7 @@
project.enhance { project.instance_eval &block } if block
# Top-level project? Invoke the project definition. Sub-project? We don't invoke
- # the project definiton yet (allow project() calls to establish order of evaluation),
+ # the project definiton yet (allow project calls to establish order of evaluation),
# but must do so before the parent project's definition is done.
project.parent.enhance { project.invoke } if project.parent
end
@@ -198,7 +289,7 @@
end
# :call-seq:
- # clear()
+ # clear
#
# Discard all project definitions.
def clear
@@ -304,7 +395,7 @@
split = name.split(':')
if split.size > 1
# Get parent project, but do not invoke it's definition to prevent circular
- # dependencies (it's being invoked right now, so calling project() will fail).
+ # dependencies (it's being invoked right now, so calling project will fail).
@parent = task(split[0...-1].join(':'))
raise "No parent project #{split[0...-1].join(':')}" unless @parent && Project === parent
end
@@ -316,7 +407,7 @@
end
# :call-seq:
- # base_dir() => path
+ # base_dir => path
#
# Returns the project's base directory.
#
@@ -342,25 +433,33 @@
@base_dir
end
+ # Returns the layout associated with this project.
+ def layout
+ @layout ||= (parent ? parent.layout : Layout.default).clone
+ end
+
# :call-seq:
# path_to(*names) => path
#
# Returns a path from a combination of name, relative to the project's base directory.
# Essentially, joins all the supplied names and expands the path relative to #base_dir.
- # Symbol arguments are converted to paths by calling the attribute accessor on the project.
+ # Symbol arguments are converted to paths based on the layout, so whenever possible stick
+ # to these. For example:
+ # path_to(:source, :main, :java)
+ # => 'src/main/java'
#
# Keep in mind that all tasks are defined and executed relative to the Buildfile directory,
# so you want to use #path_to to get the actual path within the project as a matter of practice.
#
# For example:
# path_to('foo', 'bar')
- # => /home/project1/foo/bar
+ # => foo/bar
# path_to('/tmp')
# => /tmp
# path_to(:base_dir, 'foo') # same as path_to('foo")
# => /home/project1/foo
def path_to(*names)
- File.expand_path(File.join(names.map { |name| Symbol === name ? send(name) : name.to_s }), base_dir)
+ File.expand_path(layout.expand(*names), base_dir)
end
alias :_ :path_to
@@ -490,7 +589,7 @@
%Q{project(#{name.inspect})}
end
-protected
+ protected
# :call-seq:
# base_dir = dir
@@ -508,6 +607,13 @@
@base_dir = File.expand_path(dir)
end
+ # Sets the project layout. Accepts Layout object or class (or for that matter, anything
+ # that can expand).
+ def layout=(layout)
+ raise 'Cannot set directory layout twice, or after reading its value' if @layout
+ @layout = layout.is_a?(Class) ? layout.new : layout
+ end
+
# :call-seq:
# define(name, properties?) { |project| ... } => project
#
@@ -526,8 +632,6 @@
Rake.application.instance_variable_set :@scope, scope
end
end
-
- protected
# Call all callbacks for a particular state, e.g. :before_define, :after_define.
def call_callbacks(state) #:nodoc:
Modified: incubator/buildr/trunk/lib/core/test.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/core/test.rb?rev=608023&r1=608022&r2=608023&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/core/test.rb (original)
+++ incubator/buildr/trunk/lib/core/test.rb Tue Jan 1 22:30:09 2008
@@ -318,7 +318,7 @@
# This is framework dependent, so unless you use the default test framework, call this method
# after setting the test framework.
def report_to
- @report_to ||= file(@project.path_to(:reports, framework.to_s)=>self)
+ @report_to ||= file(@project.path_to(:reports, framework)=>self)
end
protected
@@ -340,7 +340,7 @@
@failed_tests = []
else
puts "Running tests in #{@project.name}" if verbose
- @failed_tests = @framework.run(files, self, (@dependencies + [compile.target]).compact.map(&:to_s))
+ @failed_tests = @framework.run(files, self, (@dependencies + [compile.target, resources.target]).compact.map(&:to_s))
unless @failed_tests.empty?
warn "The following tests failed:\n#{@failed_tests.join('\n')}" if verbose
fail 'Tests failed!'
@@ -450,12 +450,12 @@
# Similar to the regular resources task but using different paths.
resources = ResourcesTask.define_task('test:resources')
- project.path_to('src/test/resources').tap { |dir| resources.from dir if File.exist?(dir) }
- resources.filter.into project.path_to(:target, 'test/resources')
+ project.path_to(:src, :test, :resources).tap { |dir| resources.from dir if File.exist?(dir) }
+ resources.filter.into project.path_to(:target, :test, :resources)
# Similar to the regular compile task but using different paths.
compile = CompileTask.define_task('test:compile'=>[project.compile, project.test.resources])
- compile.send :associate, project.path_to('src/test'), project.path_to(:target, 'test')
+ compile.send :associate, project.path_to(:src, :test), project.path_to(:target, :test)
project.test.enhance [compile]
# Define these tasks once, otherwise we may get a namespace error.
@@ -465,7 +465,8 @@
after_define do |project|
# Copy the regular compile dependencies over, and also include the compiled files, both of which
# can be used in the test cases. And don't forget the dependencies required by the test framework (e.g. JUnit).
- project.test.with project.compile.dependencies, Array(project.compile.target), project.test.requires
+ project.test.with project.compile.dependencies, Array(project.compile.target), Array(project.resources.target),
+ project.test.requires
if project.test.compile.target
project.clean do
verbose(false) do
Modified: incubator/buildr/trunk/lib/ide/eclipse.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/ide/eclipse.rb?rev=608023&r1=608022&r2=608023&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/ide/eclipse.rb (original)
+++ incubator/buildr/trunk/lib/ide/eclipse.rb Tue Jan 1 22:30:09 2008
@@ -101,8 +101,7 @@
end
# Main resources implicitly copied into project.compile.target
- # TODO: find solution that uses project.test.resources.filter.sources
- [ "src/main/resources" ].each do |path|
+ project.resources.sources.each do |path|
if File.exist? project.path_to(path)
xml.classpathentry :kind=>'src', :path=>path, :excluding=>excludes
end
@@ -117,8 +116,7 @@
end
# Test resources go in separate output directory as well
- # TODO: find solution that uses project.test.resources.filter.sources
- [ "src/test/resources" ].each do |path|
+ project.test.resources.sources.each do |path|
if File.exist? project.path_to(path)
xml.classpathentry :kind=>'src', :path=>path, :output => relative[project.test.compile.target], :excluding=>excludes
end
Modified: incubator/buildr/trunk/lib/ide/idea.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/ide/idea.rb?rev=608023&r1=608022&r2=608023&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/ide/idea.rb (original)
+++ incubator/buildr/trunk/lib/ide/idea.rb Tue Jan 1 22:30:09 2008
@@ -91,8 +91,10 @@
xml.sourceFolder :url=>"file://$MODULE_DIR$/#{path}", :isTestSource=>"true"
end
end
- {"src/main/resources"=>false, "src/test/resources"=>true}.each do |key, value|
- xml.sourceFolder :url=>"file://$MODULE_DIR$/#{key}", :isTestSource=>"#{value}" if File.exist?(project.path_to(key))
+ [project.resources=>false, project.test.resources=>true].each do |resources, test|
+ resources.sources.each do |path|
+ xml.sourceFolder :url=>"file://$MODULE_DIR$/#{path}", :isTestSource=>test.to_s
+ end
end
xml.excludeFolder :url=>"file://$MODULE_DIR$/#{relative[project.compile.target]}"
end
Modified: incubator/buildr/trunk/lib/java/compilers.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/java/compilers.rb?rev=608023&r1=608022&r2=608023&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/java/compilers.rb (original)
+++ incubator/buildr/trunk/lib/java/compilers.rb Tue Jan 1 22:30:09 2008
@@ -7,6 +7,8 @@
module Buildr
module Compiler
class Javac < Base #:nodoc:
+
+ OPTIONS = [:warnings, :debug, :deprecation, :source, :target, :lint, :other]
def initialize
super :language=>:java, :target_path=>'classes', :target_ext=>'.class'
@@ -14,6 +16,7 @@
def configure(task, source, target)
super
+ update_options_from_parent! task, OPTIONS
task.options.warnings ||= verbose
task.options.deprecation ||= false
task.options.lint ||= false
@@ -21,6 +24,7 @@
end
def compile(files, task)
+ check_options task, OPTIONS
::Buildr::Java.javac files, :sourcepath=>task.sources.select { |source| File.directory?(source) },
:classpath=>task.dependencies, :output=>task.target, :javac_args=>javac_args_from(task.options)
end
@@ -200,7 +204,7 @@
before_define do |project|
JavadocTask.define_task('javadoc').tap do |javadoc|
- javadoc.into project.path_to(:target, 'javadoc')
+ javadoc.into project.path_to(:target, :javadoc)
javadoc.using :windowtitle=>project.comment || project.name
end
end
Modified: incubator/buildr/trunk/lib/java/packaging.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/java/packaging.rb?rev=608023&r1=608022&r2=608023&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/java/packaging.rb (original)
+++ incubator/buildr/trunk/lib/java/packaging.rb Tue Jan 1 22:30:09 2008
@@ -490,7 +490,7 @@
warn_deprecated "The :include option in package(:war) is deprecated, please use package(:war).include(files) instead."
war.include options[:include]
else
- path_to("src/main/webapp").tap { |path| war.with path if File.exist?(path) }
+ path_to(:source, :main, :webapp).tap { |path| war.with path if File.exist?(path) }
end
end
else
@@ -504,8 +504,8 @@
unless Rake::Task.task_defined?(file_name)
Java::Packaging::AarTask.define_task(file_name).tap do |aar|
aar.with :manifest=>manifest, :meta_inf=>meta_inf
- aar.with :wsdls=>path_to("src/main/axis2/*.wsdl")
- aar.with :services_xml=>path_to("src/main/axis2/services.xml")
+ aar.with :wsdls=>path_to(:source, :main, :axis2, '*.wsdl')
+ aar.with :services_xml=>path_to(:source, :main, :axis2, 'services.xml')
aar.with compile.target unless compile.sources.empty?
aar.with resources.target unless resources.sources.empty?
aar.with :libs=>compile.classpath
Modified: incubator/buildr/trunk/spec/build_spec.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/spec/build_spec.rb?rev=608023&r1=608022&r2=608023&view=diff
==============================================================================
--- incubator/buildr/trunk/spec/build_spec.rb (original)
+++ incubator/buildr/trunk/spec/build_spec.rb Tue Jan 1 22:30:09 2008
@@ -1,33 +1,75 @@
require File.join(File.dirname(__FILE__), 'sandbox')
-describe "Local directory build task" do
- it "should execute build task for current project" do
- define "foobar"
- lambda { task("build").invoke }.should run_task("foobar:build")
+describe 'Local directory build task' do
+ it 'should execute build task for current project' do
+ define 'foobar'
+ lambda { task('build').invoke }.should run_task('foobar:build')
end
- it "should not execute build task for other projects" do
- define "foobar", :base_dir=>"elsewhere"
- lambda { task("build").invoke }.should_not run_task("foobar:build")
+ it 'should not execute build task for other projects' do
+ define 'foobar', :base_dir=>'elsewhere'
+ lambda { task('build').invoke }.should_not run_task('foobar:build')
end
end
-describe Project, " build task" do
- it "should execute build task for sub-project" do
- define("foo") { define "bar" }
- lambda { task("foo:build").invoke }.should run_task("foo:bar:build")
+describe Project, ' build task' do
+ it 'should execute build task for sub-project' do
+ define('foo') { define 'bar' }
+ lambda { task('foo:build').invoke }.should run_task('foo:bar:build')
end
- it "should not execute build task of other projects" do
- define "foo"
- define "bar"
- lambda { task("foo:build").invoke }.should_not run_task("bar:build")
+ it 'should not execute build task of other projects' do
+ define 'foo'
+ define 'bar'
+ lambda { task('foo:build').invoke }.should_not run_task('bar:build')
end
- it "should be accessible as build method" do
- define "boo"
- project("boo").build.should be(task("boo:build"))
+ it 'should be accessible as build method' do
+ define 'boo'
+ project('boo').build.should be(task('boo:build'))
+ end
+end
+
+
+describe Project, 'target' do
+ before :each do
+ @project = define('foo', :layout=>Layout.new)
+ end
+
+ it 'should default to target' do
+ @project.target.should eql('target')
+ end
+
+ it 'should set layout :target' do
+ @project.target = 'bar'
+ @project.layout.expand(:target).should eql(File.expand_path('bar'))
+ end
+
+ it 'should come from layout :target' do
+ @project.layout[:target] = 'baz'
+ @project.target.should eql('baz')
+ end
+end
+
+
+describe Project, 'reports' do
+ before :each do
+ @project = define('foo', :layout=>Layout.new)
+ end
+
+ it 'should default to reports' do
+ @project.reports.should eql('reports')
+ end
+
+ it 'should set layout :reports' do
+ @project.reports = 'bar'
+ @project.layout.expand(:reports).should eql(File.expand_path('bar'))
+ end
+
+ it 'should come from layout :reports' do
+ @project.layout[:reports] = 'baz'
+ @project.reports.should eql('baz')
end
end
Modified: incubator/buildr/trunk/spec/compile_spec.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/spec/compile_spec.rb?rev=608023&r1=608022&r2=608023&view=diff
==============================================================================
--- incubator/buildr/trunk/spec/compile_spec.rb (original)
+++ incubator/buildr/trunk/spec/compile_spec.rb Tue Jan 1 22:30:09 2008
@@ -404,6 +404,9 @@
define('hash').compile.using(:other=>{ 'foo'=>'name', 'bar'=>'value'}).javac_args.should include('-foo', 'name', '-bar', 'value')
end
+ it 'should accept unknown option'
+ it 'should complain about unknown option'
+
it "should pass to javac" do
src = "Test.java"
Modified: incubator/buildr/trunk/spec/project_spec.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/spec/project_spec.rb?rev=608023&r1=608022&r2=608023&view=diff
==============================================================================
--- incubator/buildr/trunk/spec/project_spec.rb (original)
+++ incubator/buildr/trunk/spec/project_spec.rb Tue Jan 1 22:30:09 2008
@@ -2,584 +2,681 @@
describe Project do
- it "should be findable" do
- foo = define("foo")
- project("foo").should be(foo)
+ it 'should be findable' do
+ foo = define('foo')
+ project('foo').should be(foo)
end
- it "should not exist unless defined" do
- lambda { project("foo") }.should raise_error(RuntimeError, /No such project/)
+ it 'should not exist unless defined' do
+ lambda { project('foo') }.should raise_error(RuntimeError, /No such project/)
end
- it "should exist once defined" do
- define "foo"
- lambda { project("foo") }.should_not raise_error
+ it 'should exist once defined' do
+ define 'foo'
+ lambda { project('foo') }.should_not raise_error
end
- it "should always return same project for same name" do
- foo, bar = define("foo"), define("bar")
+ it 'should always return same project for same name' do
+ foo, bar = define('foo'), define('bar')
foo.should_not be(bar)
- foo.should be(project("foo"))
- bar.should be(project("bar"))
+ foo.should be(project('foo'))
+ bar.should be(project('bar'))
end
- it "should show up in projects list if defined" do
- define("foo")
- projects.map(&:name).should include("foo")
+ it 'should show up in projects list if defined' do
+ define('foo')
+ projects.map(&:name).should include('foo')
end
- it "should not show up in projects list unless defined" do
- projects.map(&:name).should_not include("foo")
+ it 'should not show up in projects list unless defined' do
+ projects.map(&:name).should_not include('foo')
end
- it "should be findable from within a project" do
- define("foo")
- project("foo").project("foo").should be(project("foo"))
+ it 'should be findable from within a project' do
+ define('foo')
+ project('foo').project('foo').should be(project('foo'))
end
- it "should cease to exist when project list cleared" do
- define "foo"
- projects.map(&:name).should include("foo")
+ it 'should cease to exist when project list cleared' do
+ define 'foo'
+ projects.map(&:name).should include('foo')
Project.clear
projects.map(&:name).should be_empty
end
- it "should be defined only once" do
- lambda { define "foo" }.should_not raise_error
- lambda { define "foo" }.should raise_error
+ it 'should be defined only once' do
+ lambda { define 'foo' }.should_not raise_error
+ lambda { define 'foo' }.should raise_error
end
- it "should be definable in any order" do
- Buildr.define("baz") { define("bar") { project("foo:bar") } }
- Buildr.define("foo") { define("bar") }
- lambda { project("foo") }.should_not raise_error
+ it 'should be definable in any order' do
+ Buildr.define('baz') { define('bar') { project('foo:bar') } }
+ Buildr.define('foo') { define('bar') }
+ lambda { project('foo') }.should_not raise_error
end
- it "should detect circular dependency" do
- Buildr.define("baz") { define("bar") { project("foo:bar") } }
- Buildr.define("foo") { define("bar") { project("baz:bar") } }
- lambda { project("foo") }.should raise_error(RuntimeError, /Circular dependency/)
+ it 'should detect circular dependency' do
+ Buildr.define('baz') { define('bar') { project('foo:bar') } }
+ Buildr.define('foo') { define('bar') { project('baz:bar') } }
+ lambda { project('foo') }.should raise_error(RuntimeError, /Circular dependency/)
end
end
-describe Project, " name" do
- it "should be pwd if not specified" do
- foo = define("foo")
+describe Project, ' property' do
+ it 'should be set if passed as argument' do
+ define 'foo', 'version'=>'1.1'
+ project('foo').version.should eql('1.1')
+ end
+
+ it 'should be set if assigned in body' do
+ define('foo') { self.version = '1.2' }
+ project('foo').version.should eql('1.2')
+ end
+
+ it 'should take precedence when assigned in body' do
+ define('foo', 'version'=>'1.1') { self.version = '1.2' }
+ project('foo').version.should eql('1.2')
+ end
+
+ it 'should inherit from parent (for some properties)' do
+ define('foo', 'version'=>'1.2', :group=>'foobar') { define 'bar' }
+ project('foo:bar').version.should eql('1.2')
+ project('foo:bar').group.should eql('foobar')
+ end
+
+ it 'should have different value if set in sub-project' do
+ define 'foo', 'version'=>'1.2', :group=>'foobar' do
+ define 'bar', :version=>'1.3' do
+ self.group = 'barbaz'
+ end
+ end
+ project('foo:bar').version.should eql('1.3')
+ project('foo:bar').group.should eql('barbaz')
+ end
+end
+
+
+describe Project, ' block' do
+ it 'should execute once' do
+ define('foo') { self.name.should eql('foo') }
+ end
+
+ it 'should execute in describe of project' do
+ define('foo') { self.version = '1.3' }
+ project('foo').version.should eql('1.3')
+ end
+
+ it 'should execute by passing project' do
+ define('foo') { |project| project.version = '1.3' }
+ project('foo').version.should eql('1.3')
+ end
+
+ it 'should execute in namespace of project' do
+ define('foo') { define('bar') { Rake.application.current_scope.should eql(['foo', 'bar']) } }
+ end
+end
+
+
+describe Project, '#base_dir' do
+ it 'should be pwd if not specified' do
+ foo = define('foo')
foo.base_dir.should eql(Dir.pwd)
end
- it "should come from property, if specified" do
- foo = define("foo", :base_dir=>"tmp")
- foo.base_dir.should eql(File.expand_path("tmp"))
+ it 'should come from property, if specified' do
+ foo = define('foo', :base_dir=>'tmp')
+ foo.base_dir.should eql(File.expand_path('tmp'))
end
- it "should be expanded path" do
- foo = define("foo", :base_dir=>"tmp")
- foo.base_dir.should eql(File.expand_path("tmp"))
+ it 'should be expanded path' do
+ foo = define('foo', :base_dir=>'tmp')
+ foo.base_dir.should eql(File.expand_path('tmp'))
end
- it "should be relative to parent project" do
- define("foo") { define "bar" }
- project("foo:bar").base_dir.should eql(File.join(project("foo").base_dir, "bar"))
+ it 'should be relative to parent project' do
+ define('foo') { define 'bar' }
+ project('foo:bar').base_dir.should eql(File.join(project('foo').base_dir, 'bar'))
end
- it "should be settable only if not read" do
- lambda { define("foo", :base_dir=>"tmp") }.should_not raise_error
- lambda { define("bar", :base_dir=>"tmp") { self.base_dir = "bar" } }.should raise_error(Exception, /Cannot set/)
+ it 'should be settable only if not read' do
+ lambda { define('foo', :base_dir=>'tmp') }.should_not raise_error
+ lambda { define('bar', :base_dir=>'tmp') { self.base_dir = 'bar' } }.should raise_error(Exception, /Cannot set/)
end
end
-describe Project, " property" do
- it "should be set if passed as argument" do
- define "foo", "version"=>"1.1"
- project("foo").version.should eql("1.1")
+describe Layout do
+ before :each do
+ @layout = Layout.new
end
- it "should be set if assigned in body" do
- define("foo") { self.version = "1.2" }
- project("foo").version.should eql("1.2")
+ it 'should expand empty to itself' do
+ @layout.expand.should eql('')
+ @layout.expand('').should eql('')
end
- it "should take precedence when assigned in body" do
- define("foo", "version"=>"1.1") { self.version = "1.2" }
- project("foo").version.should eql("1.2")
+ it 'should expand array of symbols' do
+ @layout.expand(:foo, :bar).should eql('foo/bar')
end
- it "should inherit from parent (for some properties)" do
- define("foo", "version"=>"1.2", :group=>"foobar") { define "bar" }
- project("foo:bar").version.should eql("1.2")
- project("foo:bar").group.should eql("foobar")
+ it 'should expand array of names' do
+ @layout.expand('foo', 'bar').should eql('foo/bar')
end
- it "should have different value if set in sub-project" do
- define "foo", "version"=>"1.2", :group=>"foobar" do
- define "bar", :version=>"1.3" do
- self.group = "barbaz"
- end
- end
- project("foo:bar").version.should eql("1.3")
- project("foo:bar").group.should eql("barbaz")
+ it 'should map symbol to path' do
+ @layout[:foo] = 'baz'
+ @layout.expand(:foo, :bar).should eql('baz/bar')
end
+
+ it 'should map symbols to path' do
+ @layout[:foo, :bar] = 'none'
+ @layout.expand(:foo, :bar).should eql('none')
+ end
+
+ it 'should return nil if path not mapped' do
+ @layout[:foo].should be_nil
+ end
+
+ it 'should return path from symbol' do
+ @layout[:foo] = 'path'
+ @layout[:foo].should eql('path')
+ end
+
+ it 'should return path from symbol' do
+ @layout[:foo, :bar] = 'path'
+ @layout[:foo, :bar].should eql('path')
+ end
+
+ it 'should do eager mapping' do
+ @layout[:one] = 'none'
+ @layout[:one, :two] = '1..2'
+ @layout.expand(:one, :two, :three).should eql('1..2/three')
+ end
+
end
-describe Project, " block" do
- it "should execute once" do
- define("foo") { self.name.should eql("foo") }
+describe Project, '#layout' do
+ before :each do
+ @layout = Layout.new
end
- it "should execute in describe of project" do
- define("foo") { self.version = "1.3" }
- project("foo").version.should eql("1.3")
+ it 'should exist by default' do
+ define('foo').layout.should respond_to(:expand)
end
- it "should execute by passing project" do
- define("foo") { |project| project.version = "1.3" }
- project("foo").version.should eql("1.3")
+ it 'should be clone of default layout' do
+ define 'foo' do
+ layout.should_not be(Layout.default)
+ layout.expand(:test, :main).should eql(Layout.default.expand(:test, :main))
+ end
end
- it "should execute in namespace of project" do
- define("foo") { define("bar") { Rake.application.current_scope.should eql(["foo", "bar"]) } }
+ it 'should come from property, if specified' do
+ foo = define('foo', :layout=>@layout)
+ foo.layout.should eql(@layout)
end
+
+ it 'should inherit from parent project' do
+ define 'foo', :layout=>@layout do
+ layout[:foo] = 'foo'
+ define 'bar'
+ end
+ project('foo:bar').layout[:foo].should eql('foo')
+ end
+
+ it 'should clone when inheriting from parent project' do
+ define 'foo', :layout=>@layout do
+ layout[:foo] = 'foo'
+ define 'bar' do
+ layout[:foo] = 'bar'
+ end
+ end
+ project('foo').layout[:foo].should eql('foo')
+ project('foo:bar').layout[:foo].should eql('bar')
+ end
+
+ it 'should be settable only if not read' do
+ lambda { define('foo', :layout=>@layout) }.should_not raise_error
+ lambda { define('bar', :layout=>@layout) { self.layout = @layout.clone } }.should raise_error(Exception, /Cannot set/)
+ end
+
end
-describe Project, "#path_to" do
+describe Project, '#path_to' do
before do
- @project = define("foo") { define("bar") }
+ @project = define('foo') { define('bar') }
@base_dir = @project.base_dir
end
- it "should return absolute paths as is" do
- @project.path_to("/tmp").should eql("/tmp")
+ it 'should return absolute paths as is' do
+ @project.path_to('/tmp').should eql('/tmp')
end
- it "should resolve relative paths" do
+ it 'should resolve relative paths' do
@project.path_to().should eql(@project.base_dir)
- @project.path_to("tmp").should eql("#{@base_dir}/tmp")
+ @project.path_to('tmp').should eql("#{@base_dir}/tmp")
end
- it "should accept multiple arguments" do
- @project.path_to("foo", "bar").should eql("#{@base_dir}/foo/bar")
+ it 'should accept multiple arguments' do
+ @project.path_to('foo', 'bar').should eql("#{@base_dir}/foo/bar")
end
- it "should handle relative paths" do
- @project.path_to("..", "bar").should eql(File.join(@base_dir.pathmap("%d"), "bar"))
+ it 'should handle relative paths' do
+ @project.path_to('..', 'bar').should eql(File.join(@base_dir.pathmap('%d'), 'bar'))
end
- it "should resolve symbols using accessors" do
- class << @project
- def dir ; "foo" ; end
- end
- @project.path_to(:dir).should eql(File.join(@base_dir, @project.dir))
- @project.path_to(:dir, "tmp").should eql(File.join(@base_dir, @project.dir, "tmp"))
+ it 'should resolve symbols using layout' do
+ @project.layout[:foo] = 'bar'
+ @project.path_to(:foo).should eql(File.join(@base_dir, 'bar'))
+ @project.path_to(:foo, 'tmp').should eql(File.join(@base_dir, 'bar', 'tmp'))
end
- it "should resolve path for sub-project" do
- project("foo:bar").path_to("foo").should eql(File.join(project("foo:bar").base_dir, "foo"))
+ it 'should resolve path for sub-project' do
+ project('foo:bar').path_to('foo').should eql(File.join(project('foo:bar').base_dir, 'foo'))
end
end
-describe Project, "#on_define" do
- it "should be called when project is defined" do
+describe Project, '#on_define' do
+ it 'should be called when project is defined' do
names = []
Project.on_define { |project| names << project.name }
- define "foo" ; define "bar"
- names.should eql(["foo", "bar"])
+ define 'foo' ; define 'bar'
+ names.should eql(['foo', 'bar'])
end
- it "should be called with project object" do
- Project.on_define { |project| project.name.should eql("foo") }
- define("foo")
+ it 'should be called with project object' do
+ Project.on_define { |project| project.name.should eql('foo') }
+ define('foo')
end
- it "should be called with project object and set properties" do
- Project.on_define { |project| project.version.should eql("2.0") }
- define("foo", :version=>"2.0")
+ it 'should be called with project object and set properties' do
+ Project.on_define { |project| project.version.should eql('2.0') }
+ define('foo', :version=>'2.0')
end
- it "should execute in namespace of project" do
+ it 'should execute in namespace of project' do
scopes = []
Project.on_define { |project| scopes << Rake.application.current_scope }
- define("foo") { define "bar" }
- scopes.should eql([["foo"], ["foo", "bar"]])
+ define('foo') { define 'bar' }
+ scopes.should eql([['foo'], ['foo', 'bar']])
end
- it "should be called before project block" do
+ it 'should be called before project block' do
order = []
- Project.on_define { |project| order << "on_define" }
- define("foo") { order << "define" }
- order.should eql(["on_define", "define"])
+ Project.on_define { |project| order << 'on_define' }
+ define('foo') { order << 'define' }
+ order.should eql(['on_define', 'define'])
end
- it "should accept enhancement and call it after project block" do
+ it 'should accept enhancement and call it after project block' do
order = []
- Project.on_define { |project| project.enhance { order << "enhance" } }
- define("foo") { order << "define" }
- order.should eql(["define", "enhance"])
+ Project.on_define { |project| project.enhance { order << 'enhance' } }
+ define('foo') { order << 'define' }
+ order.should eql(['define', 'enhance'])
end
- it "should accept enhancement and call it with project" do
- Project.on_define { |project| project.enhance { |project| project.name.should eql("foo") } }
- define("foo")
+ it 'should accept enhancement and call it with project' do
+ Project.on_define { |project| project.enhance { |project| project.name.should eql('foo') } }
+ define('foo')
end
- it "should execute enhancement in namespace of project" do
+ it 'should execute enhancement in namespace of project' do
scopes = []
Project.on_define { |project| project.enhance { scopes << Rake.application.current_scope } }
- define("foo") { define "bar" }
- scopes.should eql([["foo"], ["foo", "bar"]])
+ define('foo') { define 'bar' }
+ scopes.should eql([['foo'], ['foo', 'bar']])
end
end
-describe Rake::Task, " recursive" do
+describe Rake::Task, ' recursive' do
before do
@order = []
Project.on_define do |project|
- project.recursive_task("doda") { @order << project.name }
+ project.recursive_task('doda') { @order << project.name }
end
- define("foo") { define("bar") { define("baz") } }
+ define('foo') { define('bar') { define('baz') } }
end
- it "should invoke same task in child project" do
- task("foo:doda").invoke
- @order.should include("foo:bar:baz")
- @order.should include("foo:bar")
- @order.should include("foo")
+ it 'should invoke same task in child project' do
+ task('foo:doda').invoke
+ @order.should include('foo:bar:baz')
+ @order.should include('foo:bar')
+ @order.should include('foo')
end
- it "should invoke in depth-first order" do
- task("foo:doda").invoke
- @order.should eql([ "foo:bar:baz", "foo:bar", "foo" ])
+ it 'should invoke in depth-first order' do
+ task('foo:doda').invoke
+ @order.should eql([ 'foo:bar:baz', 'foo:bar', 'foo' ])
end
- it "should not invoke task in parent project" do
- task("foo:bar:baz:doda").invoke
- @order.should eql([ "foo:bar:baz" ])
+ it 'should not invoke task in parent project' do
+ task('foo:bar:baz:doda').invoke
+ @order.should eql([ 'foo:bar:baz' ])
end
end
-describe "Sub-project" do
- it "should point at parent project" do
- define("foo") { define "bar" }
- project("foo:bar").parent.should be(project("foo"))
+describe 'Sub-project' do
+ it 'should point at parent project' do
+ define('foo') { define 'bar' }
+ project('foo:bar').parent.should be(project('foo'))
end
- it "should be defined only within parent project" do
- lambda { define("foo:bar") }.should raise_error
+ it 'should be defined only within parent project' do
+ lambda { define('foo:bar') }.should raise_error
end
- it "should have unique name" do
+ it 'should have unique name' do
lambda do
- define "foo" do
- define "bar"
- define "bar"
+ define 'foo' do
+ define 'bar'
+ define 'bar'
end
end.should raise_error
end
- it "should be findable from root" do
- define("foo") { define "bar" }
- projects.map(&:name).should include("foo:bar")
+ it 'should be findable from root' do
+ define('foo') { define 'bar' }
+ projects.map(&:name).should include('foo:bar')
end
- it "should be findable from parent project" do
- define("foo") { define "bar" }
- project("foo").projects.map(&:name).should include("foo:bar")
+ it 'should be findable from parent project' do
+ define('foo') { define 'bar' }
+ project('foo').projects.map(&:name).should include('foo:bar')
end
- it "should be findable only if exists" do
- define("foo") { define "bar" }
- lambda { project("foo").project("baz") }.should raise_error(RuntimeError, /No such project/)
+ it 'should be findable only if exists' do
+ define('foo') { define 'bar' }
+ lambda { project('foo').project('baz') }.should raise_error(RuntimeError, /No such project/)
end
- it "should always execute its definition " do
+ it 'should always execute its definition ' do
ordered = []
- define "foo" do
+ define 'foo' do
ordered << self.name
- define("bar") { ordered << self.name }
- define("baz") { ordered << self.name }
+ define('bar') { ordered << self.name }
+ define('baz') { ordered << self.name }
end
- ordered.should eql(["foo", "foo:bar", "foo:baz"])
+ ordered.should eql(['foo', 'foo:bar', 'foo:baz'])
end
- it "should execute in order of dependency" do
+ it 'should execute in order of dependency' do
ordered = []
- define "foo" do
+ define 'foo' do
ordered << self.name
- define("bar") { project("foo:baz") ; ordered << self.name }
- define("baz") { ordered << self.name }
+ define('bar') { project('foo:baz') ; ordered << self.name }
+ define('baz') { ordered << self.name }
end
- ordered.should eql(["foo", "foo:baz", "foo:bar"])
+ ordered.should eql(['foo', 'foo:baz', 'foo:bar'])
end
- it "should warn of circular dependency" do
+ it 'should warn of circular dependency' do
lambda do
- define "foo" do
- define("bar") { project("foo:baz") }
- define("baz") { project("foo:bar") }
+ define 'foo' do
+ define('bar') { project('foo:baz') }
+ define('baz') { project('foo:bar') }
end
end.should raise_error(RuntimeError, /Circular dependency/)
end
end
-describe "Top-level project" do
- it "should have no parent" do
- define("foo")
- project("foo").parent.should be_nil
+describe 'Top-level project' do
+ it 'should have no parent' do
+ define('foo')
+ project('foo').parent.should be_nil
end
end
-describe Buildr, "#project" do
- it "should raise error if no such project" do
- lambda { project("foo") }.should raise_error(RuntimeError, /No such project/)
+describe Buildr, '#project' do
+ it 'should raise error if no such project' do
+ lambda { project('foo') }.should raise_error(RuntimeError, /No such project/)
end
- it "should return a project if exists" do
- foo = define("foo")
- project("foo").should be(foo)
+ it 'should return a project if exists' do
+ foo = define('foo')
+ project('foo').should be(foo)
end
- it "should find a project by its full name" do
+ it 'should find a project by its full name' do
bar, baz = nil
- define("foo") { bar = define("bar") { baz = define("baz") } }
- project("foo:bar").should be(bar)
- project("foo:bar:baz").should be(baz)
+ define('foo') { bar = define('bar') { baz = define('baz') } }
+ project('foo:bar').should be(bar)
+ project('foo:bar:baz').should be(baz)
end
- it "should find a project from any context" do
+ it 'should find a project from any context' do
bar, baz = nil
- define("foo") { bar = define("bar") { baz = define("baz") } }
- project("foo:bar").project("foo:bar:baz").should be(baz)
- project("foo:bar:baz").project("foo:bar").should be(bar)
+ define('foo') { bar = define('bar') { baz = define('baz') } }
+ project('foo:bar').project('foo:bar:baz').should be(baz)
+ project('foo:bar:baz').project('foo:bar').should be(bar)
end
- it "should find a project from its parent or sibling project" do
- define "foo" do
- define "bar"
- define "baz"
+ it 'should find a project from its parent or sibling project' do
+ define 'foo' do
+ define 'bar'
+ define 'baz'
end
- project("foo").project("bar").should be(project("foo:bar"))
- project("foo").project("baz").should be(project("foo:baz"))
- project("foo:bar").project("baz").should be(project("foo:baz"))
+ project('foo').project('bar').should be(project('foo:bar'))
+ project('foo').project('baz').should be(project('foo:baz'))
+ project('foo:bar').project('baz').should be(project('foo:baz'))
end
- it "should fine a project from its parent by proximity" do
- define "foo" do
- define("bar") { define "baz" }
- define "baz"
+ it 'should fine a project from its parent by proximity' do
+ define 'foo' do
+ define('bar') { define 'baz' }
+ define 'baz'
end
- project("foo").project("baz").should be(project("foo:baz"))
- project("foo:bar").project("baz").should be(project("foo:bar:baz"))
+ project('foo').project('baz').should be(project('foo:baz'))
+ project('foo:bar').project('baz').should be(project('foo:bar:baz'))
end
- it "should invoke project before returning it" do
- define("foo").should_receive(:invoke).once
- project("foo")
+ it 'should invoke project before returning it' do
+ define('foo').should_receive(:invoke).once
+ project('foo')
end
- it "should fail if called without a project name" do
+ it 'should fail if called without a project name' do
lambda { project }.should raise_error(ArgumentError)
end
- it "should return self if called on a project without a name" do
- define("foo") { project.should be(self) }
+ it 'should return self if called on a project without a name' do
+ define('foo') { project.should be(self) }
end
- it "should evaluate parent project before returning" do
+ it 'should evaluate parent project before returning' do
# Note: gets around our define that also invokes the project.
- Buildr.define("foo") { define("bar"); define("baz") }
- project("foo:bar").should eql(projects[1])
+ Buildr.define('foo') { define('bar'); define('baz') }
+ project('foo:bar').should eql(projects[1])
end
end
-describe Buildr, "#projects" do
- it "should only return defined projects" do
+describe Buildr, '#projects' do
+ it 'should only return defined projects' do
projects.should eql([])
- define "foo"
- projects.should eql([project("foo")])
+ define 'foo'
+ projects.should eql([project('foo')])
end
- it "should return all defined projects" do
- define "foo"
- define("bar") { define "baz" }
- projects.should include(project("foo"))
- projects.should include(project("bar"))
- projects.should include(project("bar:baz"))
+ it 'should return all defined projects' do
+ define 'foo'
+ define('bar') { define 'baz' }
+ projects.should include(project('foo'))
+ projects.should include(project('bar'))
+ projects.should include(project('bar:baz'))
end
- it "should return only named projects" do
- define "foo" ; define "bar" ; define "baz"
- projects("foo", "bar").should include(project("foo"))
- projects("foo", "bar").should include(project("bar"))
- projects("foo", "bar").should_not include(project("baz"))
+ it 'should return only named projects' do
+ define 'foo' ; define 'bar' ; define 'baz'
+ projects('foo', 'bar').should include(project('foo'))
+ projects('foo', 'bar').should include(project('bar'))
+ projects('foo', 'bar').should_not include(project('baz'))
end
- it "should complain if named project does not exist" do
- define "foo"
- projects("foo").should include(project("foo"))
- lambda { projects("bar") }.should raise_error(RuntimeError, /No such project/)
+ it 'should complain if named project does not exist' do
+ define 'foo'
+ projects('foo').should include(project('foo'))
+ lambda { projects('bar') }.should raise_error(RuntimeError, /No such project/)
end
- it "should find a project from its parent or sibling project" do
- define "foo" do
- define "bar"
- define "baz"
+ it 'should find a project from its parent or sibling project' do
+ define 'foo' do
+ define 'bar'
+ define 'baz'
end
- project("foo").projects("bar").should eql(projects("foo:bar"))
- project("foo").projects("baz").should eql(projects("foo:baz"))
- project("foo:bar").projects("baz").should eql(projects("foo:baz"))
+ project('foo').projects('bar').should eql(projects('foo:bar'))
+ project('foo').projects('baz').should eql(projects('foo:baz'))
+ project('foo:bar').projects('baz').should eql(projects('foo:baz'))
end
- it "should fine a project from its parent by proximity" do
- define "foo" do
- define("bar") { define "baz" }
- define "baz"
+ it 'should fine a project from its parent by proximity' do
+ define 'foo' do
+ define('bar') { define 'baz' }
+ define 'baz'
end
- project("foo").projects("baz").should eql(projects("foo:baz"))
- project("foo:bar").projects("baz").should eql(projects("foo:bar:baz"))
+ project('foo').projects('baz').should eql(projects('foo:baz'))
+ project('foo:bar').projects('baz').should eql(projects('foo:bar:baz'))
end
- it "should evaluate all projects before returning" do
+ it 'should evaluate all projects before returning' do
# Note: gets around our define that also invokes the project.
- Buildr.define("foo") { define("bar"); define("baz") }
- projects.should eql(projects("foo", "foo:bar", "foo:baz"))
+ Buildr.define('foo') { define('bar'); define('baz') }
+ projects.should eql(projects('foo', 'foo:bar', 'foo:baz'))
end
end
-describe Rake::Task, " local directory" do
+describe Rake::Task, ' local directory' do
before do
- @task = Project.local_task(task(("doda")))
- Project.on_define { |project| task("doda") { |task| @task.from project.name } }
+ @task = Project.local_task(task(('doda')))
+ Project.on_define { |project| task('doda') { |task| @task.from project.name } }
end
- it "should execute project in local directory" do
- define "foo"
- @task.should_receive(:from).with("foo")
+ it 'should execute project in local directory' do
+ define 'foo'
+ @task.should_receive(:from).with('foo')
@task.invoke
end
- it "should execute sub-project in local directory" do
- @task.should_receive(:from).with("foo:bar")
- define("foo") { define "bar" }
- in_original_dir(project("foo:bar").base_dir) { @task.invoke }
+ it 'should execute sub-project in local directory' do
+ @task.should_receive(:from).with('foo:bar')
+ define('foo') { define 'bar' }
+ in_original_dir(project('foo:bar').base_dir) { @task.invoke }
end
- it "should do nothing if no project in local directory" do
+ it 'should do nothing if no project in local directory' do
@task.should_not_receive(:from)
- define("foo") { define "bar" }
- in_original_dir("../not_foo") { @task.invoke }
+ define('foo') { define 'bar' }
+ in_original_dir('../not_foo') { @task.invoke }
end
- it "should find closest project that matches current directory" do
- mkpath "bar/src/main"
- define("foo") { define "bar" }
- @task.should_receive(:from).with("foo:bar")
- in_original_dir("bar/src/main") { @task.invoke }
+ it 'should find closest project that matches current directory' do
+ mkpath 'bar/src/main'
+ define('foo') { define 'bar' }
+ @task.should_receive(:from).with('foo:bar')
+ in_original_dir('bar/src/main') { @task.invoke }
end
end
-describe Project, "#task" do
- it "should create a regular task" do
- define("foo") { task("bar") }
- Rake.application.lookup("foo:bar").should_not be_nil
+describe Project, '#task' do
+ it 'should create a regular task' do
+ define('foo') { task('bar') }
+ Rake.application.lookup('foo:bar').should_not be_nil
end
- it "should return a task defined in the project" do
- define("foo") { task("bar") }
- project("foo").task("bar").should be_instance_of(Rake::Task)
+ it 'should return a task defined in the project' do
+ define('foo') { task('bar') }
+ project('foo').task('bar').should be_instance_of(Rake::Task)
end
- it "should not create task outside project definition" do
- define "foo"
- lambda { project("foo").task("bar") }.should raise_error(RuntimeError, /no task foo:bar/)
+ it 'should not create task outside project definition' do
+ define 'foo'
+ lambda { project('foo').task('bar') }.should raise_error(RuntimeError, /no task foo:bar/)
end
- it "should include project name as prefix" do
- define("foo") { task("bar") }
- project("foo").task("bar").name.should eql("foo:bar")
+ it 'should include project name as prefix' do
+ define('foo') { task('bar') }
+ project('foo').task('bar').name.should eql('foo:bar')
end
- it "should accept single dependency" do
- define("foo") { task("bar"=>"baz") }
- project("foo").task("bar").prerequisites.should include("baz")
+ it 'should accept single dependency' do
+ define('foo') { task('bar'=>'baz') }
+ project('foo').task('bar').prerequisites.should include('baz')
end
- it "should accept multiple dependencies" do
- define("foo") { task("bar"=>["baz1", "baz2"]) }
- project("foo").task("bar").prerequisites.should include("baz1")
- project("foo").task("bar").prerequisites.should include("baz2")
+ it 'should accept multiple dependencies' do
+ define('foo') { task('bar'=>['baz1', 'baz2']) }
+ project('foo').task('bar').prerequisites.should include('baz1')
+ project('foo').task('bar').prerequisites.should include('baz2')
end
- it "should execute task exactly once" do
- define("foo") do
- task "baz"
- task "bar"=>"baz"
+ it 'should execute task exactly once' do
+ define('foo') do
+ task 'baz'
+ task 'bar'=>'baz'
end
- lambda { project("foo").task("bar").invoke }.should run_tasks(["foo:baz", "foo:bar"])
+ lambda { project('foo').task('bar').invoke }.should run_tasks(['foo:baz', 'foo:bar'])
end
- it "should create a file task" do
- define("foo") { file("bar") }
- Rake.application.lookup(File.expand_path("bar")).should_not be_nil
+ it 'should create a file task' do
+ define('foo') { file('bar') }
+ Rake.application.lookup(File.expand_path('bar')).should_not be_nil
end
- it "should create file task with absolute path" do
- define("foo") { file("/tmp") }
- Rake.application.lookup("/tmp").should_not be_nil
+ it 'should create file task with absolute path' do
+ define('foo') { file('/tmp') }
+ Rake.application.lookup('/tmp').should_not be_nil
end
- it "should create file task relative to project base directory" do
- define("foo", :base_dir=>"tmp") { file("bar") }
- Rake.application.lookup(File.expand_path("tmp/bar")).should_not be_nil
+ it 'should create file task relative to project base directory' do
+ define('foo', :base_dir=>'tmp') { file('bar') }
+ Rake.application.lookup(File.expand_path('tmp/bar')).should_not be_nil
end
- it "should accept single dependency" do
- define("foo") { file("bar"=>"baz") }
- project("foo").file("bar").prerequisites.should include("baz")
+ it 'should accept single dependency' do
+ define('foo') { file('bar'=>'baz') }
+ project('foo').file('bar').prerequisites.should include('baz')
end
- it "should accept multiple dependencies" do
- define("foo") { file("bar"=>["baz1", "baz2"]) }
- project("foo").file("bar").prerequisites.should include("baz1")
- project("foo").file("bar").prerequisites.should include("baz2")
+ it 'should accept multiple dependencies' do
+ define('foo') { file('bar'=>['baz1', 'baz2']) }
+ project('foo').file('bar').prerequisites.should include('baz1')
+ project('foo').file('bar').prerequisites.should include('baz2')
end
- it "should accept hash arguments" do
- define("foo") do
- task "bar"=>"bar_dep"
- file "baz"=>"baz_dep"
+ it 'should accept hash arguments' do
+ define('foo') do
+ task 'bar'=>'bar_dep'
+ file 'baz'=>'baz_dep'
end
- project("foo").task("bar").prerequisites.should include("bar_dep")
- project("foo").file("baz").prerequisites.should include("baz_dep")
+ project('foo').task('bar').prerequisites.should include('bar_dep')
+ project('foo').file('baz').prerequisites.should include('baz_dep')
end
- it "should return a file task defined in the project" do
- define("foo") { file("bar") }
- project("foo").file("bar").should be_instance_of(Rake::FileTask)
+ it 'should return a file task defined in the project' do
+ define('foo') { file('bar') }
+ project('foo').file('bar').should be_instance_of(Rake::FileTask)
end
- it "should create file task relative to project definition" do
- define("foo") { define "bar" }
- project("foo:bar").file("baz").name.should eql(File.expand_path("bar/baz"))
+ it 'should create file task relative to project definition' do
+ define('foo') { define 'bar' }
+ project('foo:bar').file('baz').name.should eql(File.expand_path('bar/baz'))
end
- it "should execute task exactly once" do
- define("foo") do
- task "baz"
- file "bar"=>"baz"
+ it 'should execute task exactly once' do
+ define('foo') do
+ task 'baz'
+ file 'bar'=>'baz'
end
- lambda { project("foo").file("bar").invoke }.should run_tasks(["foo:baz", project("foo").path_to("bar")])
+ lambda { project('foo').file('bar').invoke }.should run_tasks(['foo:baz', project('foo').path_to('bar')])
end
end
@@ -589,7 +686,7 @@
class TestAttributes
include InheritedAttributes
inherited_attr :foo
- inherited_attr :bar do "barring" end
+ inherited_attr :bar do 'barring' end
attr_accessor :parent
end
@parent = TestAttributes.new
@@ -597,36 +694,36 @@
@child.parent = @parent
end
- it "should have getter and setter methods" do
- @parent.foo = "foo"
- @parent.bar = "bar"
- @parent.foo.should eql("foo")
- @parent.bar.should eql("bar")
+ it 'should have getter and setter methods' do
+ @parent.foo = 'foo'
+ @parent.bar = 'bar'
+ @parent.foo.should eql('foo')
+ @parent.bar.should eql('bar')
end
- it "should take default value from block" do
+ it 'should take default value from block' do
@parent.foo.should be_nil
- @parent.bar.should eql("barring")
+ @parent.bar.should eql('barring')
end
- it "should take default value from parent" do
+ it 'should take default value from parent' do
@child.foo.should be_nil
- @parent.foo = "foo"
- @child.foo.should eql("foo")
+ @parent.foo = 'foo'
+ @child.foo.should eql('foo')
@child.foo.should be(@parent.foo)
end
- it "should cache default value from parent" do
- @parent.foo = "foo"
- @child.foo.should eql("foo")
- @parent.foo = "bar"
- @child.foo.should eql("foo")
+ it 'should cache default value from parent' do
+ @parent.foo = 'foo'
+ @child.foo.should eql('foo')
+ @parent.foo = 'bar'
+ @child.foo.should eql('foo')
end
- it "should set value in child separately from parent" do
- @child.bar = "barred"
- @child.bar.should eql("barred")
- @parent.bar.should eql("barring")
+ it 'should set value in child separately from parent' do
+ @child.bar = 'barred'
+ @child.bar.should eql('barred')
+ @parent.bar.should eql('barring')
end
after do
@@ -634,14 +731,17 @@
end
end
-describe Rake::Task, " buildr:initialize" do
- it "should be ready to run as the first task" do
- Rake.application.top_level_tasks.first.should eql("buildr:initialize")
+
+describe Rake::Task, ' buildr:initialize' do
+ it 'should be ready to run as the first task' do
+ Rake.application.top_level_tasks.first.should eql('buildr:initialize')
end
- it "should evaluate all project definitions" do
+ it 'should evaluate all project definitions' do
defined = false
- Buildr.define("foo") { defined = true }
- lambda { task("buildr:initialize").invoke }.should change { defined }.to(true)
+ Buildr.define('foo') { defined = true }
+ lambda { task('buildr:initialize').invoke }.should change { defined }.to(true)
end
end
+
+
Modified: incubator/buildr/trunk/spec/sandbox.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/spec/sandbox.rb?rev=608023&r1=608022&r2=608023&view=diff
==============================================================================
--- incubator/buildr/trunk/spec/sandbox.rb (original)
+++ incubator/buildr/trunk/spec/sandbox.rb Tue Jan 1 22:30:09 2008
@@ -269,6 +269,7 @@
# Later on we'll want to lose all the on_define created during the test.
@sandbox[:on_define] = Project.class_eval { (@on_define || []).dup }
+ @sandbox[:layout] = Layout.default.clone
# Create a local repository we can play with. However, our local repository will be void
# of some essential artifacts (e.g. JUnit artifacts required by build task), so we create
@@ -297,6 +298,7 @@
Project.clear
on_define = @sandbox[:on_define]
Project.class_eval { @on_define = on_define }
+ Layout.default = @sandbox[:layout].clone
# Switch back Rake directory.
Dir.chdir @sandbox[:pwd]