|
|
@ -64,8 +64,17 @@ public class TryIt {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private TryIt() {
|
|
|
|
private TryIt() {
|
|
|
|
osSuffix = System.getProperty(Constants.OS_NAME_PROPERTY).toLowerCase();
|
|
|
|
osSuffix = System.getProperty(Constants.OS_NAME_PROPERTY).toLowerCase();
|
|
|
|
|
|
|
|
if (osSuffix == null) {
|
|
|
|
|
|
|
|
sysPropertyError("OS NAME");
|
|
|
|
|
|
|
|
}
|
|
|
|
userHome = System.getProperty(Constants.USER_HOME_PROPERTY);
|
|
|
|
userHome = System.getProperty(Constants.USER_HOME_PROPERTY);
|
|
|
|
|
|
|
|
if (userHome == null) {
|
|
|
|
|
|
|
|
sysPropertyError("Home Directory");
|
|
|
|
|
|
|
|
}
|
|
|
|
workingDirectory = System.getProperty(Constants.USER_DIRECTORY_PROPERTY);
|
|
|
|
workingDirectory = System.getProperty(Constants.USER_DIRECTORY_PROPERTY);
|
|
|
|
|
|
|
|
if (workingDirectory == null) {
|
|
|
|
|
|
|
|
sysPropertyError("Current Working Directory");
|
|
|
|
|
|
|
|
}
|
|
|
|
if (osSuffix.contains(Constants.WINDOWS_OS)) {
|
|
|
|
if (osSuffix.contains(Constants.WINDOWS_OS)) {
|
|
|
|
osSuffix = Constants.WINDOWS_OS;
|
|
|
|
osSuffix = Constants.WINDOWS_OS;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -102,6 +111,15 @@ public class TryIt {
|
|
|
|
System.out.println("\nGood Bye!");
|
|
|
|
System.out.println("\nGood Bye!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* This method is called when then is an error in getting system properties
|
|
|
|
|
|
|
|
* @param error - system property name
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private void sysPropertyError(String error) {
|
|
|
|
|
|
|
|
System.out.println("Unable to get the " + error + " of your system");
|
|
|
|
|
|
|
|
System.exit(1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* This method downloads the files.
|
|
|
|
* This method downloads the files.
|
|
|
|
*
|
|
|
|
*
|
|
|
@ -144,7 +162,7 @@ public class TryIt {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private void setSDKPath() {
|
|
|
|
private void setSDKPath() {
|
|
|
|
System.out.println("Please provide android SDK location : ");
|
|
|
|
System.out.println("Please provide android SDK location : ");
|
|
|
|
String response = new Scanner(System.in, "UTF-8").next();
|
|
|
|
String response = new Scanner(System.in, StandardCharsets.UTF_8.toString()).next();
|
|
|
|
String emulatorLocationPath = response + File.separator + "tools" + File.separator + "emulator";
|
|
|
|
String emulatorLocationPath = response + File.separator + "tools" + File.separator + "emulator";
|
|
|
|
if (osSuffix.equals(Constants.WINDOWS_OS)) {
|
|
|
|
if (osSuffix.equals(Constants.WINDOWS_OS)) {
|
|
|
|
emulatorLocationPath += Constants.WINDOWS_EXTENSION_BAT;
|
|
|
|
emulatorLocationPath += Constants.WINDOWS_EXTENSION_BAT;
|
|
|
@ -222,7 +240,7 @@ public class TryIt {
|
|
|
|
checkForPlatform();
|
|
|
|
checkForPlatform();
|
|
|
|
checkForSystemImages();
|
|
|
|
checkForSystemImages();
|
|
|
|
if (!new File(wso2AvdLocation).isDirectory()) {
|
|
|
|
if (!new File(wso2AvdLocation).isDirectory()) {
|
|
|
|
Scanner read = new Scanner(System.in, "UTF-8");
|
|
|
|
Scanner read = new Scanner(System.in, StandardCharsets.UTF_8.toString());
|
|
|
|
System.out.print("Do you want to create WSO2_AVD with default configs (Y/n)?: ");
|
|
|
|
System.out.print("Do you want to create WSO2_AVD with default configs (Y/n)?: ");
|
|
|
|
if (read.next().toLowerCase().matches("y")) {
|
|
|
|
if (read.next().toLowerCase().matches("y")) {
|
|
|
|
createAVD();
|
|
|
|
createAVD();
|
|
|
@ -251,7 +269,7 @@ public class TryIt {
|
|
|
|
ProcessBuilder listAVDsProcessBuilder = new ProcessBuilder(emulatorLocation, "-list-avds");
|
|
|
|
ProcessBuilder listAVDsProcessBuilder = new ProcessBuilder(emulatorLocation, "-list-avds");
|
|
|
|
Process listAVDsProcess = listAVDsProcessBuilder.start();
|
|
|
|
Process listAVDsProcess = listAVDsProcessBuilder.start();
|
|
|
|
reader = new BufferedReader(new InputStreamReader(listAVDsProcess.getInputStream(),
|
|
|
|
reader = new BufferedReader(new InputStreamReader(listAVDsProcess.getInputStream(),
|
|
|
|
StandardCharsets.UTF_8));
|
|
|
|
StandardCharsets.UTF_8.toString()));
|
|
|
|
String readLine;
|
|
|
|
String readLine;
|
|
|
|
while ((readLine = reader.readLine()) != null) {
|
|
|
|
while ((readLine = reader.readLine()) != null) {
|
|
|
|
devices.add(readLine);
|
|
|
|
devices.add(readLine);
|
|
|
@ -270,6 +288,19 @@ public class TryIt {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* This method makes the thread wait.
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param milliSec -time to wait for
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private void delay(long milliSec) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
Thread.sleep(milliSec);
|
|
|
|
|
|
|
|
} catch (InterruptedException ignored) {
|
|
|
|
|
|
|
|
// interruption in main thread
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* This method enables the user to select an AVD form available AVDs.
|
|
|
|
* This method enables the user to select an AVD form available AVDs.
|
|
|
|
*
|
|
|
|
*
|
|
|
@ -289,7 +320,7 @@ public class TryIt {
|
|
|
|
count++;
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
System.out.print("\nEnter AVD number to start (eg: 1) :");
|
|
|
|
System.out.print("\nEnter AVD number to start (eg: 1) :");
|
|
|
|
Scanner read = new Scanner(System.in, "UTF-8");
|
|
|
|
Scanner read = new Scanner(System.in, StandardCharsets.UTF_8.toString());
|
|
|
|
int avdNo = read.nextInt();
|
|
|
|
int avdNo = read.nextInt();
|
|
|
|
runEmulator(devices.get(--avdNo));
|
|
|
|
runEmulator(devices.get(--avdNo));
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -344,7 +375,7 @@ public class TryIt {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Files.copy(Paths.get(configFileLocation), Paths.get(wso2ConfigFile), StandardCopyOption.REPLACE_EXISTING);
|
|
|
|
Files.copy(Paths.get(configFileLocation), Paths.get(wso2ConfigFile), StandardCopyOption.REPLACE_EXISTING);
|
|
|
|
} catch (IOException ignored) {
|
|
|
|
} catch (IOException ignored) {
|
|
|
|
System.out.println("Failed to have WSO2 default AVD configurations");
|
|
|
|
System.out.println("WARN : Failed to have WSO2 default AVD configurations");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -383,6 +414,7 @@ public class TryIt {
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* This method make sure whether the directory can be created.
|
|
|
|
* This method make sure whether the directory can be created.
|
|
|
|
|
|
|
|
*
|
|
|
|
* @param name - name of the folder to be made
|
|
|
|
* @param name - name of the folder to be made
|
|
|
|
* @param location - location to make folder
|
|
|
|
* @param location - location to make folder
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -414,9 +446,9 @@ public class TryIt {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
System.out.print(".");
|
|
|
|
System.out.print(".");
|
|
|
|
Thread.sleep(1000);
|
|
|
|
delay(1000);
|
|
|
|
} catch (IOException e) {
|
|
|
|
} catch (IOException e) {
|
|
|
|
System.out.println("Unable to check boot process");
|
|
|
|
System.out.println("WARN : Unable to check boot process");
|
|
|
|
} catch (InterruptedException ignored) {
|
|
|
|
} catch (InterruptedException ignored) {
|
|
|
|
//interruption in main thread
|
|
|
|
//interruption in main thread
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
@ -435,9 +467,10 @@ public class TryIt {
|
|
|
|
* This method gets the Android SDK location if available and sets the SDK path else downloads the SDK.
|
|
|
|
* This method gets the Android SDK location if available and sets the SDK path else downloads the SDK.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private void setAndroidSDK() {
|
|
|
|
private void setAndroidSDK() {
|
|
|
|
sdkConfigFile = new File("sdkLocation");
|
|
|
|
sdkConfigFile = new File("sdkConfigLocation");
|
|
|
|
if (!(sdkConfigFile.exists() && !sdkConfigFile.isDirectory())) {
|
|
|
|
if (!(sdkConfigFile.exists() && !sdkConfigFile.isDirectory())) {
|
|
|
|
Scanner read = new Scanner(System.in, "UTF-8");
|
|
|
|
//TODO
|
|
|
|
|
|
|
|
Scanner read = new Scanner(System.in, StandardCharsets.UTF_8.toString());
|
|
|
|
System.out.print("Do you have an Android SDK installed on your computer (y/N) ? : ");
|
|
|
|
System.out.print("Do you have an Android SDK installed on your computer (y/N) ? : ");
|
|
|
|
String response = read.next().toLowerCase();
|
|
|
|
String response = read.next().toLowerCase();
|
|
|
|
if (response.matches("y")) {
|
|
|
|
if (response.matches("y")) {
|
|
|
@ -448,10 +481,10 @@ public class TryIt {
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
Scanner scanner = null;
|
|
|
|
Scanner scanner = null;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
scanner = new Scanner(sdkConfigFile, "UTF-8");
|
|
|
|
scanner = new Scanner(sdkConfigFile, StandardCharsets.UTF_8.toString());
|
|
|
|
androidSdkHome = scanner.useDelimiter("\\Z").next();
|
|
|
|
androidSdkHome = scanner.useDelimiter("\\Z").next();
|
|
|
|
} catch (FileNotFoundException ignored) {
|
|
|
|
} catch (FileNotFoundException ignored) {
|
|
|
|
// already checked
|
|
|
|
//
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
if (scanner != null) {
|
|
|
|
if (scanner != null) {
|
|
|
|
scanner.close();
|
|
|
|
scanner.close();
|
|
|
@ -517,7 +550,7 @@ public class TryIt {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (IOException ignored) {
|
|
|
|
} catch (IOException ignored) {
|
|
|
|
//
|
|
|
|
System.out.println("WARN : Failed to get the available packages");
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
if (reader != null) {
|
|
|
|
if (reader != null) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
@ -555,7 +588,7 @@ public class TryIt {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (IOException | InterruptedException ignored) {
|
|
|
|
} catch (IOException | InterruptedException ignored) {
|
|
|
|
//
|
|
|
|
System.out.println("WARN : Failed to check the available packages, agent will be installed");
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
if (reader != null) {
|
|
|
|
if (reader != null) {
|
|
|
@ -581,7 +614,8 @@ public class TryIt {
|
|
|
|
installAgentProcess.waitFor();
|
|
|
|
installAgentProcess.waitFor();
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
System.out.println("WSO2 Agent installation failed");
|
|
|
|
System.out.println("WSO2 Agent installation failed");
|
|
|
|
Scanner read = new Scanner(System.in, "UTF-8");
|
|
|
|
//TODO
|
|
|
|
|
|
|
|
Scanner read = new Scanner(System.in, StandardCharsets.UTF_8.toString());
|
|
|
|
System.out.println("Do you want to install agent again (Y/N) ? ");
|
|
|
|
System.out.println("Do you want to install agent again (Y/N) ? ");
|
|
|
|
if (read.next().toLowerCase().matches("y")) {
|
|
|
|
if (read.next().toLowerCase().matches("y")) {
|
|
|
|
installAgent();
|
|
|
|
installAgent();
|
|
|
@ -742,11 +776,7 @@ public class TryIt {
|
|
|
|
+ File.separator + "avd" + File.separator + deviceId + ".avd" + File.separator + "cache.img");
|
|
|
|
+ File.separator + "avd" + File.separator + deviceId + ".avd" + File.separator + "cache.img");
|
|
|
|
while (!cacheImg.exists()) {
|
|
|
|
while (!cacheImg.exists()) {
|
|
|
|
System.out.print(".");
|
|
|
|
System.out.print(".");
|
|
|
|
try {
|
|
|
|
delay(1000);
|
|
|
|
Thread.sleep(1000);
|
|
|
|
|
|
|
|
} catch (InterruptedException ignored) {
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
System.out.println();
|
|
|
|
System.out.println();
|
|
|
|
}
|
|
|
|
}
|
|
|
|