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/01/24 04:11:52 UTC

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

Author: donaldp
Date: Thu Jan 24 03:11:52 2013
New Revision: 1437848

URL: http://svn.apache.org/viewvc?rev=1437848&view=rev
Log:
Support the :dir option in the Java::Commands.java method.

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=1437848&r1=1437847&r2=1437848&view=diff
==============================================================================
--- buildr/trunk/CHANGELOG (original)
+++ buildr/trunk/CHANGELOG Thu Jan 24 03:11:52 2013
@@ -1,4 +1,5 @@
 1.4.10 (Pending)
+* Added:  Support the :dir option in the Java::Commands.java method.
 * Fixed:  Scala 2.10 support - compiler now uses additional/separate jars
           introduced in 2.10 such as scala-reflect.jar and scala-actor.jar
 * Added:  Add an addon for NSIS.

Modified: buildr/trunk/lib/buildr/java/commands.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/java/commands.rb?rev=1437848&r1=1437847&r2=1437848&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/java/commands.rb (original)
+++ buildr/trunk/lib/buildr/java/commands.rb Thu Jan 24 03:11:52 2013
@@ -33,6 +33,7 @@ module Java
       #       "-o", "src/main/webapp/styles/styles-all-min.css")
       #
       # The last argument may be a Hash with additional options:
+      # * :dir -- The working directory from which to execute task..
       # * :classpath -- One or more file names, tasks or artifact specifications.
       #   These are all expanded into artifacts, and all tasks are invoked.
       # * :java_args -- Any additional arguments to pass (e.g. -hotspot, -xms)
@@ -49,7 +50,18 @@ module Java
           name = "java #{args.first}"
         end
 
-        cmd_args = [path_to_bin('java')]
+        cmd_args = []
+        if options[:dir]
+          pwd = options[:dir]
+          if Buildr::Util.win_os?
+            # Ruby uses forward slashes regardless of platform,
+            # unfortunately cd c:/some/path fails on Windows
+            cmd_args << "cd /d \"#{pwd.gsub(%r{/}, '\\')}\" && "
+          else
+            cmd_args << "cd '#{pwd}' && "
+          end
+        end
+        cmd_args << path_to_bin('java')
         cp = classpath_from(options)
         cmd_args << '-classpath' << cp.join(File::PATH_SEPARATOR) unless cp.empty?
         options[:properties].each { |k, v| cmd_args << "-D#{k}=#{v}" } if options[:properties]