Changeset 6133

Show
Ignore:
Timestamp:
11/27/06 18:13:15
Author:
jan
Message:

getting rid of platform probs

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/jerbil/java_helper.rb

    r6132 r6133  
    1212module Jerbil 
    1313  IS_WINDOWS = RUBY_PLATFORM =~ /mswin|mingw/i 
    14   JAVA_PATH_SEPERATOR = IS_WINDOWS ? ';' : ':' 
    15   DIR_SEP = IS_WINDOWS ? "\\" : "/" 
    16   DIR_SEP_FOR_SUBSTITUTION = IS_WINDOWS ? "\\\\" : "/" 
     14  JAVA_PATH_SEPARATOR = File::PATH_SEPARATOR 
    1715   
    1816  # The JavaHelper module provides common helper functionality needed across different 
     
    228226    # For example src/org/foo/Baz -> org.foo.Baz. 
    229227    def to_classnames 
    230       # remove the initial directory and separator 
    231       sub = srcdir + DIR_SEP_FOR_SUBSTITUTION 
    232       paths = self.pathmap("%{^#{sub},}X") 
    233        
    234       paths.gsub!(DIR_SEP, ".") 
    235       #paths.gsub!("/", "." ) 
     228      # remove the initial directory and separator      
     229      paths = self.pathmap("%{^#{srcdir_quoted}/?,}X") 
     230      paths.gsub!("/", ".") 
    236231    end 
    237232     
     
    239234    # load the specified classes into the virtual machine. 
    240235    def to_classes 
    241       classnames = to_classnames 
     236      classnames = to_classnames       
    242237      classes = classnames.map {|name| Rjb::import(name)} 
    243238      classes.to_a 
     
    249244    # For example src/org/foo/Baz.java -> classes/org/foo/Baz.class. 
    250245    def to_classfiles 
    251       self.pathmap("%{^#{srcdir},#{dstdir}}X.class") 
     246      self.pathmap("%{^#{srcdir_quoted},#{dstdir}}X.class") 
    252247    end 
    253248     
     
    273268    # Calls block once for each resource found in +srcdir+, passing 
    274269    # the source and destination file as parameter. 
    275     def resource_and_target # :yields: resource,target 
     270    def resource_and_target # :yields: resource,target    
    276271      resources.each do | r | 
    277         target =  r.sub(/#{srcdir}/, dstdir) 
     272        target =  r.sub(/#{srcdir_quoted}/, dstdir) 
    278273        yield r, target if block_given? 
    279274      end 
     
    284279    def source_and_target    # :yields: src,target 
    285280      self.each do |file| 
    286           yield file, file.pathmap("%{^#{srcdir},#{dstdir}}X.class") 
     281          yield file, file.pathmap("%{^#{srcdir_quoted},#{dstdir}}X.class") 
    287282      end       
    288     end 
     283    end         
    289284     
    290285    def out_of_date 
     
    314309      exts.to_a.each {|ext| add_extension(ext)}       
    315310    end     
     311     
     312    private  
     313    def srcdir_quoted 
     314      Regexp.quote(srcdir) 
     315    end 
    316316  end 
    317317   
     
    342342     
    343343    def sourcepath 
    344       self.srcdir.join(JAVA_PATH_SEPERATOR) 
     344      self.srcdir.join(JAVA_PATH_SEPARATOR) 
    345345    end 
    346346     
     
    407407    # Returns the filelist formatted as Java classpath. 
    408408    # ("/tmp/foo.jar:/tmp/baz.jar") 
    409     def to_cp(sep = Jerbil::JAVA_PATH_SEPERATOR) 
     409    def to_cp(sep = Jerbil::JAVA_PATH_SEPARATOR) 
    410410      self.join(sep) 
    411411    end 
  • trunk/lib/jerbil/javac_task.rb

    r6104 r6133  
    4747          parms += [ "-sourcepath", java_files.sourcepath ] if java_files.sourcepath  
    4848           
    49           parms << "-verbose" if verbose 
     49          parms << "-verbose" if verbose               
     50          parms += extra_args.collect {|a|a.to_s} if extra_args 
    5051           
     52          files = gather_filenames 
     53              
    5154          # must do this to prevent javac bombing out on the file package-info.java 
    5255          # due to known javac bug 6198196 - 
    53           # http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6198196 
    54           java_files.gsub!( "/", "\\" ) if Jerbil::IS_WINDOWS 
    55                   
    56           parms += extra_args.collect {|a|a.to_s} if extra_args         
    57           parms += gather_filenames     
    58             
     56          # http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6198196         
     57          if Jerbil::IS_WINDOWS 
     58            files.map! {|fn| fn.sub("/", "\\")} 
     59          end 
     60           
     61          parms += files  
     62           
    5963          #require 'pp' 
    6064          #pp parms 
  • trunk/test/test_java_helper.rb

    r6131 r6133  
    3030      assert_equal 'java.util.Map', cf[1].getName 
    3131    end 
     32     
    3233   
    3334    def test_to_cp 
     
    3839     
    3940    def test_javafiles 
    40       flist = JavaFileList.new(File.join(File.dirname(__FILE__), "../example/src"), "../example/build") 
    41       assert_equal 5, flist.to_classnames.length, flist.to_classnames 
     41      flist = JavaFileList.new( 
     42        File.join(File.dirname(__FILE__), "..", "example", "src"), 
     43        File.join(File.dirname(__FILE__), "..", "example", "build")) 
     44       
     45      classnames = flist.to_classnames 
     46      assert_equal 5, classnames.length, classnames 
    4247      assert_equal 1, flist.resources.length, flist.resources 
     48           
     49      assert_equal ['jerbil.example.JerbilEntity',  
     50        'jerbil.example.Jerbiliser', 
     51        'jerbil.example.Main', 
     52        'jerbil.example.Main2', 
     53        'jerbil.example.MyAnnotation'], classnames.sort 
     54     
     55      #assert_equal ['./../example/src/jerbil/example/example.properties'],  
     56      #  flist.resources.sort 
    4357       
    4458      #flist.source_and_target do |s,t|