Initial port of twitter/commons jar-tool.

Review Request #2071 - Created April 13, 2015 and submitted

Information
John Sirois
pants
jsirois/jvm_tools/adopt_jar_tool
1362, 1415
0feff7c...
Reviewers
pants-reviews
benjyw, jinfeng, stuhood, zundel
Copy jar-tool in from twitter/commons.
    
This ports the jar-tool used by pants but does not actually
configure pants to use the ported tool.  That will come later after
the tool is published: https://github.com/pantsbuild/pants/issues/1361
    
The jar-tool in twitter/commons will be deleted after this tool is
published and consumed by pants HEAD.


 3rdparty/BUILD                                              |  119 ++---
 BUILD                                                       |    2 +
 src/java/org/pantsbuild/tools/jar/BUILD                     |   26 ++
 src/java/org/pantsbuild/tools/jar/JarBuilder.java           | 1237 ++++++++++++++++++++++++++++++++++++++++++++++++++
 src/java/org/pantsbuild/tools/jar/JarEntryCopier.java       |  177 ++++++++
 src/java/org/pantsbuild/tools/jar/JarFileUtil.java          |   48 ++
 src/java/org/pantsbuild/tools/jar/Main.java                 |  423 +++++++++++++++++
 tests/java/org/pantsbuild/tools/jar/BUILD                   |   17 +
 tests/java/org/pantsbuild/tools/jar/JarBuilderTest.java     |  791 ++++++++++++++++++++++++++++++++
 tests/java/org/pantsbuild/tools/jar/JarEntryCopierTest.java |  237 ++++++++++
 tests/resources/org/pantsbuild/tools/jar/BUILD              |    7 +
 tests/resources/org/pantsbuild/tools/jar/a.jar              |  Bin 0 -> 631 bytes
 tests/resources/org/pantsbuild/tools/jar/b.jar              |  Bin 0 -> 645 bytes
 tests/resources/org/pantsbuild/tools/jar/c.jar              |  Bin 0 -> 763 bytes
 14 files changed, 3012 insertions(+), 72 deletions(-)

Locally dogfooded the jar-tool to build itself comparing before/after:

$ PANTS_DEV=1 ./pants clean-all binary src/java/org/pantsbuild/tools/jar:main
$ cp dist/jar-tool.jar dist/jar-tool.created-by.c.t.c.jar

$ git diff
diff --git a/BUILD.tools b/BUILD.tools
index 81fc8d8..b233485 100644
--- a/BUILD.tools
+++ b/BUILD.tools
@@ -152,7 +152,8 @@ jar_library(name = 'spindle-codegen',

 jar_library(name = 'jar-tool',
             jars = [
-              jar(org = 'com.twitter.common', name = 'jar-tool', rev = '0.1.9')
+              jar(org = 'com.twitter.common', name = 'jar-tool', rev = 'none', mutable=True,
+                  url='file:///home/jsirois/dev/3rdparty/jsirois-pants4/dist/jar-tool.jar')
             ])

 jar_library(name = 'jarjar',
diff --git a/src/python/pants/backend/jvm/tasks/jar_task.py b/src/python/pants/backend/jvm/tasks/jar_task.py
index 438e1e5..7298fac 100644
--- a/src/python/pants/backend/jvm/tasks/jar_task.py
+++ b/src/python/pants/backend/jvm/tasks/jar_task.py
@@ -288,7 +288,7 @@ class JarTask(NailgunTask):
         # need the same JVM args as its parent.
         jvm_options = self.context.config.getlist('jar-tool', 'jvm_args', default=['-Xmx64M'])
         self.runjava(self.tool_classpath('jar-tool'),
-                     'com.twitter.common.jar.tool.Main',
+                     'org.pantsbuild.tools.jar.Main',
                      jvm_options=jvm_options,
                      args=args,
                      workunit_name='jar-tool',$
$ PANTS_DEV=1 ./pants clean-all binary src/java/org/pantsbuild/tools/jar:main

$ mkdir /tmp/jar-tool.jar /tmp/jar-tool.created-by.c.t.c.jar
$ unzip -qd /tmp/jar-tool.created-by.c.t.c.jar dist/jar-tool.created-by.c.t.c.jar 
$ unzip -qd /tmp/jar-tool.jar dist/jar-tool.jar 
$ diff -r /tmp/jar-tool.created-by.c.t.c.jar /tmp/jar-tool.jar
diff -r /tmp/jar-tool.created-by.c.t.c.jar/META-INF/MANIFEST.MF /tmp/jar-tool.jar/META-INF/MANIFEST.MF
2c2
< Created-By: com.twitter.common.jar.tool.JarBuilder
---
> Created-By: org.pantsbuild.tools.jar.JarBuilder

CI went green here:
https://travis-ci.org/pantsbuild/pants/builds/58311252

John Sirois
John Sirois
John Sirois
John Sirois
Benjy Weinberger
Eric Ayers
John Sirois
John Sirois
John Sirois
Eric Ayers
John Sirois
John Sirois
John Sirois
John Sirois
John Sirois
John Sirois
Review request changed

Status: Closed (submitted)

Loading...