Replies: 2 comments 2 replies
-
Let's take the case that you want to have a buildpack that will add Spring Boot Actuator JARS if the project does not include them. There are two approaches I can think of here.
The second approach is simple and has been pretty reliable. It is something that we have used in Paketo buildpacks. We do this in the spring boot buildpack for Spring Cloud Bindings. The first approach is something that we've tried to avoid doing because, in a nutshell, it's complicated. For example:
We've not really looked into the second option, because the first option has worked well enough for us. I don't want to say it's impossible, but it would require changes to the way existing buildpacks work or forking and modifying existing buildpack. That's compared to the second option where you can just add a custom buildpack at the end of the list of existing buildpacks and have it conditionally insert the required JAR. Two other things to consider:
|
Beta Was this translation helpful? Give feedback.
-
Thanks @dmikusa! The remarks you made in the third bullet point above related to the first approach is valuable info. I think the second approach suggested is what I will adapt my own approach to. So, two scenarios exist: a) post-build for Maven or Gradle, check if artifact exists, if it doesn't add it And another thing to consider, dependencies typically have transitive dependencies. How do I add the transitives? One approach I was using was to use Your bullet point 2 in "two other things to consider" is something I had absolutely wanted to account for in my design, see 5th bullet point of my original post. Footnote: I'm not a Go-lang expert. I had been using bash. Here's the naive implementation of a bash script I'd started with and will now have to adapt...
|
Beta Was this translation helpful? Give feedback.
-
First, let me state what I'm trying to do from a design perspective...
I want to be able add an artifact dependency to a pom.xml or build.gradle file before executing build. I also want to be able to add an artifact to a pre-built executable .jar file. (Both are admittedly unorthodox approaches, but let's table that).
Here's how I'm thinking about it, and I wonder if a
detect
script in the custom buildpack will suffice for where all the logic belongs or if some (other more complicated) approach is necessary:Here's the breakdown.
The structure of my project:
Not including the script. But happy to share if you think it's valuable to.
package.toml
builder.toml
buildpack.toml
How I built everything
What I am seeing when I try to build an app container image using the custom builder:
Any pointers? I'm open to all suggestions.
(I saw an earlier post about how Maven cleans up source. I don't think I'll suffer from that problem, but I do need
mvn
,gradle
, andjar
to be available to the custom buildpack's scripts. I want to be able to invoke these before the Maven or Gradle buildpacks get involved in build. That's what I really need advice on. How can I facilitate that?)Beta Was this translation helpful? Give feedback.
All reactions