-
Notifications
You must be signed in to change notification settings - Fork 12
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
maven buildpack environment configuration #508
Conversation
Lifecycle sets buildpack provided build time env vars in the current environment. This change reads from both the platform directory (user or platform provided) as well as now the current environment (buildpack provided). This fixes compatibility with a nexus/artifactory type buildpack that sets `MAVEN_SETTINGS_PATH` or `MAVEN_SETTINGS_URL`.
Currently, `JAVA_HOME` is ignored even if set by a buildpack, user, or operator since `clear-env` is set to true. This change sets it in the maven environment if it's present.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR! The change to the buildpack logic is something I can get behind - why wouldn't we allow setting buildpack configuration from outside the platform env? 👍🏻 JAVA_HOME
is a little bit different, but with the problems you outlined, we should pass that through to Maven too!
Thinking about this more: I'm unsure how much I like the way env vars are handled in general. One one hand, I don't want to just use all env vars that are somehow set to run Maven (or any executable) as that might change the behaviour - regardless where they came from (platform or just regular env).
Maybe some sort of allow listing is the answer here and use both platform and regular env vars as the source.
This is of course out of scope for this PR and I'd be happy to merge it (after resolving the one comment) and tackle the root of the problem later. Especially since the env var behaviour should be consistent across all of our buildpacks.
Yeah, Java being on the base image and just being able to the maven buildpack seems like a pretty good use case to me.
Yeah, that makes sense to me. Hopefully, this reduces the impact radius since it's only those 3 maven env vars like before it just sources it from more than one source now.
Yeah, I didn't want to try to tackle this at that level yet since probably more discussion to be had and probably don't want to duplicate this code everywhere. It seems like a bug to not read from both places in a lot of cases especially given that operators can specify env vars at build time that will end up there, RFC. |
Just wondering, how does this pass the check for
I think I agree with it being a bug. I'll think about this some more how we can make this more convenient for buildpack authors. |
I personally did not write it, but yes there is a buildpack that does nothing during build and just provides/requires |
Context
JAVA_HOME
At Salesforce, we're trying to use the
heroku/maven
buildpack outside of the standard heroku builder images. Unfortunately,which
is not in the base image which causes themvn
binary to fail while it's trying to find the java command:If
JAVA_HOME
is set, thenmvn
does not executewhich
.NEXUS Buildpack Compatibility
Secondly, the buildpack today only reads env var from the
<platform>/env
directory which only captures env vars set by the user or operator. If a prior buildpack sets a build time env var it gets ignored sincelifecycle
will set this in the current environment. This breaks a nexus buildpack that writes out asettings.xml
withMAVEN_SETTINGS_PATH
defined.Changes
This PR introduces two changes that fix the issues for us.
<platform>/env
also check the current env as a fallback, so user/operator env vars take precedence.JAVA_HOME
in the env whenmvn
is executed, so it honors the env var.TODO
Happy to do these items assuming you're ok with these changes: