You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildr.apache.org by bo...@apache.org on 2010/04/05 02:30:24 UTC
svn commit: r930768 - /buildr/trunk/lib/buildr/scala/compiler.rb
Author: boisvert
Date: Mon Apr 5 00:30:24 2010
New Revision: 930768
URL: http://svn.apache.org/viewvc?rev=930768&view=rev
Log:
Fix cut & paste issue:
- version = Buildr.settings.build['scala.check'] || DEFAULT_VERSION
+ version = Buildr.settings.build['scala.version'] || DEFAULT_VERSION
and minor refactoring while I'm at it.
Modified:
buildr/trunk/lib/buildr/scala/compiler.rb
Modified: buildr/trunk/lib/buildr/scala/compiler.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/scala/compiler.rb?rev=930768&r1=930767&r2=930768&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/scala/compiler.rb (original)
+++ buildr/trunk/lib/buildr/scala/compiler.rb Mon Apr 5 00:30:24 2010
@@ -31,28 +31,24 @@ module Buildr::Scala
def installed_version
unless @installed_version
@installed_version = if Scalac.installed?
- version_str = begin
+ begin
# try to read the value from the properties file
props = Zip::ZipFile.open(File.expand_path('lib/scala-library.jar', Scalac.scala_home)) do |zipfile|
zipfile.read 'library.properties'
end
- md = props.match /version\.number\s*=\s*([^\s]+)/
- if md.nil? then nil else md[1] end
- rescue
- nil
- end
+ version_str = props.match(/version\.number\s*=\s*([^\s]+)/).to_a[1]
- unless version_str.nil?
- md = version_str.match(/\d+\.\d[\d\.]*/) or
- fail "Unable to parse Scala version: #{version_str}"
+ if version_str
+ md = version_str.match(/\d+\.\d[\d\.]*/) or
+ fail "Unable to parse Scala version: #{version_str}"
- md[0].sub(/.$/, "") # remove trailing dot, if any
- else
+ md[0].sub(/.$/, "") # remove trailing dot, if any
+ end
+ rescue => e
+ warn "Unable to parse library.properties in $SCALA_HOME/lib/scala-library.jar: #{e}"
nil
end
- else
- nil
end
end
@@ -60,23 +56,13 @@ module Buildr::Scala
end
def version
- if Buildr.settings.build['scala.version']
- Buildr.settings.build['scala.version']
- elsif installed_version
- installed_version
- else
- DEFAULT_VERSION
- end
+ Buildr.settings.build['scala.version'] || installed_version || DEFAULT_VERSION
end
def compatible_28?
- md = version.match /^(\d)\.(\d)/
- unless md.nil?
- if md[1].to_i == 2
- md[2].to_i >= 8
- else
- md[1].to_i > 2
- end
+ major, minor = version.match(/^(\d)\.(\d)/).to_a[1,2]
+ if major && minor
+ (major.to_i == 2 && minor.to_i >= 8) || (major.to_i > 2)
else
false
end
@@ -105,7 +91,7 @@ module Buildr::Scala
# namespace before this file is required. This is of course, only
# if SCALA_HOME is not set or invalid.
REQUIRES = ArtifactNamespace.for(self) do |ns|
- version = Buildr.settings.build['scala.check'] || DEFAULT_VERSION
+ version = Buildr.settings.build['scala.version'] || DEFAULT_VERSION
ns.library! 'org.scala-lang:scala-library:jar:>=' + version
ns.compiler! 'org.scala-lang:scala-compiler:jar:>=' + version
end
@@ -129,7 +115,7 @@ module Buildr::Scala
if installed? && Buildr.settings.build['scala.version']
Buildr.settings.build['scala.version'] == Scala.installed_version
else
- !Buildr.settings.build['scala.version'] && installed?
+ Buildr.settings.build['scala.version'].nil? && installed?
end
end