diff --git a/plugins/gradle/src/main/java/org/robovm/gradle/tasks/AbstractSimulatorTask.java b/plugins/gradle/src/main/java/org/robovm/gradle/tasks/AbstractSimulatorTask.java index c1ce0a047..508841ce1 100755 --- a/plugins/gradle/src/main/java/org/robovm/gradle/tasks/AbstractSimulatorTask.java +++ b/plugins/gradle/src/main/java/org/robovm/gradle/tasks/AbstractSimulatorTask.java @@ -15,7 +15,9 @@ */ package org.robovm.gradle.tasks; +import org.apache.tools.ant.types.Commandline; import org.gradle.api.tasks.Internal; +import org.gradle.api.tasks.options.Option; import org.robovm.compiler.AppCompiler; import org.robovm.compiler.config.Arch; import org.robovm.compiler.config.Config; @@ -25,11 +27,18 @@ import org.robovm.gradle.RoboVMGradleException; import java.io.File; +import java.util.Arrays; /** * */ public abstract class AbstractSimulatorTask extends AbstractRoboVMTask { + private String[] args; + + @Option(option = "args", description = "Command line arguments passed to app.") + public void setArgs(String args) { + this.args = Commandline.translateCommandline(args); + } protected void launch(DeviceType type) { try { @@ -42,6 +51,9 @@ protected void launch(DeviceType type) { Config config = compiler.getConfig(); IOSSimulatorLaunchParameters launchParameters = (IOSSimulatorLaunchParameters) config.getTarget().createLaunchParameters(); launchParameters.setDeviceType(type); + if (args != null) { + launchParameters.setArguments(Arrays.asList(args)); + } if (extension.getStdoutFifo() != null) { File stdoutFifo = new File(extension.getStdoutFifo()); diff --git a/plugins/gradle/src/main/java/org/robovm/gradle/tasks/ConsoleTask.java b/plugins/gradle/src/main/java/org/robovm/gradle/tasks/ConsoleTask.java index 1008e476d..3058873ef 100755 --- a/plugins/gradle/src/main/java/org/robovm/gradle/tasks/ConsoleTask.java +++ b/plugins/gradle/src/main/java/org/robovm/gradle/tasks/ConsoleTask.java @@ -15,6 +15,8 @@ */ package org.robovm.gradle.tasks; +import org.apache.tools.ant.types.Commandline; +import org.gradle.api.tasks.options.Option; import org.robovm.compiler.AppCompiler; import org.robovm.compiler.config.Arch; import org.robovm.compiler.config.Config; @@ -23,10 +25,18 @@ import org.robovm.compiler.target.LaunchParameters; import org.robovm.gradle.RoboVMGradleException; +import java.util.Arrays; + /** * */ public class ConsoleTask extends AbstractRoboVMTask { + private String[] args; + + @Option(option = "args", description = "Command line arguments passed to app.") + public void setArgs(String args) { + this.args = Commandline.translateCommandline(args); + } @Override public void invoke() { @@ -39,6 +49,9 @@ public void invoke() { AppCompiler compiler = build(OS.getDefaultOS(), arch, ConsoleTarget.TYPE); Config config = compiler.getConfig(); LaunchParameters launchParameters = config.getTarget().createLaunchParameters(); + if (args != null) { + launchParameters.setArguments(Arrays.asList(args)); + } compiler.launch(launchParameters); } catch (Throwable t) { throw new RoboVMGradleException("Failed to launch console application", t); diff --git a/plugins/gradle/src/main/java/org/robovm/gradle/tasks/IOSDeviceTask.java b/plugins/gradle/src/main/java/org/robovm/gradle/tasks/IOSDeviceTask.java index a792cfa3e..05a682457 100755 --- a/plugins/gradle/src/main/java/org/robovm/gradle/tasks/IOSDeviceTask.java +++ b/plugins/gradle/src/main/java/org/robovm/gradle/tasks/IOSDeviceTask.java @@ -15,6 +15,8 @@ */ package org.robovm.gradle.tasks; +import org.apache.tools.ant.types.Commandline; +import org.gradle.api.tasks.options.Option; import org.robovm.compiler.AppCompiler; import org.robovm.compiler.config.Arch; import org.robovm.compiler.config.Config; @@ -23,12 +25,21 @@ import org.robovm.compiler.target.ios.IOSTarget; import org.robovm.gradle.RoboVMGradleException; +import java.util.Arrays; + /** * * @author Junji Takakura */ public class IOSDeviceTask extends AbstractRoboVMTask { + private String[] args; + + @Option(option = "args", description = "Command line arguments passed to app.") + public void setArgs(String args) { + this.args = Commandline.translateCommandline(args); + } + @Override public void invoke() { try { @@ -47,6 +58,9 @@ public void invoke() { if(udid != null && !udid.isEmpty()){ launchParameters.setDeviceId(udid); } + if (args != null) { + launchParameters.setArguments(Arrays.asList(args)); + } compiler.launch(launchParameters); } catch (Throwable t) { throw new RoboVMGradleException("Failed to launch IOS Device", t);