use of org.commonjava.maven.atlas.ident.ref.ProjectRef in project pom-manipulation-ext by release-engineering.
the class VersioningCalculatorTest method incrementExistingSerialSuffix_TwoProjects_UsingRepositoryMetadata_DifferentAvailableIncrements.
@Test
public void incrementExistingSerialSuffix_TwoProjects_UsingRepositoryMetadata_DifferentAvailableIncrements() throws Exception {
final String v = "1.2.0.GA";
final String os = "-foo-1";
final String ns = "foo-10";
final Model m1 = new Model();
m1.setGroupId(GROUP_ID);
m1.setArtifactId(ARTIFACT_ID);
m1.setVersion(v + os);
final Project p1 = new Project(m1);
final String a2 = ARTIFACT_ID + "-dep";
final Model m2 = new Model();
m2.setGroupId(GROUP_ID);
m2.setArtifactId(a2);
m2.setVersion(v + os);
final Project p2 = new Project(m2);
final Properties props = new Properties();
props.setProperty(VersioningState.INCREMENT_SERIAL_SUFFIX_SYSPROP.getCurrent(), "foo-0");
final Map<ProjectRef, String[]> versionMap = new HashMap<>();
versionMap.put(new SimpleProjectRef(p1.getGroupId(), p1.getArtifactId()), new String[] { "1.2.0.GA-foo-3", "1.2.0.GA-foo-2", "1.2.0.GA-foo-9" });
versionMap.put(new SimpleProjectRef(p2.getGroupId(), p2.getArtifactId()), new String[] { "1.2.0.GA-foo-3", "1.2.0.GA-foo-2" });
setupSession(props, versionMap);
final Map<ProjectVersionRef, String> result = modder.calculateVersioningChanges(Arrays.asList(p1, p2), session);
assertThat(result.get(new SimpleProjectVersionRef(GROUP_ID, ARTIFACT_ID, v + os)), equalTo(v + "-" + ns));
assertThat(result.get(new SimpleProjectVersionRef(GROUP_ID, a2, v + os)), equalTo(v + "-" + ns));
}
use of org.commonjava.maven.atlas.ident.ref.ProjectRef in project pom-manipulation-ext by release-engineering.
the class DependencyRemovalManipulator method apply.
private boolean apply(final Project project, final Model model) throws ManipulationException {
final DependencyRemovalState state = session.getState(DependencyRemovalState.class);
logger.info("Applying Dependency changes to: " + ga(project));
List<ProjectRef> dependenciesToRemove = state.getDependencyRemoval();
boolean result = scanDependencies(project.getAllResolvedDependencies(session), dependenciesToRemove, model.getDependencies());
if (model.getDependencyManagement() != null && scanDependencies(project.getResolvedManagedDependencies(session), dependenciesToRemove, model.getDependencyManagement().getDependencies())) {
result = true;
}
final HashMap<Profile, HashMap<ArtifactRef, Dependency>> pd = project.getAllResolvedProfileDependencies(session);
final HashMap<Profile, HashMap<ArtifactRef, Dependency>> pmd = project.getResolvedProfileManagedDependencies(session);
for (Profile profile : pd.keySet()) {
int index = model.getProfiles().indexOf(profile);
if (scanDependencies(pd.get(profile), dependenciesToRemove, model.getProfiles().get(index).getDependencies())) {
result = true;
}
}
for (Profile profile : pmd.keySet()) {
int index = model.getProfiles().indexOf(profile);
DependencyManagement dm = model.getProfiles().get(index).getDependencyManagement();
if (dm != null) {
if (scanDependencies(pmd.get(profile), dependenciesToRemove, dm.getDependencies())) {
result = true;
}
}
}
return result;
}
use of org.commonjava.maven.atlas.ident.ref.ProjectRef in project pom-manipulation-ext by release-engineering.
the class RepositoryInjectionManipulator method checkProject.
private boolean checkProject(RepositoryInjectionState state, Project project) {
boolean result = false;
List<ProjectRef> gaToApply = state.getRemoteRepositoryInjectionTargets();
if (gaToApply != null) {
// If ProjectRef component contains wildcard artifact treat it differently
for (ProjectRef p : gaToApply) {
if (p.getArtifactId().contains("*") && p.getGroupId().equals(project.getKey().getGroupId())) {
result = true;
} else if (p.equals(project.getKey().asProjectRef())) {
result = true;
}
}
logger.debug("Checking project {} against possible GAs {} and found match {}", project.getKey().asProjectRef(), gaToApply, result);
} else if (project.isInheritanceRoot()) {
result = true;
}
return result;
}
use of org.commonjava.maven.atlas.ident.ref.ProjectRef in project pom-manipulation-ext by release-engineering.
the class WildcardMapTest method testPut.
@Test
public void testPut() throws Exception {
ProjectRef key = SimpleProjectRef.parse("foo:bar");
map.put(key, "value");
assertTrue("Should have retrieved value", map.containsKey(key));
}
use of org.commonjava.maven.atlas.ident.ref.ProjectRef in project pom-manipulation-ext by release-engineering.
the class WildcardMapTest method testPutWildcardSecond.
@Test
public void testPutWildcardSecond() throws Exception {
ProjectRef key1 = SimpleProjectRef.parse("org.group:artifact");
ProjectRef key2 = SimpleProjectRef.parse("org.group:*");
map.put(key1, "1.1");
map.put(key2, "1.2");
assertTrue("Should have retrieved explicit value via wildcard", map.containsKey(key1));
assertTrue("Should have retrieved wildcard value", map.containsKey(key2));
assertFalse("Should not have retrieved value 1.1", map.get(key1).equals("1.1"));
assertThat(m_listAppender.list.toString(), containsString("Emptying map with keys [artifact] as replacing with wildcard mapping org.group:*"));
}
Aggregations