# HG changeset patch # User Roman Kennke # Date 1300312041 -3600 # Node ID b2827d00500a856d9c0dcef316af195234310514 # Parent 4e841dd81d28040049f3decda426949b6124e106 Mavenize IKA. diff -r 4e841dd81d28 -r b2827d00500a .hgignore --- a/.hgignore Tue Mar 15 00:13:34 2011 +0100 +++ b/.hgignore Wed Mar 16 22:47:21 2011 +0100 @@ -1,23 +1,4 @@ -(^|/)CVS($|/) -(^|/)\.hg($|/) -(^|/)\.hgtags($|/) -^project.log$ -^tailor.state$ -^tailor.state.old$ -^tailor.state.journal$ -autom4te.cache - -syntax:glob -*~ -*\# -syntax: glob -*.orig -libs -*.out -dist -gensrc/headers/ -gensrc/native -out/ -build/ - - +.project +.classpath +.settings +target diff -r 4e841dd81d28 -r b2827d00500a build.xml --- a/build.xml Tue Mar 15 00:13:34 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,74 +0,0 @@ - - - - - - - - - - - Builds, tests, and runs the project ika. - - - diff -r 4e841dd81d28 -r b2827d00500a lib/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar Binary file lib/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar has changed diff -r 4e841dd81d28 -r b2827d00500a lib/jopt-simple-3.2.jar Binary file lib/jopt-simple-3.2.jar has changed diff -r 4e841dd81d28 -r b2827d00500a lib/junit_4/junit-4.5-api.zip Binary file lib/junit_4/junit-4.5-api.zip has changed diff -r 4e841dd81d28 -r b2827d00500a lib/junit_4/junit-4.5-src.jar Binary file lib/junit_4/junit-4.5-src.jar has changed diff -r 4e841dd81d28 -r b2827d00500a lib/junit_4/junit-4.5.jar Binary file lib/junit_4/junit-4.5.jar has changed diff -r 4e841dd81d28 -r b2827d00500a lib/nblibraries.properties --- a/lib/nblibraries.properties Tue Mar 15 00:13:34 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,12 +0,0 @@ -libs.CopyLibs.classpath=\ - ${base}/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar -libs.junit.classpath=\ - ${base}/junit/junit-3.8.2.jar -libs.junit.javadoc=\ - ${base}/junit/junit-3.8.2-api.zip -libs.junit_4.classpath=\ - ${base}/junit_4/junit-4.5.jar -libs.junit_4.javadoc=\ - ${base}/junit_4/junit-4.5-api.zip -libs.junit_4.src=\ - ${base}/junit_4/junit-4.5-src.jar diff -r 4e841dd81d28 -r b2827d00500a manifest.mf --- a/manifest.mf Tue Mar 15 00:13:34 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3 +0,0 @@ -Manifest-Version: 1.0 -X-COMMENT: Main-Class will be added automatically by build - diff -r 4e841dd81d28 -r b2827d00500a nbproject/build-impl.xml --- a/nbproject/build-impl.xml Tue Mar 15 00:13:34 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,928 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set src.dir - Must set src.resources.dir - Must set test.src.dir - Must set build.dir - Must set dist.dir - Must set build.classes.dir - Must set dist.javadoc.dir - Must set build.test.classes.dir - Must set build.test.results.dir - Must set build.classes.excludes - Must set dist.jar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - To run this application from the command line without Ant, try: - - - - - - - java -cp "${run.classpath.with.dist.jar}" ${main.class} - - - - - - - - - - - - To run this application from the command line without Ant, try: - - java -jar "${dist.jar.resolved}" - - - - - - - - To run this application from the command line without Ant, try: - - java -jar "${dist.jar.resolved}" - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - Must select one file in the IDE or set run.class - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set debug.class - - - - - Must select one file in the IDE or set debug.class - - - - - Must set fix.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - Some tests failed; see details above. - - - - - - - - - Must select some files in the IDE or set test.includes - - - - Some tests failed; see details above. - - - - - Must select one file in the IDE or set test.class - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r 4e841dd81d28 -r b2827d00500a nbproject/genfiles.properties --- a/nbproject/genfiles.properties Tue Mar 15 00:13:34 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -build.xml.data.CRC32=e658de56 -build.xml.script.CRC32=8a6bb6b2 -build.xml.stylesheet.CRC32=28e38971@1.38.3.45 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=e658de56 -nbproject/build-impl.xml.script.CRC32=a0fb1379 -nbproject/build-impl.xml.stylesheet.CRC32=229523de@1.38.3.45 diff -r 4e841dd81d28 -r b2827d00500a nbproject/private/config.properties diff -r 4e841dd81d28 -r b2827d00500a nbproject/private/private.properties --- a/nbproject/private/private.properties Tue Mar 15 00:13:34 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,6 +0,0 @@ -compile.on.save=true -do.depend=false -do.jar=true -javac.debug=true -javadoc.preview=true -user.properties.file=/home/neugens/.netbeans/6.9/build.properties diff -r 4e841dd81d28 -r b2827d00500a nbproject/private/private.xml --- a/nbproject/private/private.xml Tue Mar 15 00:13:34 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,4 +0,0 @@ - - - - diff -r 4e841dd81d28 -r b2827d00500a nbproject/project.properties --- a/nbproject/project.properties Tue Mar 15 00:13:34 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,84 +0,0 @@ -annotation.processing.enabled=true -annotation.processing.enabled.in.editor=false -annotation.processing.run.all.processors=true -annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output -application.title=ika -application.vendor=neugens -build.classes.dir=${build.dir}/classes -build.classes.excludes=**/*.java,**/*.form -# This directory is removed when the project is cleaned: -build.dir=build -build.generated.dir=${build.dir}/generated -build.generated.sources.dir=${build.dir}/generated-sources -# Only compile against the classpath explicitly listed here: -build.sysclasspath=ignore -build.test.classes.dir=${build.dir}/test/classes -build.test.results.dir=${build.dir}/test/results -# Uncomment to specify the preferred debugger connection transport: -#debug.transport=dt_socket -debug.classpath=\ - ${run.classpath} -debug.test.classpath=\ - ${run.test.classpath} -# This directory is removed when the project is cleaned: -dist.dir=dist -dist.jar=${dist.dir}/ika.jar -dist.javadoc.dir=${dist.dir}/javadoc -endorsed.classpath= -excludes= -file.reference.jopt-simple-3.2.jar=lib/jopt-simple-3.2.jar -includes=** -jar.archive.disabled=${jnlp.enabled} -jar.compress=false -jar.index=${jnlp.enabled} -javac.classpath=\ - ${file.reference.jopt-simple-3.2.jar} -# Space-separated list of extra javac options -javac.compilerargs= -javac.deprecation=false -javac.processorpath=\ - ${javac.classpath} -javac.source=1.6 -javac.target=1.6 -javac.test.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir}:\ - ${libs.junit.classpath}:\ - ${libs.junit_4.classpath} -javac.test.processorpath=\ - ${javac.test.classpath} -javadoc.additionalparam= -javadoc.author=false -javadoc.encoding=${source.encoding} -javadoc.noindex=false -javadoc.nonavbar=false -javadoc.notree=false -javadoc.private=false -javadoc.splitindex=true -javadoc.use=true -javadoc.version=false -javadoc.windowtitle= -jnlp.codebase.type=no.codebase -jnlp.descriptor=application -jnlp.enabled=false -jnlp.mixed.code=defaut -jnlp.offline-allowed=false -jnlp.signed=false -main.class=org.icedrobot.ika.IkaMain -manifest.file=manifest.mf -meta.inf.dir=${src.dir}/META-INF -platform.active=default_platform -run.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir} -# Space-separated list of JVM arguments used when running the project -# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value -# or test-sys-prop.name=value to set system properties for unit tests): -run.jvmargs= -run.test.classpath=\ - ${javac.test.classpath}:\ - ${build.test.classes.dir} -source.encoding=UTF-8 -src.dir=src -src.resources.dir=resources -test.src.dir=test diff -r 4e841dd81d28 -r b2827d00500a nbproject/project.xml --- a/nbproject/project.xml Tue Mar 15 00:13:34 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,19 +0,0 @@ - - - org.netbeans.modules.java.j2seproject - - - ika - - - - - - - - - - ./lib/nblibraries.properties - - - diff -r 4e841dd81d28 -r b2827d00500a pom.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pom.xml Wed Mar 16 22:47:21 2011 +0100 @@ -0,0 +1,87 @@ + + + 4.0.0 + + org.icedrobot + ika + 0.0.1-SNAPSHOT + jar + + ika + http://maven.apache.org + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + 1.6 + 1.6 + + + + org.apache.maven.plugins + maven-jar-plugin + + + + true + org.icedrobot.ika.IkaMain + + + + + + maven-assembly-plugin + 2.2.1 + + + jar-with-dependencies + + + + true + org.icedrobot.ika.IkaMain + + + + + + + + + junit + junit + 4.8.2 + test + + + net.sf.jopt-simple + jopt-simple + 3.2 + + + diff -r 4e841dd81d28 -r b2827d00500a resources/core_plugins.properties --- a/resources/core_plugins.properties Tue Mar 15 00:13:34 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,4 +0,0 @@ -# list of core plugins, the keys are the names and the values the class name -version=org.icedrobot.ika.plugins.help.IkaVersion -assimilate=org.icedrobot.ika.plugins.borg.IcedRobotCloner -git=org.icedrobot.ika.plugins.git.IkaGitWrapper diff -r 4e841dd81d28 -r b2827d00500a resources/org/icedrobot/ika/plugins/borg/icedrobot.properties --- a/resources/org/icedrobot/ika/plugins/borg/icedrobot.properties Tue Mar 15 00:13:34 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3 +0,0 @@ -# defautl location for the icedrobot root repositories -icedrobot=http://icedtea.classpath.org/icedrobot/hg/icedrobot/ - diff -r 4e841dd81d28 -r b2827d00500a resources/org/icedrobot/ika/plugins/borg/repositories.properties --- a/resources/org/icedrobot/ika/plugins/borg/repositories.properties Tue Mar 15 00:13:34 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ -# list of android repositories -dalvik=.,git://android.git.kernel.org/platform/dalvik.git,android-2.3.2_r1 -core=system,git://android.git.kernel.org/platform/system/core.git,android-2.3.2_r1 -safe-iop=external,git://android.git.kernel.org/platform/external/safe-iop.git,android-2.3.2_r1 -base=frameworks,git://android.git.kernel.org/platform/frameworks/base.git,android-2.3.2_r1 diff -r 4e841dd81d28 -r b2827d00500a resources/org/icedrobot/ika/plugins/borg/subrepositories.properties --- a/resources/org/icedrobot/ika/plugins/borg/subrepositories.properties Tue Mar 15 00:13:34 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ -# subrepository configurations -dalvik=vm,libnativehelper,libdex -safe-iop=. -core=libcutils -base=. diff -r 4e841dd81d28 -r b2827d00500a src/main/java/org/icedrobot/ika/Ika.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/org/icedrobot/ika/Ika.java Wed Mar 16 22:47:21 2011 +0100 @@ -0,0 +1,130 @@ +/* + * 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 . + */ + +package org.icedrobot.ika; + +import org.icedrobot.ika.plugins.IkaPluginException; +import org.icedrobot.ika.plugins.IkaPlugin; + +import java.io.IOException; + +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * @author Mario Torre + */ +public class Ika { + + public static final String VERSION = "0.1"; + public static final String CORE_PLUGIN_LIST = "/core_plugins.properties"; + + private Map plugins = new HashMap(); + + private static final Ika theInstance = new Ika(); + public static Ika getInstance() { + return theInstance; + } + + private Ika() { + /* nothing to do */ + } + + /** + * Loads the core plugins list from the internal resource file. + * The plugins are also initialised here, by calling their + * {@link IkaPlugin#initPlugin() } method. + */ + private void loadCorePluginsList() { + + Properties corePlugins = new Properties(); + try { + corePlugins.load(Ika.class.getResourceAsStream(CORE_PLUGIN_LIST)); + + } catch (IOException ex) { + throw new IkaPluginException("cannot load plugin list", ex); + } + + for (String pluginName : corePlugins.stringPropertyNames()) { + // try to load the plugin, ne exception will be thrown + // at this point if the plugin is not found + // the plugins must all be in the classpath + String pluginClass = corePlugins.getProperty(pluginName); + try { + Logger.getLogger(Ika.class.getName()).log(Level.FINEST, + "loading: {0}", pluginClass); + + Class _plugin = + (Class) Class.forName(pluginClass); + IkaPlugin plugin = _plugin.newInstance(); + + plugins.put(pluginName, plugin); + + } catch (InstantiationException ex) { + Logger.getLogger(Ika.class.getName()).log(Level.WARNING, + "cannot instantiate plugin: " + + pluginClass, ex); + + } catch (IllegalAccessException ex) { + Logger.getLogger(Ika.class.getName()).log(Level.WARNING, + "cannot access plugin: " + pluginClass, ex); + + } catch (ClassNotFoundException ex) { + Logger.getLogger(Ika.class.getName()).log(Level.WARNING, + "cannot load plugin: " + pluginClass, ex); + } + } + } + + /** + * Parses the command line and reseach the module to load accordingly + */ + public void parseArgumentAndInvoke(String ... args) { + + loadCorePluginsList(); + + if (args == null || args.length == 0 || + "version".equalsIgnoreCase(args[0]) || + "--version".equalsIgnoreCase(args[0])) + { + // print a short help message and return + plugins.get("version").execute(args); + + } else { + // check if there is a plugin with the name passed as + // argument + IkaPlugin plugin = plugins.get(args[0]); + if (plugin != null) { + plugin.execute(args); + + } else { + System.err.println("No plugins found: " + args[0]); + System.err.println("maybe you mean one of:"); + System.err.println(""); + plugins.get("version").execute(new String[]{"--list-plugins"}); + } + } + } + + public Map getPlugins() { + return plugins; + } +} diff -r 4e841dd81d28 -r b2827d00500a src/main/java/org/icedrobot/ika/IkaMain.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/org/icedrobot/ika/IkaMain.java Wed Mar 16 22:47:21 2011 +0100 @@ -0,0 +1,32 @@ +/* + * 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 . + */ + +package org.icedrobot.ika; + +/** + * Main launcher for ika. + * + * @author Mario Torre + */ +public class IkaMain { + + static public void main(String [] args) { + + Ika.getInstance().parseArgumentAndInvoke(args); + } +} diff -r 4e841dd81d28 -r b2827d00500a src/main/java/org/icedrobot/ika/plugins/IkaPlugin.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/org/icedrobot/ika/plugins/IkaPlugin.java Wed Mar 16 22:47:21 2011 +0100 @@ -0,0 +1,29 @@ +/* + * 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 . + */ + +package org.icedrobot.ika.plugins; + +/** + * @author Mario Torre + */ +public interface IkaPlugin { + + public String getName(); + public String getDescription(); + public IkaPluginResult execute(String [] args); +} diff -r 4e841dd81d28 -r b2827d00500a src/main/java/org/icedrobot/ika/plugins/IkaPluginException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/org/icedrobot/ika/plugins/IkaPluginException.java Wed Mar 16 22:47:21 2011 +0100 @@ -0,0 +1,38 @@ +/* + * 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 . + */ + +package org.icedrobot.ika.plugins; + + +/** + * @author Mario Torre + */ +public class IkaPluginException extends RuntimeException { + + public IkaPluginException(String string) { + super(string); + } + + public IkaPluginException(String string, Throwable ex) { + super(string, ex); + } + + public IkaPluginException(String string, Exception ex) { + super(string, ex); + } +} diff -r 4e841dd81d28 -r b2827d00500a src/main/java/org/icedrobot/ika/plugins/IkaPluginResult.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/org/icedrobot/ika/plugins/IkaPluginResult.java Wed Mar 16 22:47:21 2011 +0100 @@ -0,0 +1,27 @@ +/* + * 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 . + */ + +package org.icedrobot.ika.plugins; + +/** + * @author Mario Torre + */ +public enum IkaPluginResult { + + OK, FAILURE; +} diff -r 4e841dd81d28 -r b2827d00500a src/main/java/org/icedrobot/ika/plugins/borg/AndroidAssimilator.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/org/icedrobot/ika/plugins/borg/AndroidAssimilator.java Wed Mar 16 22:47:21 2011 +0100 @@ -0,0 +1,83 @@ +/* + * 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 . + */ + +package org.icedrobot.ika.plugins.borg; + +import org.icedrobot.ika.plugins.scm.Repository; +import org.icedrobot.ika.plugins.scm.GITRepository; +import java.io.File; +import java.io.IOException; +import java.util.Properties; +import java.util.concurrent.CyclicBarrier; +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.icedrobot.ika.plugins.IkaPluginException; + +/** + * @author Mario Torre + */ +class AndroidAssimilator { + + static String ANDROID_REPOS_CONFIGS = + "/org/icedrobot/ika/plugins/borg/repositories.properties"; + + static String ANDROID_SUBREPOS_CONFIGS = + "/org/icedrobot/ika/plugins/borg/subrepositories.properties"; + + static void assimilate(File base) { + + // contains all the remote repositories that we need to create and + // jeopardise + Properties configs = new Properties(); + try { + configs.load(AndroidAssimilator.class. + getResourceAsStream(ANDROID_REPOS_CONFIGS)); + + } catch (IOException ex) { + throw new IkaPluginException("cannot load configurations", ex); + } + + // we spawn as many thread as a repositories to clone + // so all the cloning (and assimilating) operations are + // actually perfomed in parallel per repository + CyclicBarrier barrier = new CyclicBarrier(configs.size() + 1); + for (Object name : configs.keySet()) { + + String[] data = configs.getProperty((String) name).split(","); + Repository repository = new GITRepository((String) name, base, + data[0], data[1], + data[2]); + + ClonerTask task = new ClonerTask(repository, barrier); + Thread thread = new Thread(task, repository.getName()); + thread.setDaemon(true); + thread.start(); + } + + // wait that all task are terinated before returning + try { + barrier.await(); + System.err.println("done!"); + } catch (Throwable ex) { + Logger.getLogger(ClonerTask.class.getName()).log(Level.SEVERE, + ex.getMessage(), ex); + throw new IkaPluginException(ex.getMessage(), ex); + } + } +} diff -r 4e841dd81d28 -r b2827d00500a src/main/java/org/icedrobot/ika/plugins/borg/ClonerTask.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/org/icedrobot/ika/plugins/borg/ClonerTask.java Wed Mar 16 22:47:21 2011 +0100 @@ -0,0 +1,97 @@ +/* + * 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 . + */ + +package org.icedrobot.ika.plugins.borg; + +import org.icedrobot.ika.plugins.scm.Repository; +import org.icedrobot.ika.plugins.scm.HGRepository; +import java.io.File; + +import java.util.Properties; + +import java.util.concurrent.CyclicBarrier; + +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.icedrobot.ika.plugins.IkaPluginException; + +/** + * @author Mario Torre + */ +class ClonerTask implements Runnable { + + private Repository repository; + private CyclicBarrier barrier; + + public ClonerTask(Repository repository, CyclicBarrier barrier) { + + this.repository = repository; + this.barrier = barrier; + } + + @Override + public void run() { + try { + // create the local path first, if it doesn't exist already + // then start populating it with the Android code + System.err.println("create local directory: " + repository); + repository.createRoot(); + + // second, clone the main icedrobot repository + + System.err.println("cloning: " + repository.getRemotePath()); + repository.makeClone(); + + Properties configs = new Properties(); + configs.load(AndroidAssimilator.class.getResourceAsStream( + AndroidAssimilator.ANDROID_SUBREPOS_CONFIGS)); + + String subrepos = configs.getProperty(repository.getName()); + for (String repo : subrepos.split(",")) { + Repository subRepository = + repository.makeSubRepository(repo, repo, "icedrobot"); + + String sep = File.separator; + Repository hgPatchQueue = + new HGRepository(repo, subRepository.getFullPath(), + ".git" + sep + "patches", + repository.getBaseDirectory() + + sep + "icedrobot" + sep + "projects" + + sep + subRepository.getName() + sep + + "patches"); + hgPatchQueue.createRoot(); + hgPatchQueue.makeClone(); + + subRepository.applyPatchQueue(); + } + + // synchronise with other tasks + barrier.await(); + + } catch (Throwable ex) { + + barrier.reset(); + Logger.getLogger(ClonerTask.class.getName()).log(Level.SEVERE, + ex.getMessage(), ex); + throw new IkaPluginException(ex.getMessage(), ex); + } + } + + +} diff -r 4e841dd81d28 -r b2827d00500a src/main/java/org/icedrobot/ika/plugins/borg/IcedRobotCloner.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/org/icedrobot/ika/plugins/borg/IcedRobotCloner.java Wed Mar 16 22:47:21 2011 +0100 @@ -0,0 +1,146 @@ +/* + * 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 . + */ + +package org.icedrobot.ika.plugins.borg; + +import org.icedrobot.ika.plugins.scm.Repository; +import org.icedrobot.ika.plugins.scm.HGRepository; +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 + */ +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 = null; + String icedrobot = null; + if (args != null) { + OptionParser parser = new OptionParser(); + parser.accepts("dest").withRequiredArg(); + parser.accepts("icedrobot").withRequiredArg(); + parser.accepts("help"); + + OptionSet options = parser.parse(args); + if (options.has("help")) { + displayUsage(); + return IkaPluginResult.OK; + } + + 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); + } + } + + if (destinationDir == null) { + displayUsage(); + return IkaPluginResult.FAILURE; + } + + // 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; + } + + private void displayUsage() { + System.out.println("Usage: ika assimilate --dest=" + + " " + + "--icedrobot="); + System.out.println("\t--dest"); + System.out.println("\t\t\tdirectory where to create the " + + "IcedRobot snapshot"); + System.out.println("\t\t\tThis argument is mandatory."); + System.out.println("\t--icedrobot"); + System.out.println("\t\t\tlocation of the remote repository"); + System.out.println("\t\t\tThis argument is optional, if not given"); + System.out.println("\t\t\tthen the default is retrived from " + + "the configuration files"); + System.out.println("\t--help"); + System.out.println("\t\t\tprint usage information"); + } +} diff -r 4e841dd81d28 -r b2827d00500a src/main/java/org/icedrobot/ika/plugins/git/IkaGitWrapper.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/org/icedrobot/ika/plugins/git/IkaGitWrapper.java Wed Mar 16 22:47:21 2011 +0100 @@ -0,0 +1,95 @@ +/* + * 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 . + */ +package org.icedrobot.ika.plugins.git; + +import java.io.File; +import joptsimple.OptionParser; +import joptsimple.OptionSet; +import org.icedrobot.ika.plugins.IkaPlugin; +import org.icedrobot.ika.plugins.IkaPluginResult; +import org.icedrobot.ika.plugins.scm.GITRepository; +import org.icedrobot.ika.plugins.scm.HGRepository; +import org.icedrobot.ika.plugins.scm.Repository; + +/** + * @author Mario Torre + */ +public class IkaGitWrapper implements IkaPlugin { + + @Override + public String getName() { + return "git"; + } + + @Override + public String getDescription() { + return "handles various git tasks for IcedRobot"; + } + + @Override + public IkaPluginResult execute(String[] args) { + + if (args != null) { + OptionParser parser = new OptionParser(); + parser.accepts("makerepo").withRequiredArg(); + + OptionSet options = parser.parse(args); + + if (options.has("makerepo")) { + String destinationDir = (String) options.valueOf("makerepo"); + + File base = new File(destinationDir); + if (!base.exists()) { + System.out.println("desitination directory doesn't exist"); + return IkaPluginResult.FAILURE; + } + + System.err.println("base.getName(): " + base.getName()); + Repository repository = new GITRepository(base.getName(), base, + "", "", "icedrobot"); + repository.create(); + + repository.initPatchQueue(); + + String s = File.separator; + File basePath = new File(repository.getFullPath() + s + + ".git" + s + "patches"); + + Repository hgRepo = new HGRepository(base.getName(), basePath, + "", ""); + hgRepo.create(); + + + return IkaPluginResult.OK; + } + } + displayUsage(); + return IkaPluginResult.OK; + } + + private void displayUsage() { + System.out.println("Usage: ika git --makerepo=" + + ""); + System.out.println("\t--makerepo"); + System.out.println("\t\t\tdirectory where to create the " + + "new git repository"); + System.out.println("\t\t\tThis argument is mandatory."); + System.out.println("\t\t\tThe respository is created with a default"); + System.out.println("\t\t\t\"icedrobot\" branch"); + } +} diff -r 4e841dd81d28 -r b2827d00500a src/main/java/org/icedrobot/ika/plugins/help/IkaVersion.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/org/icedrobot/ika/plugins/help/IkaVersion.java Wed Mar 16 22:47:21 2011 +0100 @@ -0,0 +1,70 @@ +/* + * 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 . + */ + +package org.icedrobot.ika.plugins.help; + +import joptsimple.OptionParser; +import joptsimple.OptionSet; +import org.icedrobot.ika.Ika; +import org.icedrobot.ika.plugins.IkaPlugin; +import org.icedrobot.ika.plugins.IkaPluginResult; + +/** + * @author Mario Torre + */ +public class IkaVersion implements IkaPlugin { + + private static final String VERSION_INFO = + "ika: IcedRobot Kiosk Application version " + Ika.VERSION; + + @Override + public IkaPluginResult execute(String [] args) { + + if (args != null) { + + OptionParser parser = new OptionParser(); + parser.accepts("list-plugins"); + parser.accepts("version"); + + OptionSet options = parser.parse(args); + + if (options.has("list-plugins")) { + for (IkaPlugin plugin : Ika.getInstance().getPlugins().values()) + { + System.out.println(" " + plugin.getName() + ":\n\t\t" + + plugin.getDescription()); + } + System.out.println(""); + } + } + + System.out.println(VERSION_INFO); + + return IkaPluginResult.OK; + } + + @Override + public String getDescription() { + return "display version information and return"; + } + + @Override + public String getName() { + return "version"; + } +} diff -r 4e841dd81d28 -r b2827d00500a src/main/java/org/icedrobot/ika/plugins/scm/GITRepository.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/org/icedrobot/ika/plugins/scm/GITRepository.java Wed Mar 16 22:47:21 2011 +0100 @@ -0,0 +1,129 @@ +/* + * 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 . + */ + +package org.icedrobot.ika.plugins.scm; + +import java.io.File; +import java.io.IOException; +import org.icedrobot.ika.plugins.IkaPluginException; + +/** + * @author Mario Torre + */ +public class GITRepository extends Repository { + + /** + * Creates a new git Repository with the give name as ID, the + * base directory as the location where the clone will be performed, the + * relativePath as the name of the cloned repository, the remotePath as the + * location of the source repository and branch as the version of the + * repository to clone. + */ + public GITRepository(String name, File baseDirectory, String relativePath, + String remotePath, String branch) { + + this.name = name; + this.baseDirectory = baseDirectory; + this.relativePath = relativePath; + this.remotePath = remotePath; + + this.branch = branch; + + String canonicalPath; + try { + canonicalPath = baseDirectory.getCanonicalPath(); + } catch (IOException ex) { + throw new IkaPluginException(ex.getMessage(), ex); + } + + this.fullPath = new File(canonicalPath + File.separator + relativePath); + } + + /** + * + */ + @Override + public void makeClone() { + String command = "git clone -b " + getBranch() + " " + remotePath; + System.err.println(command); + exec(command, getFullPath()); + } + + + /** + * + */ + @Override + public void create() { + + String command = "git init ."; + System.err.println(command); + exec(command, getFullPath()); + + command = "git add --all"; + System.err.println(command); + exec(command, getFullPath()); + + command = "git commit -m initial_repository --verbose"; + System.err.println(command); + exec(command, getFullPath()); + + command = "git branch " + branch; + System.err.println(command); + exec(command, getFullPath()); + + command = "git checkout " + branch; + System.err.println(command); + exec(command, getFullPath()); + + System.err.println(">>>>>>>> done: " + this + " <<<<<<<<"); + } + + /** + * + */ + @Override + public Repository makeSubRepository(String name, String relativePath, + String branch) { + + if (name.equals(".")) { + name = this.getName(); + } + Repository subRepository = + new GITRepository(name, new File(getFullPath() + File.separator + + getName()), + relativePath, null, branch); + subRepository.create(); + return subRepository; + } + + @Override + public void applyPatchQueue() { + String command = "guilt push --all"; + System.err.println(command); + exec(command, getFullPath()); + } + + @Override + public void initPatchQueue() { + + String command = "guilt init"; + System.err.println(command); + exec(command, getFullPath()); + } +} diff -r 4e841dd81d28 -r b2827d00500a src/main/java/org/icedrobot/ika/plugins/scm/HGRepository.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/org/icedrobot/ika/plugins/scm/HGRepository.java Wed Mar 16 22:47:21 2011 +0100 @@ -0,0 +1,99 @@ +/* + * 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 . + */ + +package org.icedrobot.ika.plugins.scm; + +import java.io.File; + +/** + * @author Mario Torre + */ +public class HGRepository extends Repository { + + /** + * Creates a new mercurial forest Repository with the give name as ID, the + * base directory as the location where the clone will be performed, the + * relativePath as the name of the cloned repository, the remotePath as the + * location of the source repository. The Forest extension is needed + * to create the repository. The branch is always HEAD. + */ + public HGRepository(String name, File baseDirectory, + String relativePath, + String remotePath) { + + this.name = name; + this.baseDirectory = baseDirectory; + this.relativePath = relativePath; + this.remotePath = remotePath; + + this.fullPath = new File(baseDirectory.getAbsolutePath() + + File.separator + relativePath); + } + + /** + * + */ + @Override + public void makeClone() { + String command = "hg clone " + remotePath + " " + getFullPath(); + System.err.println(command); + exec(command, getFullPath()); + } + + @Override + public String getBranch() { + // only HEAD is supported + return "HEAD"; + } + + /** + * + */ + @Override + public Repository makeSubRepository(String name, String relativePath, + String branch) { + + throw new UnsupportedOperationException("not supported yet"); + } + + @Override + public void applyPatchQueue() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void create() { + + String command = "hg init ."; + System.err.println(command); + exec(command, getFullPath()); + + command = "hg add"; + System.err.println(command); + exec(command, getFullPath()); + + command = "hg commit -minitial_repository"; + System.err.println(command); + exec(command, getFullPath()); + } + + @Override + public void initPatchQueue() { + throw new UnsupportedOperationException("Not supported yet."); + } +} diff -r 4e841dd81d28 -r b2827d00500a src/main/java/org/icedrobot/ika/plugins/scm/Repository.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/org/icedrobot/ika/plugins/scm/Repository.java Wed Mar 16 22:47:21 2011 +0100 @@ -0,0 +1,133 @@ +/* + * 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 . + */ + +package org.icedrobot.ika.plugins.scm; + +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; + +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.icedrobot.ika.plugins.IkaPluginException; + +/** + * @author Mario Torre + */ +public abstract class Repository { + + protected String name; + protected File baseDirectory; + protected File fullPath; + + protected String relativePath; + protected String remotePath; + protected String branch; + + public abstract void create(); + abstract public void initPatchQueue(); + public abstract void applyPatchQueue(); + public abstract void makeClone(); + public abstract Repository makeSubRepository(String name, + String relativePath, + String branch); + + protected static void exec(String command, File path) { + try { + System.err.println("command: " + command + ", path: " + path); + Process process = Runtime.getRuntime().exec(command, null, path); + + InputStream is = process.getInputStream(); + InputStreamReader reader = new InputStreamReader(is); + + BufferedReader br = new BufferedReader(reader); + + String line; + while ((line = br.readLine()) != null) { + System.out.println(line); + } + + } catch (IOException ex) { + Logger.getLogger(Repository.class.getName()). + log(Level.SEVERE, "cannot execute: " + command, ex); + throw new IkaPluginException("cannot execute: " + command, ex); + } + } + + /** + * Create the directory under which this repository will be located if it + * doesn't exist. + */ + public void createRoot() { + getFullPath().mkdir(); + } + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @return the baseDirectory + */ + public File getBaseDirectory() { + return baseDirectory; + } + + /** + * @return the fullPath + */ + public File getFullPath() { + try { + return fullPath.getCanonicalFile(); + } catch (IOException ex) { + throw new IkaPluginException(ex.toString(), ex); + } + } + + /** + * @return the relativePath + */ + public String getRelativePath() { + return relativePath; + } + + /** + * @return the remotePath + */ + public String getRemotePath() { + return remotePath; + } + + /** + * @return the branch + */ + public String getBranch() { + return branch; + } + + @Override + public String toString() { + return fullPath.toString(); + } +} diff -r 4e841dd81d28 -r b2827d00500a src/main/resources/core_plugins.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/resources/core_plugins.properties Wed Mar 16 22:47:21 2011 +0100 @@ -0,0 +1,4 @@ +# list of core plugins, the keys are the names and the values the class name +version=org.icedrobot.ika.plugins.help.IkaVersion +assimilate=org.icedrobot.ika.plugins.borg.IcedRobotCloner +git=org.icedrobot.ika.plugins.git.IkaGitWrapper diff -r 4e841dd81d28 -r b2827d00500a src/main/resources/org/icedrobot/ika/plugins/borg/icedrobot.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/resources/org/icedrobot/ika/plugins/borg/icedrobot.properties Wed Mar 16 22:47:21 2011 +0100 @@ -0,0 +1,3 @@ +# defautl location for the icedrobot root repositories +icedrobot=http://icedtea.classpath.org/icedrobot/hg/icedrobot/ + diff -r 4e841dd81d28 -r b2827d00500a src/main/resources/org/icedrobot/ika/plugins/borg/repositories.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/resources/org/icedrobot/ika/plugins/borg/repositories.properties Wed Mar 16 22:47:21 2011 +0100 @@ -0,0 +1,5 @@ +# list of android repositories +dalvik=.,git://android.git.kernel.org/platform/dalvik.git,android-2.3.2_r1 +core=system,git://android.git.kernel.org/platform/system/core.git,android-2.3.2_r1 +safe-iop=external,git://android.git.kernel.org/platform/external/safe-iop.git,android-2.3.2_r1 +base=frameworks,git://android.git.kernel.org/platform/frameworks/base.git,android-2.3.2_r1 diff -r 4e841dd81d28 -r b2827d00500a src/main/resources/org/icedrobot/ika/plugins/borg/subrepositories.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/resources/org/icedrobot/ika/plugins/borg/subrepositories.properties Wed Mar 16 22:47:21 2011 +0100 @@ -0,0 +1,5 @@ +# subrepository configurations +dalvik=vm,libnativehelper,libdex +safe-iop=. +core=libcutils +base=. diff -r 4e841dd81d28 -r b2827d00500a src/org/icedrobot/ika/Ika.java --- a/src/org/icedrobot/ika/Ika.java Tue Mar 15 00:13:34 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,130 +0,0 @@ -/* - * 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 . - */ - -package org.icedrobot.ika; - -import org.icedrobot.ika.plugins.IkaPluginException; -import org.icedrobot.ika.plugins.IkaPlugin; - -import java.io.IOException; - -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * @author Mario Torre - */ -public class Ika { - - public static final String VERSION = "0.1"; - public static final String CORE_PLUGIN_LIST = "/core_plugins.properties"; - - private Map plugins = new HashMap(); - - private static final Ika theInstance = new Ika(); - public static Ika getInstance() { - return theInstance; - } - - private Ika() { - /* nothing to do */ - } - - /** - * Loads the core plugins list from the internal resource file. - * The plugins are also initialised here, by calling their - * {@link IkaPlugin#initPlugin() } method. - */ - private void loadCorePluginsList() { - - Properties corePlugins = new Properties(); - try { - corePlugins.load(Ika.class.getResourceAsStream(CORE_PLUGIN_LIST)); - - } catch (IOException ex) { - throw new IkaPluginException("cannot load plugin list", ex); - } - - for (String pluginName : corePlugins.stringPropertyNames()) { - // try to load the plugin, ne exception will be thrown - // at this point if the plugin is not found - // the plugins must all be in the classpath - String pluginClass = corePlugins.getProperty(pluginName); - try { - Logger.getLogger(Ika.class.getName()).log(Level.FINEST, - "loading: {0}", pluginClass); - - Class _plugin = - (Class) Class.forName(pluginClass); - IkaPlugin plugin = _plugin.newInstance(); - - plugins.put(pluginName, plugin); - - } catch (InstantiationException ex) { - Logger.getLogger(Ika.class.getName()).log(Level.WARNING, - "cannot instantiate plugin: " + - pluginClass, ex); - - } catch (IllegalAccessException ex) { - Logger.getLogger(Ika.class.getName()).log(Level.WARNING, - "cannot access plugin: " + pluginClass, ex); - - } catch (ClassNotFoundException ex) { - Logger.getLogger(Ika.class.getName()).log(Level.WARNING, - "cannot load plugin: " + pluginClass, ex); - } - } - } - - /** - * Parses the command line and reseach the module to load accordingly - */ - public void parseArgumentAndInvoke(String ... args) { - - loadCorePluginsList(); - - if (args == null || args.length == 0 || - "version".equalsIgnoreCase(args[0]) || - "--version".equalsIgnoreCase(args[0])) - { - // print a short help message and return - plugins.get("version").execute(args); - - } else { - // check if there is a plugin with the name passed as - // argument - IkaPlugin plugin = plugins.get(args[0]); - if (plugin != null) { - plugin.execute(args); - - } else { - System.err.println("No plugins found: " + args[0]); - System.err.println("maybe you mean one of:"); - System.err.println(""); - plugins.get("version").execute(new String[]{"--list-plugins"}); - } - } - } - - public Map getPlugins() { - return plugins; - } -} diff -r 4e841dd81d28 -r b2827d00500a src/org/icedrobot/ika/IkaMain.java --- a/src/org/icedrobot/ika/IkaMain.java Tue Mar 15 00:13:34 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ -/* - * 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 . - */ - -package org.icedrobot.ika; - -/** - * Main launcher for ika. - * - * @author Mario Torre - */ -public class IkaMain { - - static public void main(String [] args) { - - Ika.getInstance().parseArgumentAndInvoke(args); - } -} diff -r 4e841dd81d28 -r b2827d00500a src/org/icedrobot/ika/plugins/IkaPlugin.java --- a/src/org/icedrobot/ika/plugins/IkaPlugin.java Tue Mar 15 00:13:34 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,29 +0,0 @@ -/* - * 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 . - */ - -package org.icedrobot.ika.plugins; - -/** - * @author Mario Torre - */ -public interface IkaPlugin { - - public String getName(); - public String getDescription(); - public IkaPluginResult execute(String [] args); -} diff -r 4e841dd81d28 -r b2827d00500a src/org/icedrobot/ika/plugins/IkaPluginException.java --- a/src/org/icedrobot/ika/plugins/IkaPluginException.java Tue Mar 15 00:13:34 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ -/* - * 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 . - */ - -package org.icedrobot.ika.plugins; - - -/** - * @author Mario Torre - */ -public class IkaPluginException extends RuntimeException { - - public IkaPluginException(String string) { - super(string); - } - - public IkaPluginException(String string, Throwable ex) { - super(string, ex); - } - - public IkaPluginException(String string, Exception ex) { - super(string, ex); - } -} diff -r 4e841dd81d28 -r b2827d00500a src/org/icedrobot/ika/plugins/IkaPluginResult.java --- a/src/org/icedrobot/ika/plugins/IkaPluginResult.java Tue Mar 15 00:13:34 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,27 +0,0 @@ -/* - * 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 . - */ - -package org.icedrobot.ika.plugins; - -/** - * @author Mario Torre - */ -public enum IkaPluginResult { - - OK, FAILURE; -} diff -r 4e841dd81d28 -r b2827d00500a src/org/icedrobot/ika/plugins/borg/AndroidAssimilator.java --- a/src/org/icedrobot/ika/plugins/borg/AndroidAssimilator.java Tue Mar 15 00:13:34 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,83 +0,0 @@ -/* - * 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 . - */ - -package org.icedrobot.ika.plugins.borg; - -import org.icedrobot.ika.plugins.scm.Repository; -import org.icedrobot.ika.plugins.scm.GITRepository; -import java.io.File; -import java.io.IOException; -import java.util.Properties; -import java.util.concurrent.CyclicBarrier; -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.icedrobot.ika.plugins.IkaPluginException; - -/** - * @author Mario Torre - */ -class AndroidAssimilator { - - static String ANDROID_REPOS_CONFIGS = - "/org/icedrobot/ika/plugins/borg/repositories.properties"; - - static String ANDROID_SUBREPOS_CONFIGS = - "/org/icedrobot/ika/plugins/borg/subrepositories.properties"; - - static void assimilate(File base) { - - // contains all the remote repositories that we need to create and - // jeopardise - Properties configs = new Properties(); - try { - configs.load(AndroidAssimilator.class. - getResourceAsStream(ANDROID_REPOS_CONFIGS)); - - } catch (IOException ex) { - throw new IkaPluginException("cannot load configurations", ex); - } - - // we spawn as many thread as a repositories to clone - // so all the cloning (and assimilating) operations are - // actually perfomed in parallel per repository - CyclicBarrier barrier = new CyclicBarrier(configs.size() + 1); - for (Object name : configs.keySet()) { - - String[] data = configs.getProperty((String) name).split(","); - Repository repository = new GITRepository((String) name, base, - data[0], data[1], - data[2]); - - ClonerTask task = new ClonerTask(repository, barrier); - Thread thread = new Thread(task, repository.getName()); - thread.setDaemon(true); - thread.start(); - } - - // wait that all task are terinated before returning - try { - barrier.await(); - System.err.println("done!"); - } catch (Throwable ex) { - Logger.getLogger(ClonerTask.class.getName()).log(Level.SEVERE, - ex.getMessage(), ex); - throw new IkaPluginException(ex.getMessage(), ex); - } - } -} diff -r 4e841dd81d28 -r b2827d00500a src/org/icedrobot/ika/plugins/borg/ClonerTask.java --- a/src/org/icedrobot/ika/plugins/borg/ClonerTask.java Tue Mar 15 00:13:34 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,97 +0,0 @@ -/* - * 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 . - */ - -package org.icedrobot.ika.plugins.borg; - -import org.icedrobot.ika.plugins.scm.Repository; -import org.icedrobot.ika.plugins.scm.HGRepository; -import java.io.File; - -import java.util.Properties; - -import java.util.concurrent.CyclicBarrier; - -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.icedrobot.ika.plugins.IkaPluginException; - -/** - * @author Mario Torre - */ -class ClonerTask implements Runnable { - - private Repository repository; - private CyclicBarrier barrier; - - public ClonerTask(Repository repository, CyclicBarrier barrier) { - - this.repository = repository; - this.barrier = barrier; - } - - @Override - public void run() { - try { - // create the local path first, if it doesn't exist already - // then start populating it with the Android code - System.err.println("create local directory: " + repository); - repository.createRoot(); - - // second, clone the main icedrobot repository - - System.err.println("cloning: " + repository.getRemotePath()); - repository.makeClone(); - - Properties configs = new Properties(); - configs.load(AndroidAssimilator.class.getResourceAsStream( - AndroidAssimilator.ANDROID_SUBREPOS_CONFIGS)); - - String subrepos = configs.getProperty(repository.getName()); - for (String repo : subrepos.split(",")) { - Repository subRepository = - repository.makeSubRepository(repo, repo, "icedrobot"); - - String sep = File.separator; - Repository hgPatchQueue = - new HGRepository(repo, subRepository.getFullPath(), - ".git" + sep + "patches", - repository.getBaseDirectory() + - sep + "icedrobot" + sep + "projects" + - sep + subRepository.getName() + sep + - "patches"); - hgPatchQueue.createRoot(); - hgPatchQueue.makeClone(); - - subRepository.applyPatchQueue(); - } - - // synchronise with other tasks - barrier.await(); - - } catch (Throwable ex) { - - barrier.reset(); - Logger.getLogger(ClonerTask.class.getName()).log(Level.SEVERE, - ex.getMessage(), ex); - throw new IkaPluginException(ex.getMessage(), ex); - } - } - - -} diff -r 4e841dd81d28 -r b2827d00500a src/org/icedrobot/ika/plugins/borg/IcedRobotCloner.java --- a/src/org/icedrobot/ika/plugins/borg/IcedRobotCloner.java Tue Mar 15 00:13:34 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,146 +0,0 @@ -/* - * 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 . - */ - -package org.icedrobot.ika.plugins.borg; - -import org.icedrobot.ika.plugins.scm.Repository; -import org.icedrobot.ika.plugins.scm.HGRepository; -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 - */ -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 = null; - String icedrobot = null; - if (args != null) { - OptionParser parser = new OptionParser(); - parser.accepts("dest").withRequiredArg(); - parser.accepts("icedrobot").withRequiredArg(); - parser.accepts("help"); - - OptionSet options = parser.parse(args); - if (options.has("help")) { - displayUsage(); - return IkaPluginResult.OK; - } - - 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); - } - } - - if (destinationDir == null) { - displayUsage(); - return IkaPluginResult.FAILURE; - } - - // 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; - } - - private void displayUsage() { - System.out.println("Usage: ika assimilate --dest=" + - " " + - "--icedrobot="); - System.out.println("\t--dest"); - System.out.println("\t\t\tdirectory where to create the " + - "IcedRobot snapshot"); - System.out.println("\t\t\tThis argument is mandatory."); - System.out.println("\t--icedrobot"); - System.out.println("\t\t\tlocation of the remote repository"); - System.out.println("\t\t\tThis argument is optional, if not given"); - System.out.println("\t\t\tthen the default is retrived from " + - "the configuration files"); - System.out.println("\t--help"); - System.out.println("\t\t\tprint usage information"); - } -} diff -r 4e841dd81d28 -r b2827d00500a src/org/icedrobot/ika/plugins/git/IkaGitWrapper.java --- a/src/org/icedrobot/ika/plugins/git/IkaGitWrapper.java Tue Mar 15 00:13:34 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,95 +0,0 @@ -/* - * 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 . - */ -package org.icedrobot.ika.plugins.git; - -import java.io.File; -import joptsimple.OptionParser; -import joptsimple.OptionSet; -import org.icedrobot.ika.plugins.IkaPlugin; -import org.icedrobot.ika.plugins.IkaPluginResult; -import org.icedrobot.ika.plugins.scm.GITRepository; -import org.icedrobot.ika.plugins.scm.HGRepository; -import org.icedrobot.ika.plugins.scm.Repository; - -/** - * @author Mario Torre - */ -public class IkaGitWrapper implements IkaPlugin { - - @Override - public String getName() { - return "git"; - } - - @Override - public String getDescription() { - return "handles various git tasks for IcedRobot"; - } - - @Override - public IkaPluginResult execute(String[] args) { - - if (args != null) { - OptionParser parser = new OptionParser(); - parser.accepts("makerepo").withRequiredArg(); - - OptionSet options = parser.parse(args); - - if (options.has("makerepo")) { - String destinationDir = (String) options.valueOf("makerepo"); - - File base = new File(destinationDir); - if (!base.exists()) { - System.out.println("desitination directory doesn't exist"); - return IkaPluginResult.FAILURE; - } - - System.err.println("base.getName(): " + base.getName()); - Repository repository = new GITRepository(base.getName(), base, - "", "", "icedrobot"); - repository.create(); - - repository.initPatchQueue(); - - String s = File.separator; - File basePath = new File(repository.getFullPath() + s + - ".git" + s + "patches"); - - Repository hgRepo = new HGRepository(base.getName(), basePath, - "", ""); - hgRepo.create(); - - - return IkaPluginResult.OK; - } - } - displayUsage(); - return IkaPluginResult.OK; - } - - private void displayUsage() { - System.out.println("Usage: ika git --makerepo=" + - ""); - System.out.println("\t--makerepo"); - System.out.println("\t\t\tdirectory where to create the " + - "new git repository"); - System.out.println("\t\t\tThis argument is mandatory."); - System.out.println("\t\t\tThe respository is created with a default"); - System.out.println("\t\t\t\"icedrobot\" branch"); - } -} diff -r 4e841dd81d28 -r b2827d00500a src/org/icedrobot/ika/plugins/help/IkaVersion.java --- a/src/org/icedrobot/ika/plugins/help/IkaVersion.java Tue Mar 15 00:13:34 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,70 +0,0 @@ -/* - * 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 . - */ - -package org.icedrobot.ika.plugins.help; - -import joptsimple.OptionParser; -import joptsimple.OptionSet; -import org.icedrobot.ika.Ika; -import org.icedrobot.ika.plugins.IkaPlugin; -import org.icedrobot.ika.plugins.IkaPluginResult; - -/** - * @author Mario Torre - */ -public class IkaVersion implements IkaPlugin { - - private static final String VERSION_INFO = - "ika: IcedRobot Kiosk Application version " + Ika.VERSION; - - @Override - public IkaPluginResult execute(String [] args) { - - if (args != null) { - - OptionParser parser = new OptionParser(); - parser.accepts("list-plugins"); - parser.accepts("version"); - - OptionSet options = parser.parse(args); - - if (options.has("list-plugins")) { - for (IkaPlugin plugin : Ika.getInstance().getPlugins().values()) - { - System.out.println(" " + plugin.getName() + ":\n\t\t" + - plugin.getDescription()); - } - System.out.println(""); - } - } - - System.out.println(VERSION_INFO); - - return IkaPluginResult.OK; - } - - @Override - public String getDescription() { - return "display version information and return"; - } - - @Override - public String getName() { - return "version"; - } -} diff -r 4e841dd81d28 -r b2827d00500a src/org/icedrobot/ika/plugins/scm/GITRepository.java --- a/src/org/icedrobot/ika/plugins/scm/GITRepository.java Tue Mar 15 00:13:34 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,129 +0,0 @@ -/* - * 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 . - */ - -package org.icedrobot.ika.plugins.scm; - -import java.io.File; -import java.io.IOException; -import org.icedrobot.ika.plugins.IkaPluginException; - -/** - * @author Mario Torre - */ -public class GITRepository extends Repository { - - /** - * Creates a new git Repository with the give name as ID, the - * base directory as the location where the clone will be performed, the - * relativePath as the name of the cloned repository, the remotePath as the - * location of the source repository and branch as the version of the - * repository to clone. - */ - public GITRepository(String name, File baseDirectory, String relativePath, - String remotePath, String branch) { - - this.name = name; - this.baseDirectory = baseDirectory; - this.relativePath = relativePath; - this.remotePath = remotePath; - - this.branch = branch; - - String canonicalPath; - try { - canonicalPath = baseDirectory.getCanonicalPath(); - } catch (IOException ex) { - throw new IkaPluginException(ex.getMessage(), ex); - } - - this.fullPath = new File(canonicalPath + File.separator + relativePath); - } - - /** - * - */ - @Override - public void makeClone() { - String command = "git clone -b " + getBranch() + " " + remotePath; - System.err.println(command); - exec(command, getFullPath()); - } - - - /** - * - */ - @Override - public void create() { - - String command = "git init ."; - System.err.println(command); - exec(command, getFullPath()); - - command = "git add --all"; - System.err.println(command); - exec(command, getFullPath()); - - command = "git commit -m initial_repository --verbose"; - System.err.println(command); - exec(command, getFullPath()); - - command = "git branch " + branch; - System.err.println(command); - exec(command, getFullPath()); - - command = "git checkout " + branch; - System.err.println(command); - exec(command, getFullPath()); - - System.err.println(">>>>>>>> done: " + this + " <<<<<<<<"); - } - - /** - * - */ - @Override - public Repository makeSubRepository(String name, String relativePath, - String branch) { - - if (name.equals(".")) { - name = this.getName(); - } - Repository subRepository = - new GITRepository(name, new File(getFullPath() + File.separator + - getName()), - relativePath, null, branch); - subRepository.create(); - return subRepository; - } - - @Override - public void applyPatchQueue() { - String command = "guilt push --all"; - System.err.println(command); - exec(command, getFullPath()); - } - - @Override - public void initPatchQueue() { - - String command = "guilt init"; - System.err.println(command); - exec(command, getFullPath()); - } -} diff -r 4e841dd81d28 -r b2827d00500a src/org/icedrobot/ika/plugins/scm/HGRepository.java --- a/src/org/icedrobot/ika/plugins/scm/HGRepository.java Tue Mar 15 00:13:34 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,99 +0,0 @@ -/* - * 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 . - */ - -package org.icedrobot.ika.plugins.scm; - -import java.io.File; - -/** - * @author Mario Torre - */ -public class HGRepository extends Repository { - - /** - * Creates a new mercurial forest Repository with the give name as ID, the - * base directory as the location where the clone will be performed, the - * relativePath as the name of the cloned repository, the remotePath as the - * location of the source repository. The Forest extension is needed - * to create the repository. The branch is always HEAD. - */ - public HGRepository(String name, File baseDirectory, - String relativePath, - String remotePath) { - - this.name = name; - this.baseDirectory = baseDirectory; - this.relativePath = relativePath; - this.remotePath = remotePath; - - this.fullPath = new File(baseDirectory.getAbsolutePath() + - File.separator + relativePath); - } - - /** - * - */ - @Override - public void makeClone() { - String command = "hg clone " + remotePath + " " + getFullPath(); - System.err.println(command); - exec(command, getFullPath()); - } - - @Override - public String getBranch() { - // only HEAD is supported - return "HEAD"; - } - - /** - * - */ - @Override - public Repository makeSubRepository(String name, String relativePath, - String branch) { - - throw new UnsupportedOperationException("not supported yet"); - } - - @Override - public void applyPatchQueue() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void create() { - - String command = "hg init ."; - System.err.println(command); - exec(command, getFullPath()); - - command = "hg add"; - System.err.println(command); - exec(command, getFullPath()); - - command = "hg commit -minitial_repository"; - System.err.println(command); - exec(command, getFullPath()); - } - - @Override - public void initPatchQueue() { - throw new UnsupportedOperationException("Not supported yet."); - } -} diff -r 4e841dd81d28 -r b2827d00500a src/org/icedrobot/ika/plugins/scm/Repository.java --- a/src/org/icedrobot/ika/plugins/scm/Repository.java Tue Mar 15 00:13:34 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,133 +0,0 @@ -/* - * 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 . - */ - -package org.icedrobot.ika.plugins.scm; - -import java.io.BufferedReader; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; - -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.icedrobot.ika.plugins.IkaPluginException; - -/** - * @author Mario Torre - */ -public abstract class Repository { - - protected String name; - protected File baseDirectory; - protected File fullPath; - - protected String relativePath; - protected String remotePath; - protected String branch; - - public abstract void create(); - abstract public void initPatchQueue(); - public abstract void applyPatchQueue(); - public abstract void makeClone(); - public abstract Repository makeSubRepository(String name, - String relativePath, - String branch); - - protected static void exec(String command, File path) { - try { - System.err.println("command: " + command + ", path: " + path); - Process process = Runtime.getRuntime().exec(command, null, path); - - InputStream is = process.getInputStream(); - InputStreamReader reader = new InputStreamReader(is); - - BufferedReader br = new BufferedReader(reader); - - String line; - while ((line = br.readLine()) != null) { - System.out.println(line); - } - - } catch (IOException ex) { - Logger.getLogger(Repository.class.getName()). - log(Level.SEVERE, "cannot execute: " + command, ex); - throw new IkaPluginException("cannot execute: " + command, ex); - } - } - - /** - * Create the directory under which this repository will be located if it - * doesn't exist. - */ - public void createRoot() { - getFullPath().mkdir(); - } - - /** - * @return the name - */ - public String getName() { - return name; - } - - /** - * @return the baseDirectory - */ - public File getBaseDirectory() { - return baseDirectory; - } - - /** - * @return the fullPath - */ - public File getFullPath() { - try { - return fullPath.getCanonicalFile(); - } catch (IOException ex) { - throw new IkaPluginException(ex.toString(), ex); - } - } - - /** - * @return the relativePath - */ - public String getRelativePath() { - return relativePath; - } - - /** - * @return the remotePath - */ - public String getRemotePath() { - return remotePath; - } - - /** - * @return the branch - */ - public String getBranch() { - return branch; - } - - @Override - public String toString() { - return fullPath.toString(); - } -}