Trying the dev list, since I got no answer in the user one... :(

---------- Forwarded message ----------
From: Cristiano Gavião <cvgav...@gmail.com>
Date: 2014-05-07 12:35 GMT-03:00
Subject: How to resolve and get the right packaging type?
To: Maven Users List <us...@maven.apache.org>


 Hello,

I'm using maven-bundle-plugin in a project. it generates a jar but its
packaging type is "bundle".

Maven doesn't complains when I declare a bundle dependency without the type
property (that defaults to "jar").

In the plugin that I'm developing I need to create some files based on that
packaging type.
I tried to resolve each direct dependency and tried to get its packaging
type (the one fixed in its pom), but it is not working, because I always
get the "jar" value.

 for (Artifact artifact : artifacts) {

            getLog().debug("Resolving dependency artifact " + artifact);
            ArtifactResolutionRequest request = new
ArtifactResolutionRequest()
                    .setArtifact(artifact)
                    .setRemoteRepositories(remoteRepositories)
                    .setLocalRepository(localArtifactRepository);

            ArtifactResolutionResult resolutionResult = repositorySystem
                    .resolve(request);
            if (resolutionResult.hasExceptions()) {
                throw new MojoExecutionException("Could not resolve
artifact: "
                        + artifact,
resolutionResult.getExceptions().get(0));
            }
            artifact = (Artifact) resolutionResult.getArtifacts().iterator()
                    .next();

            String type = artifact.getType();


I need to know the declared artifact packaging type. How could I achieve
this?

thanks for any tip.

Cristiano

Reply via email to