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

Feature Request: constraints support #1222

Open
plobsing opened this issue Aug 27, 2024 · 0 comments
Open

Feature Request: constraints support #1222

plobsing opened this issue Aug 27, 2024 · 0 comments

Comments

@plobsing
Copy link
Contributor

plobsing commented Aug 27, 2024

Using multiple maven_install declarations for isolated artifact version trees is awesome; it makes some hard things a lot easier. But there's a catch: the setup is not protected from mixing artifacts across different artifact trees. Users need to be diligent in ensuring that only one deps tree is in the transitive dependencies of a java_binary, or it is possible that incompatibly-versioned libraries may get used together.

One way this problem could be avoided is if the jvm_import targets declared by rules_jvm_external could have platform constraints attached. I think it would be sufficient to have one constraint spec for an entire maven_install repo; I don't think it'd need to be more granular. Going back to the README's example, that might look something like:

  maven_install(
      name = "server_app",
      artifacts = [
          "com.google.guava:guava:27.0-jre",
      ],
      repositories = [
          "https://repo1.maven.org/maven2",
      ],
+     targets_compatible_with = ["@platforms//os:linux"],
  )
  
  maven_install(
      name = "android_app",
      artifacts = [
          "com.google.guava:guava:27.0-android",
      ],
      repositories = [
          "https://repo1.maven.org/maven2",
      ],
+     targets_compatible_with = ["@platforms//os:android"],
  )

And then callers could be certain that they only used dependencies from @android_app when building for Android and only used dependencies from @server_app when building for the server.

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