private Event<AndroidExtensionConfigured> afterConfiguration;
public void configureAndroidSdk(@Observes BeforeSuite event, ArquillianDescriptor descriptor)
throws AndroidConfigurationException {
AndroidExtensionConfiguration configuration = new AndroidExtensionConfiguration();
boolean configured = false;
for (ExtensionDef extensionDef : descriptor.getExtensions()) {
if (ANDROID_EXTENSION_NAME.equals(extensionDef.getExtensionName())) {
ConfigurationMapper.fromArquillianDescriptor(descriptor, configuration, extensionDef.getExtensionProperties());
configured = true;
log.fine("Configured Android extension from Arquillian configuration file");
}
}
if (configured && configuration.isSkip() != true) {
Validate.isReadableDirectory(
configuration.getHome(),
"You must provide Android SDK Home. The value you've provided is not valid ("
+ (configuration.getHome() == null ? "" : configuration.getHome())
+ "). You can either set it via an environment variable ANDROID_HOME or via a property called \"home\" in Arquillian configuration.");
Validate.notAllNullsOrEmpty(
new String[] { configuration.getAvdName(), configuration.getSerialId() },
"You must provide either \"avdName\" if you want to use an emulator, or \"serialId\" property if you want to use a real device.");
if (configuration.getAvdName() != null && configuration.getSerialId() != null) {
log.log(Level.WARNING,
"Both \"avdName\"({0}) and \"serialId\"({1}) properties are defined, the device specified by \"serialId\" will get priority if connected.",
new Object[] { configuration.getAvdName(), configuration.getSerialId() });
}
AndroidSdk sdk = new AndroidSdk(configuration);
androidExtensionConfiguration.set(configuration);
androidSdk.set(sdk);