KEMBAR78
Modify maven_export to allow exporting zip archives by AustinSchuh · Pull Request #1368 · bazel-contrib/rules_jvm_external · GitHub
Skip to content

Conversation

@AustinSchuh
Copy link
Contributor

This enables publishing zip files to maven. The project I'm converting over to bazel publishes C++ artifacts (JNI and others) as zip files to maven.

This enables publishing zip files to maven.  The project I'm converting
over to bazel publishes C++ artifacts (JNI and others) as zip files to
maven.

Signed-off-by: Austin Schuh <austin.linux@gmail.com>
@AustinSchuh
Copy link
Contributor Author

Build failure looks like a flake

@shs96c
Copy link
Collaborator

shs96c commented Jun 6, 2025

Apologies for getting to this so late. Is there any reason why you wouldn't use the classifier_artifacts attribute of java_export? eg:

java_export(
    name = "example-export",
    classifier_artifacts = {
        "zip": ":create-zip-archive",
    },
    maven_coordinates = "com.example:bazel-example:0.0.1",
)

@AustinSchuh
Copy link
Contributor Author

AustinSchuh commented Jun 7, 2025

Unfortunately, java_export creates both an empty .jar artifact and a -javadoc.jar artifact. The repository I'm moving over to Bazel doesn't upload and doesn't want uploaded. I dug through the starlark and didn't see a way to disable the .jar file (comes through lib_name argument to the macro).

This creates:

/tmp/.m2/repository/edu/wpi/first/wpilibc/wpilibc-cpp/2025.424242.3.2-20250517170110-126-gf66d18f-dirty/wpilibc-cpp-2025.424242.3.2-20250517170110-126-gf66d18f-dirty.pom
/tmp/.m2/repository/edu/wpi/first/wpilibc/wpilibc-cpp/2025.424242.3.2-20250517170110-126-gf66d18f-dirty/wpilibc-cpp-2025.424242.3.2-20250517170110-126-gf66d18f-dirty.jar
/tmp/.m2/repository/edu/wpi/first/wpilibc/wpilibc-cpp/2025.424242.3.2-20250517170110-126-gf66d18f-dirty/wpilibc-cpp-2025.424242.3.2-20250517170110-126-gf66d18f-dirty-headers.zip
/tmp/.m2/repository/edu/wpi/first/wpilibc/wpilibc-cpp/2025.424242.3.2-20250517170110-126-gf66d18f-dirty/wpilibc-cpp-2025.424242.3.2-20250517170110-126-gf66d18f-dirty-sources.zip
/tmp/.m2/repository/edu/wpi/first/wpilibc/wpilibc-cpp/2025.424242.3.2-20250517170110-126-gf66d18f-dirty/wpilibc-cpp-2025.424242.3.2-20250517170110-126-gf66d18f-dirty-linuxsystemcore.zip
/tmp/.m2/repository/edu/wpi/first/wpilibc/wpilibc-cpp/2025.424242.3.2-20250517170110-126-gf66d18f-dirty/wpilibc-cpp-2025.424242.3.2-20250517170110-126-gf66d18f-dirty-linuxsystemcorestatic.zip
/tmp/.m2/repository/edu/wpi/first/wpilibc/wpilibc-cpp/2025.424242.3.2-20250517170110-126-gf66d18f-dirty/wpilibc-cpp-2025.424242.3.2-20250517170110-126-gf66d18f-dirty-linuxsystemcoredebug.zip
/tmp/.m2/repository/edu/wpi/first/wpilibc/wpilibc-cpp/2025.424242.3.2-20250517170110-126-gf66d18f-dirty/wpilibc-cpp-2025.424242.3.2-20250517170110-126-gf66d18f-dirty-linuxsystemcorestaticdebug.zip
/tmp/.m2/repository/edu/wpi/first/wpilibc/wpilibc-cpp/2025.424242.3.2-20250517170110-126-gf66d18f-dirty/wpilibc-cpp-2025.424242.3.2-20250517170110-126-gf66d18f-dirty-linuxx86-64.zip
/tmp/.m2/repository/edu/wpi/first/wpilibc/wpilibc-cpp/2025.424242.3.2-20250517170110-126-gf66d18f-dirty/wpilibc-cpp-2025.424242.3.2-20250517170110-126-gf66d18f-dirty-linuxx86-64static.zip
/tmp/.m2/repository/edu/wpi/first/wpilibc/wpilibc-cpp/2025.424242.3.2-20250517170110-126-gf66d18f-dirty/wpilibc-cpp-2025.424242.3.2-20250517170110-126-gf66d18f-dirty-linuxx86-64debug.zip
/tmp/.m2/repository/edu/wpi/first/wpilibc/wpilibc-cpp/2025.424242.3.2-20250517170110-126-gf66d18f-dirty/wpilibc-cpp-2025.424242.3.2-20250517170110-126-gf66d18f-dirty-linuxx86-64staticdebug.zip
/tmp/.m2/repository/edu/wpi/first/wpilibc/wpilibc-cpp/2025.424242.3.2-20250517170110-126-gf66d18f-dirty/wpilibc-cpp-2025.424242.3.2-20250517170110-126-gf66d18f-dirty-javadoc.jar

vs the required

