]> source.dussan.org Git - gitblit.git/commitdiff
Remove Launcher from Manager and Federation Client.
authorFlorian Zschocke <florian.zschocke@devolo.de>
Fri, 8 Nov 2019 10:27:51 +0000 (11:27 +0100)
committerFlorian Zschocke <florian.zschocke@devolo.de>
Fri, 8 Nov 2019 10:27:51 +0000 (11:27 +0100)
They will need to be called with the classpath and main class now,
instead of simply using the Jar.

build.xml
src/main/java/com/gitblit/client/GitblitManagerLauncher.java [deleted file]
src/site/federation.mkd

index c8bace507c69acf84da4b4c2c9ba63e2ac4ad215..9fe516b4b89599822ad4a7ed892350f2e2d88a8a 100644 (file)
--- a/build.xml
+++ b/build.xml
                        excludes="**/.class, **/*.java, **/Thumbs.db, **/*.mkd, **/*.md, **/*.css, com/gitblit/wicket/**">\r
                        <mainclass name="com.gitblit.FederationClient" />\r
                        <class name="com.gitblit.Keys" />\r
-                       <launcher paths="ext" />\r
                        <resource file="${project.compileOutputDirectory}/log4j.properties" />\r
                </mx:genjar>\r
                \r
                                </fileset>\r
                        </resource>\r
 \r
-                       <mainclass name="com.gitblit.client.GitblitManagerLauncher" />\r
+                       <mainclass name="com.gitblit.client.GitblitManager" />\r
                        <class name="com.gitblit.Keys" />\r
                        <class name="com.gitblit.client.GitblitClient" />\r
                        <class name="com.gitblit.models.FederationModel" />\r
