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

Allow users to provide a custom gradle.properties file #60

Merged
merged 7 commits into from
Apr 28, 2021
Merged

Conversation

dmikusa
Copy link
Contributor

@dmikusa dmikusa commented Apr 9, 2021

Summary

When a binding of type or kind equals gradle is present, the contents of that file are copied to $GRADLE_USER_HOME/gradle.properties. This is picked up by Gradle when it runs and allows the user to pass additional configuration to Gradle. For example, this can be used for providing credentials to a remote Maven repository.

Use Cases

Resolves #23

Checklist

  • I have viewed, signed, and submitted the Contributor License Agreement.
  • I have linked issue(s) that this PR should close using keywords or the Github UI (See docs)
  • I have added an integration test, if necessary.
  • I have reviewed the styleguide for guidance on my code quality.

When a binding of type or kind equals `gradle` is present, the contents of that file are copied to `$GRADLE_USER_HOME/gradle.properties`. This is picked up by Gradle when it runs and allows the user to pass additional configuration to Gradle. For example, this can be used for providing credentials to a remote Maven repository.
@dmikusa dmikusa requested a review from a team April 9, 2021 17:31
@dmikusa
Copy link
Contributor Author

dmikusa commented Apr 9, 2021

A couple of notes on this PR:

  1. Gradle doesn't have a property similar to Maven's where you can point it directly to a configuration file. You can set a property that changes the $GRADLE_USER_HOME location, but that is not the same.
  2. If we use a system property or env variable to change $GRADLE_USER_HOME, that causes issues with caching of Gradle downloaded resources, which also live under this directory. We should probably document these settings as under the control of the buildpack & off-limits to users setting them.
  3. Rather than try to move things around, I just move the config file into $GRADLE_USER_HOME/gradle.properties. This should be safe because that directory is created by the build pack and there should be no user config in that location (the user can only put a gradle.properties file into their application.

dmikusa pushed a commit to paketo-buildpacks/samples that referenced this pull request Apr 9, 2021
This is based on the work added with paketo-buildpacks/gradle#60, so requires a version of the Gradle CNB with this feature.
gradle/build.go Outdated Show resolved Hide resolved
gradle/build.go Outdated Show resolved Hide resolved
gradle/build.go Outdated Show resolved Hide resolved
gradle/build.go Outdated Show resolved Hide resolved
gradle/build_test.go Outdated Show resolved Hide resolved
gradle/build_test.go Outdated Show resolved Hide resolved
gradle/build_test.go Outdated Show resolved Hide resolved
@ekcasey ekcasey added semver:minor A change requiring a minor version bump type:enhancement A general enhancement labels Apr 9, 2021
dmikusa pushed a commit to paketo-buildpacks/samples that referenced this pull request Apr 13, 2021
This is based on the work added with paketo-buildpacks/gradle#60, so requires a version of the Gradle CNB with this feature.
gradle/build.go Outdated Show resolved Hide resolved
gradle/build.go Outdated Show resolved Hide resolved
gradle/build.go Outdated Show resolved Hide resolved
gradle/build.go Outdated Show resolved Hide resolved
Daniel Mikusa and others added 4 commits April 14, 2021 13:47
Co-authored-by: Emily Casey <ecasey@vmware.com>
…r to the layer where gradle runs, but after the cache layer. This allows the cache code to run and initialize the symlink for the cache, then this layer contributes next, adding the symlink into the cache directory and finally gradle runs.
@dmikusa dmikusa merged commit 83a6a27 into main Apr 28, 2021
@dmikusa dmikusa deleted the gh_issue_23 branch April 28, 2021 15:23
gradle/gradle_properties.go Show resolved Hide resolved
gradle/gradle_properties.go Show resolved Hide resolved
gradle/gradle_properties.go Show resolved Hide resolved
@ekcasey
Copy link
Member

ekcasey commented Apr 28, 2021

I think we need to add a hash of the properties file to the application layer metadata. Right now a change to the properties file won't trigger a rebuild of the app layer.

@dmikusa
Copy link
Contributor Author

dmikusa commented Apr 28, 2021

I think we need to add a hash of the properties file to the application layer metadata. Right now a change to the properties file won't trigger a rebuild of the app layer.

I added this. It stores the sha256 hash of the properties into the metadata now, similar to what we do in the maven cnb with settings.xml.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver:minor A change requiring a minor version bump type:enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow users to provide a custom gradle.properties file
2 participants