You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildr.apache.org by la...@apache.org on 2008/10/25 19:59:50 UTC

svn commit: r707877 - in /incubator/buildr/trunk: CHANGELOG lib/buildr/ide/eclipse.rb spec/ide/eclipse_spec.rb

Author: lacton
Date: Sat Oct 25 10:59:49 2008
New Revision: 707877

URL: http://svn.apache.org/viewvc?rev=707877&view=rev
Log:
BUILDR-187 Source code attachment for Eclipse .classpath

Modified:
    incubator/buildr/trunk/CHANGELOG
    incubator/buildr/trunk/lib/buildr/ide/eclipse.rb
    incubator/buildr/trunk/spec/ide/eclipse_spec.rb

Modified: incubator/buildr/trunk/CHANGELOG
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/CHANGELOG?rev=707877&r1=707876&r2=707877&view=diff
==============================================================================
--- incubator/buildr/trunk/CHANGELOG (original)
+++ incubator/buildr/trunk/CHANGELOG Sat Oct 25 10:59:49 2008
@@ -10,6 +10,7 @@
 * Change: BUILDR-171 Eclipse task generates meta-data files for projects with
           test source code but no main source code. 
 * Change: BUILDR-177 Moved cobertura and emma extensions to lib directory.
+* Change: BUILDR-187 Source code attachment for Eclipse .classpath.
 * Fixed:  Removed double complete/fail messages showing up on console.
 * Fixed:  BUILDR-158 Nailgun is now a delegate for buildr/drb (a pure-ruby dRuby server)
 * Fixed:  BUILDR-172 Scala compiler not loaded by default.

Modified: incubator/buildr/trunk/lib/buildr/ide/eclipse.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/ide/eclipse.rb?rev=707877&r1=707876&r2=707877&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/buildr/ide/eclipse.rb (original)
+++ incubator/buildr/trunk/lib/buildr/ide/eclipse.rb Sat Oct 25 10:59:49 2008
@@ -150,7 +150,7 @@
       end
 
       # Write a classpathentry of kind 'src'.
-      # Accepts an array of absolute paths or a task.
+      # Accept an array of absolute paths or a task.
       def src arg
         if [:sources, :target].all? { |message| arg.respond_to?(message) }
           src_from_task arg
@@ -160,7 +160,7 @@
       end
 
       # Write a classpathentry of kind 'src' for dependent projects.
-      # Accepts an array of projects.
+      # Accept an array of projects.
       def src_projects project_libs
         project_libs.map(&:id).sort.uniq.each do |project_id|
           @xml.classpathentry :kind=>'src', :combineaccessrules=>'false', :path=>"/#{project_id}"
@@ -171,9 +171,15 @@
         @xml.classpathentry :kind=>'output', :path=>relative(target)
       end
 
+      # Write a classpathentry of kind 'var' (variable) for Maven2 dependencies.
+      # E.g., var([lib1, lib2], 'M2_REPO', '/home/me/.m2/repo')
       def var libs, var_name, var_value
-        libs.map { |lib| lib.to_s.sub(var_value, var_name) }.sort.uniq.each do |path|
-          @xml.classpathentry :kind=>'var', :path=>path
+        libs.each do |lib_path|
+          lib_artifact = file(lib_path)
+          source_path = lib_artifact.sources_artifact.to_s
+          relative_lib_path = lib_path.sub(var_value, var_name)
+          relative_source_path = source_path.sub(var_value, var_name)
+          @xml.classpathentry :kind=>'var', :path=>relative_lib_path, :sourcepath=>relative_source_path
         end
       end
               

Modified: incubator/buildr/trunk/spec/ide/eclipse_spec.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/spec/ide/eclipse_spec.rb?rev=707877&r1=707876&r2=707877&view=diff
==============================================================================
--- incubator/buildr/trunk/spec/ide/eclipse_spec.rb (original)
+++ incubator/buildr/trunk/spec/ide/eclipse_spec.rb Sat Oct 25 10:59:49 2008
@@ -301,6 +301,11 @@
     it 'should be downloaded' do
       file(artifact('com.example:library:jar:2.0').name).should exist
     end
+    
+    it 'should have a source artifact reference in the .classpath file' do
+      sourcepath_for_path('M2_REPO/com/example/library/2.0/library-2.0.jar').
+        should == ['M2_REPO/com/example/library/2.0/library-2.0-sources.jar']
+    end
   end
   
 end