salesforce / rules_spring

Bazel rule for building Spring Boot apps as a deployable jar
BSD 3-Clause "New" or "Revised" License
224 stars 48 forks source link

Spring Boot version extraction in `springboot/write_manifest.sh` #111

Closed mcamenzind closed 3 years ago

mcamenzind commented 3 years ago

We're relying on johnynek/bazel-deps to manage our external JVM dependencies. They are installed in an external Bazel repository (bazel-${PROJECT}/external/org_springframework_boot_spring_boot_starter) and imported as follows from the BUILD file 3rdparty/jvm/default/org/springframework/boot/BUILD:

java_library(
    name = "spring_boot_starter",
    exports = [
        "//3rdparty/jvm/default/jakarta/annotation:jakarta_annotation_api",
        "//3rdparty/jvm/default/org/springframework:spring_core",
        "//3rdparty/jvm/default/org/yaml:snakeyaml",
        "//external:jar/org/springframework/boot/spring_boot_starter",
        ":spring_boot",
        ":spring_boot_autoconfigure",
        ":spring_boot_starter_logging"
    ],
    visibility = [
        "//3rdparty/jvm/default:__subpackages__"
    ]
)

One would now import //3rdparty/jvm/default/org/springframework/boot:spring_boot_starter in a BUILD file.

This way of handling it has an effect on the JAR name in the sandbox, the version number is abandoned as the file is called external/org_springframework_boot_spring_boot_starter/jar/org_springframework_boot_spring_boot_starter.jar.

The script springboot/write_manifest.sh tries to extract the version number from the Spring Boot dependency from its name. This does not work in our case, as the jar file names do not contain version numbers. What would be the best approach to fix it?

Would you have any other suggestions?

plaird commented 3 years ago

Thanks @mcamenzind your solution was merged and will be released as 2.1.0.