Discussion:
Packaging from Aether
Elliotte Rusty Harold
2018-09-20 20:05:42 UTC
Permalink
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
***@ibiblio.org

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-***@maven.apache.org
For additional commands, e-mail: dev-***@maven.apache.org
Lennart Jörelid
2018-09-21 02:34:34 UTC
Permalink
Hello Elliotte,

I usually use the depends-maven-plugin, which collects information about
dependencies within a property file.
The data format within this property file (typically placed within
target/classes/META-INF/maven/dependencies.properties is shown below - and
the dependency type and classification can be read as the property
[groupID]/[artifactID]/type and .../classification

If this meet your needs, you don't need to fiddle around with Aether to get
the job done.

org.hamcrest/hamcrest-core/version = 1.3
org.hamcrest/hamcrest-core/type = jar
org.hamcrest/hamcrest-core/scope = test


Den fre 21 sep. 2018 kl 00:05 skrev Elliotte Rusty Harold <
Post by 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
---------------------------------------------------------------------
--
--
+==============================+
| BÀsta hÀlsningar,
| [sw. "Best regards"]
|
| Lennart Jörelid
| EAI Architect & Integrator
|
| jGuru Europe AB
| Mölnlycke - Kista
|
| Email: ***@jguru.se
| URL: www.jguru.se
| Phone
| (skype): jgurueurope
| (intl): +46 708 507 603
| (domestic): 0708 - 507 603
+==============================+
Elliotte Rusty Harold
2018-09-21 09:01:49 UTC
Permalink
On Thu, Sep 20, 2018 at 10:34 PM, Lennart Jörelid
Post by Lennart Jörelid
Hello Elliotte,
I usually use the depends-maven-plugin, which collects information about
dependencies within a property file.
The data format within this property file (typically placed within
target/classes/META-INF/maven/dependencies.properties is shown below - and
the dependency type and classification can be read as the property
[groupID]/[artifactID]/type and .../classification
That would be nice. However if I read it right that would require
everything I depend on to use it, and it doesn't. That is, I can
produce that file for my own artifacts but not for everyone else's.
:-(
--
Elliotte Rusty Harold
***@ibiblio.org

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-***@maven.apache.org
For additional commands, e-mail: dev-***@maven.apache.org
h***@free.fr
2018-09-21 07:21:08 UTC
Permalink
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.
The only misleading field IMHO is that a type does not really define a packaging: there is a typical packaging that produces the type, but anybody could attach an artifact by hand without using the packaging recipe (and if someone produces his artifact with a build tool that is not Maven, the packaging is not used at all)

Regards,

Hervé


[1] https://maven.apache.org/shared/maven-artifact-transfer/comparison.html

[2] http://maven.apache.org/ref/current/maven-core/artifact-handlers.html

----- Mail original -----
De: "Elliotte Rusty Harold" <***@ibiblio.org>
À: "Maven Developers List" <***@maven.apache.org>
Envoyé: Jeudi 20 Septembre 2018 22:05:42
Objet: Packaging from Aether

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
***@ibiblio.org

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-***@maven.apache.org
For additional commands, e-mail: dev-***@maven.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-***@maven.apache.org
For additional commands, e-mail: dev-***@maven.apache.org
Elliotte Rusty Harold
2018-09-21 09:19:58 UTC
Permalink
Post by h***@free.fr
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
***@ibiblio.org

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-***@maven.apache.org
For additional commands, e-mail: dev-***@maven.apache.org
Elliotte Rusty Harold
2018-09-21 09:52:02 UTC
Permalink
Found it. The type was hiding in the properties. That is,

String type = artifact.getProperty(ArtifactProperties.TYPE, "jar");


On Thu, Sep 20, 2018 at 4:05 PM, Elliotte Rusty Harold
Post by 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
--
Elliotte Rusty Harold
***@ibiblio.org

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-***@maven.apache.org
For additional commands, e-mail: dev-***@maven.apache.org
Loading...