/** {@inheritDoc} */ public void setVersion( String version ) { artifact.setVersion( version ); }
farthest.getArtifact().setVersion( nearest.getArtifact().getVersion() ); fireEvent( ResolutionListener.OMIT_FOR_NEARER, listeners, nearest, farthest.getArtifact() );
/** {@inheritDoc} */ public void setVersion( String version ) { artifact.setVersion( version ); }
private Artifact setLatestVersionIfMissing(final Artifact artifact, final ArtifactRepository localRepository, final List<ArtifactRepository> remoteRepositories) throws GemException { if (artifact.getVersion() == null) { final List<String> versions = availableVersions(artifact, localRepository, remoteRepositories); artifact.setVersionRange(null); artifact.setVersion(versions.get(versions.size() - 1)); } return artifact; }
private void manageArtifact( ResolutionNode node, ManagedVersionMap managedVersions, List<ResolutionListener> listeners ) { Artifact artifact = managedVersions.get( node.getKey() ); // Before we update the version of the artifact, we need to know // whether we are working on a transitive dependency or not. This // allows depMgmt to always override transitive dependencies, while // explicit child override depMgmt (viz. depMgmt should only // provide defaults to children, but should override transitives). // We can do this by calling isChildOfRootNode on the current node. if ( ( artifact.getVersion() != null ) && ( !node.isChildOfRootNode() || node.getArtifact().getVersion() == null ) ) { fireEvent( ResolutionListener.MANAGE_ARTIFACT_VERSION, listeners, node, artifact ); node.getArtifact().setVersion( artifact.getVersion() ); } if ( ( artifact.getScope() != null ) && ( !node.isChildOfRootNode() || node.getArtifact().getScope() == null ) ) { fireEvent( ResolutionListener.MANAGE_ARTIFACT_SCOPE, listeners, node, artifact ); node.getArtifact().setScope( artifact.getScope() ); } if ( Artifact.SCOPE_SYSTEM.equals( node.getArtifact().getScope() ) && ( node.getArtifact().getFile() == null ) && ( artifact.getFile() != null ) ) { fireEvent( ResolutionListener.MANAGE_ARTIFACT_SYSTEM_PATH, listeners, node, artifact ); node.getArtifact().setFile( artifact.getFile() ); } }
/** * Updates artifact versions for a given branch name. * @param a artifact to update (may be null) * @param branchName the branch name */ private void updateArtifactVersion(Artifact a, String branchName) { if (a != null) { a.setVersion(getAsBranchSnapshotVersion(a.getVersion(), branchName)); try { a.setVersionRange(VersionRange.createFromVersion(a.getVersion())); } catch (UnsupportedOperationException uoe) { // Some artifact types don't like this. getLog().debug("Unable to update VersionRange for artifact."); } } }
public void setVersion( String version ) { delegate.setVersion( version ); }
public void setVersion(String version) { original.setVersion(version); }
public void setVersion(final String version) { this.artifact.setVersion(version); }
public void setVersion(String version) { original.setVersion(version); }
public void setVersion(final String version) { this.artifact.setVersion(version); }
private void setAlignment( Artifact artifact, Map<String, GroupVersionAlignment> groupVersionAlignments ) { GroupVersionAlignment alignment = groupVersionAlignments.get( artifact.getGroupId() ); if ( alignment != null ) { if ( !alignment.getExcludes().contains( artifact.getArtifactId() ) ) { artifact.setVersion( alignment.getVersion() ); } } } }
private void installBaseSnapshot( Artifact artifact, ProjectBuildingRequest buildingRequest ) throws ArtifactInstallerException { if ( artifact.isSnapshot() && !artifact.getBaseVersion().equals( artifact.getVersion() ) ) { String version = artifact.getVersion(); try { artifact.setVersion( artifact.getBaseVersion() ); installer.install( buildingRequest, Collections.singletonList( artifact ) ); } finally { artifact.setVersion( version ); } } }
public void manageArtifact(final Artifact artifact, final Artifact replacement) { Node node = (Node) artifacts.get(artifact.getDependencyConflictId()); if (node != null) { if (replacement.getVersion() != null) { node.artifact.setVersion(replacement.getVersion()); } if (replacement.getScope() != null) { node.artifact.setScope(replacement.getScope()); } } } }
public void manageArtifact(final Artifact artifact, final Artifact replacement) { Node node = (Node) artifacts.get(artifact.getDependencyConflictId()); if (node != null) { if (replacement.getVersion() != null) { node.artifact.setVersion(replacement.getVersion()); } if (replacement.getScope() != null) { node.artifact.setScope(replacement.getScope()); } } } }
@Override public void manageArtifact( Artifact artifact, Artifact replacement ) { Node node = (Node) artifacts.get( artifact.getDependencyConflictId() ); if ( node != null ) { if ( replacement.getVersion() != null ) { node.artifact.setVersion( replacement.getVersion() ); } if ( replacement.getScope() != null ) { node.artifact.setScope( replacement.getScope() ); } } }
private void applyOverrides(BomConfig config, Map<Artifact, Dependency> dependencies) { if (config.getOverrides() != null) { for (VersionOverride override : config.getOverrides()) { List<ArtifactFilter> filters = new LinkedList<ArtifactFilter>(); filters.add(new IncludesFilter(override.getDependencies().getIncludes())); filters.add(new ExcludesFilter(override.getDependencies().getExcludes())); CompositeFilter filter = new CompositeFilter(filters); for (Map.Entry<Artifact, Dependency> entry : dependencies.entrySet()) { if (filter.apply(entry.getKey()) != null) { getLog().debug("Changing version of dependency " + dependencyKey(entry.getValue()) + " to " + override.getVersion()); entry.getKey().setVersion(override.getVersion()); entry.getValue().setVersion(override.getVersion()); } } } } }
@Override public void mojoStarted( ExecutionEvent event ) { if (event.getMojoExecution().getExecutionId() != null && event.getMojoExecution().getExecutionId().endsWith("-snapshot")) { frozenPomFile = event.getProject().getFile(); event.getProject().setFile(new File( frozenPomFile.getParent(), MavenConventions.POM_FILE)); frozenArtifact = event.getProject().getArtifact(); Artifact snapshotArtifact = ArtifactUtils.copyArtifact(frozenArtifact); snapshotArtifact.setVersion(transformToSnapshotVersion(frozenArtifact.getVersion())); event.getProject().setArtifact(snapshotArtifact); if (!isPomArtifact(event.getProject())) { frozenFinalName = event.getProject().getBuild().getFinalName(); event.getProject().getBuild().setFinalName(transformToSnapshot(frozenFinalName, frozenArtifact, snapshotArtifact)); event.getProject().getArtifact().setFile(new File(transformToSnapshot(frozenArtifact.getFile().getAbsolutePath(), frozenArtifact, snapshotArtifact))); logger.info("[SnapshotExecutionListener]: Switched frozenArtifact file to " + transformToSnapshot(frozenArtifact.getFile().getAbsolutePath(), frozenArtifact, snapshotArtifact)); } frozenAttachedArtifacts = new LinkedList<Artifact>(); for (Artifact attachedArtifact : event.getProject().getAttachedArtifacts()) { String attachedFileAbsolutePath = attachedArtifact.getFile().getAbsolutePath(); logger.info("[SnapshotExecutionListener]: Attached frozenArtifact file : " + attachedFileAbsolutePath); frozenAttachedArtifacts.add(attachedArtifact); } event.getProject().getAttachedArtifacts().clear(); for (Artifact frozenAttachedArtifact : frozenAttachedArtifacts) { Artifact unfrozenAttachedArtifact = ArtifactUtils.copyArtifact(frozenAttachedArtifact); unfrozenAttachedArtifact.setVersion(transformToSnapshot(unfrozenAttachedArtifact.getVersion(), frozenArtifact, snapshotArtifact)); event.getProject().addAttachedArtifact(unfrozenAttachedArtifact); } } }
private MavenProject projectFromArtifact(final Artifact artifact) throws ProjectBuildingException, GemException { final ProjectBuildingRequest request = new DefaultProjectBuildingRequest().setLocalRepository(this.localRepository) .setRemoteRepositories(this.project.getRemoteArtifactRepositories()); manager.setRepositorySession(request, this.repositorySession ); final MavenProject project = this.builder.build(artifact, request) .getProject(); if (project.getDistributionManagement() != null && project.getDistributionManagement().getRelocation() != null) { final Relocation reloc = project.getDistributionManagement() .getRelocation(); final String key = artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getType() + ":" + artifact.getVersion(); artifact.setArtifactId(reloc.getArtifactId()); artifact.setGroupId(reloc.getGroupId()); if (reloc.getVersion() != null) { artifact.setVersion(reloc.getVersion()); } this.relocationMap.put(key, artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getType() + ":" + artifact.getVersion()); return projectFromArtifact(artifact); } else { return project; } }
private MavenProject projectFromArtifact(final Artifact artifact) throws ProjectBuildingException, GemException { final ProjectBuildingRequest request = new DefaultProjectBuildingRequest().setLocalRepository(this.localRepository) .setRemoteRepositories(this.project.getRemoteArtifactRepositories()); manager.setRepositorySession(request, this.repositorySession ); final MavenProject project = this.builder.build(artifact, request) .getProject(); if (project.getDistributionManagement() != null && project.getDistributionManagement().getRelocation() != null) { final Relocation reloc = project.getDistributionManagement() .getRelocation(); final String key = artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getType() + ":" + artifact.getVersion(); artifact.setArtifactId(reloc.getArtifactId()); artifact.setGroupId(reloc.getGroupId()); if (reloc.getVersion() != null) { artifact.setVersion(reloc.getVersion()); } this.relocationMap.put(key, artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getType() + ":" + artifact.getVersion()); return projectFromArtifact(artifact); } else { return project; } }