lib/jbundler/classpath_file.rb in jbundler-0.6.4 vs lib/jbundler/classpath_file.rb in jbundler-0.7.0

- old
+ new

@@ -23,10 +23,14 @@ class ClasspathFile def initialize(classpathfile = '.jbundler/classpath.rb') @classpathfile = classpathfile end + + def file + @classpathfile + end def load_classpath load File.expand_path @classpathfile end @@ -59,11 +63,11 @@ def jarlock_newer?( jarfile ) jarfile.exists_lock? && (jarfile.mtime_lock > mtime) end def needs_update?(jarfile, gemfile_lock) - if jarfile.exists? || gemfile_lock.exists? || jarfile.exists_lock? + if ( jarfile.exists? || gemfile_lock.exists? || jarfile.exists_lock? ) missing?( jarfile ) || jarfile_newer?( jarfile ) || jarlock_newer?( jarfile ) || gemfile_lock.newer?( mtime ) else false end end @@ -85,16 +89,27 @@ private def dump_array( file, array, prefix, local_repo ) file.puts "JBUNDLER_#{prefix}CLASSPATH = []" array.each do |path| - if local_repo - path.sub!( /#{local_repo}/, '' ) - file.puts "JBUNDLER_#{prefix}CLASSPATH << (JBUNDLER_LOCAL_REPO + '#{path}')" unless path =~ /pom$/ - else - file.puts "JBUNDLER_#{prefix}CLASSPATH << '#{path}'" unless path =~ /pom$/ - end + dump_jar( file, path, prefix, local_repo ) end file.puts "JBUNDLER_#{prefix}CLASSPATH.freeze" + end + + def dump_jar( file, path, prefix, local_repo ) + return if path =~ /pom$/ + if local_repo + path.sub!( /#{local_repo}/, '' ) + unless File.exists?( path ) + file.puts "JBUNDLER_#{prefix}CLASSPATH << (JBUNDLER_LOCAL_REPO + '#{path}')" + path = nil + end + end + if path + # either we do not have a local_repo or the path is a absolute + # path from system artifact + file.puts "JBUNDLER_#{prefix}CLASSPATH << '#{path}'" + end end end end