Java – best practices for installing third-party libraries into a hosted Maven repository?

Suppose you have a project that uses a third-party library, such as Google's Analytics data API (gdata), which does not seem to be currently deployed to any well-known or popular Maven public repository / index This is not a big problem because I can deploy artifacts to my locally hosted nexus repository

However, are there any best practices in the Maven community, and how should I name the "coordinates" of this library in my POM, because the standard has not been set in the public repository?

For example, I should reference it in my POM

<dependency>
    <groupId>com.google</groupId>
    <artifactId>gdata-analytics</artifactId>
    <version>1.0</version>
</dependency>

Or are there some better / more standard ways for me to think of artifactid?

(and why don't providers of dozens of libraries like Google spend some effort hosting them in the mainstream public Maven repository / index? It won't make it easier for people to use them and drive their adoption?)

Solution

You did a good job Some additional points:

>When Maven gets an artifact from nexus, the artifact is named artifactid version Groupid is omitted Therefore, when the artifact is moved (for example, copied to WEB-INF / Lib in the web application), your jar file will be displayed as "gdata-analytics-1.0" This is usually not a problem However, if the artifact name is very common, such as "util", you may want to include group information in the artifact ID, such as using the groupid of "com. Google" and the artifact ID of "com. Google. Gdata Analytics" Yes, repetition is annoying, but it produces maximum clarity in the file system and search I actually have a problem. Two different groupids have a "core-1.0" jar. One is copied to the Lib directory at build time and overwrites the other. > My second mattk suggests aligning maven versionid with the commonly known artifact version. > If you follow Dominic's advice and add groupid as your own company name (such as acme), you can more easily take advantage of nexus's routing function It will ensure that requests for internal artifacts are not propagated to Maven central and eventually appear in their logs (this may be important if your groupid is "acme. Secret. Project"!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>