Esempio n. 1
0
 private static String getUnmigrationCommandLine(File jenkinsHome) {
   StringBuilder cp = new StringBuilder();
   for (Class<?> c :
       new Class<?>[] {
         RunIdMigrator.class, /* TODO how to calculate transitive dependencies automatically? */
         Charsets.class,
         WriterOutputStream.class,
         BuildException.class,
         FastDateFormat.class
       }) {
     URL location = c.getProtectionDomain().getCodeSource().getLocation();
     String locationS = location.toString();
     if (location.getProtocol().equals("file")) {
       try {
         locationS = new File(location.toURI()).getAbsolutePath();
       } catch (URISyntaxException x) {
         // never mind
       }
     }
     if (cp.length() > 0) {
       cp.append(File.pathSeparator);
     }
     cp.append(locationS);
   }
   return String.format(
       "java -classpath \"%s\" %s \"%s\"", cp, RunIdMigrator.class.getName(), jenkinsHome);
 }