Skip to main content
Version: 2.10 (deprecated)

jvm_artifact


A third-party JVM artifact, as identified by its Maven-compatible coordinate.

That is, an artifact identified by its group, artifact, and version components.

Each artifact is associated with one or more resolves (a logical name you give to a lockfile). For this artifact to be used by your first-party code, it must be associated with the resolve(s) used by that code. See the compatible_resolves field.

Backend: pants.backend.experimental.java


artifact

str
required

The 'artifact' part of a Maven-compatible coordinate to a third-party JAR artifact.

For the JAR coordinate com.google.guava:guava:30.1.1-jre, the artifact is guava.

group

str
required

The 'group' part of a Maven-compatible coordinate to a third-party JAR artifact.

For the JAR coordinate com.google.guava:guava:30.1.1-jre, the group is com.google.guava.

version

str
required

The 'version' part of a Maven-compatible coordinate to a third-party JAR artifact.

For the JAR coordinate com.google.guava:guava:30.1.1-jre, the version is 30.1.1-jre.

compatible_resolves

Iterable[str] | None
default: None

The resolves from [jvm].resolves that this artifact should be included in.

If not defined, will default to [jvm].default_resolve.

When generating a lockfile for a particular resolve via the coursier-resolve goal, it will include all artifacts that are declared compatible with that resolve. First-party targets like java_source and scala_source then declare which resolve(s) they use via the resolve and compatible_resolves field; so, for your first-party code to use a particular jvm_artifact target, that artifact must be included in the resolve(s) used by that code.

description

str | None
default: None

A human-readable description of the target.

Use ./pants list --documented :: to see all targets with descriptions.

jar

str | None
default: None

A local JAR file that provides this artifact to the lockfile resolver, instead of a Maven repository.

Path is relative to the BUILD file.

Use the url field for remote artifacts.

packages

Iterable[str] | None
default: None

The JVM packages this artifact provides for the purposes of dependency inference.

For example, the JVM artifact junit:junit might provide ["org.junit.**"].

Usually you can leave this field off. If unspecified, Pants will fall back to the [java-infer].third_party_import_mapping, then to a built in mapping (https://github.com/pantsbuild/pants/blob/release_2.10.1/src/python/pants/jvm/dependency_inference/jvm_artifact_mappings.py), and then finally it will default to the normalized group of the artifact. For example, in the absence of any other mapping the artifact io.confluent:common-config would default to providing ["io.confluent.**"].

The package path may be made recursive to match symbols in subpackages by adding .** to the end of the package path. For example, specify ["org.junit.**"] to infer a dependency on the artifact for any file importing a symbol from org.junit or its subpackages.

tags

Iterable[str] | None
default: None

Arbitrary strings to describe a target.

For example, you may tag some test targets with 'integration_test' so that you could run ./pants --tag='integration_test' test :: to only run on targets with that tag.

url

str | None
default: None

A URL that points to the location of this artifact.

If specified, Pants will not fetch this artifact from default Maven repositories, and will instead fetch the artifact from this URL. To use default maven repositories, do not set this value.

Note that file: URLs are not supported. Instead, use the jar field for local artifacts.