Ejemplo n.º 1
0
 private static String getVersionFromFilename(String moduleName, String name) {
   if (!ModuleUtil.isDefaultModule(moduleName)) {
     String type = ArtifactContext.getSuffixFromFilename(name);
     return name.substring(moduleName.length() + 1, name.length() - type.length());
   } else {
     return "";
   }
 }
Ejemplo n.º 2
0
  @Override
  public ModuleVersionDetails readModuleInfo(
      String moduleName,
      String moduleVersion,
      File moduleArchive,
      boolean includeMembers,
      Overrides overrides) {
    Index index = readModuleIndex(moduleArchive, true);
    final AnnotationInstance moduleAnnotation = getAnnotation(index, moduleName, MODULE_ANNOTATION);
    if (moduleAnnotation == null) return null;

    AnnotationValue doc = moduleAnnotation.value("doc");
    AnnotationValue license = moduleAnnotation.value("license");
    AnnotationValue by = moduleAnnotation.value("by");
    AnnotationValue dependencies = moduleAnnotation.value("dependencies");
    String type = ArtifactContext.getSuffixFromFilename(moduleArchive.getName());

    final AnnotationInstance ceylonAnnotation = getAnnotation(index, moduleName, CEYLON_ANNOTATION);
    if (ceylonAnnotation == null) return null;

    AnnotationValue majorVer = ceylonAnnotation.value("major");
    AnnotationValue minorVer = ceylonAnnotation.value("minor");

    ModuleVersionDetails mvd =
        new ModuleVersionDetails(
            moduleName, getVersionFromFilename(moduleName, moduleArchive.getName()));
    mvd.setDoc(doc != null ? doc.asString() : null);
    mvd.setLicense(license != null ? license.asString() : null);
    if (by != null) {
      mvd.getAuthors().addAll(Arrays.asList(by.asStringArray()));
    }
    mvd.getDependencies()
        .addAll(getDependencies(dependencies, moduleName, mvd.getVersion(), overrides));
    ModuleVersionArtifact mva =
        new ModuleVersionArtifact(
            type, majorVer != null ? majorVer.asInt() : 0, minorVer != null ? minorVer.asInt() : 0);
    mvd.getArtifactTypes().add(mva);

    if (includeMembers) {
      mvd.setMembers(getMembers(index));
    }

    return mvd;
  }