• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Snapshot类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.maven.artifact.repository.metadata.Snapshot的典型用法代码示例。如果您正苦于以下问题:Java Snapshot类的具体用法?Java Snapshot怎么用?Java Snapshot使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Snapshot类属于org.apache.maven.artifact.repository.metadata包,在下文中一共展示了Snapshot类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: buildSnapshotMavenMetadata

import org.apache.maven.artifact.repository.metadata.Snapshot; //导入依赖的package包/类
/**
 * Build custom maven-metadata.xml according to a specific version.
 *
 * @param moduleInfo The original {@code ModuleInfo} to assemble the maven metadata according to the same
 *                   gid,aid,and version, {@link org.apache.maven.artifact.repository.metadata.Versioning#setLastUpdatedTimestamp(java.util.Date)} is updated to now. and
 *                   the build number and timestamp in the {@link org.apache.maven.artifact.repository.metadata.Snapshot} is set according to the name.
 * @param fileName   The file name
 * @return The custom maven-metadata.xml
 */
public static Metadata buildSnapshotMavenMetadata(ModuleInfo moduleInfo, String fileName) {
    Metadata metadata = new Metadata();
    metadata.setGroupId(moduleInfo.getOrganization());
    metadata.setArtifactId(moduleInfo.getModule());
    metadata.setVersion(moduleInfo.getBaseRevision() + "-" + moduleInfo.getFolderIntegrationRevision());
    Versioning versioning = new Versioning();
    metadata.setVersioning(versioning);
    versioning.setLastUpdatedTimestamp(new Date());
    Snapshot snapshot = new Snapshot();
    versioning.setSnapshot(snapshot);
    snapshot.setBuildNumber(MavenNaming.getUniqueSnapshotVersionBuildNumber(fileName));
    snapshot.setTimestamp(MavenNaming.getUniqueSnapshotVersionTimestamp(fileName));
    if (ConstantValues.mvnMetadataVersion3Enabled.getBoolean()) {
        SnapshotVersion snapshotVersion = new SnapshotVersion();
        snapshotVersion.setUpdated(StringUtils.remove(snapshot.getTimestamp(), '.'));
        snapshotVersion.setVersion(moduleInfo.getBaseRevision() + "-" +
                moduleInfo.getFileIntegrationRevision());
        //Should always be a pom, since this method is called only by PropertiesAddonImpl.assembleDynamicMetadata
        snapshotVersion.setExtension(moduleInfo.getExt());
        versioning.setSnapshotVersions(Lists.newArrayList(snapshotVersion));
    }
    return metadata;
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:33,代码来源:MavenModelUtils.java


示例2: constructVersion

import org.apache.maven.artifact.repository.metadata.Snapshot; //导入依赖的package包/类
protected String constructVersion( Versioning versioning, String baseVersion )
{
    String version = null;
    Snapshot snapshot = versioning.getSnapshot();
    if ( snapshot != null )
    {
        if ( snapshot.getTimestamp() != null && snapshot.getBuildNumber() > 0 )
        {
            String newVersion = snapshot.getTimestamp() + "-" + snapshot.getBuildNumber();
            version = StringUtils.replace( baseVersion, Artifact.SNAPSHOT_VERSION, newVersion );
        }
        else
        {
            version = baseVersion;
        }
    }
    return version;
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:19,代码来源:SnapshotTransformation.java


示例3: getBuildNumber

import org.apache.maven.artifact.repository.metadata.Snapshot; //导入依赖的package包/类
private static int getBuildNumber( Metadata metadata )
{
    int number = 0;

    Versioning versioning = metadata.getVersioning();
    if ( versioning != null )
    {
        Snapshot snapshot = versioning.getSnapshot();
        if ( snapshot != null && snapshot.getBuildNumber() > 0 )
        {
            number = snapshot.getBuildNumber();
        }
    }

    return number;
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:17,代码来源:RemoteSnapshotMetadata.java


示例4: createMetadata

import org.apache.maven.artifact.repository.metadata.Snapshot; //导入依赖的package包/类
private static Metadata createMetadata( Artifact artifact, boolean legacyFormat )
{
    Snapshot snapshot = new Snapshot();
    snapshot.setLocalCopy( true );
    Versioning versioning = new Versioning();
    versioning.setSnapshot( snapshot );

    Metadata metadata = new Metadata();
    metadata.setVersioning( versioning );
    metadata.setGroupId( artifact.getGroupId() );
    metadata.setArtifactId( artifact.getArtifactId() );
    metadata.setVersion( artifact.getBaseVersion() );

    if ( !legacyFormat )
    {
        metadata.setModelVersion( "1.1.0" );
    }

    return metadata;
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:21,代码来源:LocalSnapshotMetadata.java


示例5: getSnapshot

import org.apache.maven.artifact.repository.metadata.Snapshot; //导入依赖的package包/类
public static List<Snapshot> getSnapshot( String response )
{
    List<Snapshot> snapshots = new ArrayList<>();
    ObjectMapper mapper = new ObjectMapper();
    try
    {
        snapshots = mapper.readValue( response, new TypeReference<List<Snapshot>>()
        {
        } );
    }
    catch ( IOException e )
    {
        e.printStackTrace();
    }
    return snapshots;
}
 
开发者ID:oncecloud,项目名称:devops-cstack,代码行数:17,代码来源:JsonConverter.java


示例6: v

import org.apache.maven.artifact.repository.metadata.Snapshot; //导入依赖的package包/类
private Metadata v(final String groupId,
                   final String artifactId,
                   final String versionPrefix,
                   final String timestamp,
                   final int buildNumber)
{
  final Metadata m = new Metadata();
  m.setGroupId(groupId);
  m.setArtifactId(artifactId);
  m.setVersion(versionPrefix + "-SNAPSHOT");
  m.setVersioning(new Versioning());
  final Versioning mv = m.getVersioning();
  mv.setLastUpdated(timestamp.replace(".", ""));
  final Snapshot snapshot = new Snapshot();
  snapshot.setTimestamp(timestamp);
  snapshot.setBuildNumber(buildNumber);
  mv.setSnapshot(snapshot);
  final SnapshotVersion pom = new SnapshotVersion();
  pom.setExtension("pom");
  pom.setVersion(versionPrefix + "-" + timestamp + "-" + buildNumber);
  pom.setUpdated(timestamp);
  mv.getSnapshotVersions().add(pom);

  final SnapshotVersion jar = new SnapshotVersion();
  jar.setExtension("jar");
  jar.setVersion(versionPrefix + "-" + timestamp + "-" + buildNumber);
  jar.setUpdated(timestamp);
  mv.getSnapshotVersions().add(jar);

  final SnapshotVersion sources = new SnapshotVersion();
  sources.setExtension("jar");
  sources.setClassifier("sources");
  sources.setVersion(versionPrefix + "-" + timestamp + "-" + buildNumber);
  sources.setUpdated(timestamp);
  mv.getSnapshotVersions().add(sources);

  return m;
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:39,代码来源:RepositoryMetadataMergerTest.java


示例7: compare

import org.apache.maven.artifact.repository.metadata.Snapshot; //导入依赖的package包/类
@Override
public int compare(Snapshot o1, Snapshot o2) {
    long time1 = MavenModelUtils.uniqueSnapshotTimestampToDate(o1.getTimestamp()).getTime();
    long time2 = MavenModelUtils.uniqueSnapshotTimestampToDate(o2.getTimestamp()).getTime();
    long dif = time1 - time2;
    return dif > 0 ? 1 : dif < 0 ? -1 : 0;
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:8,代码来源:TimestampSnapshotComparator.java


示例8: getLastBuildNumber

import org.apache.maven.artifact.repository.metadata.Snapshot; //导入依赖的package包/类
/**
 * @return The last build number for snapshot version. 0 if maven-metadata not found for the path.
 */
private int getLastBuildNumber(RepoPath repoPath) {
    int buildNumber = 0;
    try {
        // get the parent path which should contains the maven-metadata
        RepoPath parentRepoPath = repoPath.getParent();
        RepositoryService repoService = ContextHelper.get().getRepositoryService();
        RepoPathImpl mavenMetadataPath = new RepoPathImpl(parentRepoPath, MavenNaming.MAVEN_METADATA_NAME);
        if (repoService.exists(mavenMetadataPath)) {
            String mavenMetadataStr = repoService.getStringContent(mavenMetadataPath);
            Metadata metadata = MavenModelUtils.toMavenMetadata(mavenMetadataStr);
            Versioning versioning = metadata.getVersioning();
            if (versioning != null) {
                Snapshot snapshot = versioning.getSnapshot();
                if (snapshot != null) {
                    buildNumber = snapshot.getBuildNumber();
                }
            }
        } else {
            // ok probably not found. just log
            log.debug("No maven metadata found for {}.", repoPath);
        }
    } catch (Exception e) {
        log.error("Cannot obtain build number from metadata.", e);
    }
    return buildNumber;
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:30,代码来源:UniqueSnapshotVersionAdapter.java


示例9: transformForInstall

import org.apache.maven.artifact.repository.metadata.Snapshot; //导入依赖的package包/类
public void transformForInstall( Artifact artifact, ArtifactRepository localRepository )
{
    if ( artifact.isSnapshot() )
    {
        Snapshot snapshot = new Snapshot();
        snapshot.setLocalCopy( true );
        RepositoryMetadata metadata = new SnapshotArtifactRepositoryMetadata( artifact, snapshot );

        artifact.addMetadata( metadata );
    }
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:12,代码来源:SnapshotTransformation.java


示例10: transformForDeployment

import org.apache.maven.artifact.repository.metadata.Snapshot; //导入依赖的package包/类
public void transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository,
                                    ArtifactRepository localRepository )
    throws ArtifactDeploymentException
{
    if ( artifact.isSnapshot() )
    {
        Snapshot snapshot = new Snapshot();

        snapshot.setTimestamp( getDeploymentTimestamp() );

        // we update the build number anyway so that it doesn't get lost. It requires the timestamp to take effect
        try
        {
            int buildNumber = resolveLatestSnapshotBuildNumber( artifact, localRepository, remoteRepository );

            snapshot.setBuildNumber( buildNumber + 1 );
        }
        catch ( RepositoryMetadataResolutionException e )
        {
            throw new ArtifactDeploymentException( "Error retrieving previous build number for artifact '"
                + artifact.getDependencyConflictId() + "': " + e.getMessage(), e );
        }

        RepositoryMetadata metadata = new SnapshotArtifactRepositoryMetadata( artifact, snapshot );

        artifact.setResolvedVersion(
            constructVersion( metadata.getMetadata().getVersioning(), artifact.getBaseVersion() ) );

        artifact.addMetadata( metadata );
    }
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:32,代码来源:SnapshotTransformation.java


示例11: merge

import org.apache.maven.artifact.repository.metadata.Snapshot; //导入依赖的package包/类
private void merge( Artifact artifact, Map<String, VersionInfo> infos, Versioning versioning,
                    ArtifactRepository repository )
{
    if ( StringUtils.isNotEmpty( versioning.getRelease() ) )
    {
        merge( RELEASE, infos, versioning.getLastUpdated(), versioning.getRelease(), repository );
    }

    if ( StringUtils.isNotEmpty( versioning.getLatest() ) )
    {
        merge( LATEST, infos, versioning.getLastUpdated(), versioning.getLatest(), repository );
    }

    for ( SnapshotVersion sv : versioning.getSnapshotVersions() )
    {
        if ( StringUtils.isNotEmpty( sv.getVersion() ) )
        {
            String key = getKey( sv.getClassifier(), sv.getExtension() );
            merge( SNAPSHOT + key, infos, sv.getUpdated(), sv.getVersion(), repository );
        }
    }

    Snapshot snapshot = versioning.getSnapshot();
    if ( snapshot != null && versioning.getSnapshotVersions().isEmpty() )
    {
        String version = artifact.getVersion();
        if ( snapshot.getTimestamp() != null && snapshot.getBuildNumber() > 0 )
        {
            String qualifier = snapshot.getTimestamp() + '-' + snapshot.getBuildNumber();
            version = version.substring( 0, version.length() - SNAPSHOT.length() ) + qualifier;
        }
        merge( SNAPSHOT, infos, versioning.getLastUpdated(), version, repository );
    }
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:35,代码来源:DefaultVersionResolver.java


示例12: generateMavenMetadata

import org.apache.maven.artifact.repository.metadata.Snapshot; //导入依赖的package包/类
/**
 * Generate the maven-metadata-local.xml for the given Maven <code>Artifact</code>.
 *
 * @param artifact the Maven <code>Artifact</code>.
 * @param target   the target maven-metadata-local.xml file to generate.
 * @throws IOException if the maven-metadata-local.xml can't be generated.
 */
static void generateMavenMetadata(Artifact artifact, File target) throws IOException {
    target.getParentFile().mkdirs();
    Metadata metadata = new Metadata();
    metadata.setGroupId(artifact.getGroupId());
    metadata.setArtifactId(artifact.getArtifactId());
    metadata.setVersion(artifact.getVersion());
    metadata.setModelVersion("1.1.0");

    Versioning versioning = new Versioning();
    versioning.setLastUpdatedTimestamp(new Date(System.currentTimeMillis()));
    Snapshot snapshot = new Snapshot();
    snapshot.setLocalCopy(true);
    versioning.setSnapshot(snapshot);
    SnapshotVersion snapshotVersion = new SnapshotVersion();
    snapshotVersion.setClassifier(artifact.getClassifier());
    snapshotVersion.setVersion(artifact.getVersion());
    snapshotVersion.setExtension(artifact.getType());
    snapshotVersion.setUpdated(versioning.getLastUpdated());
    versioning.addSnapshotVersion(snapshotVersion);

    metadata.setVersioning(versioning);

    MetadataXpp3Writer metadataWriter = new MetadataXpp3Writer();
    Writer writer = new FileWriter(target);
    metadataWriter.write(writer, metadata);
}
 
开发者ID:retog,项目名称:karaf-maven-plugin,代码行数:34,代码来源:MavenUtil.java


示例13: readVersions

import org.apache.maven.artifact.repository.metadata.Snapshot; //导入依赖的package包/类
private Versioning readVersions( RepositorySystemSession session, RequestTrace trace, Metadata metadata,
                                 ArtifactRepository repository, VersionResult result )
{
    Versioning versioning = null;

    FileInputStream fis = null;
    try
    {
        if ( metadata != null )
        {
            SyncContext syncContext = syncContextFactory.newInstance( session, true );

            try
            {
                syncContext.acquire( null, Collections.singleton( metadata ) );

                if ( metadata.getFile() != null && metadata.getFile().exists() )
                {
                    fis = new FileInputStream( metadata.getFile() );
                    org.apache.maven.artifact.repository.metadata.Metadata m =
                        new MetadataXpp3Reader().read( fis, false );
                    versioning = m.getVersioning();

                    /*
                     * NOTE: Users occasionally misuse the id "local" for remote repos which screws up the metadata
                     * of the local repository. This is especially troublesome during snapshot resolution so we try
                     * to handle that gracefully.
                     */
                    if ( versioning != null && repository instanceof LocalRepository)
                    {
                        if ( versioning.getSnapshot() != null && versioning.getSnapshot().getBuildNumber() > 0 )
                        {
                            Versioning repaired = new Versioning();
                            repaired.setLastUpdated( versioning.getLastUpdated() );
                            Snapshot snapshot = new Snapshot();
                            snapshot.setLocalCopy( true );
                            repaired.setSnapshot( snapshot );
                            versioning = repaired;

                            throw new IOException( "Snapshot information corrupted with remote repository data"
                                + ", please verify that no remote repository uses the id '" + repository.getId()
                                + "'" );
                        }
                    }
                }
            }
            finally
            {
                syncContext.release();
            }
        }
    }
    catch ( Exception e )
    {
        invalidMetadata( session, trace, metadata, repository, e );
        result.addException( e );
    }
    finally
    {
        IOUtil.close(fis);
    }

    return ( versioning != null ) ? versioning : new Versioning();
}
 
开发者ID:cloudbees,项目名称:bees-maven-components,代码行数:65,代码来源:VersionResolverImpl.java


示例14: createSnapshotsMetadata

import org.apache.maven.artifact.repository.metadata.Snapshot; //导入依赖的package包/类
private boolean createSnapshotsMetadata(RepoPath repoPath, ItemNode treeNode) {
    if (!folderContainsPoms(treeNode)) {
        return false;
    }
    List<ItemNode> folderItems = treeNode.getChildren();
    Iterable<ItemNode> poms = Iterables.filter(folderItems, new Predicate<ItemNode>() {
        @Override
        public boolean apply(@Nullable ItemNode input) {
            return (input != null) && MavenNaming.isPom(input.getItemInfo().getName());
        }
    });

    RepoPath firstPom = poms.iterator().next().getRepoPath();
    MavenArtifactInfo artifactInfo = MavenArtifactInfo.fromRepoPath(firstPom);
    if (!artifactInfo.isValid()) {
        return true;
    }
    Metadata metadata = new Metadata();
    metadata.setGroupId(artifactInfo.getGroupId());
    metadata.setArtifactId(artifactInfo.getArtifactId());
    metadata.setVersion(artifactInfo.getVersion());
    Versioning versioning = new Versioning();
    metadata.setVersioning(versioning);
    versioning.setLastUpdatedTimestamp(new Date());
    Snapshot snapshot = new Snapshot();
    versioning.setSnapshot(snapshot);

    LocalRepoDescriptor localRepoDescriptor =
            getRepositoryService().localOrCachedRepoDescriptorByKey(repoPath.getRepoKey());
    SnapshotVersionBehavior snapshotBehavior = localRepoDescriptor.getSnapshotVersionBehavior();
    String latestUniquePom = getLatestUniqueSnapshotPomName(poms);
    if (snapshotBehavior.equals(SnapshotVersionBehavior.NONUNIQUE) ||
            (snapshotBehavior.equals(SnapshotVersionBehavior.DEPLOYER) && latestUniquePom == null)) {
        snapshot.setBuildNumber(1);
    } else if (snapshotBehavior.equals(SnapshotVersionBehavior.UNIQUE)) {
        // take the latest unique snapshot file file
        if (latestUniquePom != null) {
            snapshot.setBuildNumber(MavenNaming.getUniqueSnapshotVersionBuildNumber(latestUniquePom));
            snapshot.setTimestamp(MavenNaming.getUniqueSnapshotVersionTimestamp(latestUniquePom));
        }

        if (ConstantValues.mvnMetadataVersion3Enabled.getBoolean()) {
            List<SnapshotVersion> snapshotVersions = Lists.newArrayList(getFolderItemSnapshotVersions(folderItems));
            if (!snapshotVersions.isEmpty()) {
                versioning.setSnapshotVersions(snapshotVersions);
            }
        }
    }
    saveMetadata(repoPath, metadata);
    return true;
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:52,代码来源:MavenMetadataCalculator.java


示例15: compare

import org.apache.maven.artifact.repository.metadata.Snapshot; //导入依赖的package包/类
@Override
public int compare(Snapshot o1, Snapshot o2) {
    int buildNumber1 = o1.getBuildNumber();
    int buildNumber2 = o2.getBuildNumber();
    return buildNumber1 - buildNumber2;
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:7,代码来源:BuildNumberSnapshotComparator.java


示例16: merge

import org.apache.maven.artifact.repository.metadata.Snapshot; //导入依赖的package包/类
public void merge(Metadata otherMetadata, RepoResource foundResource) {
    long otherLastModified = foundResource.getLastModified();
    if (metadata == null) {
        metadata = otherMetadata;
        lastModified = otherLastModified;
        if (!mergeSnapshotVersions) {
            Versioning versioning = metadata.getVersioning();
            if (versioning != null) {
                versioning.setSnapshotVersions(null);
            }
        }
    } else {
        metadata.merge(otherMetadata);
        lastModified = Math.max(otherLastModified, lastModified);

        Versioning existingVersioning = metadata.getVersioning();
        if (existingVersioning != null) {
            List<String> versions = existingVersioning.getVersions();
            if (!CollectionUtils.isNullOrEmpty(versions)) {
                try {
                    Collections.sort(versions, new MavenVersionComparator());
                } catch (IllegalArgumentException e) {
                    // New Java 7 TimSort is pointing out the non transitive behavior
                    // of the Mercury version comparator => Doing fallback to natural string order
                    log.info(
                            "Hitting Mercury version comparator non transitive behavior message='" + e.getMessage() + "'");
                    if (log.isDebugEnabled()) {
                        log.debug("The lists of versions is: " + versions);
                    }
                    Collections.sort(versions);
                }
                // latest is simply the last (be it snapshot or release version)
                String latestVersion = versions.get(versions.size() - 1);
                existingVersioning.setLatest(latestVersion);

                // release is the latest non snapshot version
                for (String version : versions) {
                    if (!MavenNaming.isSnapshot(version)) {
                        existingVersioning.setRelease(version);
                    }
                }
            }
            SnapshotComparator comparator = MavenMetadataCalculator.createSnapshotComparator();
            // if there's a unique snapshot version prefer the one with the bigger build number
            Snapshot snapshot = existingVersioning.getSnapshot();
            Versioning otherMetadataVersioning = otherMetadata.getVersioning();
            if (otherMetadataVersioning != null) {
                Snapshot otherSnapshot = otherMetadataVersioning.getSnapshot();
                if (snapshot != null && otherSnapshot != null) {
                    if (comparator.compare(otherSnapshot, snapshot) > 0) {
                        snapshot.setBuildNumber(otherSnapshot.getBuildNumber());
                        snapshot.setTimestamp(otherSnapshot.getTimestamp());
                    }
                }
                if (mergeSnapshotVersions) {
                    addSnapshotVersions(existingVersioning, otherMetadataVersioning);
                }
            }
        }
    }
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:62,代码来源:MergeableMavenMetadata.java


示例17: getRequestContext

import org.apache.maven.artifact.repository.metadata.Snapshot; //导入依赖的package包/类
/**
 * Downloads maven-metadata.xml from the remote and analyzes the latest version from it. If it does not exist, we
 * return the original request context.
 */
@Override
protected InternalRequestContext getRequestContext(InternalRequestContext requestContext, Repo repo,
        ModuleInfo originalModuleInfo) {
    if (!(repo instanceof RemoteRepo)) {
        return requestContext;
    }
    RemoteRepo remoteRepo = (RemoteRepo) repo;
    if (!remoteRepo.getDescriptor().isMavenRepoLayout()) {
        // Latest from remote is supported only for maven2 layout
        return requestContext;
    }
    if (remoteRepo.isOffline()) {
        // will fallback to local cache search
        return requestContext;
    }

    String path = requestContext.getResourcePath();
    if (MavenNaming.isMavenMetadata(path)) {
        // Recursive request for maven metadata, simply return the original request context
        return requestContext;
    }
    boolean searchForReleaseVersion = StringUtils.contains(path, "[RELEASE]");
    RepoPath repoPath;
    if (searchForReleaseVersion) {
        repoPath = InternalRepoPathFactory.create(repo.getKey(), path).getParent();
    } else {
        repoPath = InternalRepoPathFactory.create(repo.getKey(), path);
    }
    Metadata metadata = tryDownloadingMavenMetadata(repoPath);
    if (metadata != null) {
        try {
            Versioning versioning = metadata.getVersioning();
            if (versioning != null) {
                if (searchForReleaseVersion) {
                    String release = versioning.getRelease();
                    if (StringUtils.isNotBlank(release)) {
                        String releaseRepoPath = path.replace("[RELEASE]", release);
                        requestContext = translateRepoRequestContext(requestContext, repo, releaseRepoPath);
                    }
                } else {
                    Snapshot snapshot = versioning.getSnapshot();
                    if (snapshot != null) {
                        String timestamp = snapshot.getTimestamp();
                        int buildNumber = snapshot.getBuildNumber();
                        if (StringUtils.isNotBlank(timestamp) && buildNumber > 0) {
                            String originalFileName = PathUtils.getFileName(path);
                            String fileName = originalFileName.replaceFirst("SNAPSHOT",
                                    timestamp + "-" + buildNumber);
                            RepoPath parentRepoPath = repoPath.getParent();
                            String uniqueRepoPath = PathUtils.addTrailingSlash(parentRepoPath.getPath()) + fileName;
                            requestContext = translateRepoRequestContext(requestContext, repo, uniqueRepoPath);
                        }
                    }
                }
            }
        } catch (Exception e) {
            log.warn("Failed parsing maven metadata from remote repo '{}' for repoPath '{}'",
                    repoPath.getRepoKey(), repoPath.getPath());
        }
    }

    return requestContext;
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:68,代码来源:RemoteLatestMavenVersionResolver.java


示例18: install

import org.apache.maven.artifact.repository.metadata.Snapshot; //导入依赖的package包/类
public void install( File source, Artifact artifact, ArtifactRepository localRepository )
    throws ArtifactInstallationException
{
    RepositorySystemSession session =
        LegacyLocalRepositoryManager.overlay( localRepository, legacySupport.getRepositorySession(), repoSystem );

    InstallRequest request = new InstallRequest();

    request.setTrace( DefaultRequestTrace.newChild( null, legacySupport.getSession().getCurrentProject() ) );

    org.sonatype.aether.artifact.Artifact mainArtifact = RepositoryUtils.toArtifact( artifact );
    mainArtifact = mainArtifact.setFile( source );
    request.addArtifact( mainArtifact );

    for ( ArtifactMetadata metadata : artifact.getMetadataList() )
    {
        if ( metadata instanceof ProjectArtifactMetadata )
        {
            org.sonatype.aether.artifact.Artifact pomArtifact = new SubArtifact( mainArtifact, "", "pom" );
            pomArtifact = pomArtifact.setFile( ( (ProjectArtifactMetadata) metadata ).getFile() );
            request.addArtifact( pomArtifact );
        }
        else if ( metadata instanceof SnapshotArtifactRepositoryMetadata
            || metadata instanceof ArtifactRepositoryMetadata )
        {
            // eaten, handled by repo system
        }
        else
        {
            request.addMetadata( new MetadataBridge( metadata ) );
        }
    }

    try
    {
        repoSystem.install( session, request );
    }
    catch ( InstallationException e )
    {
        throw new ArtifactInstallationException( e.getMessage(), e );
    }

    /*
     * NOTE: Not used by Maven core, only here to provide backward-compat with plugins like the Install Plugin.
     */

    if ( artifact.isSnapshot() )
    {
        Snapshot snapshot = new Snapshot();
        snapshot.setLocalCopy( true );
        artifact.addMetadata( new SnapshotArtifactRepositoryMetadata( artifact, snapshot ) );
    }

    Versioning versioning = new Versioning();
    versioning.updateTimestamp();
    versioning.addVersion( artifact.getBaseVersion() );
    if ( artifact.isRelease() )
    {
        versioning.setRelease( artifact.getBaseVersion() );
    }
    artifact.addMetadata( new ArtifactRepositoryMetadata( artifact, versioning ) );
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:63,代码来源:DefaultArtifactInstaller.java


示例19: readVersions

import org.apache.maven.artifact.repository.metadata.Snapshot; //导入依赖的package包/类
private Versioning readVersions( RepositorySystemSession session, RequestTrace trace, Metadata metadata,
                                 ArtifactRepository repository, VersionResult result )
{
    Versioning versioning = null;

    FileInputStream fis = null;
    try
    {
        if ( metadata != null )
        {
            SyncContext syncContext = syncContextFactory.newInstance( session, true );

            try
            {
                syncContext.acquire( null, Collections.singleton( metadata ) );

                if ( metadata.getFile() != null && metadata.getFile().exists() )
                {
                    fis = new FileInputStream( metadata.getFile() );
                    org.apache.maven.artifact.repository.metadata.Metadata m =
                        new MetadataXpp3Reader().read( fis, false );
                    versioning = m.getVersioning();

                    /*
                     * NOTE: Users occasionally misuse the id "local" for remote repos which screws up the metadata
                     * of the local repository. This is especially troublesome during snapshot resolution so we try
                     * to handle that gracefully.
                     */
                    if ( versioning != null && repository instanceof LocalRepository )
                    {
                        if ( versioning.getSnapshot() != null && versioning.getSnapshot().getBuildNumber() > 0 )
                        {
                            Versioning repaired = new Versioning();
                            repaired.setLastUpdated( versioning.getLastUpdated() );
                            Snapshot snapshot = new Snapshot();
                            snapshot.setLocalCopy( true );
                            repaired.setSnapshot( snapshot );
                            versioning = repaired;

                            throw new IOException( "Snapshot information corrupted with remote repository data"
                                + ", please verify that no remote repository uses the id '" + repository.getId()
                                + "'" );
                        }
                    }
                }
            }
            finally
            {
                syncContext.release();
            }
        }
    }
    catch ( Exception e )
    {
        invalidMetadata( session, trace, metadata, repository, e );
        result.addException( e );
    }
    finally
    {
        IOUtil.close( fis );
    }

    return ( versioning != null ) ? versioning : new Versioning();
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:65,代码来源:DefaultVersionResolver.java


示例20: compare

import org.apache.maven.artifact.repository.metadata.Snapshot; //导入依赖的package包/类
int compare(Snapshot o1, Snapshot o2); 
开发者ID:alancnet,项目名称:artifactory,代码行数:2,代码来源:SnapshotComparator.java



注:本文中的org.apache.maven.artifact.repository.metadata.Snapshot类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java OFTableStatsReply类代码示例发布时间:2022-05-21
下一篇:
Java Element类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap