Ejemplo n.º 1
0
 private List<JsonObject> convertArray(JsonArray permitted) {
   List<JsonObject> l = new ArrayList<>();
   for (Object elem : permitted) {
     if (!(elem instanceof JsonObject)) {
       throw new IllegalArgumentException("Permitted must only contain JsonObject");
     }
     l.add((JsonObject) elem);
   }
   return l;
 }
Ejemplo n.º 2
0
 private List<URL> getModuleClasspath(File modDir) {
   List<URL> urls = new ArrayList<>();
   // Add the urls for this module
   try {
     urls.add(modDir.toURI().toURL());
     File libDir = new File(modDir, "lib");
     if (libDir.exists()) {
       File[] jars = libDir.listFiles();
       for (File jar : jars) {
         URL jarURL = jar.toURI().toURL();
         urls.add(jarURL);
       }
     }
     return urls;
   } catch (MalformedURLException e) {
     // Won't happen
     log.error("malformed url", e);
     return null;
   }
 }
Ejemplo n.º 3
0
 private void loadRepos() {
   try (InputStream is = getClass().getClassLoader().getResourceAsStream(REPOS_FILE_NAME)) {
     if (is != null) {
       BufferedReader rdr = new BufferedReader(new InputStreamReader(is));
       String line;
       while ((line = rdr.readLine()) != null) {
         line = line.trim();
         if (line.isEmpty() || line.startsWith("#")) {
           // blank line or comment
           continue;
         }
         int colonPos = line.indexOf(':');
         if (colonPos == -1 || colonPos == line.length() - 1) {
           throw new IllegalArgumentException("Invalid repo: " + line);
         }
         String type = line.substring(0, colonPos);
         String repoID = line.substring(colonPos + 1);
         RepoResolver resolver;
         switch (type) {
           case "mavenLocal":
             resolver = new MavenLocalRepoResolver(repoID);
             type = "maven";
             break;
           case "maven":
             resolver = new MavenRepoResolver(vertx, repoID);
             break;
           case "bintray":
             resolver = new BintrayRepoResolver(vertx, repoID);
             break;
           case "old":
             resolver = new OldRepoResolver(vertx, repoID);
             break;
           default:
             throw new IllegalArgumentException("Unknown repo type: " + type);
         }
         repos.add(resolver);
       }
     }
   } catch (IOException e) {
     log.error("Failed to load " + LANG_PROPS_FILE_NAME + " " + e.getMessage());
   }
 }