Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

* gradle plugin: arguments support for launch* tasks #789

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand All @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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() {
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand All @@ -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);
Expand Down
Loading