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 transitive jar dependencies to depmap project info goal for intel…
…lij plugin. Add transitive jar dependencies to depmap goal for Pants Intellij plugin When creating projects using the plugin, the depmap showed direct dependencies for 3rdparty jar libraries. This change add the trasitive dependency jars to the depmap output. The transitive jars are required to correctly configure intellij modules. Testing Done: yes. Added integration tests but need to verify the contents. PR created here: pantsbuild#626 {Coverage increased (+0.04%) when pulling 09790ec on add_transitive_jar_deps into ad7d09d on master.} Locally tested ./pants tests/python/pants_test/tasks:depmap_integration Reviewed at https://rbcommons.com/s/twitter/r/1047/
- Loading branch information
Showing
4 changed files
with
125 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# coding=utf-8 | ||
# Copyright 2014 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
from __future__ import (nested_scopes, generators, division, absolute_import, with_statement, | ||
print_function, unicode_literals) | ||
|
||
import json | ||
import os | ||
|
||
from pants.util.contextutil import temporary_dir | ||
|
||
from pants.ivy.bootstrapper import Bootstrapper | ||
from pants.base.build_environment import get_buildroot | ||
from pants_test.pants_run_integration_test import PantsRunIntegrationTest | ||
|
||
|
||
class DepmapIntegrationTest(PantsRunIntegrationTest): | ||
|
||
def _assert_run_success(self, pants_run): | ||
self.assertEquals(pants_run.returncode, self.PANTS_SUCCESS_CODE, | ||
'goal depmap expected success, got {0}\n' | ||
'got stderr:\n{1}\n' | ||
'got stdout:\n{2}\n'.format(pants_run.returncode, | ||
pants_run.stderr_data, | ||
pants_run.stdout_data)) | ||
|
||
def run_depmap_project_info(self, test_target, workdir): | ||
depmap_out_file = '{workdir}/depmap_out.txt'.format(workdir=workdir) | ||
pants_run = self.run_pants_with_workdir( | ||
['goal', 'resolve', 'depmap', test_target, '--depmap-project-info', | ||
'--depmap-output-file={out_file}'.format(out_file=depmap_out_file)], workdir) | ||
self._assert_run_success(pants_run) | ||
self.assertTrue(os.path.exists(depmap_out_file), | ||
msg='Could not find depmap output file in {out_file}' | ||
.format(out_file=depmap_out_file)) | ||
with open(depmap_out_file) as json_file: | ||
json_data = json.load(json_file) | ||
return json_data | ||
|
||
def test_depmap_code_gen(self): | ||
with temporary_dir(root_dir=self.workdir_root()) as workdir: | ||
test_target = 'examples/tests/java/com/pants/examples/usethrift:usethrift' | ||
json_data = self.run_depmap_project_info(test_target, workdir) | ||
thrift_target_name = 'examples.src.thrift.com.pants.examples.precipitation.precipitation-java' | ||
codegen_target = os.path.join(os.path.relpath(workdir, get_buildroot()), | ||
'gen/thrift/combined/gen-java:%s' % thrift_target_name) | ||
self.assertTrue(codegen_target in json_data.get('targets')) | ||
|
||
def test_depmap_json_transitive_jar(self): | ||
with temporary_dir(root_dir=self.workdir_root()) as workdir: | ||
test_target = 'examples/tests/java/com/pants/examples/usethrift:usethrift' | ||
json_data = self.run_depmap_project_info(test_target, workdir) | ||
targets = json_data.get('targets') | ||
self.assertTrue('org.hamcrest:hamcrest-core:1.3' in targets[test_target]['libraries']) | ||
|
||
def test_depmap_jar_path(self): | ||
with temporary_dir(root_dir=self.workdir_root()) as workdir: | ||
test_target = 'examples/tests/java/com/pants/examples/usethrift:usethrift' | ||
json_data = self.run_depmap_project_info(test_target, workdir) | ||
ivy_cache_dir = Bootstrapper.instance().ivy_cache_dir | ||
self.assertEquals(json_data.get('libraries').get('commons-lang:commons-lang:2.5'), | ||
[os.path.join(ivy_cache_dir, | ||
'commons-lang/commons-lang/jars/commons-lang-2.5.jar')]) | ||
|
||
def test_depmap_without_resolve(self): | ||
with temporary_dir(root_dir=self.workdir_root()) as workdir: | ||
depmap_out_file = '{workdir}/depmap_out.txt'.format(workdir=workdir) | ||
pants_run = self.run_pants_with_workdir( | ||
['goal', 'depmap', 'testprojects/src/java/com/pants/testproject/unicode/main', | ||
'--depmap-project-info', | ||
'--depmap-output-file={out_file}'.format(out_file=depmap_out_file)], workdir) | ||
self._assert_run_success(pants_run) | ||
self.assertTrue(os.path.exists(depmap_out_file), | ||
msg='Could not find depmap output file {out_file}' | ||
.format(out_file=depmap_out_file)) |