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

Profile issue when running bazel build command in java_binary #255

Open
gabrielmirandat opened this issue Dec 18, 2024 · 2 comments
Open
Labels
P2 We'll consider to work on this in future. (Assignee optional)

Comments

@gabrielmirandat
Copy link

I am getting different behaviors when running a java_binary using bazel build and bazel run.

java_library(
  name = "artifact",
  srcs = glob(["src/main/java/**/*.java"]),
  javacopts = [
      "-source",
      "21",
      "-target",
      "21",
  ],
  resources = glob(["src/main/resources/**"]) + ["@newrelic_java//:newrelic.yml"],
  ...
)

java_binary(
    name = "uber",
    main_class = "...OrdersApplication",
    runtime_deps = [":artifact"],
)
  1. When running with bazel run and setting correct profile everything works fine (profile is loaded)
export SPRING_PROFILES_ACTIVE=local
bazel run //orders:uber
...
...OrdersApplication     : The following 1 profile is active: "local"
  1. When generating jar with bazel build and running jar, it seems it cannot find resources/profiles
export SPRING_PROFILES_ACTIVE=local
bazel build //orders:uber_deploy.jar
java -jar bazel-bin/orders/uber_deploy.jar
...
...OrdersApplication     : No active profile set, falling back to 1  default profile: default

I already tried other ways to set the profile, like using the command line -Dspring.profiles.active=local or --spring.profiles.active=local, but nothing seems to work.

Can anyone give some help on that?

@gabrielmirandat gabrielmirandat changed the title Profile problem when running bazel bazel build in java_binary Profile issue when running bazel build command in java_binary Dec 18, 2024
@gabrielmirandat
Copy link
Author

gabrielmirandat commented Dec 20, 2024

@fmeum / @hvadehra

@hvadehra
Copy link
Member

hvadehra commented Jan 7, 2025

It sounds like you're running into bazelbuild/bazel#7330

@hvadehra hvadehra added the P2 We'll consider to work on this in future. (Assignee optional) label Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 We'll consider to work on this in future. (Assignee optional)
Projects
None yet
Development

No branches or pull requests

2 participants