Search in sources :

Example 1 with InvalidVersionSpecificationException

use of org.commonjava.atlas.maven.ident.version.InvalidVersionSpecificationException in project indy by Commonjava.

the class KojiMavenMetadataProvider method scanArchive.

private ArchiveScan scanArchive(final KojiArchiveInfo archive, final Set<Integer> seenBuilds) throws KojiClientException {
    Logger logger = LoggerFactory.getLogger(getClass());
    ArchiveScan scan = new ArchiveScan();
    if (!archive.getFilename().endsWith(".pom")) {
        logger.debug("Skipping non-POM: {}", archive.getFilename());
        scan.setDisqualified(true);
        return scan;
    }
    if (!isVerSignedAllowed(archive.getVersion())) {
        logger.debug("version filter pattern not matched: {}", archive.getVersion());
        scan.setDisqualified(true);
        return scan;
    }
    SingleVersion singleVersion = null;
    try {
        singleVersion = VersionUtils.createSingleVersion(archive.getVersion());
        scan.setSingleVersion(singleVersion);
    } catch (InvalidVersionSpecificationException ivse) {
        logger.warn("Skipping mal-formatted version: {}, relPath: {}, buildId: {}", archive.getVersion(), archive.getRelPath(), archive.getBuildId());
        scan.setDisqualified(true);
        return scan;
    }
    KojiBuildInfo build = null;
    if (seenBuilds.contains(archive.getBuildId())) {
        logger.debug("Skipping already seen build: {}", archive.getBuildId());
        scan.setDisqualified(true);
        return scan;
    } else {
        build = kojiContentProvider.getBuildInfo(archive.getBuildId(), null);
        seenBuilds.add(archive.getBuildId());
        scan.setBuild(build);
    }
    if (build == null) {
        logger.debug("Cannot retrieve build info: {}. Skipping: {}", archive.getBuildId(), archive.getFilename());
        scan.setDisqualified(true);
        return scan;
    }
    if (build.getBuildState() != KojiBuildState.COMPLETE) {
        logger.debug("Build: {} is not completed. The state is {}. Skipping.", build.getNvr(), build.getBuildState());
        scan.setDisqualified(true);
        return scan;
    }
    if (build.getTaskId() == null) {
        logger.debug("Build: {} is not a real build. It looks like a binary import. Skipping.", build.getNvr());
        // This is not a real build, it's a binary import.
        scan.setDisqualified(true);
        return scan;
    }
    return scan;
}
Also used : InvalidVersionSpecificationException(org.commonjava.atlas.maven.ident.version.InvalidVersionSpecificationException) Logger(org.slf4j.Logger) SingleVersion(org.commonjava.atlas.maven.ident.version.SingleVersion) KojiBuildInfo(com.redhat.red.build.koji.model.xmlrpc.KojiBuildInfo)

Example 2 with InvalidVersionSpecificationException

use of org.commonjava.atlas.maven.ident.version.InvalidVersionSpecificationException in project indy by Commonjava.

the class MavenMetadataMerger method sortVersions.

public void sortVersions(Metadata metadata) {
    Versioning versioning = metadata.getVersioning();
    if (versioning != null && versioning.getVersions() != null) {
        List<SingleVersion> versionObjects = versioning.getVersions().stream().map((v) -> {
            try {
                return VersionUtils.createSingleVersion(v);
            } catch (InvalidVersionSpecificationException e) {
                return null;
            }
        }).filter(Objects::nonNull).collect(Collectors.toList());
        Collections.sort(versionObjects);
        versioning.setVersions(versionObjects.stream().map(SingleVersion::renderStandard).collect(Collectors.toList()));
        if (versionObjects.size() > 0) {
            String latest = versionObjects.get(versionObjects.size() - 1).renderStandard();
            versioning.setLatest(latest);
            if (!latest.endsWith(LOCAL_SNAPSHOT_VERSION_PART)) {
                versioning.setRelease(latest);
            }
        }
    }
}
Also used : Versioning(org.apache.maven.artifact.repository.metadata.Versioning) InvalidVersionSpecificationException(org.commonjava.atlas.maven.ident.version.InvalidVersionSpecificationException) SingleVersion(org.commonjava.atlas.maven.ident.version.SingleVersion)

Aggregations

InvalidVersionSpecificationException (org.commonjava.atlas.maven.ident.version.InvalidVersionSpecificationException)2 SingleVersion (org.commonjava.atlas.maven.ident.version.SingleVersion)2 KojiBuildInfo (com.redhat.red.build.koji.model.xmlrpc.KojiBuildInfo)1 Versioning (org.apache.maven.artifact.repository.metadata.Versioning)1 Logger (org.slf4j.Logger)1