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

Add root classloader support for custom classes #188

Merged
merged 1 commit into from
Jan 30, 2024
Merged

Conversation

plaird
Copy link
Contributor

@plaird plaird commented Jan 30, 2024

This feature is a simple partial solution to #129 . It is for cases where a service needs to inject more classes into the root of the executable jar. This means the classes are written directly into the root of the jar, not in BOOT-INF/classes or BOOT-INF/libs.

It works by creating a java_library target with the special name: rootclassloader_lib

java_library(
    name = "rootclassloader_lib",
    srcs = glob(["src_root/main/java/**/*.java"]),
)

then adding the java_library to the deps attribute of the springboot rule:

springboot(
    name = "demoapp",
    boot_app_class = "com.sample.SampleMain",
    java_library = ":demoapp_lib",

    # inject the root classloaded classes
    deps = [ ":rootclassloader_lib", ],
    ...

I am not comfortable making this an official feature since it is a bit hacky, using a naming convention. But adding it in, such that anyone can have a solution for root classes in #129 .

@plaird plaird merged commit 4eec7f1 into main Jan 30, 2024
1 check passed
@plaird plaird deleted the beta/rootclassloaders branch January 30, 2024 04:14
@plaird plaird restored the beta/rootclassloaders branch January 30, 2024 04:14
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.

1 participant