From 3199ec7ef231631a97a689a9ca1e1ccde8d99620 Mon Sep 17 00:00:00 2001 From: Borodin Gregory Date: Wed, 8 May 2024 12:18:18 +0200 Subject: [PATCH 1/6] Add docs for `jvm_artifacts` generator target --- docs/docs/jvm/java-and-scala.mdx | 49 ++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/docs/docs/jvm/java-and-scala.mdx b/docs/docs/jvm/java-and-scala.mdx index 3a69544881a..9d92c7d2f0b 100644 --- a/docs/docs/jvm/java-and-scala.mdx +++ b/docs/docs/jvm/java-and-scala.mdx @@ -117,6 +117,55 @@ To efficiently determine which symbols are provided by thirdparty code (i.e., wi The `packages` argument allows you to override which symbols a `jvm_artifact` provides. See the [`jvm_artifact` docs](../../reference/targets/jvm_artifact.mdx#packages) for more information. ::: +To enable better IDE integration, Pants has `jvm_artifacts` target generator to generate `jvm_artifact` targets for you. + +### `pom.xml` + +The `jvm_artifacts()` target generator parses a [`pom.xml`](https://maven.apache.org/guides/introduction/introduction-to-the-pom.html) to produce a `jvm_artifact` target for each `dependency` in `project.dependencies`. + +For example: + +```xml tab={"label":"pom.xml"} + + + + com.google.guava + guava + 33.2.0-jre + + + org.apache.commons + commons-lang3 + 3.14.0 + + + +``` + +```python tab={"label":"BUILD"} + +# This will generate two targets: +# +# - //:reqs#guava +# - //:reqs#commons-lang3 +jvm_artifacts(name="reqs") +``` + +The above target generator is spiritually equivalent to this: + +```python title="BUILD" +jvm_artifact( + group="com.google.guava", + artifact="guava", + version="33.2.0-jre", +) +jvm_artifact( + group="org.apache.commons", + artifact="commons-lang3", + version="3.14.0", +) +``` + ### `resource` targets To have your code [load files as "resources"](https://docs.oracle.com/javase/8/docs/technotes/guides/lang/resources.html): From 77e1a7408ac748b10545c247bf90c2bff188b681 Mon Sep 17 00:00:00 2001 From: Borodin Gregory Date: Wed, 8 May 2024 12:19:13 +0200 Subject: [PATCH 2/6] Wrap text --- docs/docs/jvm/java-and-scala.mdx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/docs/jvm/java-and-scala.mdx b/docs/docs/jvm/java-and-scala.mdx index 9d92c7d2f0b..7c9f781b759 100644 --- a/docs/docs/jvm/java-and-scala.mdx +++ b/docs/docs/jvm/java-and-scala.mdx @@ -117,11 +117,15 @@ To efficiently determine which symbols are provided by thirdparty code (i.e., wi The `packages` argument allows you to override which symbols a `jvm_artifact` provides. See the [`jvm_artifact` docs](../../reference/targets/jvm_artifact.mdx#packages) for more information. ::: -To enable better IDE integration, Pants has `jvm_artifacts` target generator to generate `jvm_artifact` targets for you. +To enable better IDE integration, Pants has `jvm_artifacts` target generator to +generate `jvm_artifact` targets for you. ### `pom.xml` -The `jvm_artifacts()` target generator parses a [`pom.xml`](https://maven.apache.org/guides/introduction/introduction-to-the-pom.html) to produce a `jvm_artifact` target for each `dependency` in `project.dependencies`. +The `jvm_artifacts()` target generator parses a +[`pom.xml`](https://maven.apache.org/guides/introduction/introduction-to-the-pom.html) +to produce a `jvm_artifact` target for each `dependency` in +`project.dependencies`. For example: From ffc8d70c92c37fb8195de2287f133226007b11e6 Mon Sep 17 00:00:00 2001 From: Borodin Gregory Date: Wed, 8 May 2024 12:20:01 +0200 Subject: [PATCH 3/6] Remove newline --- docs/docs/jvm/java-and-scala.mdx | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/docs/jvm/java-and-scala.mdx b/docs/docs/jvm/java-and-scala.mdx index 7c9f781b759..1742edf4fab 100644 --- a/docs/docs/jvm/java-and-scala.mdx +++ b/docs/docs/jvm/java-and-scala.mdx @@ -147,7 +147,6 @@ For example: ``` ```python tab={"label":"BUILD"} - # This will generate two targets: # # - //:reqs#guava From 22884edda9952b41a138a6e3bd0f6ddfe76082a3 Mon Sep 17 00:00:00 2001 From: Borodin Gregory Date: Wed, 8 May 2024 12:31:10 +0200 Subject: [PATCH 4/6] Docs for package_mapping --- docs/docs/jvm/java-and-scala.mdx | 33 ++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/docs/docs/jvm/java-and-scala.mdx b/docs/docs/jvm/java-and-scala.mdx index 1742edf4fab..0c1da76a334 100644 --- a/docs/docs/jvm/java-and-scala.mdx +++ b/docs/docs/jvm/java-and-scala.mdx @@ -169,6 +169,39 @@ jvm_artifact( ) ``` +To define `jvm_artifact` packages use `package_mapping` field: + +```python tab={"label":"BUILD"} +jvm_artifacts( + name="reqs", + package_mapping={ + "com.google.guava:guava": [ + "com.google.common.**", + ], + "org.apache.commons:commons-lang3": [ + "org.apache.commons.lang3.**", + ], + }, +) +``` + +```xml tab={"label":"pom.xml"} + + + + com.google.guava + guava + 33.2.0-jre + + + org.apache.commons + commons-lang3 + 3.14.0 + + + +``` + ### `resource` targets To have your code [load files as "resources"](https://docs.oracle.com/javase/8/docs/technotes/guides/lang/resources.html): From 5b956fe6d0c645a127096b5ef8deeed28db1c61f Mon Sep 17 00:00:00 2001 From: Borodin Gregory Date: Fri, 10 May 2024 17:13:50 +0200 Subject: [PATCH 5/6] Add release notes --- docs/notes/2.22.x.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/notes/2.22.x.md b/docs/notes/2.22.x.md index ee0f256e463..3de6718ae41 100644 --- a/docs/notes/2.22.x.md +++ b/docs/notes/2.22.x.md @@ -20,6 +20,8 @@ Keep reading to see the details and what's also included. #### JVM +[Added documentation](https://www.pantsbuild.org/2.22/docs/jvm/java-and-scala#pomxml) for [`jvm_artifacts`] targets generator from `pom.xml`. + ##### Scala Setting the `orphan_files_behaviour = "ignore"` option for [`pants.backend.experimental.scala.lint.scalafix`](https://www.pantsbuild.org/2.22/reference/subsystems/scalafix#orphan_files_behavior) or [`pants.backend.experimental.scala.lint.scalafmt`](https://www.pantsbuild.org/2.22/reference/subsystems/scalafmt#orphan_files_behavior) backend is now properly silent. It previously showed spurious warnings. From e3934c87ab01a09c70aa6d82ea4a757247a37a34 Mon Sep 17 00:00:00 2001 From: Borodin Gregory Date: Fri, 10 May 2024 17:15:49 +0200 Subject: [PATCH 6/6] Add target link --- docs/notes/2.22.x.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/notes/2.22.x.md b/docs/notes/2.22.x.md index 3de6718ae41..942fca4cf9c 100644 --- a/docs/notes/2.22.x.md +++ b/docs/notes/2.22.x.md @@ -20,7 +20,9 @@ Keep reading to see the details and what's also included. #### JVM -[Added documentation](https://www.pantsbuild.org/2.22/docs/jvm/java-and-scala#pomxml) for [`jvm_artifacts`] targets generator from `pom.xml`. +[Added documentation](https://www.pantsbuild.org/2.22/docs/jvm/java-and-scala#pomxml) +for [`jvm_artifacts`](https://www.pantsbuild.org/2.22/reference/targets/jvm_artifacts) +targets generator from `pom.xml`. ##### Scala