use of org.commonjava.maven.atlas.ident.ref.ProjectVersionRef in project galley by Commonjava.
the class MavenPomReader method readLocalPom.
public MavenPomView readLocalPom(final ProjectVersionRef ref, final Transfer transfer, final boolean cache, final EventMetadata eventMetadata, final String... activeProfileIds) throws GalleyMavenException {
DocRef<ProjectVersionRef> dr;
try {
dr = getDocRef(ref, transfer, cache, eventMetadata);
} catch (final TransferException e) {
throw new GalleyMavenException("Failed to parse POM for: {}. Reason: {}", e, ref, e.getMessage());
}
final MavenPomView view = new MavenPomView(ref, Collections.singletonList(dr), xpath, pluginDefaults, pluginImplications, xml, activeProfileIds);
logStructure(view);
return view;
}
use of org.commonjava.maven.atlas.ident.ref.ProjectVersionRef in project galley by Commonjava.
the class MavenPomReader method getDocRef.
private DocRef<ProjectVersionRef> getDocRef(final ProjectVersionRef ref, final List<? extends Location> locations, final boolean cache, final EventMetadata eventMetadata) throws TransferException, GalleyMavenException {
DocRef<ProjectVersionRef> dr = getFirstCached(ref, locations);
if (dr == null) {
final Transfer transfer = artifacts.retrieveFirst(locations, ref.asPomArtifact(), eventMetadata);
if (transfer == null) {
return null;
}
final Document doc = xml.parse(transfer, new EventMetadata());
dr = new DocRef<ProjectVersionRef>(ref, transfer.getLocation().toString(), doc);
if (cache) {
cache(dr);
}
}
return dr;
}
use of org.commonjava.maven.atlas.ident.ref.ProjectVersionRef in project galley by Commonjava.
the class MavenPomReader method read.
public MavenPomView read(final ProjectVersionRef ref, final List<? extends Location> locations, final boolean cache, final EventMetadata eventMetadata, final String... activeProfileIds) throws GalleyMavenException {
final List<DocRef<ProjectVersionRef>> stack = new ArrayList<DocRef<ProjectVersionRef>>();
ProjectVersionRef next = ref;
do {
DocRef<ProjectVersionRef> dr;
try {
dr = getDocRef(next, locations, cache, eventMetadata);
} catch (final TransferException e) {
throw new GalleyMavenException("Failed to retrieve POM for: {}, {} levels deep in ancestry stack of: {}. Reason: {}", e, next, stack.size(), ref, e.getMessage());
}
if (dr == null) {
throw new GalleyMavenException("Cannot resolve {}, {} levels dep in the ancestry stack of: {}", next, stack.size(), ref);
}
stack.add(dr);
next = xml.getParentRef(dr.getDoc());
} while (next != null);
final MavenPomView view = new MavenPomView(ref, stack, xpath, pluginDefaults, pluginImplications, xml, activeProfileIds);
assembleImportedInformation(view, locations);
logStructure(view);
return view;
}
use of org.commonjava.maven.atlas.ident.ref.ProjectVersionRef 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);
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!");
}
}
use of org.commonjava.maven.atlas.ident.ref.ProjectVersionRef in project galley by Commonjava.
the class ArtifactPathUtilsTest method handleRemoteSnapshotArtifactPath.
@Test
public void handleRemoteSnapshotArtifactPath() throws Exception {
final ProjectVersionRef pvr = new SimpleProjectVersionRef("org.group", "artifact-id", "1.0-20140603.151226-11");
final TypeMapper mapper = new StandardTypeMapper();
final String path = ArtifactPathUtils.formatArtifactPath(pvr.asJarArtifact(), mapper);
assertThat(path.equals("org/group/artifact-id/1.0-SNAPSHOT/artifact-id-" + pvr.getVersionString() + ".jar"), equalTo(true));
}
Aggregations