We have some code that reads some information that I believe comes out of Manifest.MF, specifically, the Implementation-Version: field
Here is a manifest generated by our Maven builder:
Manifest-Version: 1.0
Implementation-Title: foo-service
Implementation-Version: 4adca25a3e0a8faf686833e8cd4879e9607f4f8d
Archiver-Version: Plexus Archiver
Built-By: zundel
Implementation-Build: 4adca25a3e0a8faf686833e8cd4879e9607f4f8d
Implementation-Vendor-Id: com.example.foo
Created-By: Apache Maven 3.1.1
Build-Jdk: 1.8.0_25
Main-Class: com.example.foo.FooService
Here are the fields that current come out of the pants build:
Manifest-Version: 1.0
Created-By: com.twitter.common.jar.tool.JarBuilder
Main-Class: com.squareup.pants.SpyPantsApp
I am shaving some yaks right now on my way to updating jar_task.py to be able to set more of these fields.
I think I could meet my need by just hard coding the setting of Implementation-Build to be the git sha but I was wondering if anyone wanted more flexibility than this. One thought I had was to be
able to configure the manifest in a jvm_binary() target using a new attribute that takes a dictionary.
jvm_binary(name='foo-service', main="com.example.foo.FooService', manifest={ "Implementation-Version": '%git_sha', # could also be '%provides_version' to read from the 'provides` version or a hard-coded string "Implementation-Build": 'git', "Created-by" : <whatever string you like>, "Implementation-Vendor-Id": <whatever string you like>, # or maybe `%provides_org` "Built-By": <way to get the user id in a BUILD file?>, }
Thoughts?
The example is a manifest from a fat jar. That's where I want it to land, anyway. Many of these are standard fields in the manifest specification at: http://docs.oracle.com/javase/8/docs/technotes/guides/jar/jar.html
The Twitter case Stu refers to embeds a root build.properties resource in binaries with much the same info presumably for much the same purpose (standard servers read the resource and export these "variables" on a monitoring endpoint).