All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.openbakery.simulators.SimulatorsListTask Maven / Gradle / Ivy

Go to download

XCode-Plugin is a plugin to allow custom XCode projects to build as generated by CMake

There is a newer version: 0.0.201
Show newest version
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);
		}


	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy