Search in sources :

Example 16 with ProjectRef

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));
}
Also used : Project(org.commonjava.maven.ext.common.model.Project) SimpleProjectRef(org.commonjava.maven.atlas.ident.ref.SimpleProjectRef) HashMap(java.util.HashMap) ProjectVersionRef(org.commonjava.maven.atlas.ident.ref.ProjectVersionRef) SimpleProjectVersionRef(org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef) Model(org.apache.maven.model.Model) Properties(java.util.Properties) SimpleProjectRef(org.commonjava.maven.atlas.ident.ref.SimpleProjectRef) ProjectRef(org.commonjava.maven.atlas.ident.ref.ProjectRef) SimpleProjectVersionRef(org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef) Test(org.junit.Test)

Example 17 with ProjectRef

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;
}
Also used : DependencyRemovalState(org.commonjava.maven.ext.core.state.DependencyRemovalState) HashMap(java.util.HashMap) ProjectRef(org.commonjava.maven.atlas.ident.ref.ProjectRef) Profile(org.apache.maven.model.Profile) DependencyManagement(org.apache.maven.model.DependencyManagement)

Example 18 with ProjectRef

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;
}
Also used : ProjectRef(org.commonjava.maven.atlas.ident.ref.ProjectRef)

Example 19 with ProjectRef

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));
}
Also used : SimpleProjectRef(org.commonjava.maven.atlas.ident.ref.SimpleProjectRef) ProjectRef(org.commonjava.maven.atlas.ident.ref.ProjectRef) Test(org.junit.Test)

Example 20 with ProjectRef

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:*"));
}
Also used : SimpleProjectRef(org.commonjava.maven.atlas.ident.ref.SimpleProjectRef) ProjectRef(org.commonjava.maven.atlas.ident.ref.ProjectRef) Test(org.junit.Test)

Aggregations

ProjectRef (org.commonjava.maven.atlas.ident.ref.ProjectRef)22 SimpleProjectRef (org.commonjava.maven.atlas.ident.ref.SimpleProjectRef)15 HashMap (java.util.HashMap)6 ProjectVersionRef (org.commonjava.maven.atlas.ident.ref.ProjectVersionRef)5 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)4 HashSet (java.util.HashSet)4 ArtifactRef (org.commonjava.maven.atlas.ident.ref.ArtifactRef)4 SimpleArtifactRef (org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef)4 ManipulationException (org.commonjava.maven.ext.common.ManipulationException)4 LinkedHashMap (java.util.LinkedHashMap)3 Map (java.util.Map)3 GalleyMavenException (org.commonjava.maven.galley.maven.GalleyMavenException)3 Set (java.util.Set)2 Model (org.apache.maven.model.Model)2 Profile (org.apache.maven.model.Profile)2 InvalidRefException (org.commonjava.maven.atlas.ident.ref.InvalidRefException)2 SimpleProjectVersionRef (org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef)2 JoinString (org.commonjava.maven.atlas.ident.util.JoinString)2 Project (org.commonjava.maven.ext.common.model.Project)2