You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildr.apache.org by vb...@apache.org on 2008/05/01 08:02:00 UTC
svn commit: r652435 - in /incubator/buildr/trunk:
lib/buildr/core/application.rb lib/buildr/java/version_requirement.rb
lib/buildr/packaging/artifact_namespace.rb spec/artifact_spec.rb
spec/version_requirement_spec.rb
Author: vborja
Date: Wed Apr 30 23:01:59 2008
New Revision: 652435
URL: http://svn.apache.org/viewvc?rev=652435&view=rev
Log:
Artifacts should be loaded from build.yaml just as documentation says.
Added specs for this.
Modified:
incubator/buildr/trunk/lib/buildr/core/application.rb
incubator/buildr/trunk/lib/buildr/java/version_requirement.rb
incubator/buildr/trunk/lib/buildr/packaging/artifact_namespace.rb
incubator/buildr/trunk/spec/artifact_spec.rb
incubator/buildr/trunk/spec/version_requirement_spec.rb
Modified: incubator/buildr/trunk/lib/buildr/core/application.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/core/application.rb?rev=652435&r1=652434&r2=652435&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/buildr/core/application.rb (original)
+++ incubator/buildr/trunk/lib/buildr/core/application.rb Wed Apr 30 23:01:59 2008
@@ -173,6 +173,7 @@
standard_exception_handling do
find_buildfile
load_gems
+ load_artifacts
load_buildfile
top_level
load_tasks
@@ -187,6 +188,16 @@
end
end
+ # Load artifact specs from the build.yaml file, making them available
+ # by name ( ruby symbols ).
+ def load_artifacts #:nodoc:
+ hash = settings.build['artifacts']
+ return unless hash
+ raise "Expected 'artifacts' element to be a hash" unless Hash === hash
+ # Currently we only use one artifact namespace to rule them all. (the root NS)
+ Buildr::ArtifactNamespace.load(:root => hash)
+ end
+
# Load/install all Gems specified in build.yaml file.
def load_gems #:nodoc:
missing_deps, installed = listed_gems.partition { |gem| gem.is_a?(Gem::Dependency) }
Modified: incubator/buildr/trunk/lib/buildr/java/version_requirement.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/java/version_requirement.rb?rev=652435&r1=652434&r2=652435&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/buildr/java/version_requirement.rb (original)
+++ incubator/buildr/trunk/lib/buildr/java/version_requirement.rb Wed Apr 30 23:01:59 2008
@@ -24,8 +24,8 @@
CMP_REGEX = Gem::Requirement::OP_RE.dup
CMP_CHARS = CMP_PROCS.keys.join
BOOL_CHARS = '\|\&\!'
- VER_CHARS = '\w\.'
-
+ VER_CHARS = '\w\.\-'
+
class << self
# is +str+ a version string?
def version?(str)
Modified: incubator/buildr/trunk/lib/buildr/packaging/artifact_namespace.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/packaging/artifact_namespace.rb?rev=652435&r1=652434&r2=652435&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/buildr/packaging/artifact_namespace.rb (original)
+++ incubator/buildr/trunk/lib/buildr/packaging/artifact_namespace.rb Wed Apr 30 23:01:59 2008
@@ -496,13 +496,25 @@
# Return an artifact spec without the version part.
def unversioned_spec
- to_spec[/^([a-zA-Z._-]+(:[a-zA-Z._-]+){2,3})/]
+ str = to_spec
+ return nil if str =~ /^:+/
+ ary = str.split(':')
+ ary = ary[0...-1] if ary.size > 3
+ ary.join(':')
end
class << self
# Return an artifact spec without the version part.
def unversioned_spec(spec)
- spec.to_s[/^([a-zA-Z._-]+(:[a-zA-Z._-]+){2,3})/] || new(spec).unversioned_spec
+ str = spec.to_s
+ return nil if str =~ /^:+/
+ ary = str.split(':')
+ ary = ary[0...-1] if ary.size > 3
+ if ary.size > 2
+ ary.join(':')
+ else
+ new(spec).unversioned_spec
+ end
end
end
end
Modified: incubator/buildr/trunk/spec/artifact_spec.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/spec/artifact_spec.rb?rev=652435&r1=652434&r2=652435&view=diff
==============================================================================
--- incubator/buildr/trunk/spec/artifact_spec.rb (original)
+++ incubator/buildr/trunk/spec/artifact_spec.rb Wed Apr 30 23:01:59 2008
@@ -424,6 +424,15 @@
artifact = artifact('group:id:jar:1.0').from('test.jar')
lambda { artifact.invoke }.should change { File.exist?(artifact.to_s) }.to(true)
end
+
+ it 'should reference artifacts defined on build.yaml by using ruby symbols' do
+ write 'build.yaml', <<-YAML
+ artifacts:
+ j2ee: geronimo-spec:geronimo-spec-j2ee:jar:1.4-rc4
+ YAML
+ Buildr.application.load_artifacts
+ artifact(:j2ee).to_s.pathmap('%f').should == 'geronimo-spec-j2ee-1.4-rc4.jar'
+ end
end
Modified: incubator/buildr/trunk/spec/version_requirement_spec.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/spec/version_requirement_spec.rb?rev=652435&r1=652434&r2=652435&view=diff
==============================================================================
--- incubator/buildr/trunk/spec/version_requirement_spec.rb (original)
+++ incubator/buildr/trunk/spec/version_requirement_spec.rb Wed Apr 30 23:01:59 2008
@@ -30,6 +30,10 @@
lambda { create('1.0') }.should_not raise_error(Exception)
lambda { create('1.0rc3') }.should_not raise_error(Exception)
end
+
+ it 'should allow versions using hyphen' do
+ lambda { create('1.0-rc3') }.should_not raise_error(Exception)
+ end
it 'should create a single version requirement' do
create('1.0').should_not have_alternatives