Search in sources :

Example 46 with SimpleProjectVersionRef

use of org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef 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 47 with SimpleProjectVersionRef

use of org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef in project pom-manipulation-ext by release-engineering.

the class VersioningCalculatorTest method incrementExistingSerialSuffix_TwoProjects_UsingRepositoryMetadata_AvailableOnlyForOne.

@Test
public void incrementExistingSerialSuffix_TwoProjects_UsingRepositoryMetadata_AvailableOnlyForOne() 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");
    setupSession(props, "1.2.0.GA-foo-3", "1.2.0.GA-foo-2", "1.2.0.GA-foo-9");
    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) 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) SimpleProjectVersionRef(org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef) Test(org.junit.Test)

Example 48 with SimpleProjectVersionRef

use of org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef in project galley by Commonjava.

the class ArtifactManagerImplTest method resolveSnapshot_FirstMatch_SingletonLocationList_SingletonSnapshotList_LatestVersionStrategy.

@Test
public void resolveSnapshot_FirstMatch_SingletonLocationList_SingletonSnapshotList_LatestVersionStrategy() throws Exception {
    final String base = "single-snapshot/";
    final String testResource = base + "single-snapshot.xml";
    final String testPomResource = base + "single-snapshot-pom.xml";
    final ProjectVersionRef ref = new SimpleProjectVersionRef("org.group", "artifact", "1.0-SNAPSHOT");
    final ConcreteResource metadataResource = new ConcreteResource(LOCATION, fixture.snapshotMetadataPath(ref));
    final ConcreteResource pomResource = new ConcreteResource(LOCATION, fixture.pomPath(ref.selectVersion("1.0-20140604.101244-1").asPomArtifact()));
    fixture.getTransport().registerDownload(metadataResource, new TestDownload(ROOT + testResource));
    fixture.getTransport().registerDownload(pomResource, new TestDownload(ROOT + testPomResource));
    final Transfer retrieved = fixture.getArtifactManager().retrieve(LOCATION, ref.asPomArtifact(), new EventMetadata());
    final Document document = fixture.getXml().parse(retrieved, new EventMetadata());
    final ProjectVersionRef result = fixture.getXml().getProjectVersionRef(document);
    System.out.println(result);
// assertThat( result, notNullValue() );
// assertThat( result.getVersionString(), equalTo( "1.0-20140604.101244-1" ) );
}
Also used : TestDownload(org.commonjava.maven.galley.testing.core.transport.job.TestDownload) ProjectVersionRef(org.commonjava.maven.atlas.ident.ref.ProjectVersionRef) SimpleProjectVersionRef(org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef) ConcreteResource(org.commonjava.maven.galley.model.ConcreteResource) Transfer(org.commonjava.maven.galley.model.Transfer) SimpleProjectVersionRef(org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef) Document(org.w3c.dom.Document) EventMetadata(org.commonjava.maven.galley.event.EventMetadata) Test(org.junit.Test)

Example 49 with SimpleProjectVersionRef

use of org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef in project galley by Commonjava.

the class MavenModelProcessorTest method resolvePluginDependencyFromManagedInfo.

