Packaging from Aether

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Packaging from Aether

Elliotte Rusty Harold
With Eclipse Aether I can read a pom and gather information in the
form of import org.eclipse.aether.graph.Dependency and
org.eclipse.aether.artifact.Artifact objects.

Is there some way from these or related objects I can gather the
information about the packaging of the dependency? That is, the type
child element of the dependency element in the original pom.xml file?

I seem to be able to get the extension of the file, but that's not
quite the same thing.

--
Elliotte Rusty Harold
[hidden email]

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Packaging from Aether

Elliotte Rusty Harold
On Fri, Sep 21, 2018 at 3:21 AM,  <[hidden email]> wrote:
> a dependency has a type, but not really a packaging: a packaging is a recipe to build a project that will produce multiple artifacts, each with its own type
>
> see the comparison [1]
>
> and default artifact handlers [2] gives you informations about default types.

I'm not really using Maven core. I have my own Java code that does
things Maven doesn't do. It relies on Aether to parse the pom.xml
files. I could just parse XML directly, but Aether handles property
resolution, artifact resolution, parent POMs, BOMs, finding repos, and
a lot of other Maven specific details I'd otherwise have to reinvent.

The POM I'm struggling with now looks like this:

I'm not trying to package, just read the value of the type element out
of the pom.xml. That is, the pom.xml contains dependencies like this:

<project>>
...
  <dependencyManagement>
    <dependencies>
 ...
      <dependency>
        <groupId>com.google.cloud</groupId>
        <artifactId>google-cloud-bigtable</artifactId>
        <version>0.62.1-alpha-SNAPSHOT</version><!--
{x-version-update:google-cloud-bigtable:current} -->
      </dependency>
      <dependency>
        <groupId>com.google.cloud</groupId>
        <artifactId>google-cloud-bigtable</artifactId>
        <version>0.62.1-alpha-SNAPSHOT</version><!--
{x-version-update:google-cloud-bigtable:current} -->
        <type>test-jar</type>
      </dependency>
 ...
    </dependencies>
  </dependencyManagement>

</project>


Since Aether doesn't report the type element in the dependency, so far
as I can tell, my code ends up with duplicates and no way to
distinguish them.

I'm not totally clear on why this pom.xml (google-cloud-bom if
anyone's interested) includes test-jar types. If anyone can make a
strong argument that these should not be there in the first place, I
may be able to get them removed though I don't own this code. However,
in the meantime I do need to distinguish the first
dependency from the second.

--
Elliotte Rusty Harold
[hidden email]

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]