2 ms·
This sounds pretty sensible. I wonder if there's a simple way to reproduce it. Maybe: I. Build your app as a thin JAR, with: a. a Main-Class entry in the
by twic 10y ago
This sounds pretty sensible. I wonder if there's a simple way to reproduce it. Maybe:
I. Build your app as a thin JAR, with:
a. a Main-Class entry in the manifest
b. Class-Path entries in the manifest
c. a file containing a list of dependency coordinates (group, artifact, version) in META-INF
II. Write a shell script (for whatever value of 'shell' you like) which:
1. takes a Maven repo URL and a Maven coordinate (group, artifact, version)
2. downloads the JAR from the repo, extracts its dependency list, then pulls its dependencies too
3. (optionally) somehow records which JAR is the main one, say by writing a tiny shell script or a symlink pointing at it
You might be able to use a standard embedded POM instead of a dependency list, which might reduce the work a bit, but that would then require doing transitive dependency resolution at deploy time, which is probably a bad idea.
Phase I is something like 10 - 20 lines of Gradle, tops. You could pack it up into a plugin easily enough. Phase II is a similar amount of shell script, maybe more.
For extra safety, add SHA3 hashes to the dependency list file, and check them when you download the dependencies.
I've described this as using a Maven repo, but that doesn't mean it has to hit Nexus or whatever; you can just put JARs in S3 in the right layout. A while ago, i was doing this by maintaining a repository locally, and just pushing the whole thing to a Bitbucket website:
https://bitbucket.org/twic/twic.bitbucket.org/src/14ac48d4c4a9/repository/?at=default https://bitbucket.org/twic/twic.bitbucket.org/src/14ac48d4c4...
You could do something similar, perhaps going from Nexus to S3.
- HiJon89 10y agoThis similar to our setup with the slimfast-plugin. We use the maven-jar-plugin to add the Main-Class and Class-Path entries to the manifest. At build time, we use the upload goal of the slimfast-plugin to upload the dependencies. It automatically reads the configuration of the maven-jar-plugin to make sure the paths it generates match the classpath in the manifest. Then it spits out a JSON file that has info on each dependency, including its location in S3, file size, checksum, and relative path where it needs to be copied to match the Class-Path in the manifest (the JSON entries look like this https://gist.github.com/jhaber/3029dc55a568f0954b1c4b459657e1bc https://gist.github.com/jhaber/3029dc55a568f0954b1c4b459657e...). On deploy, the simplest way to get up and running is to use the download goal of the slimfast-plugin. It reads this JSON file, downloads each dependency (using an optional cache folder), verifies the file size and checksum, and copies it to the correct relative path. The application will then start up happily with java -jar. At HubSpot, we instead integrated this download step more transparently into our deploy process. At build time we read this JSON file and store the dependency information in our build database. Our deploy infrastructure already accepts S3 URLs and handles downloading, caching, verifying checksums, and copying to arbitrary directories so we just piggybacked on this existing functionality to have it download the application plus all of its dependencies for us.
- twic 10y agoHere's my very rough attempt in Gradle: https://bitbucket.org/twic/ensure https://bitbucket.org/twic/ensure Turned out to be more than 20 lines, but then i did it in Java rather than Groovy. I do the downloads from the Maven repo (which should be your internal Maven repo!), so there's no need for an upload step. Deployment is done with a shell script with a few undemanding dependencies - unzip, curl, and openssl to verify the digests. I use a TSV file rather than JSON because it's easier for the shell script to read! My next trick will be to figure out how to get this into a Cloud Foundry buildpack ... Oh, the name: https://ensure.com/nutrition-products https://ensure.com/nutrition-products