buildr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vbo...@apache.org
Subject svn commit: r645590 - in /incubator/buildr/trunk: addon/buildr/ lib/buildr/core/ lib/buildr/ide/ lib/buildr/java/ lib/buildr/tasks/
Date Mon, 07 Apr 2008 16:19:16 GMT
Author: vborja
Date: Mon Apr  7 09:19:15 2008
New Revision: 645590

URL: http://svn.apache.org/viewvc?rev=645590&view=rev
Log:
Util.relative_path

Modified:
    incubator/buildr/trunk/addon/buildr/xmlbeans.rb
    incubator/buildr/trunk/lib/buildr/core/compile.rb
    incubator/buildr/trunk/lib/buildr/core/filter.rb
    incubator/buildr/trunk/lib/buildr/ide/eclipse.rb
    incubator/buildr/trunk/lib/buildr/ide/idea.rb
    incubator/buildr/trunk/lib/buildr/ide/idea7x.rb
    incubator/buildr/trunk/lib/buildr/java/packaging.rb
    incubator/buildr/trunk/lib/buildr/java/test_frameworks.rb
    incubator/buildr/trunk/lib/buildr/tasks/zip.rb

Modified: incubator/buildr/trunk/addon/buildr/xmlbeans.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/addon/buildr/xmlbeans.rb?rev=645590&r1=645589&r2=645590&view=diff
==============================================================================
--- incubator/buildr/trunk/addon/buildr/xmlbeans.rb (original)
+++ incubator/buildr/trunk/addon/buildr/xmlbeans.rb Mon Apr  7 09:19:15 2008
@@ -76,9 +76,9 @@
       # into the target directory, or the rest is useless.
       compile do |task|
         verbose(false) do
-          base = Pathname.new(generated.to_s)
+          base = generated.to_s
           FileList["#{base}/**/*.{class,xsb,xsd}"].each do |file|
-            target = File.join(compile.target.to_s, Pathname.new(file).relative_path_from(base))
+            target = File.join(compile.target.to_s, Util.relative_path(base, file))
             mkpath File.dirname(target) ; cp file, target
           end
         end

Modified: incubator/buildr/trunk/lib/buildr/core/compile.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/core/compile.rb?rev=645590&r1=645589&r2=645590&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/buildr/core/compile.rb (original)
+++ incubator/buildr/trunk/lib/buildr/core/compile.rb Mon Apr  7 09:19:15 2008
@@ -170,9 +170,8 @@
         ext_glob = Array(self.class.source_ext).join(',')
         sources.flatten.inject({}) do |map, source|
           if File.directory?(source)
-            base = Pathname.new(source)
             FileList["#{source}/**/*.{#{ext_glob}}"].reject { |file| File.directory?(file)
}.
-              each { |file| map[file] = File.join(target, Pathname.new(file).relative_path_from(base).to_s.ext(target_ext))
}
+              each { |file| map[file] = File.join(target, Util.relative_path(source, file).ext(target_ext))
}
           else
             map[source] = File.join(target, File.basename(source).ext(target_ext))
           end

Modified: incubator/buildr/trunk/lib/buildr/core/filter.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/core/filter.rb?rev=645590&r1=645589&r2=645590&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/buildr/core/filter.rb (original)
+++ incubator/buildr/trunk/lib/buildr/core/filter.rb Mon Apr  7 09:19:15 2008
@@ -165,9 +165,8 @@
       raise 'No target directory specified, where am I going to copy the files to?' if target.nil?
 
       copy_map = sources.flatten.map(&:to_s).inject({}) do |map, source|
-        base = Pathname.new(source)
         files = FileList.recursive(source).
-          map { |file| Pathname.new(file).relative_path_from(base).to_s }.
+          map { |file| Util.relative_path(file, source) }.
           select { |file| @include.empty? || @include.any? { |pattern| File.fnmatch(pattern,
file, File::FNM_PATHNAME) } }.
           reject { |file| @exclude.any? { |pattern| File.fnmatch(pattern, file, File::FNM_PATHNAME)
} }
         files.each do |file|

Modified: incubator/buildr/trunk/lib/buildr/ide/eclipse.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/ide/eclipse.rb?rev=645590&r1=645589&r2=645590&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/buildr/ide/eclipse.rb (original)
+++ incubator/buildr/trunk/lib/buildr/ide/eclipse.rb Mon Apr  7 09:19:15 2008
@@ -14,7 +14,6 @@
 # the License.
 
 
-require 'pathname'
 require 'buildr/core/project'
 require 'buildr/java/artifact'
 
@@ -65,7 +64,7 @@
             path or raise "Invalid path '#{path.inspect}'"
             msg = [:to_path, :to_str, :to_s].find { |msg| path.respond_to? msg }
             path = path.__send__(msg)
-            Pathname.new(File.expand_path(path)).relative_path_from(Pathname.new(project.path_to)).to_s
+            Util.relative_path(File.expand_path(path), project.path_to)
           end
 
           m2repo = Buildr::Repositories.instance.local

Modified: incubator/buildr/trunk/lib/buildr/ide/idea.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/ide/idea.rb?rev=645590&r1=645589&r2=645590&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/buildr/ide/idea.rb (original)
+++ incubator/buildr/trunk/lib/buildr/ide/idea.rb Mon Apr  7 09:19:15 2008
@@ -14,7 +14,6 @@
 # the License.
 
 
-require 'pathname'
 require 'buildr/core/project'
 require 'buildr/java/artifact'
 require 'stringio'
