# Allow jdk / install-jdk.sh to use the build cache

**URL:** https://travis-ci.community/t/allow-jdk-install-jdk-sh-to-use-the-build-cache/3145
**Category:** Java
**Created:** [April 23, 2019, 8:18pm UTC](https://travis-ci.community/t/allow-jdk-install-jdk-sh-to-use-the-build-cache/3145 "2019-04-23T20:18:53Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![strangemonad-faire](https://avatars.discourse-cdn.com/v4/letter/s/858c86/32.png) [@strangemonad-faire](https://travis-ci.community/u/strangemonad-faire)
#### Post date: [April 23, 2019, 8:18pm UTC](https://travis-ci.community/t/allow-jdk-install-jdk-sh-to-use-the-build-cache/3145/1 "2019-04-23T20:18:53Z")

</div>

If you set jdk to use a version that uses install-jdk.sh to install itself (e.g. opendjk12) you end up downloading the build artifact from oracle for every build. This ends up running into issues of rate limiting and connection failures leading to flaky builds. Adding “$HOME/.cache/install-jdk” to the cache directories doesn’t solve the issue because the jdk is installed before the build cache is restored.

Is there a valid reason to not restore the build cache first? install-jdk.sh invokes wget with the correct timestamp options to prevent re-downloading.

---

<div class="post-metadata">

### Author: ![sormuras](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/sormuras/32/2770_2.png) [@sormuras](https://travis-ci.community/u/sormuras)
#### Post date: [July 9, 2019, 4:34pm UTC](https://travis-ci.community/t/allow-jdk-install-jdk-sh-to-use-the-build-cache/3145/2 "2019-07-09T16:34:33Z")

</div>

Yeah, a cache would be awesome.

---

<div class="post-metadata">

### Author: ![native-api](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/native-api/32/430_2.png) [@native-api](https://travis-ci.community/u/native-api)
#### Post date: [July 10, 2019, 12:26am UTC](https://travis-ci.community/t/allow-jdk-install-jdk-sh-to-use-the-build-cache/3145/3 "2019-07-10T00:26:37Z")

</div>

> [@Run a chunk of user code before the stock installation logic](https://travis-ci.community/t/run-stock-installation-logic-platform-install-addons-after-before-install-or-other-chunk-of-user-code/4141):
>
> As it is now, stock installation logic (platform install, build addons) run before any user-supplied code gets control. As a consequence, if that logic doesn’t quite fit the needs or something goes wrong with it, all a user can do is ditch it altogether – they can’t do anything about the problem. I’m suggesting to run some user-supplied code before any stock logic fires, [except perhaps cache restoration.](https://travis-ci.community/t/allow-jdk-install-jdk-sh-to-use-the-build-cache/3145) before\_install looks like the perfect candidate: before\_install: – stock logic – install: w…
