Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exported target pom does not include exclusions #1181

Open
JohnnyMorganz opened this issue Jun 25, 2024 · 0 comments
Open

Exported target pom does not include exclusions #1181

JohnnyMorganz opened this issue Jun 25, 2024 · 0 comments

Comments

@JohnnyMorganz
Copy link

Using the examples in the documentation, consider the following setup:

# MODULE.bazel
bazel_dep(name = "rules_jvm_external", version = "6.1")
maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
maven.artifact(
    artifact = "grpc-core",
    exclusions = ["io.grpc:grpc-util"],
    group = "io.grpc",
    version = "1.58.0"
)
maven.install(
    artifacts = [],
    lock_file = "//:maven_install.json"
)
use_repo(maven, "maven", "unpinned_maven")

# library/BUILD.bazel
load("@rules_jvm_external//:defs.bzl", "java_export")

java_export(
  name = "exported_lib",
  maven_coordinates = "com.example:project:0.0.1",
  srcs = [],
  runtime_deps = [
    "@maven//:io_grpc_grpc_core",
  ],
)

If we build the generated pom for exported_lib, we get the following output:

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>project</artifactId>
    <version>0.0.1</version>

    <dependencies>
        <dependency>
            <groupId>io.grpc</groupId>
            <artifactId>grpc-core</artifactId>
            <version>1.58.0</version>
        </dependency>
    </dependencies>
</project>

The dependency definition for grpc-core is missing the exclusion of grpc-util. This exclusion is important to keep for downstream consumers.

We used to work around this because exclusions were stored in the old maven_install.json format (4.X). However we want to now upgrade to 6.1 with the newer lockfile format, but it does not include exclusions information anymore.

I think this could be done by extending MavenInfo and https://github.com/bazelbuild/rules_jvm_external/blob/master/private/rules/has_maven_deps.bzl to pick up exclusions, then wiring it into the pom.xml. Maybe jvm_import should store exclusions in an attribute, or it should be tag based?

@JohnnyMorganz JohnnyMorganz changed the title Exported target pom does not include artifacts Exported target pom does not include exclusions Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant