Add check if jars exists before registering products

Review Request #1808 - Created Feb. 20, 2015 and submitted

Information
Tejal Desai
pants
57c5f61...
Reviewers
pants-reviews
benjyw, ity, jsirois, stuhood, zundel

Commits:
Add check if jar exists before registering products and also move the check out of with context

Pants, registers a empty jar product when there were no products generated by the target.

I saw this happen for sure when a target contained an empty scala file.
compile task did not produce any classes for that target and hence a jar with zero length got created.
(Obviously the fix was the remove the empty scala file, but pants needs to be more robust to handle such cases)

The reason for this was in commit 570498ed51fee6a6558bfe3fae2bf63d641d26bd Benjy added a change to add empty products for a target. Hence, the condition https://github.com/pantsbuild/pants/blob/master/src/python/pants/backend/jvm/tasks/jar_task.py#L342 always returned true.
I added the method nonzero for python 2.x and bool for python 3.x in MultipleRootedProducts and RootedProducts to return true only if there were any products registered.
Added test case for this scenario.

We also saw this happen in idea --intransitive phase. The jar phase registered products for synthetic java_thrift_library target created from twitter internal task. We create 2 synthetic targets (scala and java) for one thrift_library and attach same sources.
At runtime, however only one jar product was created but two got registered.
We saw this error
{code}
IOError: [Errno 2] No such file or directory: u'/Users/bzhang/workspace/source/birdcage/.pants.d/jar/jar/.pants.d.gen.scrooge.java-finagle..pants.d.gen.idl-extract.3rdparty.jvm.com.twitter.ibis.deprecated-ibis-thrift-service-java.3rdparty.jvm.com.twitter.ibis.deprecated-ibis-thrift-service-java.jar'

IOError: [Errno 2] No such file or directory: u'/Users/tdesai/projects/source2/birdcage/.pants.d/jar/jar/ibis.ibis-executor.src.test.java.java.jar'
{code}

I am happy to hear any other potential fixes.

yes:
https://travis-ci.org/pantsbuild/pants/builds/51559910

Issues

  • 0
  • 1
  • 2
  • 3
Description From Last Updated
Tejal Desai
John Sirois
Tejal Desai
Tejal Desai
Eric Ayers
Stu Hood
Tejal Desai
Tejal Desai
John Sirois
Tejal Desai
Tejal Desai
Tejal Desai
Tejal Desai
Tejal Desai
Review request changed

Status: Closed (submitted)

Tejal Desai

Follow up code changed here -> https://github.com/pantsbuild/pants/pull/1173/files

Loading...