Packaging Library Path Dependencies With A Package


#1

I have some Java applications that need to be built with Gradle. There is no core package so I wrote one here.

Note: my package uses the Gradle binary because attempts to build Gradle from source in the Hab studio blew up due to memory limitations that I didn’t have the time, skill or patience to resolve at this time. Moving on…

When I try to run Gradle it will fail unless I set LD_LIBRARY_PATH to include a gcc-libs library dependency. What I want to do is pass this dependency with the Gradle package so that I don’t have to add this environment variable to every Java application that uses Gradle as a build dependency. I tried adding export LD_LIBRARY_PATH and export LD_RUN_PATH to do_install, but neither work.

Normally, I would solve this by using patchelf against the a Gradle binary, but there is no such thing as a Gradle binary. bin/gradle is a shell script that calls bin/java to run a JAR. Is there a way to solve this issue without writing my own custom Java plan and depending on that? I can do it, but it seems like a heavy handed approach to what should be an easy fix. I assume I’m just misunderstanding something here.

UPDATE
While writing this, @smith hit me back (thanks brother!) in Slack with a clever idea:

@tmichael you could place the bin outside of the bin directory and put a wrapper script in its place.

I’m going to try this tomorrow and see how it goes. In the meantime, figured as I long as I typed this all out I’d post it to the board in case: (1) there are other solutions to share (2) someone else runs into this problem and needs the solution suggested by @smith. I’ll follow up by end of week with status and link to example if it works.

Cheers

Todd Michael