diff --git a/src/main/java/com/gitblit/client/GitblitManagerLauncher.java b/src/main/java/com/gitblit/client/GitblitManagerLauncher.java
deleted file mode 100644 (file)
index 8a43c47..0000000
+++ /dev/null
@@ -1,165 +0,0 @@
-/*\r
- * Copyright 2011 gitblit.com.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package com.gitblit.client;\r
-\r
-import java.awt.Color;\r
-import java.awt.EventQueue;\r
-import java.awt.FontMetrics;\r
-import java.awt.Graphics2D;\r
-import java.awt.SplashScreen;\r
-import java.io.File;\r
-import java.io.FileFilter;\r
-import java.io.IOException;\r
-import java.lang.reflect.Method;\r
-import java.net.URL;\r
-import java.net.URLClassLoader;\r
-import java.text.MessageFormat;\r
-import java.util.ArrayList;\r
-import java.util.Arrays;\r
-import java.util.Collections;\r
-import java.util.List;\r
-\r
-import com.gitblit.Constants;\r
-\r
-/**\r
- * Downloads dependencies and launches Gitblit Manager.\r
- *\r
- * @author James Moger\r
- *\r
- */\r
-public class GitblitManagerLauncher {\r
-\r
-       public static final boolean DEBUG = false;\r
-\r
-       /**\r
-        * Parameters of the method to add an URL to the System classes.\r
-        */\r
-       private static final Class<?>[] PARAMETERS = new Class[] { URL.class };\r
-\r
-       public static void main(String[] args) {\r
-               final SplashScreen splash = SplashScreen.getSplashScreen();\r
-\r
-               File libFolder = new File("ext");\r
-               List<File> jars = findJars(libFolder.getAbsoluteFile());\r
-\r
-               // sort the jars by name and then reverse the order so the newer version\r
-               // of the library gets loaded in the event that this is an upgrade\r
-               Collections.sort(jars);\r
-               Collections.reverse(jars);\r
-               for (File jar : jars) {\r
-                       try {\r
-                               updateSplash(splash, Translation.get("gb.loading") + " " + jar.getName() + "...");\r
-                               addJarFile(jar);\r
-                       } catch (IOException e) {\r
-\r
-                       }\r
-               }\r
-\r
-               updateSplash(splash, Translation.get("gb.starting") + " Gitblit Manager...");\r
-               GitblitManager.main(args);\r
-       }\r
-\r
-       private static void updateSplash(final SplashScreen splash, final String string) {\r
-               if (splash == null) {\r
-                       return;\r
-               }\r
-               try {\r
-                       EventQueue.invokeAndWait(new Runnable() {\r
-                               @Override\r
-                               public void run() {\r
-                                       Graphics2D g = splash.createGraphics();\r
-                                       if (g != null) {\r
-                                               // Splash is 320x120\r
-                                               FontMetrics fm = g.getFontMetrics();\r
-\r
-                                               // paint startup status\r
-                                               g.setColor(Color.darkGray);\r
-                                               int h = fm.getHeight() + fm.getMaxDescent();\r
-                                               int x = 5;\r
-                                               int y = 115;\r
-                                               int w = 320 - 2 * x;\r
-                                               g.fillRect(x, y - h, w, h);\r
-                                               g.setColor(Color.lightGray);\r
-                                               g.drawRect(x, y - h, w, h);\r
-                                               g.setColor(Color.WHITE);\r
-                                               int xw = fm.stringWidth(string);\r
-                                               g.drawString(string, x + ((w - xw) / 2), y - 5);\r
-\r
-                                               // paint version\r
-                                               String ver = "v" + Constants.getVersion();\r
-                                               int vw = g.getFontMetrics().stringWidth(ver);\r
-                                               g.drawString(ver, 320 - vw - 5, 34);\r
-                                               g.dispose();\r
-                                               splash.update();\r
-                                       }\r
-                               }\r
-                       });\r
-               } catch (Throwable t) {\r
-                       t.printStackTrace();\r
-               }\r
-       }\r
-\r
-       public static List<File> findJars(File folder) {\r
-               List<File> jars = new ArrayList<File>();\r
-               if (folder.exists()) {\r
-                       File[] libs = folder.listFiles(new FileFilter() {\r
-                               @Override\r
-                               public boolean accept(File file) {\r
-                                       return !file.isDirectory() && file.getName().toLowerCase().endsWith(".jar");\r
-                               }\r
-                       });\r
-                       if (libs != null && libs.length > 0) {\r
-                               jars.addAll(Arrays.asList(libs));\r
-                               if (DEBUG) {\r
-                                       for (File jar : jars) {\r
-                                               System.out.println("found " + jar);\r
-                                       }\r
-                               }\r
-                       }\r
-               }\r
-\r
-               return jars;\r
-       }\r
-\r
-       /**\r
-        * Adds a file to the classpath\r
-        *\r
-        * @param f\r
-        *            the file to be added\r
-        * @throws IOException\r
-        */\r
-       public static void addJarFile(File f) throws IOException {\r
-               if (f.getName().indexOf("-sources") > -1 || f.getName().indexOf("-javadoc") > -1) {\r
-                       // don't add source or javadoc jars to runtime classpath\r
-                       return;\r
-               }\r
-               URL u = f.toURI().toURL();\r
-               if (DEBUG) {\r
-                       System.out.println("load=" + u.toExternalForm());\r
-               }\r
-               URLClassLoader sysloader = (URLClassLoader) ClassLoader.getSystemClassLoader();\r
-               Class<?> sysclass = URLClassLoader.class;\r
-               try {\r
-                       Method method = sysclass.getDeclaredMethod("addURL", PARAMETERS);\r
-                       method.setAccessible(true);\r
-                       method.invoke(sysloader, new Object[] { u });\r
-               } catch (Throwable t) {\r
-                       throw new IOException(MessageFormat.format(\r
-                                       "Error, could not add {0} to system classloader", f.getPath()), t);\r
-               }\r
-       }\r
-\r
-}\r
index 7574a32169d9a26cbaf4cbc24181ec4c5455e21c..231a9f3573f25b94530adf3132c1d6c0ad655d39 100644 (file)
@@ -332,9 +332,9 @@ If you are pulling from a Gitblit with a self-signed SSL certificate you will ne
 ### Command-Line Parameters\r
 Instead of using `federation.properties` you may directly specify a Gitblit instance to pull from with command-line parameters.\r
 \r
-    java -jar fedclient.jar --url https://go.gitblit.com --mirror --bare --token 123456789\r
+    java -cp fedclient.jar;"%CD%/ext/*" com.gitblit.FederationClient --url https://go.gitblit.com --mirror --bare --token 123456789\r
          --repositoriesFolder c:/mymirror\r
     \r
-    java -jar fedclient.jar --url https://go.gitblit.com --mirror --bare --token 123456789\r
-         --repositoriesFolder c:/mymirror --daemon --frequency "24 hours"\r
+    java -cp fedclient.jar:ext/* com.gitblit.FederationClient --url https://go.gitblit.com --mirror --bare --token 123456789\r
+         --repositoriesFolder /srv/mymirror --daemon --frequency "24 hours"\r
     \r