-
-
Save patricklaw/4d7678d6b74b0c384254 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HadoopBinaryCreate(BundleCreate): | |
# override to only support HadoopBinary | |
@staticmethod | |
def is_binary(target): | |
return isinstance(target, HadoopBinary) | |
# TODO(pl): I'd rather not override execute, but because we move the deploy jar | |
# at the end of our custom bundle, it's best to avoid potential fallout from | |
# BundleCreate.execute's expectation that the bundle is in the place returned. | |
def execute(self): | |
for target in self.context.target_roots: | |
for app in map(self.App, filter(self.App.is_app, [target])): | |
self.bundle(app) | |
def bundle(self, app): | |
bundle_dir = super(HadoopBinaryCreate, self).bundle(app) | |
jar_name = '{}.jar'.format(app.binary.basename) | |
bundle_jar = os.path.join(bundle_dir, jar_name) | |
version = get_version_string() | |
if version: | |
self.context.log.info("Generating a VERSION file in binary with version: " + version) | |
# TODO(pl): Do this with a synthetic resources target? | |
with self.context.new_workunit(name='add-version-file'): | |
with self.open_jar(bundle_jar) as jar: | |
jar.writestr('VERSION', version) | |
else: | |
self.context.log.info("Could not determine version info.") | |
# TODO(pl): We should just consume these jars from the bundle directory | |
# in which they're normally produced. This is a quick hack to keep our | |
# existing build processes the same. | |
dest_path = os.path.join(self.get_options().pants_distdir, jar_name) | |
os.rename(bundle_jar, dest_path) | |
return bundle_dir |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment