Search in sources :

Example 1 with Plugin

use of org.apache.maven.artifact.repository.metadata.Plugin in project indy by Commonjava.

the class PluginMarshaller method readFrom.

@Override
public Plugin readFrom(ProtoStreamReader reader) throws IOException {
    Plugin plugin = new Plugin();
    plugin.setArtifactId(reader.readString("artifactId"));
    plugin.setName(reader.readString("name"));
    plugin.setPrefix(reader.readString("prefix"));
    return plugin;
}
Also used : Plugin(org.apache.maven.artifact.repository.metadata.Plugin)

Example 2 with Plugin

use of org.apache.maven.artifact.repository.metadata.Plugin in project indy by Commonjava.

the class MavenMetadataGenerator method generateGroupMetadata.

/**
 * Generate group related files (e.g maven-metadata.xml) from three levels.
 * 1. cache, which means all the generation of the files will be cached. In terms of cache clearing, see #{@link MetadataMergeListener}
 * 2. read cached from member hosted repos and try to download from member remote repos
 * 3. generate by member hosted repos (list dir trying to find version directories)
 *
 * @param group
 * @param members concrete store in group
 * @param path
 */
private Metadata generateGroupMetadata(final Group group, final List<ArtifactStore> members, final List<StoreKey> contributingMembers, final String path) throws IndyWorkflowException {
    if (!canProcess(path)) {
        logger.error("The path is not a metadata file: {} ", path);
        return null;
    }
    String toMergePath = path;
    if (!path.endsWith(MavenMetadataMerger.METADATA_NAME)) {
        toMergePath = normalize(normalize(parentPath(toMergePath)), MavenMetadataMerger.METADATA_NAME);
    }
    Metadata meta = getMetaFromCache(group.getKey(), toMergePath);
    if (meta != null) {
        return meta;
    }
    Metadata master = new Metadata();
    master.setVersioning(new Versioning());
    MetadataIncrementalResult incrementalResult = new MetadataIncrementalResult(new HashSet<>(members), Collections.emptySet(), master);
    incrementalResult = mergeMissing(group, incrementalResult, toMergePath, "cached", this::retrieveCached);
    contributingMembers.addAll(incrementalResult.merged);
    incrementalResult = mergeMissing(group, incrementalResult, toMergePath, "downloaded", this::downloadMissing);
    contributingMembers.addAll(incrementalResult.merged);
    incrementalResult = mergeMissing(group, incrementalResult, toMergePath, "generated", this::generateMissing);
    contributingMembers.addAll(incrementalResult.merged);
    if (metadataProviders != null) {
        master = mergeProviderMetadata(group, incrementalResult.result, toMergePath);
    } else {
        master = incrementalResult.result;
    }
    if (!incrementalResult.missing.isEmpty()) {
        logger.warn("After download and generation attempts, metadata is still missing from the following stores: {}, size: {}", incrementalResult.missing, incrementalResult.missing.size());
    }
    Versioning versioning = master.getVersioning();
    List<String> versions = versioning.getVersions();
    logger.debug("Get versioning, versions: {}, release: {}, latest: {}", versions, versioning.getRelease(), versioning.getLatest());
    if (versions != null && !versions.isEmpty()) {
        merger.sortVersions(master);
        return master;
    }
    List<SnapshotVersion> snapshotVersions = versioning.getSnapshotVersions();
    if (snapshotVersions != null && !snapshotVersions.isEmpty()) {
        if (logger.isTraceEnabled()) {
            snapshotVersions.forEach(snapshotVersion -> logger.trace("snapshotVersion: {}", snapshotVersion.getVersion()));
        }
        return master;
    }
    List<Plugin> plugins = master.getPlugins();
    if (plugins != null && !plugins.isEmpty()) {
        return master;
    }
    logger.info("The group metadata generation is not successful for path: {} in group: {}", path, group);
    return null;
}
Also used : Versioning(org.apache.maven.artifact.repository.metadata.Versioning) SnapshotVersion(org.apache.maven.artifact.repository.metadata.SnapshotVersion) EventMetadata(org.commonjava.maven.galley.event.EventMetadata) Metadata(org.apache.maven.artifact.repository.metadata.Metadata) Plugin(org.apache.maven.artifact.repository.metadata.Plugin)

Example 3 with Plugin

use of org.apache.maven.artifact.repository.metadata.Plugin in project indy by Commonjava.

the class MetadataMarshaller method readFrom.

@Override
public Metadata readFrom(ProtoStreamReader reader) throws IOException {
    Metadata md = new Metadata();
    md.setModelVersion(reader.readString("modelVersion"));
    md.setGroupId(reader.readString("groupId"));
    md.setArtifactId(reader.readString("artifactId"));
    md.setVersion(reader.readString("version"));
    md.setPlugins(reader.readCollection("plugins", new ArrayList<Plugin>(), Plugin.class));
    md.setVersioning(reader.readObject("versioning", Versioning.class));
    md.setModelEncoding(reader.readString("modelEncoding"));
    return md;
}
Also used : Versioning(org.apache.maven.artifact.repository.metadata.Versioning) Metadata(org.apache.maven.artifact.repository.metadata.Metadata) ArrayList(java.util.ArrayList) Plugin(org.apache.maven.artifact.repository.metadata.Plugin)

Aggregations

Plugin (org.apache.maven.artifact.repository.metadata.Plugin)3 Metadata (org.apache.maven.artifact.repository.metadata.Metadata)2 Versioning (org.apache.maven.artifact.repository.metadata.Versioning)2 ArrayList (java.util.ArrayList)1 SnapshotVersion (org.apache.maven.artifact.repository.metadata.SnapshotVersion)1 EventMetadata (org.commonjava.maven.galley.event.EventMetadata)1