简体   繁体   中英

How can I populate what is indexed under the tags metadata field in Maven central?

Maven Central's search facility offers several different fields you can search on. The most familiar are, of course, group ID, artifact ID and version. But there are others. For example, here is a query that searches on a field called tags :

http://search.maven.org/#search%7Cga%7C1%7Ctags%3Asbtplugin

If you choose an artifact in that list and dig into it, you will find indeed that (once you get past the broken links!) the pom.xml has an sbtVersion property in it.

So maybe, I thought, that's how you get the tags field populated: just add an arbitrary property in the properties stanza. Of course, the tag sought above is sbtplugin whereas the property checked is sbtVersion , so clearly something else is involved, but that mechanism isn't documented anywhere I can find.

So how does this index field get populated? Is it a Nexus-specific feature? Can I populate it using the maven-deploy-plugin , whose goals do not seem to hint at such a thing?

Being able to search programmatically on this field would be very, very helpful if I can control what gets put in there.

Quoting from the API description on the Maven central itself.

http://search.maven.org/#search|ga|1|tags:sbtplugin

Returns al artifacts in central that are sbtplugins . An sbtplugin is defined as an artifact with a pom including the properties "sbtVersion" and "scalaVersion" .

Also

http://search.maven.org/#search|ga|1|tags:sbtVersion-0.11

Returns all artifacts in central that use sbt version 0.11

Joel Orlina of Sonatype writes:

Older versions of the indexer that backs search.maven.org populated the tags field with the contents of the <description> element in the POM. The field is passed through some standard StopWord filters and maybe some other Lucene analyzers, so the full contents won't make it into the tag s field. We made some changes a couple years back to help out the scala/sbt community where, based on specific elements we discover in scala/sbt-plugin poms, we synthesize three tags: sbtPlugin , sbtVersion , and scalaVersion . This allows users of sbt plugins to search for those types of artifacts, which, in many cases don't conform to the Maven2 repository layout and, as such, don't normally get indexed by the search.maven.org indexer.

There's not much else to the tags field.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM