Example usage for org.apache.maven.artifact.repository ArtifactRepository isUniqueVersion

List of usage examples for org.apache.maven.artifact.repository ArtifactRepository isUniqueVersion

Introduction

In this page you can find the example usage for org.apache.maven.artifact.repository ArtifactRepository isUniqueVersion.

Prototype

@Deprecated
    boolean isUniqueVersion();

Source Link

Usage

From source file:hudson.gridmaven.reporters.MavenArtifactRecord.java

License:Open Source License

@Override
public void deploy(MavenEmbedder embedder, ArtifactRepository deploymentRepository, TaskListener listener)
        throws MavenEmbedderException, IOException, ComponentLookupException, ArtifactDeploymentException {
    ArtifactHandlerManager handlerManager = embedder.lookup(ArtifactHandlerManager.class);

    ArtifactFactory artifactFactory = embedder.lookup(ArtifactFactory.class);
    PrintStream logger = listener.getLogger();
    boolean maven3orLater = MavenUtil.maven3orLater(parent.getModuleSetBuild().getMavenVersionUsed());
    boolean uniqueVersion = true;
    if (!deploymentRepository.isUniqueVersion()) {
        if (maven3orLater) {
            logger.println("[ERROR] uniqueVersion == false is not anymore supported in maven 3");
        } else {/*ww w. jav a2  s. com*/
            ((WrappedArtifactRepository) deploymentRepository).setUniqueVersion(false);
            uniqueVersion = false;
        }
    } else {
        ((WrappedArtifactRepository) deploymentRepository).setUniqueVersion(true);
    }
    Artifact main = mainArtifact.toArtifact(handlerManager, artifactFactory, parent);
    if (!isPOM())
        main.addMetadata(new ProjectArtifactMetadata(main, pomArtifact.getFile(parent)));

    if (main.getType().equals("maven-plugin")) {
        GroupRepositoryMetadata metadata = new GroupRepositoryMetadata(main.getGroupId());
        String goalPrefix = PluginDescriptor.getGoalPrefixFromArtifactId(main.getArtifactId());
        metadata.addPluginMapping(goalPrefix, main.getArtifactId(), null);
        main.addMetadata(metadata);
    }

    ArtifactDeployer deployer = embedder.lookup(ArtifactDeployer.class, uniqueVersion ? "default" : "maven2");
    logger.println("[INFO] Deployment in " + deploymentRepository.getUrl() + " (id="
            + deploymentRepository.getId() + ",uniqueVersion=" + deploymentRepository.isUniqueVersion() + ")");

    // deploy the main artifact. This also deploys the POM
    logger.println(Messages.MavenArtifact_DeployingMainArtifact(main.getFile().getName()));
    deployer.deploy(main.getFile(), main, deploymentRepository, embedder.getLocalRepository());

    for (MavenArtifact aa : attachedArtifacts) {
        Artifact a = aa.toArtifact(handlerManager, artifactFactory, parent);
        logger.println(Messages.MavenArtifact_DeployingMainArtifact(a.getFile().getName()));
        deployer.deploy(a.getFile(), a, deploymentRepository, embedder.getLocalRepository());
    }
}

From source file:hudson.maven.artifact.transform.SnapshotTransformation.java

License:Apache License

public void transformForDeployment(Artifact artifact, ArtifactRepository remoteRepository,
        ArtifactRepository localRepository) throws ArtifactDeploymentException {
    if (artifact.isSnapshot()) {
        Snapshot snapshot = new Snapshot();
        if (remoteRepository.isUniqueVersion()) {
            snapshot.setTimestamp(getDeploymentTimestamp());
        }/*from w  w w .  j a v  a2  s  . c o m*/

        // 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);
    }
}