Author: lacton
Date: Sat Oct 25 10:59:14 2008
New Revision: 707876
URL: http://svn.apache.org/viewvc?rev=707876&view=rev
Log:
BUILDR-187 Convenience method to easily access sources artifacts for IDE tasks
Modified:
incubator/buildr/trunk/lib/buildr/packaging/artifact.rb
incubator/buildr/trunk/spec/packaging/artifact_spec.rb
Modified: incubator/buildr/trunk/lib/buildr/packaging/artifact.rb
URL:
http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/packaging/artifact.rb?rev=707876&r1=707875&r2=707876&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/buildr/packaging/artifact.rb (original)
+++ incubator/buildr/trunk/lib/buildr/packaging/artifact.rb Sat Oct 25 10:59:14
2008
@@ -98,6 +98,17 @@
end
# :call-seq:
+ # sources_artifact => Artifact
+ #
+ # Convenience method that returns a sources artifact.
+ def sources_artifact
+ sources_spec = to_spec_hash.merge(:classifier=>'sources')
+ sources_task =
OptionalArtifact.define_task(Buildr.repositories.locate(sources_spec))
+ sources_task.send :apply_spec, sources_spec
+ sources_task
+ end
+
+ # :call-seq:
# pom_xml => string
#
# Creates POM XML for this artifact.
@@ -414,22 +425,6 @@
# If downloading fails, the user will be informed but it will not raise an
exception.
class OptionalArtifact < Artifact
- class << self
-
- # :call-seq:
- # register_source_artifact_for(spec)
- #
- # Register the source artifact corresponding to the provided artifact
spec
- # so that the 'sources' task will try to download it.
- def register_source_artifact_for(spec)
- sources_spec = spec.merge(:classifier=>'sources')
- sources_task =
OptionalArtifact.define_task(Buildr.repositories.locate(sources_spec))
- sources_task.send :apply_spec, sources_spec
- Rake::Task['artifacts:sources'].enhance [sources_task]
- end
-
- end
-
protected
# If downloading fails, the user will be informed but it will not raise an
exception.
@@ -627,7 +622,7 @@
task.send :apply_spec, spec
Rake::Task['rake:artifacts'].enhance [task]
Artifact.register(task)
- OptionalArtifact.register_source_artifact_for(spec) unless spec[:type]
== :pom
+ Rake::Task['artifacts:sources'].enhance [task.sources_artifact] unless
spec[:type] == :pom
end
task.enhance &block
end
Modified: incubator/buildr/trunk/spec/packaging/artifact_spec.rb
URL:
http://svn.apache.org/viewvc/incubator/buildr/trunk/spec/packaging/artifact_spec.rb?rev=707876&r1=707875&r2=707876&view=diff
==============================================================================
--- incubator/buildr/trunk/spec/packaging/artifact_spec.rb (original)
+++ incubator/buildr/trunk/spec/packaging/artifact_spec.rb Sat Oct 25 10:59:14
2008
@@ -75,6 +75,10 @@
@classified.pom.to_hash.should ==
@classified.to_hash.merge(:type=>:pom).except(:classifier)
end
+ it 'should have associated sources artifact' do
+ @artifact.sources_artifact.to_hash.should ==
@artifact.to_hash.merge(:classifier=>'sources')
+ end
+
it 'should download file if file does not exist' do
lambda { @artifact.invoke }.should raise_error(Exception, /No remote
repositories/)
lambda { @classified.invoke }.should raise_error(Exception, /No remote
repositories/)