List of usage examples for org.apache.maven.artifact Artifact addMetadata
void addMetadata(ArtifactMetadata metadata);
From source file:com.alibaba.citrus.maven.eclipse.base.eclipse.EclipseToMavenMojo.java
License:Open Source License
/** * Writes the artifact to the repo//from ww w . j av a 2s . c o m * * @param model * @param remoteRepo remote repository (if set) * @throws MojoExecutionException */ private void writeArtifact(EclipseOsgiPlugin plugin, Model model, ArtifactRepository remoteRepo) throws MojoExecutionException { Writer fw = null; ArtifactMetadata metadata = null; File pomFile = null; Artifact pomArtifact = artifactFactory.createArtifact(model.getGroupId(), model.getArtifactId(), model.getVersion(), null, "pom"); //$NON-NLS-1$ Artifact artifact = artifactFactory.createArtifact(model.getGroupId(), model.getArtifactId(), model.getVersion(), null, Constants.PROJECT_PACKAGING_JAR); try { pomFile = File.createTempFile("pom-", ".xml"); //$NON-NLS-1$ //$NON-NLS-2$ // TODO use WriterFactory.newXmlWriter() when plexus-utils is upgraded to 1.4.5+ fw = new OutputStreamWriter(new FileOutputStream(pomFile), "UTF-8"); //$NON-NLS-1$ model.setModelEncoding("UTF-8"); // to be removed when encoding is detected instead of forced to UTF-8 //$NON-NLS-1$ pomFile.deleteOnExit(); new MavenXpp3Writer().write(fw, model); metadata = new ProjectArtifactMetadata(pomArtifact, pomFile); pomArtifact.addMetadata(metadata); } catch (IOException e) { throw new MojoExecutionException( Messages.getString("EclipseToMavenMojo.errorwritingtemporarypom", e.getMessage()), e); //$NON-NLS-1$ } finally { IOUtil.close(fw); } try { File jarFile = plugin.getJarFile(); if (remoteRepo != null) { deployer.deploy(pomFile, pomArtifact, remoteRepo, localRepository); deployer.deploy(jarFile, artifact, remoteRepo, localRepository); } else { installer.install(pomFile, pomArtifact, localRepository); installer.install(jarFile, artifact, localRepository); } } catch (ArtifactDeploymentException e) { throw new MojoExecutionException( Messages.getString("EclipseToMavenMojo.errordeployartifacttorepository"), e); //$NON-NLS-1$ } catch (ArtifactInstallationException e) { throw new MojoExecutionException( Messages.getString("EclipseToMavenMojo.errorinstallartifacttorepository"), e); //$NON-NLS-1$ } catch (IOException e) { throw new MojoExecutionException( Messages.getString("EclipseToMavenMojo.errorgettingjarfileforplugin", plugin), e); //$NON-NLS-1$ } finally { pomFile.delete(); } }
From source file:com.googlecode.addjars.mojo.AddJarsMojo.java
License:Apache License
private void executeInt() throws Exception { File workdir = new File(project.getBuild().getDirectory(), getClass().getName()); workdir.mkdirs();//from w w w. ja va2 s . co m Set<Artifact> dependenciesArtifacts = new HashSet<Artifact>(); for (JarResource resource : resources) { for (File jar : getJars(resource)) { Artifact a = artifactFactory.createArtifact(project.getGroupId(), project.getArtifactId() + "-" + jar.getName(), project.getVersion(), resource.getScope(), "jar"); File stamp = new File(workdir, a.getArtifactId()); if (jar.lastModified() > stamp.lastModified()) { a.addMetadata(new ProjectArtifactMetadata(a, createArtifactPom(a))); artifactInstaller.install(jar, a, null); stamp.createNewFile(); stamp.setLastModified(jar.lastModified()); } dependenciesArtifacts.add(a); } } Set newDependenciesArtifacts = new HashSet(project.getDependencyArtifacts()); newDependenciesArtifacts.addAll(dependenciesArtifacts); project.setDependencyArtifacts(newDependenciesArtifacts); for (Artifact dependency : dependenciesArtifacts) project.getOriginalModel().addDependency(createDependency(dependency)); File pomFile = new File(workdir, "pom.xml"); writePom(pomFile, project.getOriginalModel()); project.setFile(pomFile); }
From source file:com.savage7.maven.plugin.dependency.DeployExternalDependencyMojo.java
License:Apache License
public void execute() throws MojoExecutionException, MojoFailureException { // update base configuration parameters // (not sure why this is needed, but doesn't see to work otherwise?) super.localRepository = this.localRepository; getLog().info("starting to deploy external dependencies to distribution repository"); // loop over and process all configured artifacts for (ArtifactItem artifactItem : artifactItems) { getLog().info("resolving artifact in locale repository for deployment: " + artifactItem.toString()); ///*from w ww. ja va 2 s . c o m*/ // CREATE MAVEN ARTIFACT // Artifact artifact = createArtifact(artifactItem); // determine if the artifact is already installed in the local Maven // repository File installedArtifactFile = getLocalRepoFile(artifact); // only proceed with this artifact if it is not already // installed or it is configured to be forced. if (installedArtifactFile.exists()) { try { artifactResolver.resolve(artifact, project.getRemoteArtifactRepositories(), localRepository); // // DEPLOY TO DISTRIBUTION MAVEN REPOSITORY // if (artifactItem.getDeploy()) { failIfOffline(); ArtifactRepository repo = getDeploymentRepository(); String protocol = repo.getProtocol(); if (protocol.equalsIgnoreCase("scp")) { File sshFile = new File(System.getProperty("user.home"), ".ssh"); if (!sshFile.exists()) { sshFile.mkdirs(); } } // create Maven artifact POM file File generatedPomFile = null; // don't generate a POM file for POM artifacts if (!"pom".equals(artifactItem.getPackaging())) { // if a POM file was provided for the artifact item, // then // use that POM file instead of generating a new one if (artifactItem.getPomFile() != null) { ArtifactMetadata pomMetadata = new ProjectArtifactMetadata(artifact, artifactItem.getPomFile()); artifact.addMetadata(pomMetadata); } else { // dynamically create a new POM file for this // artifact generatedPomFile = generatePomFile(artifactItem); ArtifactMetadata pomMetadata = new ProjectArtifactMetadata(artifact, generatedPomFile); if (artifactItem.getGeneratePom() == true) { artifact.addMetadata(pomMetadata); } } } // deploy now getLog().info("deploying artifact to distribution repository: " + artifactItem.toString()); artifactDeployer.deploy(artifact.getFile(), artifact, repo, localRepository); //TODO Deploy Checksums? } else { getLog().debug("configured to not deploy artifact: " + artifactItem.toString()); } } catch (MojoFailureException e) { throw e; } catch (ArtifactResolutionException e) { throw new MojoExecutionException("Error occurred while attempting to resolve artifact.", e); } catch (ArtifactNotFoundException e) { throw new MojoExecutionException("Unable to find external dependency in local repository.", e); } catch (ArtifactDeploymentException e) { throw new MojoExecutionException("Deployment of external dependency failed.", e); } } else { // throw error because we were unable to find the installed // external dependency try { throw new MojoFailureException("Unable to find external dependency '" + artifactItem.getArtifactId() + "'; file not found in local repository: " + installedArtifactFile.getCanonicalPath()); } catch (IOException e) { throw new MojoExecutionException("Unable to resolve dependency path in locale repository.", e); } } } getLog().info("finished deploying external dependencies to distribution repository"); }
From source file:com.savage7.maven.plugin.dependency.InstallExternalDependencyMojo.java
License:Apache License
public void execute() throws MojoExecutionException, MojoFailureException { try {/*from w w w . j ava 2 s. c o m*/ // update base configuration parameters // (not sure why this is needed, but doesn't see to work otherwise?) super.localRepository = this.localRepository; super.createChecksum = this.createChecksum; super.md5Digester = this.md5Digester; super.sha1Digester = this.sha1Digester; Boolean cachedCreateChecksums = this.createChecksum; getLog().info("starting to install external dependencies into local repository"); // loop over and process all configured artifacts for (ArtifactItem artifactItem : artifactItems) { getLog().info("resolving artifact for installation: " + artifactItem.toString()); // // CREATE MAVEN ARTIFACT // Artifact artifact = createArtifact(artifactItem); // determine if the artifact is already installed in the local // Maven repository Boolean artifactAlreadyInstalled = getLocalRepoFile(artifact).exists(); // only proceed with this artifact if it is not already // installed or it is configured to be forced. if (!artifactAlreadyInstalled || artifactItem.getForce() || force) { if (artifactItem.getForce()) { getLog().debug("this artifact is flagged as a FORCED install: " + artifactItem.toString()); } // ensure the artifact file is located in the staging // directory File stagedArtifactFile = getFullyQualifiedArtifactFilePath(artifactItem); if (stagedArtifactFile.exists()) { // if this artifact is configured to extract a file, // then the checksum verification will need to take // place // if there is a separate extract file checksum property // defined if (artifactItem.hasExtractFile()) { if (artifactItem.hasExtractFileChecksum()) { // verify extracted file checksum (if an extract // file checksum was defined); // 'MojoFailureException' exception will be // thrown if // verification fails verifyArtifactItemExtractFileChecksum(artifactItem, stagedArtifactFile); } } // if this is not an extracted file, then verify the // downloaded file using the regular checksum property else { // verify file checksum (if a checksum was defined); // 'MojoFailureException' exception will be thrown // if verification fails verifyArtifactItemChecksum(artifactItem, stagedArtifactFile); } // perform Sonatype REST query to ensure that this // artifacts checksum // is not resolved to an existing artifact already // hosted in another // Maven repository verifyArtifactItemChecksumBySonatypeLookup(artifactItem, stagedArtifactFile); // // INSTALL MAVEN ARTIFACT TO LOCAL REPOSITORY // if (artifact != null && artifactItem.getInstall()) { // create Maven artifact POM file File generatedPomFile = null; // don't generate a POM file for POM artifacts if (!"pom".equals(artifactItem.getPackaging())) { // if a POM file was provided for the artifact // item, then // use that POM file instead of generating a new // one if (artifactItem.getPomFile() != null) { ArtifactMetadata pomMetadata = new ProjectArtifactMetadata(artifact, artifactItem.getPomFile()); getLog().debug("installing defined POM file: " + artifactItem.getPomFile()); artifact.addMetadata(pomMetadata); } else { // dynamically create a new POM file for // this artifact generatedPomFile = generatePomFile(artifactItem); ArtifactMetadata pomMetadata = new ProjectArtifactMetadata(artifact, generatedPomFile); if (artifactItem.getGeneratePom() == true) { getLog().debug("installing generated POM file: " + generatedPomFile.getCanonicalPath()); artifact.addMetadata(pomMetadata); } } } getLog().info("installing artifact into local repository: " + localRepository.getId()); // install artifact to local repository installer.install(stagedArtifactFile, artifact, localRepository); // install checksum files to local repository if (artifactItem.getCreateChecksum() != null) { super.createChecksum = artifactItem.getCreateChecksum().equalsIgnoreCase("true"); } else { super.createChecksum = cachedCreateChecksums; } installChecksums(artifact); } else { getLog().debug("configured to not install artifact: " + artifactItem.toString()); } } else { // throw error because we were unable to install the // external dependency throw new MojoFailureException("Unable to install external dependency '" + artifactItem.getArtifactId() + "'; file not found in staging path: " + stagedArtifactFile.getCanonicalPath()); } } else { getLog().info("this aritifact already exists in the local repository; no download is needed: " + artifactItem.toString()); } } getLog().info("finished installing all external dependencies into local repository"); } catch (MojoFailureException e) { throw e; } catch (Exception e) { getLog().error(e); throw new MojoExecutionException(e.getMessage(), e); } }
From source file:com.universalmediaserver.external.AbstractExternalDependencyMojo.java
License:Apache License
/** * Install an artifact into the local repository * * @param artifactItem the current <code>ArtifactItem</code> * @param artifact the <code>Artifact</code> representing the <code>ArtifactItem</code> * @param stagedArtifactFile the <code>File</code> representing the staged * location for the <code>ArtifactItem</code> * @throws MojoExecutionException MojoExecutionException *//* w w w. jav a 2 s . c om*/ protected void installArtifact(ArtifactItem artifactItem, Artifact artifact, File stagedArtifactFile) throws MojoExecutionException { // Create Maven artifact POM file File generatedPomFile = null; // Don't generate a POM file for POM artifacts if (!"pom".equals(artifactItem.getPackaging())) { if (artifactItem.getPomFile() != null) { /* * If a POM file was provided for the artifact * item, then use that POM file instead of * generating a new one */ ProjectArtifactMetadata pomMetadata = new ProjectArtifactMetadata(artifact, artifactItem.getPomFile()); getLog().debug("Installing defined POM file: " + artifactItem.getPomFile()); artifact.addMetadata(pomMetadata); } else { // Dynamically create a new POM file for this artifact generatedPomFile = generatePomFile(artifactItem); ProjectArtifactMetadata pomMetadata = new ProjectArtifactMetadata(artifact, generatedPomFile); if (artifactItem.getGeneratePom() == true) { getLog().debug("installing generated POM file: " + generatedPomFile.getAbsolutePath()); artifact.addMetadata(pomMetadata); } } } // Install artifact to local repository try { installer.install(stagedArtifactFile, artifact, localRepository); } catch (ArtifactInstallationException e) { throw new MojoExecutionException( "Could not install artifact " + artifact.toString() + " to local repository: " + e.getMessage(), e); } // Install checksum files to local repository boolean createChecksum; if (artifactItem.getCreateChecksum() != null) { createChecksum = artifactItem.getCreateChecksum(); } else { createChecksum = this.createChecksum; } installChecksums(artifact, createChecksum); }
From source file:com.universalmediaserver.external.DeployExternalDependencyMojo.java
License:Apache License
public void execute() throws MojoExecutionException, MojoFailureException { super.execute(); getLog().info("Starting to deploy external dependencies to distribution repository"); // Loop over and process all configured artifacts for (ArtifactItem artifactItem : artifactItems) { getLog().info("Resolving artifact in locale repository for deployment: " + artifactItem.toString()); // Create Maven artifact Artifact artifact = createArtifact(artifactItem); // Determine if the artifact is already installed in the local Maven repository File installedArtifactFile = getLocalRepoFile(artifact); // Only proceed with this artifact if it is installed in the local repository. if (installedArtifactFile.exists()) { if (!resolveArtifactItem(artifact)) { throw new MojoExecutionException("Could not resolve artifact " + artifact.toString() + NEWLINE + "Make sure \"resolve\" and \"install\" goals has been executed first"); }// ww w . jav a2 s. c o m // Deploy to distribution Maven repository if (artifactItem.getDeploy()) { ArtifactRepository repo = getDeploymentRepository(); String protocol = repo.getProtocol(); if (protocol.equalsIgnoreCase("scp")) { File sshFolder = new File(System.getProperty("user.home"), ".ssh"); if (!sshFolder.exists() && !sshFolder.mkdirs()) { throw new MojoExecutionException( "Could not create folder: " + sshFolder.getAbsolutePath()); } } // Create Maven artifact POM file File generatedPomFile = null; // Don't generate a POM file for POM artifacts if (!"pom".equals(artifactItem.getPackaging())) { if (artifactItem.getPomFile() != null) { /* * If a POM file was provided for the artifact * item, then use that POM file instead of * generating a new one */ ProjectArtifactMetadata pomMetadata = new ProjectArtifactMetadata(artifact, artifactItem.getPomFile()); artifact.addMetadata(pomMetadata); } else { // Dynamically create a new POM file for this artifact generatedPomFile = generatePomFile(artifactItem); ProjectArtifactMetadata pomMetadata = new ProjectArtifactMetadata(artifact, generatedPomFile); if (artifactItem.getGeneratePom() == true) { artifact.addMetadata(pomMetadata); } } } // Deploy now getLog().info("Deploying artifact to distribution repository: " + artifactItem.toString()); try { artifactDeployer.deploy(artifact.getFile(), artifact, repo, localRepository); } catch (ArtifactDeploymentException e) { throw new MojoExecutionException( "Deployment of external dependency failed with: " + e.getMessage(), e); } } else { getLog().debug("Configured to not deploy artifact: " + artifactItem.toString()); } } else { // Throw exception because we were unable to find the installed external dependency throw new MojoExecutionException("Unable to find external dependency \"" + artifactItem.getArtifactId() + "\"; file not found in local repository: " + installedArtifactFile.getAbsolutePath()); } } getLog().info("Finished deploying external dependencies to distribution repository"); }
From source file:com.webcohesion.enunciate.mojo.DeployArtifactBaseMojo.java
License:Apache License
public void execute() throws MojoExecutionException, MojoFailureException { if (this.enunciateArtifactId == null) { throw new MojoExecutionException("An enunciate artifact id must be supplied."); }/*from w w w .j a v a2 s .c o m*/ Enunciate enunciate = (Enunciate) getPluginContext().get(ConfigMojo.ENUNCIATE_PROPERTY); if (enunciate == null) { throw new MojoExecutionException("No enunciate mechanism found in the project!"); } com.webcohesion.enunciate.artifacts.Artifact enunciateArtifact = enunciate .findArtifact(this.enunciateArtifactId); if (enunciateArtifact == null) { throw new MojoExecutionException("Unknown Enunciate artifact: " + this.enunciateArtifactId + "."); } File mainArtifact = null; File sources = null; File javadocs = null; if (enunciateArtifact instanceof ClientLibraryArtifact) { for (com.webcohesion.enunciate.artifacts.Artifact childArtifact : ((ClientLibraryArtifact) enunciateArtifact) .getArtifacts()) { if (childArtifact instanceof FileArtifact) { ArtifactType artifactType = ((FileArtifact) childArtifact).getArtifactType(); if (artifactType != null) { switch (artifactType) { case binaries: mainArtifact = ((FileArtifact) childArtifact).getFile(); break; case sources: sources = ((FileArtifact) childArtifact).getFile(); break; case javadocs: javadocs = ((FileArtifact) childArtifact).getFile(); break; } } } } } else if (enunciateArtifact instanceof FileArtifact) { mainArtifact = ((FileArtifact) enunciateArtifact).getFile(); } else { try { mainArtifact = enunciate.createTempFile(this.enunciateArtifactId, "artifact"); enunciateArtifact.exportTo(mainArtifact, enunciate); } catch (IOException e) { throw new MojoExecutionException("Unable to create a temp file.", e); } } if (mainArtifact == null) { if (sources != null) { mainArtifact = sources; sources = null; } } if (mainArtifact == null) { throw new MojoExecutionException( "Unable to determine the file to deploy from enunciate artifact " + enunciateArtifactId + "."); } // Process the supplied POM (if there is one) Model model = null; if (pomFile != null) { generatePom = false; model = readModel(pomFile); processModel(model); } if (this.packaging == null) { String artifactName = mainArtifact.getName(); int dotIndex = artifactName.indexOf('.'); if (dotIndex > 0 && (dotIndex + 1 < artifactName.length())) { this.packaging = artifactName.substring(dotIndex + 1); } } if (this.packaging == null) { throw new MojoExecutionException("Unable to determine the packaging of enunciate artifact " + enunciateArtifactId + ". Please specify it in the configuration."); } if (this.version == null) { throw new MojoExecutionException("Null version."); } if (model == null) { model = new Model(); model.setModelVersion("4.0.0"); model.setGroupId(this.groupId); model.setArtifactId(this.artifactId); model.setVersion(this.version); model.setPackaging(this.packaging); model.setDescription(this.description); } ArtifactRepository repo = getDeploymentRepository(); String protocol = repo.getProtocol(); if (protocol.equals("scp")) { File sshFile = new File(System.getProperty("user.home"), ".ssh"); if (!sshFile.exists()) { sshFile.mkdirs(); } } Artifact artifact = this.artifactFactory.createArtifactWithClassifier(groupId, artifactId, version, packaging, classifier); // Upload the POM if requested, generating one if need be if (generatePom) { ArtifactMetadata metadata = new ProjectArtifactMetadata(artifact, generatePomFile(model)); artifact.addMetadata(metadata); } else { ArtifactMetadata metadata = new ProjectArtifactMetadata(artifact, pomFile); artifact.addMetadata(metadata); } try { getDeployer().deploy(mainArtifact, artifact, repo, this.localRepository); if (sources != null || javadocs != null) { MavenProject project = new MavenProject(model); project.setArtifact(artifact); if (sources != null) { //we have to do it this way because of classloading issues. this.projectHelper.attachArtifact(project, artifact.getType(), "sources", sources); getDeployer().deploy(sources, (Artifact) project.getAttachedArtifacts().get(0), repo, this.localRepository); } if (javadocs != null) { //we have to do it this way because of classloading issues. this.projectHelper.attachArtifact(project, artifact.getType(), "javadoc", javadocs); getDeployer().deploy(javadocs, (Artifact) project.getAttachedArtifacts().get(0), repo, this.localRepository); } } } catch (ArtifactDeploymentException e) { throw new MojoExecutionException(e.getMessage(), e); } }
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 {//from w w w . j ava2s. c o m ((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.gridmaven.reporters.MavenArtifactRecord.java
License:Open Source License
/** * Installs the artifact to the local Maven repository. *///w ww .j a v a 2 s . c om public void install(MavenEmbedder embedder) throws MavenEmbedderException, IOException, ComponentLookupException, ArtifactInstallationException { ArtifactHandlerManager handlerManager = embedder.lookup(ArtifactHandlerManager.class); ArtifactInstaller installer = embedder.lookup(ArtifactInstaller.class); ArtifactFactory factory = embedder.lookup(ArtifactFactory.class); Artifact main = mainArtifact.toArtifact(handlerManager, factory, parent); if (!isPOM()) main.addMetadata(new ProjectArtifactMetadata(main, pomArtifact.getFile(parent))); installer.install(mainArtifact.getFile(parent), main, embedder.getLocalRepository()); for (MavenArtifact aa : attachedArtifacts) installer.install(aa.getFile(parent), aa.toArtifact(handlerManager, factory, parent), embedder.getLocalRepository()); }
From source file:hudson.maven.artifact.transform.AbstractVersionTransformation.java
License:Apache License
protected String resolveVersion(Artifact artifact, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories) throws RepositoryMetadataResolutionException { RepositoryMetadata metadata;/* ww w . ja v a 2 s . co m*/ // Don't use snapshot metadata for LATEST (which isSnapshot returns true for) if (!artifact.isSnapshot() || Artifact.LATEST_VERSION.equals(artifact.getBaseVersion())) { metadata = new ArtifactRepositoryMetadata(artifact); } else { metadata = new SnapshotArtifactRepositoryMetadata(artifact); } repositoryMetadataManager.resolve(metadata, remoteRepositories, localRepository); artifact.addMetadata(metadata); Metadata repoMetadata = metadata.getMetadata(); String version = null; if (repoMetadata != null && repoMetadata.getVersioning() != null) { version = constructVersion(repoMetadata.getVersioning(), artifact.getBaseVersion()); } if (version == null) { // use the local copy, or if it doesn't exist - go to the remote repo for it version = artifact.getBaseVersion(); } // TODO: also do this logging for other metadata? // TODO: figure out way to avoid duplicated message if (getLogger().isDebugEnabled()) { if (!version.equals(artifact.getBaseVersion())) { String message = artifact.getArtifactId() + ": resolved to version " + version; if (artifact.getRepository() != null) { message += " from repository " + artifact.getRepository().getId(); } else { message += " from local repository"; } getLogger().debug(message); } else { // Locally installed file is newer, don't use the resolved version getLogger().debug(artifact.getArtifactId() + ": using locally installed snapshot"); } } return version; }