You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildr.apache.org by dj...@apache.org on 2009/06/23 02:02:45 UTC
svn commit: r787465 - in /buildr/trunk/lib/buildr: groovy/shell.rb
scala/shell.rb shell.rb
Author: djspiewak
Date: Tue Jun 23 00:02:44 2009
New Revision: 787465
URL: http://svn.apache.org/viewvc?rev=787465&view=rev
Log:
Generic shell specification support
Modified:
buildr/trunk/lib/buildr/groovy/shell.rb
buildr/trunk/lib/buildr/scala/shell.rb
buildr/trunk/lib/buildr/shell.rb
Modified: buildr/trunk/lib/buildr/groovy/shell.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/groovy/shell.rb?rev=787465&r1=787464&r2=787465&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/groovy/shell.rb (original)
+++ buildr/trunk/lib/buildr/groovy/shell.rb Tue Jun 23 00:02:44 2009
@@ -2,19 +2,13 @@
module Buildr
module Groovy
- class Shell
- attr_reader :project
-
+ class GroovySH < Buildr::Shell::Base
class << self
def lang
:groovy
end
end
- def initialize(project)
- @project = project
- end
-
def launch
# TODO make this more generic!!
@@ -29,4 +23,4 @@
end
end
-Buildr::ShellProviders << Buildr::Groovy::Shell
+Buildr::ShellProviders << Buildr::Groovy::GroovySH
Modified: buildr/trunk/lib/buildr/scala/shell.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/scala/shell.rb?rev=787465&r1=787464&r2=787465&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/scala/shell.rb (original)
+++ buildr/trunk/lib/buildr/scala/shell.rb Tue Jun 23 00:02:44 2009
@@ -2,17 +2,15 @@
module Buildr
module Scala
- class Shell
- attr_reader :project
-
+ class ScalaShell < Buildr::Shell::Base
class << self
def lang
:scala
end
- end
-
- def initialize(project)
- @project = project
+
+ def to_sym
+ :scala
+ end
end
def launch
@@ -32,4 +30,4 @@
end
end
-Buildr::ShellProviders << Buildr::Scala::Shell
+Buildr::ShellProviders << Buildr::Scala::ScalaShell
Modified: buildr/trunk/lib/buildr/shell.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/shell.rb?rev=787465&r1=787464&r2=787465&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/shell.rb (original)
+++ buildr/trunk/lib/buildr/shell.rb Tue Jun 23 00:02:44 2009
@@ -1,6 +1,5 @@
module Buildr
module ShellProviders
-
class << self
def add(p)
@providers ||= {}
@@ -21,20 +20,50 @@
Project.local_task 'shell'
end
- after_define do |project|
- project.task 'shell' => :compile do
- lang = project.compile.language
- trace "Launching shell based on language #{lang}"
-
- p = ShellProviders.providers[lang]
+ before_define do |project|
+ ShellProviders.providers.each do |lang, p|
+ name = p.to_sym
- if p
+ project.task "shell:#{name}" => :compile do
+ trace "Launching #{name} shell"
p.new(project).launch
- else
- fail "No shell provider defined for language #{lang}"
end
end
end
+
+ after_define do |project|
+ lang = project.compile.language
+ default_shell = ShellProviders.providers[lang]
+
+ if default_shell
+ dep = "shell:#{default_shell.to_sym}"
+
+ trace "Defining :shell task based on #{dep}"
+ project.task :shell => dep
+ else
+ project.task :shell do
+ fail "No shell provider defined for language '#{lang}'"
+ end
+ end
+ end
+
+ class Base
+ attr_reader :project
+
+ class << self
+ def to_sym
+ @symbol ||= name.split('::').last.downcase.to_sym
+ end
+ end
+
+ def initialize(project)
+ @project = project
+ end
+
+ def launch
+ fail 'Not implemented'
+ end
+ end
end
class Project