Search in sources :

Example 1 with ModuleInfoReader

use of org.eclipse.ceylon.cmr.api.ModuleInfoReader in project ceylon by eclipse.

the class AbstractRepository method checkBinaryVersion.

private boolean checkBinaryVersion(String module, String version, Node node, ModuleQuery lookup, String suffix) {
    Integer binaryMajor = null, binaryMinor = null;
    switch(suffix) {
        case ArtifactContext.CAR:
        case ArtifactContext.JAR:
            binaryMajor = lookup.getJvmBinaryMajor();
            binaryMinor = lookup.getJvmBinaryMinor();
            break;
        case ArtifactContext.JS:
        case ArtifactContext.JS_MODEL:
            binaryMajor = lookup.getJsBinaryMajor();
            binaryMinor = lookup.getJsBinaryMinor();
            break;
    }
    if (binaryMajor == null && binaryMinor == null)
        return true;
    try {
        File file = node.getContent(File.class);
        if (file == null)
            // can't verify
            return false;
        ModuleInfoReader reader = getModuleInfoReader(suffix);
        if (reader != null) {
            int[] versions = reader.getBinaryVersions(module, version, file);
            if (versions == null)
                // can't verify
                return false;
            if (binaryMajor != null && binaryMinor != null && !Versions.isBinaryVersionCompatible(binaryMajor, binaryMinor, versions[0], versions[1]))
                return false;
            return true;
        }
    } catch (Exception x) {
    // can't verify
    }
    return false;
}
Also used : File(java.io.File) ModuleInfoReader(org.eclipse.ceylon.cmr.api.ModuleInfoReader)

Example 2 with ModuleInfoReader

use of org.eclipse.ceylon.cmr.api.ModuleInfoReader in project ceylon by eclipse.

the class AbstractRepository method addArtifactInfo.

private ArtifactInfoResult addArtifactInfo(Node artifact, String name, String version, String suffix, String memberName, ModuleVersionDetails mvd, ModuleQuery lookup) {
    // let's see if we can extract some information
    try {
        File file = artifact.getContent(File.class);
        if (file != null) {
            ModuleInfoReader reader = getModuleInfoReader(suffix);
            if (reader != null) {
                ModuleVersionDetails mvd2 = reader.readModuleInfo(name, version, file, memberName != null, getOverrides());
                Set<String> matchingMembers = null;
                if (memberName != null) {
                    matchingMembers = matchMembers(mvd2, lookup);
                    if (matchingMembers.isEmpty()) {
                        // just continue to the next suffix/artifact if any
                        return ArtifactInfoResult.NO_MATCH;
                    }
                    mvd.getMembers().addAll(matchingMembers);
                }
                if (mvd2.getGroupId() != null) {
                    mvd.setGroupId(mvd2.getGroupId());
                }
                if (mvd2.getArtifactId() != null) {
                    mvd.setArtifactId(mvd2.getArtifactId());
                }
                if (mvd2.getLabel() != null) {
                    mvd.setLabel(mvd2.getLabel());
                }
                if (mvd2.getDoc() != null) {
                    mvd.setDoc(mvd2.getDoc());
                }
                if (mvd2.getLicense() != null) {
                    mvd.setLicense(mvd2.getLicense());
                }
                mvd.getAuthors().addAll(mvd2.getAuthors());
                mvd.getDependencies().addAll(mvd2.getDependencies());
                mvd.getArtifactTypes().addAll(mvd2.getArtifactTypes());
                return ArtifactInfoResult.INFO_FOUND;
            } else {
                if (memberName == null) {
                    // We didn't get any information but we'll at least add the artifact type to the result
                    mvd.getArtifactTypes().add(new ModuleVersionArtifact(suffix, null, null));
                }
            }
        }
    } catch (Exception e) {
    // bah
    }
    return ArtifactInfoResult.OTHER;
}
Also used : ModuleVersionDetails(org.eclipse.ceylon.cmr.api.ModuleVersionDetails) ModuleVersionArtifact(org.eclipse.ceylon.cmr.api.ModuleVersionArtifact) File(java.io.File) ModuleInfoReader(org.eclipse.ceylon.cmr.api.ModuleInfoReader)

Aggregations

File (java.io.File)2 ModuleInfoReader (org.eclipse.ceylon.cmr.api.ModuleInfoReader)2 ModuleVersionArtifact (org.eclipse.ceylon.cmr.api.ModuleVersionArtifact)1 ModuleVersionDetails (org.eclipse.ceylon.cmr.api.ModuleVersionDetails)1