@@ -48,9 +47,7 @@
       sources << File.expand_path(Rake.application.rakefile, root_path) if Rake.application.rakefile
 
       # Find a path relative to the project's root directory.
-      relative = lambda do |path|
-        Pathname.new(path.to_s).relative_path_from(Pathname.new(project.path_to)).to_s
-      end
+      relative = lambda { |path| Util.relative_path(path.to_s, project.path_to) }
 
       m2repo = Buildr::Repositories.instance.local
       excludes = [ '**/.svn/', '**/CVS/' ].join('|')

Modified: incubator/buildr/trunk/lib/buildr/ide/idea7x.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/ide/idea7x.rb?rev=645590&r1=645589&r2=645590&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/buildr/ide/idea7x.rb (original)
+++ incubator/buildr/trunk/lib/buildr/ide/idea7x.rb Mon Apr  7 09:19:15 2008
@@ -14,7 +14,6 @@
 # the License.
 
 
-require 'pathname'
 require 'buildr/core/project'
 require 'buildr/java/artifact'
 require 'stringio'
@@ -54,9 +53,7 @@
       sources << File.expand_path(Rake.application.rakefile, root_path) if Rake.application.rakefile
 
       # Find a path relative to the project's root directory.
-      relative = lambda do |path|
-        Pathname.new(File.expand_path(path.to_s)).relative_path_from(Pathname.new(project.path_to)).to_s
-      end
+      relative = lambda { |path| Util.relative_path(File.expand_path(path.to_s), project.path_to)
}
 
       m2repo = Buildr::Repositories.instance.local
       excludes = [ '**/.svn/', '**/CVS/' ].join('|')

Modified: incubator/buildr/trunk/lib/buildr/java/packaging.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/java/packaging.rb?rev=645590&r1=645589&r2=645590&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/buildr/java/packaging.rb (original)
+++ incubator/buildr/trunk/lib/buildr/java/packaging.rb Mon Apr  7 09:19:15 2008
@@ -455,20 +455,14 @@
 
       private
 
-        # :call-seq:
-        #   relative_path(to_component, from_component = nil)
-        #
-        def relative_path(to, from = ".")
-          to = File.join(to[:path].to_s, File.basename(to[:artifact].to_s)) if to.kind_of?(Hash)
-          from = from[:path].to_s if from.kind_of?(Hash)
-          to, from = File.expand_path(to, "/"), File.expand_path(from, "/")
-          Util.relative_path(to, from)
-        end
-
         # Classpath of all packages included as libraries (type :lib).
         def libs_classpath(component)
+          from = component[:path]
           @classpath = @components.select { |comp| comp[:type] == :lib }.
-            map { |comp| relative_path(comp, component) }
+            map do |lib| 
+            lib_path = File.join(lib[:path].to_s, lib[:artifact].pathmap('%f'))
+            Util.relative_path(lib_path, from)
+          end
         end
 
         def descriptor_xml
@@ -480,7 +474,7 @@
           xml.application do
             xml.tag! 'display-name', display_name
             @components.each do |comp|
-              uri = relative_path(comp)
+              uri = relative_path(File.join(comp[:path].to_s, comp[:artifact].pathmap('%f')))
               case comp[:type]
               when :war
                 xml.module :id=>comp[:id] do

Modified: incubator/buildr/trunk/lib/buildr/java/test_frameworks.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/java/test_frameworks.rb?rev=645590&r1=645589&r2=645590&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/buildr/java/test_frameworks.rb (original)
+++ incubator/buildr/trunk/lib/buildr/java/test_frameworks.rb Mon Apr  7 09:19:15 2008
@@ -18,7 +18,6 @@
 require 'buildr/core/compile'
 require 'buildr/java/ant'
 
-
 module Buildr
 
   class TestFramework
@@ -46,9 +45,9 @@
       #
       def filter_classes(dependencies, criteria = {})
         return [] unless task.compile.target
-        target = Pathname.new(task.compile.target.to_s)
+        target = task.compile.target.to_s
         candidates = Dir["#{target}/**/*.class"].
-          map { |file| Pathname.new(file).relative_path_from(target).to_s.ext('').gsub(File::SEPARATOR,
'.') }.
+          map { |file| Util.relative_path(file, target).ext('').gsub(File::SEPARATOR, '.')
}.
           reject { |name| name =~ /\$/ }
         result = []
         if criteria[:class_names]

Modified: incubator/buildr/trunk/lib/buildr/tasks/zip.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/tasks/zip.rb?rev=645590&r1=645589&r2=645590&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/buildr/tasks/zip.rb (original)
+++ incubator/buildr/trunk/lib/buildr/tasks/zip.rb Mon Apr  7 09:19:15 2008
@@ -217,8 +217,7 @@
           source.entries.reject { |entry| entry.directory? }.each do |entry|
             if @includes.any? { |pattern| File.fnmatch(pattern, entry.name, File::FNM_PATHNAME)
} &&
                !@excludes.any? { |pattern| File.fnmatch(pattern, entry.name, File::FNM_PATHNAME)
}
-              dest = Pathname.new(File.expand_path(path + "/" + entry.name, '/')).
-                              relative_path_from(Pathname.new(File.expand_path('/'))).to_s
+              dest = Util.relative_path(path + "/" + entry.name)
               puts "Adding #{dest}" if Rake.application.options.trace
               file_map[dest] = lambda { |output| output.write source.read(entry) }
             end



Mime
View raw message