You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildr.apache.org by to...@apache.org on 2011/07/11 08:59:32 UTC
svn commit: r1145043 - in /buildr/trunk: CHANGELOG
lib/buildr/java/commands.rb
Author: toulmean
Date: Mon Jul 11 06:59:32 2011
New Revision: 1145043
URL: http://svn.apache.org/viewvc?rev=1145043&view=rev
Log:
BUILDR-439 'The command line is too long' when running TestNG tests
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=1145043&r1=1145042&r2=1145043&view=diff
==============================================================================
--- buildr/trunk/CHANGELOG (original)
+++ buildr/trunk/CHANGELOG Mon Jul 11 06:59:32 2011
@@ -1,6 +1,8 @@
1.4.7 (Pending)
+* Fixed: BUILDR-439 "The command line is too long" when running TestNG tests (Tammo Van Lessen)
* Fixed: BUILDR-596 Update installation notes to talk about the all-in-one bundle
+
1.4.6 (2011-06-21)
* Added: BUILDR-592 Allow Users to Specify SSH Options for Deployment (Marc-André Laverdière)
* Fixed: BUILDR-591 Sort modules in iml files generated by idea task to ensure
Modified: buildr/trunk/lib/buildr/java/commands.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/java/commands.rb?rev=1145043&r1=1145042&r2=1145043&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/java/commands.rb (original)
+++ buildr/trunk/lib/buildr/java/commands.rb Mon Jul 11 06:59:32 2011
@@ -56,12 +56,39 @@ module Java
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
- unless Buildr.application.options.dryrun
- info "Running #{name}" if name && options[:verbose]
- block = lambda { |ok, res| fail "Failed to execute #{name}, see errors above" unless ok } unless block
- cmd_args = cmd_args.map(&:inspect).join(' ') if Util.win_os?
- sh(*cmd_args) do |ok, ps|
- block.call ok, ps
+
+ tmp = nil
+ begin
+ # Windows can't handle cmd lines greater than 2048/8192 chars.
+ # If our cmd line is longer, we create a batch file and execute it instead.
+ if Util.win_os? && cmd_args.map(&:inspect).join(' ').size > 2048
+ # remove '-classpath' and the classpath itself from the cmd line.
+ cp_i = cmd_args.index{|x| x.starts_with('-classpath')}
+ 2.times do
+ cmd_args.delete_at cp_i unless cp_i.nil?
+ end
+ # create tmp batch file.
+ tmp = Tempfile.new(['starter', '.bat'])
+ tmp.write "@echo off\n"
+ tmp.write "SET CLASSPATH=#{cp.join(File::PATH_SEPARATOR).gsub(%r{/}, '\\')}\n"
+ tmp.write cmd_args.map(&:inspect).join(' ')
+ tmp.close
+ # set new cmd line.
+ cmd_args = [tmp.path]
+ end
+
+ unless Buildr.application.options.dryrun
+ info "Running #{name}" if name && options[:verbose]
+ block = lambda { |ok, res| fail "Failed to execute #{name}, see errors above" unless ok } unless block
+ cmd_args = cmd_args.map(&:inspect).join(' ') if Util.win_os?
+ sh(*cmd_args) do |ok, ps|
+ block.call ok, ps
+ end
+ end
+ ensure
+ unless tmp.nil?
+ tmp.close
+ tmp.unlink
end
end
end