Hi Ittay,
On Aug 31, 2008, at 3:02 AM, Ittay Dror wrote:
This patch adds the ability to run buildr as 'buildr -p <project
name>', instead of 'cd' to the project's base directory. This is
more comfortable when building several projects and when using
buildr as a tool from an ide (since specifying an argument is easier
than specifying a working dir)
I think all patches (both fixes and enhancements) need to be submitted
via buildr's issue tracker for apache licensing reasons.
http://issues.apache.org/jira/browse/Buildr
I'm sure someone will correct me if I'm wrong.
Thanks,
Rhett
---
lib/buildr/core/application_cli.rb | 6 +++++-
lib/buildr/core/project.rb | 4 ++++
2 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/lib/buildr/core/application_cli.rb b/lib/buildr/core/
application_cli.rb
index 3a19cf9..3f826e8 100644
--- a/lib/buildr/core/application_cli.rb
+++ b/lib/buildr/core/application_cli.rb
@@ -59,7 +59,9 @@ module Buildr
['--version', '-v', GetoptLong::NO_ARGUMENT,
'Display the program version.'],
['--environment', '-e', GetoptLong::REQUIRED_ARGUMENT,
- 'Environment name (e.g. development, test, production).']
+ 'Environment name (e.g. development, test, production).'],
+ ['--project', '-p', GetoptLong::REQUIRED_ARGUMENT,
+ 'Project name, can be relative to current directory']
]
def collect_tasks
@@ -99,6 +101,8 @@ module Buildr
options.show_task_pattern = Regexp.new(value || '.')
when '--nosearch', '--quiet', '--trace'
super
+ when '--project'
+ options.project = value
end
end
diff --git a/lib/buildr/core/project.rb b/lib/buildr/core/project.rb
index 6a37751..d5c511a 100644
--- a/lib/buildr/core/project.rb
+++ b/lib/buildr/core/project.rb
@@ -336,6 +336,10 @@ module Buildr
end
def local_projects(dir = nil, &block) #:nodoc:
+ if dir.nil? and Buildr.application.options.project
+ projects = local_projects('.').map{|p|
project("#{p}:#{Buildr.application.options.project}")}
+ return projects if projects
+ end
dir = File.expand_path(dir || Buildr.application.original_dir)
projects = Project.projects.select { |project|
project.base_dir == dir }
if projects.empty? && dir != Dir.pwd && File.dirname(dir) !=
dir
--
1.6.0.36.g3814c
--
Ittay Dror <[EMAIL PROTECTED]>
Tikal <http://www.tikalk.com>
Tikal Project <http://tikal.sourceforge.net>