/home/austin/releases/maven/development/edu/wpi/first/wpilibc/wpilibc-cpp/2025.424242.3.2-20250517170110-126-gf66d18f-dirty/wpilibc-cpp-2025.424242.3.2-20250517170110-126-gf66d18f-dirty.pom
/home/austin/releases/maven/development/edu/wpi/first/wpilibc/wpilibc-cpp/2025.424242.3.2-20250517170110-126-gf66d18f-dirty/wpilibc-cpp-2025.424242.3.2-20250517170110-126-gf66d18f-dirty-linuxx86-64.zip
/home/austin/releases/maven/development/edu/wpi/first/wpilibc/wpilibc-cpp/2025.424242.3.2-20250517170110-126-gf66d18f-dirty/wpilibc-cpp-2025.424242.3.2-20250517170110-126-gf66d18f-dirty-linuxx86-64debug.zip
/home/austin/releases/maven/development/edu/wpi/first/wpilibc/wpilibc-cpp/2025.424242.3.2-20250517170110-126-gf66d18f-dirty/wpilibc-cpp-2025.424242.3.2-20250517170110-126-gf66d18f-dirty-linuxsystemcore.zip
/home/austin/releases/maven/development/edu/wpi/first/wpilibc/wpilibc-cpp/2025.424242.3.2-20250517170110-126-gf66d18f-dirty/wpilibc-cpp-2025.424242.3.2-20250517170110-126-gf66d18f-dirty-sources.zip
/home/austin/releases/maven/development/edu/wpi/first/wpilibc/wpilibc-cpp/2025.424242.3.2-20250517170110-126-gf66d18f-dirty/wpilibc-cpp-2025.424242.3.2-20250517170110-126-gf66d18f-dirty-linuxx86-64staticdebug.zip
/home/austin/releases/maven/development/edu/wpi/first/wpilibc/wpilibc-cpp/2025.424242.3.2-20250517170110-126-gf66d18f-dirty/wpilibc-cpp-2025.424242.3.2-20250517170110-126-gf66d18f-dirty-headers.zip
/home/austin/releases/maven/development/edu/wpi/first/wpilibc/wpilibc-cpp/2025.424242.3.2-20250517170110-126-gf66d18f-dirty/wpilibc-cpp-2025.424242.3.2-20250517170110-126-gf66d18f-dirty-linuxsystemcoredebug.zip
/home/austin/releases/maven/development/edu/wpi/first/wpilibc/wpilibc-cpp/2025.424242.3.2-20250517170110-126-gf66d18f-dirty/wpilibc-cpp-2025.424242.3.2-20250517170110-126-gf66d18f-dirty-linuxx86-64static.zip
/home/austin/releases/maven/development/edu/wpi/first/wpilibc/wpilibc-cpp/2025.424242.3.2-20250517170110-126-gf66d18f-dirty/wpilibc-cpp-2025.424242.3.2-20250517170110-126-gf66d18f-dirty-linuxsystemcorestatic.zip
/home/austin/releases/maven/development/edu/wpi/first/wpilibc/wpilibc-cpp/2025.424242.3.2-20250517170110-126-gf66d18f-dirty/wpilibc-cpp-2025.424242.3.2-20250517170110-126-gf66d18f-dirty-linuxsystemcorestaticdebug.zip
/home/austin/releases/maven/development/edu/wpi/first/wpilibc/wpilibc-cpp/maven-metadata.xml

If there's another way to do this, I'm all ears. The simplest way I could find was to make a new rule.

@shs96c
Copy link
Collaborator

shs96c commented Jun 7, 2025

I'd be okay if you made it possible for the jar and javadoc artifacts to be optional. It seems like a smaller change than a new rule....

Signed-off-by: Austin Schuh <austin.linux@gmail.com>
@AustinSchuh
Copy link
Contributor Author

I'm not sure it ends up cleaner, but here you go.

@AustinSchuh AustinSchuh changed the title Add zip_export rule Modify maven_export to allow exporting zip archives Jun 23, 2025
@AustinSchuh
Copy link
Contributor Author

CI now passes. Looks like updating to the latest master made that work.

What do you think? Any feedback?

Copy link
Collaborator

@shs96c shs96c left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you for the reworking.

@shs96c shs96c merged commit f50d46f into bazel-contrib:master Jun 24, 2025
7 checks passed
shs96c added a commit to jin/rules_jvm_external that referenced this pull request Jul 4, 2025
* master: (39 commits)
  Fix resolution of Android/AAR artifacts with Gradle resolver (bazel-contrib#1395)
  fail_if_repin_required is now True by default and minor improvement to failure message (bazel-contrib#1397)
  Housekeeping before we release 6.8 (bazel-contrib#1384)
  Add dll, dylib and so types to maven package mappings (bazel-contrib#1392)
  [bzlmod] Allow suppressing warning about multiple contributing modules. (bazel-contrib#1393)
  Use the artifact default values when adding them to a struct and add tests for coursier artifacts that have empty versions provided by BOMs and don't inlcude them in outdated (bazel-contrib#1390)
  Allow package exclusions and inclusions in javadocs (bazel-contrib#1293)
  Document well-known issues with `bzlmod` (bazel-contrib#1388)
  Begin documenting the gradle resolver (bazel-contrib#1389)
  Run gradle regression tests in CI (bazel-contrib#1385)
  Modify maven_export to allow exporting zip archives (bazel-contrib#1368)
  Allow root module's override tags to take precedence over the overridees from transitive deps. (bazel-contrib#1381)
  Ensure root module artifacts and boms take precedence with warnings (bazel-contrib#1373)
  Update maven-metadata.xml when publishing locally (bazel-contrib#1369)
  Add support for gradle resolver (bazel-contrib#1357)
  Prepare for 6.8 release (bazel-contrib#1380)
  Remove the Windows `kt_jvm_export` example (bazel-contrib#1383)
  Avoid spurious warnings about poorly formatted artifact coordinates (bazel-contrib#1374)
  Flip `fail_if_repin_required` to `True` by default (bazel-contrib#1371)
  Allow the same coordinate to be overridden in different repos (bazel-contrib#1378)
  ...
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

Successfully merging this pull request may close these issues.

2 participants