[shrinkwrap-issues] [JBoss JIRA] Commented: (SHRINKWRAP-261) Shorthand for including maven artifacts
Samuel Santos (JIRA)
jira-events at lists.jboss.org
Wed Jun 29 09:20:23 EDT 2011
[ https://issues.jboss.org/browse/SHRINKWRAP-261?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12611761#comment-12611761 ]
Samuel Santos commented on SHRINKWRAP-261:
------------------------------------------
I was doing something very similar:
{code}
public class Maven
{
public static GenericArchive artifact(String coordinates) throws ResolutionException
{
// ...
}
public static Collection<GenericArchive> artifacts(String... coordinates) throws ResolutionException
{
// ...
}
public static MavenInternal withPom(String path) throws ResolutionException
{
// ...
}
static class MavenInternal
{
private final MavenRepositorySystem system;
private final RepositorySystemSession session;
private Map<ArtifactAsKey, MavenDependency> pomInternalDependencyManagement;
MavenInternal()
{
this.system = new MavenRepositorySystem(new MavenRepositorySettings());
this.pomInternalDependencyManagement = new HashMap<ArtifactAsKey, MavenDependency>();
this.session = system.getSession();
}
MavenInternal(String path)
{
this.system = new MavenRepositorySystem(new MavenRepositorySettings());
this.pomInternalDependencyManagement = new HashMap<ArtifactAsKey, MavenDependency>();
this.session = system.getSession();
File pom = new File(path);
Model model = system.loadPom(pom, session);
ArtifactTypeRegistry stereotypes = session.getArtifactTypeRegistry();
// store all dependency information to be able to retrieve versions later
for (org.apache.maven.model.Dependency dependency : model.getDependencies())
{
MavenDependency d = MavenConverter.fromDependency(dependency, stereotypes);
pomInternalDependencyManagement.put(new ArtifactAsKey(d.getCoordinates()), d);
}
}
}
}
{code}
But you have to make the inner class static or would have the error {{non-static variable this cannot be referenced from a static context}}.
> Shorthand for including maven artifacts
> ---------------------------------------
>
> Key: SHRINKWRAP-261
> URL: https://issues.jboss.org/browse/SHRINKWRAP-261
> Project: ShrinkWrap
> Issue Type: Feature Request
> Components: ext-resolver
> Affects Versions: 1.0.0-alpha-12
> Reporter: Nicklas Karlsson
> Assignee: Samuel Santos
> Priority: Minor
>
> It would be handy to have a shortcut for including maven artifacts, something along the lines of
> MavenArtifact.resolve(Coordinate.of("joda-time", "joda-time", "1.6")).as(GenericArchive.class) or
> MavenArtifact.resolve("joda-time:joda-time:1.6").as(GenericArchive.class) or
> Maven.artifact("joda-time:joda-time:1.6")
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the shrinkwrap-issues
mailing list