JavaExec: args with blanks and "


(Juergen Zimmermann) #1

Using the JavaExec I want to execute this command:

java -cp %JBOSS_HOME%\jboss-modules.jar ^
org.jboss.modules.Main ^
-mp %JBOSS_HOME%\modules org.jboss.as.cli -c --command="deploy build/libs/shop.war --force"

I tried the following settings without success. Any hint is appreciated!

classpath = configurations.deploy
main = 'org.jboss.modules.Main'
args '-mp', "${System.getenv('JBOSS_HOME')}/modules", 'org.jboss.as.cli', '-c', '--command="deploy build/libs/shop.war --force"'

(François Guillot) #2

What happens exactly? What’s the error message?


(Juergen Zimmermann) #3

I’m getting this error message:

:deploy
INFO  [org.jboss.modules] JBoss Modules version 1.4.3.Final
'build/libs/shop.war' is assumed to be a command(s) but the commands to execute have been specified by another argument: [deploy]
:deploy FAILED

It’ just the same like doing the wrong invocation:

java -cp ... --command=deploy build/libs/shop.war --force

Instead of the correct invocation:

java -cp ... --command="deploy build/libs/shop.war --force"

However, I don’t know where the " is lost.


(François Guillot) #4

I’m assuming you are running under Windows, in which case it looks like https://issues.gradle.org/plugins/servlet/mobile#issue/GRADLE-2779
See JavaExec and quotes on Windows


(Juergen Zimmermann) #5

Yes, I’m running on Windows. In fact it looks like https://issues.gradle.org/browse/GRADLE-2779.
When I’m using

args ..., '--command="deploy build/libs/shop.war --force"'

then the quote is lost. Also when using " instead of ".
However, when I’m using

args ..., '--command=""deploy build/libs/shop.war --force""'

then both quotes remain. Also when using " instead of ".
Therefore, I cannot deploy a Java EE app to WildFly aka JBoss when running on Windows…
BTW, the same issue happens when I try to use the ANT plugin for executing the Java class.


(Chris Robinson) #6

I got my Wildfly 8 working by adding “\x22” instead of the quotes.

Example:
–command=\x22deploy PATH --all-server-groups\x22


(Rajnandini Ranbhare) #7

I am facing the same problem with wildfly 10 when I am executing undeploy command using groovy script as below

‘{Wildfly_home}/bin/jboss-cli.sh -c --command=“undeploy {earfile}”’.execute()

The error I received is as below
’***.ear"’ is assumed to be a command(s) but the commands to execute have been specified by another argument: ["undeploy]

Can anyone help me with this? I tried with escape quotes as well but of no use