Пример #1
0
 private static Library createPre15Library(File libFolder) {
   // construct an old style library
   Library res = new Library();
   res.folder = libFolder;
   res.srcFolder = libFolder;
   res.name = libFolder.getName();
   res.architectures = Arrays.asList(new String[] {"*"});
   res.pre15Lib = true;
   return res;
 }
Пример #2
0
  private static Library createLibrary(File libFolder) throws IOException {
    // Parse metadata
    File propertiesFile = new File(libFolder, "library.properties");
    PreferencesMap properties = new PreferencesMap();
    properties.load(propertiesFile);

    // Library sanity checks
    // ---------------------

    // 1. Check mandatory properties
    for (String p : MANDATORY_PROPERTIES)
      if (!properties.containsKey(p)) throw new IOException("Missing '" + p + "' from library");

    // 2. Check mandatory folders
    File srcFolder = new File(libFolder, "src");
    if (!srcFolder.exists() || !srcFolder.isDirectory())
      throw new IOException("Missing 'src' folder");

    // 3. check if root folder contains prohibited stuff
    for (File file : libFolder.listFiles()) {
      if (file.isDirectory()) {
        if (!OPTIONAL_FOLDERS.contains(file.getName()))
          throw new IOException("Invalid folder '" + file.getName() + "'.");
      } else {
        if (!OPTIONAL_FILES.contains(file.getName()))
          throw new IOException("Invalid file '" + file.getName() + "'.");
      }
    }

    // Extract metadata info
    List<String> archs = new ArrayList<String>();
    for (String arch : properties.get("architectures").split(",")) archs.add(arch.trim());

    List<String> coreDeps = new ArrayList<String>();
    for (String dep : properties.get("core-dependencies").split(",")) coreDeps.add(dep.trim());

    List<String> dependencies = new ArrayList<String>();
    for (String dependency : properties.get("dependencies").split(",")) {
      dependency = dependency.trim();
      if (!dependency.equals("")) {
        dependencies.add(dependency);
      }
    }

    Library res = new Library();
    res.folder = libFolder;
    res.srcFolder = srcFolder;
    res.archFolder = new File(libFolder, "arch");
    res.name = properties.get("name").trim();
    res.author = properties.get("author").trim();
    res.email = properties.get("email").trim();
    res.sentence = properties.get("sentence").trim();
    res.paragraph = properties.get("paragraph").trim();
    res.url = properties.get("url").trim();
    res.architectures = archs;
    res.coreDependencies = coreDeps;
    res.dependencies = dependencies;
    res.version = properties.get("version").trim();
    res.pre15Lib = false;
    return res;
  }
Пример #3
0
 @Override
 public int compare(Library o1, Library o2) {
   return o1.getName().compareToIgnoreCase(o2.getName());
 }