You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildr.apache.org by do...@apache.org on 2013/10/08 05:36:43 UTC

svn commit: r1530141 - in /buildr/trunk: CHANGELOG lib/buildr/java/commands.rb

Author: donaldp
Date: Tue Oct  8 03:36:43 2013
New Revision: 1530141

URL: http://svn.apache.org/r1530141
Log:
Support disabling the new "pathing_jar" functionality in Java::Commands.java utility method. Required for tools that introspect the classpath.

Modified:
    buildr/trunk/CHANGELOG
    buildr/trunk/lib/buildr/java/commands.rb

Modified: buildr/trunk/CHANGELOG
URL: http://svn.apache.org/viewvc/buildr/trunk/CHANGELOG?rev=1530141&r1=1530140&r2=1530141&view=diff
==============================================================================
--- buildr/trunk/CHANGELOG (original)
+++ buildr/trunk/CHANGELOG Tue Oct  8 03:36:43 2013
@@ -1,4 +1,7 @@
 1.4.14 (Pending)
+* Change: Support disabling the new "pathing_jar" functionality in
+          Java::Commands.java utility method. Required for tools
+          that introspect the classpath.
 * Change: Update wsgen addon to generate source into a directory
           hierarchy based on maven conventions.
 * Fixed:  Fixed regression using transitive dependencies due to

Modified: buildr/trunk/lib/buildr/java/commands.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/java/commands.rb?rev=1530141&r1=1530140&r2=1530141&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/java/commands.rb (original)
+++ buildr/trunk/lib/buildr/java/commands.rb Tue Oct  8 03:36:43 2013
@@ -40,10 +40,13 @@ module Java
       # * :properties -- Hash of system properties (e.g. 'path'=>base_dir).
       # * :name -- Shows this name, otherwise shows the first argument (the class name).
       # * :verbose -- If true, prints the command and all its argument.
+      # * :pathing_jar -- If true, forces the use of a "pathing" jar, false disables. Nil
+      #                   will default to using a "pathing" jar under windows with long classpaths.
+      #                   See http://stackoverflow.com/questions/201816/how-to-set-a-long-java-classpath-in-msdos-windows
       def java(*args, &block)
         options = Hash === args.last ? args.pop : {}
         options[:verbose] ||= trace?(:java)
-        rake_check_options options, :classpath, :java_args, :properties, :name, :verbose, :dir
+        rake_check_options options, :classpath, :java_args, :properties, :name, :verbose, :dir, :pathing_jar
 
         name = options[:name]
         if name.nil?
@@ -63,21 +66,27 @@ module Java
         end
         cmd_args << path_to_bin('java')
         cp = classpath_from(options)
-        paths = cp.map do |c|
-          path = File.directory?(c) && !c.end_with?('/') ? "#{c}/" : c.to_s
-          Buildr::Util.win_os? ? "/#{path}" : path
-        end
-        manifest = Buildr::Packaging::Java::Manifest.new([{'Class-Path' => paths.join(" ")}])
 
-        tjar = Tempfile.new(['javacmd', '.jar'])
-        Zip::ZipOutputStream.open(tjar.path) do |zos|
-          zos.put_next_entry('META-INF/MANIFEST.MF')
-          zos.write manifest.to_s
-          zos.write "\n"
-        end
-        tjar.close
+        unless cp.empty?
+          if options[:pathing_jar] == true || (options[:pathing_jar].nil? && Util.win_os? && cp.join(':').size > 2048)
+            paths = cp.map do |c|
+              path = File.directory?(c) && !c.end_with?('/') ? "#{c}/" : c.to_s
+              Buildr::Util.win_os? ? "/#{path}" : path
+            end
+            manifest = Buildr::Packaging::Java::Manifest.new([{'Class-Path' => paths.join(" ")}])
+            tjar = Tempfile.new(['javacmd', '.jar'])
+            Zip::ZipOutputStream.open(tjar.path) do |zos|
+              zos.put_next_entry('META-INF/MANIFEST.MF')
+              zos.write manifest.to_s
+              zos.write "\n"
+            end
+            tjar.close
 
-        cmd_args << '-classpath' << tjar.path
+            cmd_args << '-classpath' << tjar.path
+          else
+            cmd_args << '-classpath' << cp.join(File::PATH_SEPARATOR)
+          end
+        end
         options[:properties].each { |k, v| cmd_args << "-D#{k}=#{v}" } if options[:properties]
         cmd_args += (options[:java_args] || (ENV['JAVA_OPTS'] || ENV['JAVA_OPTIONS']).to_s.split).flatten
         cmd_args += args.flatten.compact