org.openbakery.simulators.SimulatorsListTask Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of xcode-plugin Show documentation
Show all versions of xcode-plugin Show documentation
XCode-Plugin is a plugin to allow custom XCode projects to build as generated by CMake
package org.openbakery.simulators;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.gradle.api.tasks.TaskAction;
import org.openbakery.xcode.Destination;
import org.openbakery.xcode.Type;
import org.openbakery.XcodePlugin;
public class SimulatorsListTask extends AbstractSimulatorTask {
int compareTo(String first, String second) {
if (first == null && second == null) {
return 0;
}
if (first == null && second != null) {
return 1;
}
if (first != null && second == null) {
return -1;
}
return first.compareTo(second);
}
public SimulatorsListTask() {
setDescription("List all available Simulators");
}
@TaskAction
void list() {
List availableSimulators = getSimulatorControl().getAllDestinations(Type.iOS);
List tvOsSimulators = getSimulatorControl().getAllDestinations(Type.tvOS);
availableSimulators.addAll(tvOsSimulators);
Collections.sort(availableSimulators, new Comparator() {
@Override
public int compare(Destination first, Destination second) {
int result = compareTo(first.getOs(), second.getOs());
if (result != 0) {
return result;
}
return compareTo(first.getName(), second.getName());
}
});
String currentOS = "";
for (Destination destination : availableSimulators) {
if (!currentOS.equals(destination.getOs())) {
getLogger().lifecycle("-- " + destination.getPlatform()+" {} -- ", destination.getOs());
currentOS = destination.getOs();
}
String id = "";
if (destination.getId() != null) {
id = "(" + destination.getId() + ")";
}
getLogger().lifecycle("\t {} {}", destination.getName(), id);
}
}
}