Mercurial > hg > icedrobot > ika
view src/org/icedrobot/ika/plugins/borg/IcedRobotCloner.java @ 0:91ff28c21e0b
initial code drop
author | Mario Torre <neugens.limasoftware@gmail.com> |
---|---|
date | Fri, 04 Mar 2011 00:37:30 +0100 |
parents | |
children | 8c6dc2a5506b |
line wrap: on
line source
/* * IKA - IcedRobot Kiosk Application * Copyright (C) 2011 IcedRobot team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package org.icedrobot.ika.plugins.borg; import java.io.File; import java.io.IOException; import java.util.Properties; import joptsimple.OptionParser; import joptsimple.OptionSet; import org.icedrobot.ika.plugins.IkaPlugin; import org.icedrobot.ika.plugins.IkaPluginException; import org.icedrobot.ika.plugins.IkaPluginResult; /** * @author Mario Torre <neugens.limasoftware@gmail.com> */ public class IcedRobotCloner implements IkaPlugin { static final String ICEDROBOT_REPOS_CONFIGS = "/org/icedrobot/ika/plugins/borg/icedrobot.properties"; @Override public String getName() { return "assimilate"; } @Override public String getDescription() { return "clone the necessary Android respositories and " + "assimilate IcedRobot"; } @Override public IkaPluginResult execute(String[] args) { String destinationDir = "."; String icedrobot = null; if (args != null) { OptionParser parser = new OptionParser(); parser.accepts("dest").withRequiredArg(); parser.accepts("icedrobot").withRequiredArg(); OptionSet options = parser.parse(args); if (options.has("dest")) { destinationDir = (String) options.valueOf("dest"); } if (options.has("icedrobot")) { icedrobot = (String) options.valueOf("icedrobot"); } } if (icedrobot == null) { Properties configs = new Properties(); try { configs.load(IcedRobotCloner.class. getResourceAsStream(ICEDROBOT_REPOS_CONFIGS)); icedrobot = configs.getProperty("icedrobot"); } catch (IOException ex) { throw new IkaPluginException("cannot determine icedrobot " + "repository location", ex); } } // create first the main source directory System.out.println("creating main repository container into " + "directory \"" + destinationDir + "\"..."); File repositoryLocation = new File(destinationDir); if (repositoryLocation.exists()) { throw new IkaPluginException("destination directory " + repositoryLocation + " already existing"); } if (!repositoryLocation.mkdir()) { throw new IkaPluginException("cannot create directory " + repositoryLocation); } // now clone the icedrobot reposutory System.out.println("...done... now cloning icedrobot: " + icedrobot); Repository icedrobotRepository = new HGRepository("icedrobot", repositoryLocation, "icedrobot", icedrobot); icedrobotRepository.createRoot(); icedrobotRepository.makeClone(); // now assimilate! System.out.println("cloning repositories..."); AndroidAssimilator.assimilate(repositoryLocation); System.out.println("creating main repository container..."); System.out.println("resistance is futile, IcedRobot assimilated"); return IkaPluginResult.OK; } }