forked from pantsbuild/pants
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add check if jars exists before registering products
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 570498e 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. Testing Done: yes: https://travis-ci.org/pantsbuild/pants/builds/51559910 Reviewed at https://rbcommons.com/s/twitter/r/1808/
- Loading branch information
Showing
8 changed files
with
93 additions
and
39 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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