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

Path to emulator #777

Merged
merged 3 commits into from
Mar 10, 2019
Merged
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
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<groupId>com.simpligility.maven.plugins</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>4.5.1-SNAPSHOT</version>
<version>4.5.2-SNAPSHOT</version>
<packaging>maven-plugin</packaging>

<name>Android Maven Plugin - android-maven-plugin</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public abstract class AbstractEmulatorMojo extends AbstractAndroidMojo
* &lt;wait&gt;20000&lt;/wait&gt;
* &lt;options&gt;-no-skin&lt;/options&gt;
* &lt;executable&gt;emulator-arm&lt;/executable&gt;
* &lt;location&gt;C:/SDK/emulator&lt;/location&gt;
* &lt;/emulator&gt;
* </pre>
* or configure as properties on the command line as android.emulator.avd, android.emulator.wait,
Expand Down Expand Up @@ -143,7 +144,6 @@ public abstract class AbstractEmulatorMojo extends AbstractAndroidMojo
@Parameter( property = "android.emulator.options" )
private String emulatorOptions;


/**
* Override default emulator executable. Default uses just "emulator".
*
Expand All @@ -152,21 +152,34 @@ public abstract class AbstractEmulatorMojo extends AbstractAndroidMojo
@Parameter( property = "android.emulator.executable" )
private String emulatorExecutable;

/**
* Override default path to emulator folder.
*/
@Parameter( property = "android.emulator.location" )
private String emulatorLocation;

/**
* parsed value for avd that will be used for the invocation.
*/
private String parsedAvd;

/**
* parsed value for options that will be used for the invocation.
*/
private String parsedOptions;

/**
* parsed value for wait that will be used for the invocation.
*/
private String parsedWait;

private String parsedExecutable;

/**
* parsed value for location that will be used for the invocation.
*/
private String parsedEmulatorLocation;

private static final String START_EMULATOR_MSG = "Starting android emulator with script: ";
private static final String START_EMULATOR_WAIT_MSG = "Waiting for emulator start:";

Expand Down Expand Up @@ -264,7 +277,7 @@ protected void startAndroidEmulator() throws MojoExecutionException
throw new MojoExecutionException( "", e );
}
}

/**
* Unlocks the emulator.
* @param androidDebugBridge
Expand Down Expand Up @@ -767,7 +780,15 @@ public Boolean call() throws IOException
*/
private String assembleStartCommandLine() throws MojoExecutionException
{
String emulatorPath = new File ( getAndroidSdk().getToolsPath(), parsedExecutable ).getAbsolutePath();
String emulatorPath;
if ( !"SdkTools".equals( parsedEmulatorLocation ) )
{
emulatorPath = new File( parsedEmulatorLocation, parsedExecutable ).getAbsolutePath();
}
else
{
emulatorPath = new File( getAndroidSdk().getToolsPath(), parsedExecutable ).getAbsolutePath();
}
StringBuilder startCommandline = new StringBuilder( "\"\"" ).append( emulatorPath ).append( "\"\"" )
.append( " -avd " ).append( parsedAvd ).append( " " );
if ( !StringUtils.isEmpty( parsedOptions ) )
Expand All @@ -789,7 +810,7 @@ private void parseParameters()
parsedAvd = emulator.getAvd();
}
else
{
{
parsedAvd = determineAvd();
}
// <emulator><options> exists in pom file
Expand All @@ -798,7 +819,7 @@ private void parseParameters()
parsedOptions = emulator.getOptions();
}
else
{
{
parsedOptions = determineOptions();
}
// <emulator><wait> exists in pom file
Expand All @@ -807,7 +828,7 @@ private void parseParameters()
parsedWait = emulator.getWait();
}
else
{
{
parsedWait = determineWait();
}
// <emulator><emulatorExecutable> exists in pom file
Expand All @@ -816,9 +837,18 @@ private void parseParameters()
parsedExecutable = emulator.getExecutable();
}
else
{
{
parsedExecutable = determineExecutable();
}
// <emulator><location> exists in pom file
if ( emulator.getLocation() != null )
{
parsedEmulatorLocation = emulator.getLocation();
}
else
{
parsedEmulatorLocation = determineEmulatorLocation();
}
}
// commandline options
else
Expand All @@ -827,6 +857,7 @@ private void parseParameters()
parsedOptions = determineOptions();
parsedWait = determineWait();
parsedExecutable = determineExecutable();
parsedEmulatorLocation = determineEmulatorLocation();
}
}

Expand Down Expand Up @@ -905,4 +936,24 @@ String determineAvd()
}
return avd;
}

/**
* Get location value for emulator from command line option.
*
* @return if available return command line value otherwise return default value ("SdkTools").
*/
String determineEmulatorLocation()
{
String location;
if ( emulatorLocation != null )
{
location = emulatorLocation;
}
else
{
location = "SdkTools";
}
return location;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ public class Emulator
*/
private String executable;

public String getLocation()
{
return location;
}

private String location;

public String getAvd()
{
return avd;
Expand Down