@Test
public void resolvePluginDependencyFromManagedInfo() throws Exception {
    final URI src = new URI("http://nowhere.com/path/to/repo");
    final ProjectVersionRef childRef = new SimpleProjectVersionRef("org.test", "test-child", "1.0");
    final LinkedHashMap<ProjectVersionRef, String> lineage = new LinkedHashMap<ProjectVersionRef, String>();
    lineage.put(childRef, "child.pom.xml");
    lineage.put(new SimpleProjectVersionRef("org.test", "test-parent", "1.0"), "parent.pom.xml");
    final Location location = new SimpleLocation("test", src.toString(), false, true, true, false, true, false);
    final String base = PROJ_BASE + "dependency-in-managed-parent-plugin/";
    for (final Entry<ProjectVersionRef, String> entry : lineage.entrySet()) {
        final ProjectVersionRef ref = entry.getKey();
        final String filename = entry.getValue();
        final String path = ArtifactPathUtils.formatArtifactPath(ref.asPomArtifact(), fixture.getTypeMapper());
        fixture.getTransport().registerDownload(new ConcreteResource(location, path), new TestDownload(base + filename));
    }
    final Transfer transfer = fixture.getArtifactManager().retrieve(location, childRef.asPomArtifact());
    final MavenPomView pomView = fixture.getPomReader().read(childRef, transfer, Collections.singletonList(location));
    final List<PluginView> buildPlugins = pomView.getAllBuildPlugins();
    assertThat(buildPlugins, notNullValue());
    assertThat(buildPlugins.size(), equalTo(1));
    final PluginView pv = buildPlugins.get(0);
    assertThat(pv, notNullValue());
    final List<PluginDependencyView> deps = pv.getLocalPluginDependencies();
    assertThat(deps, notNullValue());
    assertThat(deps.size(), equalTo(1));
    final PluginDependencyView pdv = deps.get(0);
    assertThat(pdv, notNullValue());
    assertThat(pdv.asArtifactRef().getVersionString(), equalTo("1.0"));
    final ModelProcessorConfig discoveryConfig = new ModelProcessorConfig();
    discoveryConfig.setIncludeManagedDependencies(true);
    discoveryConfig.setIncludeBuildSection(true);
    discoveryConfig.setIncludeManagedPlugins(false);
    EProjectDirectRelationships result = fixture.getModelProcessor().readRelationships(pomView, src, discoveryConfig);
    final Set<ProjectRelationship<?, ?>> rels = result.getExactAllRelationships();
    logger.info("Found {} relationships:\n\n  {}", rels.size(), new JoinString("\n  ", rels));
    boolean seen = false;
    for (final ProjectRelationship<?, ?> rel : rels) {
        if (rel.getType() == RelationshipType.PLUGIN_DEP && !rel.isManaged()) {
            if (seen) {
                fail("Multiple plugin dependencies found!");
            }
            seen = true;
            assertThat(rel.getTarget().getVersionString(), equalTo("1.0"));
        }
    }
    if (!seen) {
        fail("Plugin-dependency relationship not found!");
    }
}
Also used : TestDownload(org.commonjava.maven.galley.testing.core.transport.job.TestDownload) JoinString(org.commonjava.maven.atlas.ident.util.JoinString) SimpleProjectVersionRef(org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef) URI(java.net.URI) LinkedHashMap(java.util.LinkedHashMap) PluginDependencyView(org.commonjava.maven.galley.maven.model.view.PluginDependencyView) JoinString(org.commonjava.maven.atlas.ident.util.JoinString) ProjectVersionRef(org.commonjava.maven.atlas.ident.ref.ProjectVersionRef) SimpleProjectVersionRef(org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef) ProjectRelationship(org.commonjava.maven.atlas.graph.rel.ProjectRelationship) ConcreteResource(org.commonjava.maven.galley.model.ConcreteResource) Transfer(org.commonjava.maven.galley.model.Transfer) EProjectDirectRelationships(org.commonjava.maven.atlas.graph.model.EProjectDirectRelationships) PluginView(org.commonjava.maven.galley.maven.model.view.PluginView) SimpleLocation(org.commonjava.maven.galley.model.SimpleLocation) MavenPomView(org.commonjava.maven.galley.maven.model.view.MavenPomView) SimpleLocation(org.commonjava.maven.galley.model.SimpleLocation) Location(org.commonjava.maven.galley.model.Location) Test(org.junit.Test)

Aggregations

SimpleProjectVersionRef (org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef)49 ProjectVersionRef (org.commonjava.maven.atlas.ident.ref.ProjectVersionRef)41 Test (org.junit.Test)36 ArrayList (java.util.ArrayList)22 HashMap (java.util.HashMap)11 ConcreteResource (org.commonjava.maven.galley.model.ConcreteResource)11 TestDownload (org.commonjava.maven.galley.testing.core.transport.job.TestDownload)11 Model (org.apache.maven.model.Model)9 RestException (org.commonjava.maven.ext.io.rest.exception.RestException)9 Transfer (org.commonjava.maven.galley.model.Transfer)9 SimpleLocation (org.commonjava.maven.galley.model.SimpleLocation)7 MavenProject (org.apache.maven.project.MavenProject)6 EventMetadata (org.commonjava.maven.galley.event.EventMetadata)6 URI (java.net.URI)5 LinkedHashMap (java.util.LinkedHashMap)5 Dependency (org.apache.maven.model.Dependency)5 DependencyManagement (org.apache.maven.model.DependencyManagement)5 JoinString (org.commonjava.maven.atlas.ident.util.JoinString)5 Map (java.util.Map)4 Project (org.commonjava.maven.ext.common.model.Project)4