예제 #1
0
  def register_options(cls, register, register_jvm_tool):
    slf4j_jar = JarDependency(org='org.slf4j', name='slf4j-simple', rev='1.7.5')
    slf4j_api_jar = JarDependency(org='org.slf4j', name='slf4j-api', rev='1.7.5')

    register('--coverage-cobertura-include-classes', advanced=True, type=list,
             help='Regex patterns passed to cobertura specifying which classes should be '
                  'instrumented. (see the "includeclasses" element description here: '
                  'https://github.com/cobertura/cobertura/wiki/Ant-Task-Reference)')

    register('--coverage-cobertura-exclude-classes', advanced=True, type=list,
             help='Regex patterns passed to cobertura specifying which classes should NOT be '
                  'instrumented. (see the "excludeclasses" element description here: '
                  'https://github.com/cobertura/cobertura/wiki/Ant-Task-Reference')

    def cobertura_jar(**kwargs):
      return JarDependency(org='net.sourceforge.cobertura', name='cobertura', rev='2.1.1', **kwargs)

    # The Cobertura jar needs all its dependencies when instrumenting code.
    register_jvm_tool(register,
                      'cobertura-instrument',
                      classpath=[
                        cobertura_jar(),
                        slf4j_jar
                      ])

    # Instrumented code needs cobertura.jar in the classpath to run, but not most of the
    # dependencies; inject the SLF4J API so that Cobertura doesn't crash when it attempts to log
    register_jvm_tool(register,
                      'cobertura-run',
                      classpath=[
                        cobertura_jar(intransitive=True),
                        slf4j_api_jar
                      ])

    register_jvm_tool(register, 'cobertura-report', classpath=[cobertura_jar()])
예제 #2
0
    def test_resolve_multiple_artifacts1(self):
        no_classifier = JarDependency('junit', 'junit', rev='4.12')
        classifier_and_no_classifier = JarDependency(
            'junit',
            'junit',
            rev='4.12',
            classifier='sources',
            artifacts=[IvyArtifact('junit')])

        no_classifier_lib = self.make_target('//:a',
                                             JarLibrary,
                                             jars=[no_classifier])
        classifier_and_no_classifier_lib = self.make_target(
            '//:b', JarLibrary, jars=[classifier_and_no_classifier])

        compile_classpath = self.resolve(
            [no_classifier_lib, classifier_and_no_classifier_lib])

        no_classifier_cp = compile_classpath.get_for_target(no_classifier_lib)
        classifier_and_no_classifier_cp = compile_classpath.get_for_target(
            classifier_and_no_classifier_lib)

        sources_jar = 'junit-4.12-sources.jar'
        regular_jar = 'junit-4.12.jar'
        self.assertIn(sources_jar, (os.path.basename(j[-1])
                                    for j in classifier_and_no_classifier_cp))
        self.assertIn(regular_jar, (os.path.basename(j[-1])
                                    for j in classifier_and_no_classifier_cp))

        self.assertNotIn(sources_jar,
                         (os.path.basename(j[-1]) for j in no_classifier_cp))
        self.assertIn(regular_jar,
                      (os.path.basename(j[-1]) for j in no_classifier_cp))
예제 #3
0
    def test_identical_jar_libraries_with_differing_managed_deps_differ(self):
        confs = ()
        strategy = IvyResolveFingerprintStrategy(
            self.create_task(self.context()), confs)

        managed_jar_deps = self.make_target(
            ':managed',
            target_type=ManagedJarDependencies,
            artifacts=[JarDependency('org.some', 'name')])
        self.set_artifact_set_for(managed_jar_deps, PinnedJarArtifactSet())

        jar_lib_with_managed_deps = self.make_target(
            ':jar-lib-1',
            target_type=JarLibrary,
            jars=[JarDependency('org.some', 'name')],
            managed_dependencies=':managed')

        jar_lib_without_managed_deps = self.make_target(
            ':jar-lib-no-managed-dep',
            target_type=JarLibrary,
            jars=[JarDependency('org.some', 'name')])

        self.assertNotEqual(
            strategy.compute_fingerprint(jar_lib_with_managed_deps),
            strategy.compute_fingerprint(jar_lib_without_managed_deps))
예제 #4
0
 def test_jar_dependencies(self):
   jar1 = JarDependency(org='testOrg1', name='testName1', rev='123')
   jar2 = JarDependency(org='testOrg2', name='testName2', rev='456')
   lib = JarLibrary(name='foo', address=SyntheticAddress.parse('//:foo'),
                    build_graph=self.build_graph,
                    jars=[jar1, jar2])
   self.assertEquals((jar1, jar2), lib.jar_dependencies)
예제 #5
0
    def test_jars_field_artifacts(self):
        jar1 = (JarDependency('com', 'foo', '1.0.0').with_artifact(
            'com', 'baz').with_artifact('org', 'bat'))
        jar2 = (JarDependency('com', 'foo', '1.0.0').with_artifact(
            'org', 'bat').with_artifact('com', 'baz'))
        jar3 = (JarDependency('com', 'foo',
                              '1.0.0').with_artifact('org', 'bat'))

        jar4 = JarDependency('com', 'foo', '1.0.0')

        self.assertEqual(
            JarsField([jar1]).fingerprint(),
            JarsField([jar2]).fingerprint(),
        )
        self.assertNotEqual(
            JarsField([jar1]).fingerprint(),
            JarsField([jar3]).fingerprint(),
        )
        self.assertNotEqual(
            JarsField([jar1]).fingerprint(),
            JarsField([jar4]).fingerprint(),
        )
        self.assertNotEqual(
            JarsField([jar3]).fingerprint(),
            JarsField([jar4]).fingerprint(),
        )
예제 #6
0
 def test_explicit_and_default_target(self):
     default_target = self.make_target(spec='//foo:foobar',
                                       target_type=ManagedJarDependencies,
                                       artifacts=[
                                           JarDependency(org='foobar',
                                                         name='foobar',
                                                         rev='2'),
                                       ])
     management_target = self.make_target(
         spec='//foo:management',
         target_type=ManagedJarDependencies,
         artifacts=[
             JarDependency(org='foobar', name='foobar', rev='3'),
         ])
     jar_library = self.make_target(spec='//foo:library',
                                    target_type=JarLibrary,
                                    jars=[
                                        JarDependency(org='foobar',
                                                      name='foobar'),
                                    ],
                                    managed_dependencies='//foo:management')
     context = self.context(
         target_roots=[default_target, management_target, jar_library])
     with self._subsystem(default_target='//foo:management') as manager:
         task = self.create_task(context)
         task.execute()
         artifact_set = manager.for_target(jar_library)
         self.assertFalse(artifact_set is None)
         self.assertEquals(
             '3', artifact_set[M2Coordinate('foobar', 'foobar')].rev)
예제 #7
0
 def test_indirection(self):
     management_target = self.make_target(
         target_type=ManagedJarDependencies,
         spec='//foo:management_indirect',
         artifacts=[
             JarDependency(org='foobar', name='foobar', rev='2'),
         ],
     )
     default_target = self.make_target(
         target_type=Target,
         spec='//foo:management',
         dependencies=[
             management_target,
         ],
     )
     jar_library1 = self.make_target(
         target_type=JarLibrary,
         spec='//foo:library',
         jars=[
             JarDependency(org='foobar', name='foobar'),
         ],
     )
     context = self.context(
         target_roots=[default_target, jar_library1, management_target])
     with self._subsystem(default_target='//foo:management') as manager:
         task = self.create_task(context)
         task.execute()
         artifact_set = self._single_artifact_set(manager, [jar_library1])
         self.assertFalse(artifact_set is None)
         self.assertEquals(
             '2', artifact_set[M2Coordinate('foobar', 'foobar')].rev)
예제 #8
0
    def setUp(self):
        """Prepare targets, context, runtime classpath. """
        super(TestBundleCreate, self).setUp()

        self.jar_artifact = self.create_artifact(org='org.example',
                                                 name='foo',
                                                 rev='1.0.0')
        self.zip_artifact = self.create_artifact(org='org.pantsbuild',
                                                 name='bar',
                                                 rev='2.0.0',
                                                 ext='zip')
        self.bundle_artifact = self.create_artifact(org='org.apache',
                                                    name='baz',
                                                    rev='3.0.0',
                                                    classifier='tests')
        self.tar_gz_artifact = self.create_artifact(org='org.gnu',
                                                    name='gary',
                                                    rev='4.0.0',
                                                    ext='tar.gz')

        self.jar_lib = self.make_target(spec='3rdparty/jvm/org/example:foo',
                                        target_type=JarLibrary,
                                        jars=[
                                            JarDependency(org='org.example',
                                                          name='foo',
                                                          rev='1.0.0'),
                                            JarDependency(org='org.pantsbuild',
                                                          name='bar',
                                                          rev='2.0.0',
                                                          ext='zip'),
                                            JarDependency(org='org.apache',
                                                          name='baz',
                                                          rev='3.0.0',
                                                          classifier='tests'),
                                            JarDependency(org='org.gnu',
                                                          name='gary',
                                                          rev='4.0.0',
                                                          ext='tar.gz')
                                        ])

        safe_file_dump(os.path.join(self.build_root, 'resources/foo/file'),
                       '// dummy content')
        self.resources_target = self.make_target('//resources:foo-resources',
                                                 Resources,
                                                 sources=['foo/file'])

        # This is so that payload fingerprint can be computed.
        safe_file_dump(os.path.join(self.build_root, 'foo/Foo.java'),
                       '// dummy content')
        self.java_lib_target = self.make_target('//foo:foo-library',
                                                JavaLibrary,
                                                sources=['Foo.java'])

        self.binary_target = self.make_target(
            spec='//foo:foo-binary',
            target_type=JvmBinary,
            dependencies=[self.java_lib_target, self.jar_lib],
            resources=[self.resources_target.address.spec])

        self.dist_root = os.path.join(self.build_root, 'dist')
예제 #9
0
 def test_jar_dependency_excludes_change_hash(self):
   exclude = Exclude(org='example.com', name='foo-lib')
   with_excludes = JarDependency(org='foo',
                                 name='foo',
                                 excludes=[exclude])
   without_excludes = JarDependency(org='foo', name='foo')
   self.assertNotEqual(with_excludes.cache_key(), without_excludes.cache_key())
예제 #10
0
  def register_options(cls, register):
    super(BenchmarkRun, cls).register_options(register)
    register('--target', help='Name of the benchmark class. This is a mandatory argument.')
    register('--memory', default=False, action='store_true', help='Enable memory profiling.')
    register('--debug', action='store_true',
             help='Run the benchmark tool with in process debugging.')

    cls.register_jvm_tool(register,
                          'benchmark-tool',
                          classpath=[
                            # TODO (Eric Ayers) Caliper is old. Add jmh support?
                            # The caliper tool is shaded, and so shouldn't interfere with Guava 16.
                            JarDependency(org='com.google.caliper', name='caliper', rev='0.5-rc1'),
                          ],
                          classpath_spec='//:benchmark-caliper-0.5',
                          main=cls._CALIPER_MAIN)
    cls.register_jvm_tool(register,
                          'benchmark-agent',
                          classpath=[
                            JarDependency(org='com.google.code.java-allocation-instrumenter',
                                          name='java-allocation-instrumenter',
                                          rev='2.1',
                                          intransitive=True),
                          ],
                          classpath_spec='//:benchmark-java-allocation-instrumenter-2.1')
예제 #11
0
    def scala_platform_setup(self):
        options = {
            ScalaPlatform.options_scope: {
                'version': 'custom',
                'suffix_version': '2.10',
            }
        }
        init_subsystem(ScalaPlatform, options)

        self.make_target(
            '//:scalastyle',
            JarLibrary,
            jars=[JarDependency('org.scalastyle', 'scalastyle_2.10', '0.3.2')])

        self.make_target('//:scala-repl',
                         JarLibrary,
                         jars=[
                             JarDependency(org='org.scala-lang',
                                           name='jline',
                                           rev='2.10.5'),
                             JarDependency(org='org.scala-lang',
                                           name='scala-compiler',
                                           rev='2.10.5')
                         ])

        self.make_target(
            '//:scalac',
            JarLibrary,
            jars=[JarDependency('org.scala-lang', 'scala-compiler', '2.10.5')])
예제 #12
0
    def scala_platform_setup(self):
        options = {
            'scala-platform': {
                'version': 'custom',
                'suffix_version': '2.10',
                'runtime_spec': '//:scala-library-custom',
            }
        }
        with subsystem_instance(ScalaPlatform, **options):
            self.make_target('//:scalastyle',
                             JarLibrary,
                             jars=[
                                 JarDependency('org.scalastyle',
                                               'scalastyle_2.10', '0.3.2')
                             ])

            self.make_target('//:scala-repl',
                             JarLibrary,
                             jars=[
                                 JarDependency(org='org.scala-lang',
                                               name='jline',
                                               rev='2.10.5'),
                                 JarDependency(org='org.scala-lang',
                                               name='scala-compiler',
                                               rev='2.10.5')
                             ])

            self.make_target('//:scalac',
                             JarLibrary,
                             jars=[
                                 JarDependency('org.scala-lang',
                                               'scala-compiler', '2.10.5')
                             ])
            yield
예제 #13
0
    def test_a_jar_with_rev_less_than_other_jar_is_less_than(self):
        jar_dep_1_0 = JarDependency('com.example', 'dependency', rev="1.0")
        jar_dep_1_1 = JarDependency('com.example', 'dependency', rev="1.1")

        self.assertTrue(
            jar_dep_1_0 < jar_dep_1_1,
            '{} should be less than {}'.format(jar_dep_1_0, jar_dep_1_1))
예제 #14
0
 def test_using_jar_library_address(self):
     pin_jar_library = self.make_target(
         spec='//foo:pinned-library',
         target_type=JarLibrary,
         jars=[
             JarDependency(org='foobar', name='foobar', rev='2'),
         ],
     )
     management_target = self.make_target(
         spec='//foo:management',
         target_type=ManagedJarDependencies,
         artifacts=[
             '//foo:pinned-library',
         ])
     jar_library = self.make_target(spec='//foo:library',
                                    target_type=JarLibrary,
                                    jars=[
                                        JarDependency(org='foobar',
                                                      name='foobar'),
                                    ],
                                    managed_dependencies='//foo:management')
     context = self.context(
         target_roots=[management_target, jar_library, pin_jar_library])
     with self._subsystem() as manager:
         task = self.create_task(context)
         task.execute()
         artifact_set = manager.for_target(jar_library)
         self.assertFalse(artifact_set is None)
         self.assertEquals(
             '2', artifact_set[M2Coordinate('foobar', 'foobar')].rev)
예제 #15
0
    def setUp(self):
        super(TestBase, self).setUp()

        self.pants_workdir = "workdir"
        self.conf = "default"

        self.jar_lib = self.make_target(spec='3rdparty/jvm/org/example:foo',
                                        target_type=JarLibrary,
                                        jars=[
                                            JarDependency(org='org.example',
                                                          name='foo',
                                                          rev='1.0.0'),
                                            JarDependency(org='org.pantsbuild',
                                                          name='bar',
                                                          rev='2.0.0',
                                                          ext='zip')
                                        ])

        self.binary_target = self.make_target(spec='//foo:foo-binary',
                                              target_type=JvmBinary,
                                              source='Foo.java',
                                              dependencies=[self.jar_lib])

        self.app_target = self.make_target(spec='//foo:foo-app',
                                           target_type=JvmApp,
                                           basename='FooApp',
                                           dependencies=[self.binary_target])

        self.java_target = self.make_target(spec='//foo:foo-java',
                                            target_type=JavaLibrary)

        self.annotation_target = self.make_target(
            spec='//foo:foo-anno', target_type=AnnotationProcessor)
예제 #16
0
class JUnit(JvmToolMixin, Subsystem):
    options_scope = 'junit'

    LIBRARY_REV = '4.12'
    RUNNER_MAIN = 'org.pantsbuild.tools.junit.ConsoleRunner'

    _LIBRARY_JAR = JarDependency(org='junit', name='junit', rev=LIBRARY_REV)
    _RUNNER_JAR = JarDependency(org='org.pantsbuild',
                                name='junit-runner',
                                rev='1.0.13')

    @classmethod
    def register_options(cls, register):
        super(JUnit, cls).register_options(register)
        cls.register_jvm_tool(register,
                              'junit_library',
                              classpath=[
                                  cls._LIBRARY_JAR,
                              ])

        cls.register_jvm_tool(
            register,
            'junit',
            classpath=[
                cls._RUNNER_JAR,
            ],
            main=cls.RUNNER_MAIN,
            # TODO(John Sirois): Investigate how much less we can get away with.
            # Clearly both tests and the runner need access to the same @Test,
            # @Before, as well as other annotations, but there is also the Assert
            # class and some subset of the @Rules, @Theories and @RunWith APIs.
            custom_rules=[
                Shader.exclude_package('junit.framework', recursive=True),
                Shader.exclude_package('org.junit', recursive=True),
                Shader.exclude_package('org.hamcrest', recursive=True),
                Shader.exclude_package('org.pantsbuild.junit.annotations',
                                       recursive=True),
            ])

    @memoized_method
    def library_spec(self, buildgraph):
        """Returns a target spec for the junit library, useable as a dependency.

    :param pants.build_graph.build_graph.BuildGraph buildgraph: buildgraph object.
    :return: a target spec
    """
        junit_addr = Address.parse(self.get_options().junit_library)
        if not buildgraph.contains_address(junit_addr):
            buildgraph.inject_synthetic_target(junit_addr,
                                               JarLibrary,
                                               jars=[self._LIBRARY_JAR],
                                               scope='forced')
        return junit_addr.spec

    def runner_classpath(self, context):
        """Returns an iterable of classpath elements for the runner.
    """
        return self.tool_classpath_from_products(context.products, 'junit',
                                                 self.options_scope)
예제 #17
0
    def test_jars_field_order(self):
        jar1 = JarDependency('com', 'foo', '1.0.0')
        jar2 = JarDependency('org', 'baz')

        self.assertNotEqual(
            JarsField([jar1, jar2]).fingerprint(),
            JarsField([jar2, jar1]).fingerprint(),
        )
예제 #18
0
    def test_jars_with_different_classifiers_dont_hash_to_the_same_value(self):
        jar_dep_c1 = JarDependency('com.example',
                                   'dependency',
                                   classifier='c1')
        jar_dep_c2 = JarDependency('com.example',
                                   'dependency',
                                   classifier='c2')

        self.assertEqual(2, len({jar_dep_c1, jar_dep_c2}))
예제 #19
0
    def test_resolve_conflict_conflict(self):
        v1_force = JarDependency('org.example', 'foo', '1', force=True)
        v2_force = JarDependency('org.example', 'foo', '2', force=True)

        with self.assertRaises(IvyUtils.IvyResolveConflictingDepsError):
            IvyUtils._resolve_conflict(v1_force, v2_force)

        with self.assertRaises(IvyUtils.IvyResolveConflictingDepsError):
            IvyUtils._resolve_conflict(v2_force, v1_force)
예제 #20
0
    def test_jars_with_different_classifiers_are_not_equal(self):
        jar_dep_c1 = JarDependency('com.example',
                                   'dependency',
                                   classifier='c1')
        jar_dep_c2 = JarDependency('com.example',
                                   'dependency',
                                   classifier='c2')

        self.assertNotEqual(jar_dep_c1, jar_dep_c2)
예제 #21
0
    def test_jars_field_artifacts_arg_vs_method(self):
        jar1 = JarDependency('com',
                             'foo',
                             '1.0.0',
                             artifacts=[IvyArtifact('com', 'baz')])
        jar2 = JarDependency('com', 'foo', '1.0.0').with_artifact('com', 'baz')

        self.assertEqual(
            JarsField([jar1]).fingerprint(),
            JarsField([jar2]).fingerprint(),
        )
예제 #22
0
    def test_resolve_multiple_artifacts(self):
        no_classifier = JarDependency('junit', 'junit', rev='4.12')
        classifier = JarDependency('junit',
                                   'junit',
                                   rev='4.12',
                                   classifier='sources')

        no_classifier_lib = self.make_target('//:a',
                                             JarLibrary,
                                             jars=[no_classifier])
        classifier_lib = self.make_target('//:b',
                                          JarLibrary,
                                          jars=[classifier])
        classifier_and_no_classifier_lib = self.make_target(
            '//:c', JarLibrary, jars=[classifier, no_classifier])

        compile_classpath = self.resolve([
            no_classifier_lib, classifier_lib, classifier_and_no_classifier_lib
        ])
        no_classifier_cp = compile_classpath.get_classpath_entries_for_targets(
            [no_classifier_lib])
        classifier_cp = compile_classpath.get_classpath_entries_for_targets(
            [classifier_lib])
        classifier_and_no_classifier_cp = compile_classpath.get_classpath_entries_for_targets(
            classifier_and_no_classifier_lib.closure(bfs=True))

        self.assertIn(
            no_classifier.coordinate, {
                resolved_jar.coordinate
                for conf, resolved_jar in classifier_and_no_classifier_cp
            })
        self.assertIn(
            classifier.coordinate, {
                resolved_jar.coordinate
                for conf, resolved_jar in classifier_and_no_classifier_cp
            })

        self.assertNotIn(classifier.coordinate, {
            resolved_jar.coordinate
            for conf, resolved_jar in no_classifier_cp
        })
        self.assertIn(no_classifier.coordinate, {
            resolved_jar.coordinate
            for conf, resolved_jar in no_classifier_cp
        })

        self.assertNotIn(
            no_classifier.coordinate,
            {resolved_jar.coordinate
             for conf, resolved_jar in classifier_cp})
        self.assertIn(
            classifier.coordinate,
            {resolved_jar.coordinate
             for conf, resolved_jar in classifier_cp})
예제 #23
0
    def test_deprecated_jars_field_methods(self):
        """with_sources() and with_docs() are now no-ops.  This test shows they don't affect
    fingerprinting.
    """
        jar1 = (JarDependency('com', 'foo', '1.0.0'))
        jar2 = (JarDependency('com', 'foo',
                              '1.0.0').with_sources().with_docs())

        self.assertEqual(
            JarsField([jar1]).fingerprint(),
            JarsField([jar2]).fingerprint(),
        )
예제 #24
0
 def test_wire_compiler_version_conflict(self):
     george = self.make_target('3rdparty:george',
                               JarLibrary,
                               jars=[
                                   JarDependency('com.squareup.wire',
                                                 'wire-compiler', '3.0.0'),
                                   JarDependency('com.squareup.wire',
                                                 'wire-compiler', '1.6.0')
                               ])
     self.set_options(wire_compiler='3rdparty:george')
     task = self.create_task(self.context(target_roots=[george]))
     with self.assertRaises(task.WireCompilerVersionError):
         task.wire_compiler_version
예제 #25
0
 def test_duplicate_coord_error(self):
     management_target = self.make_target(
         spec='//foo:management',
         target_type=ManagedJarDependencies,
         artifacts=[
             JarDependency(org='foobar', name='foobar', rev='2'),
             JarDependency(org='foobar', name='foobar', rev='3'),
         ])
     context = self.context(target_roots=[management_target])
     with self._subsystem():
         task = self.create_task(context)
         with self.assertRaises(
                 JarDependencyManagementSetup.DuplicateCoordinateError):
             task.execute()
예제 #26
0
 def test_resolve_conflicted(self):
     # Create jar_libraries with different versions of the same dep: this will cause
     # a pre-ivy "eviction" in IvyUtils.generate_ivy, but the same case can be triggered
     # due to an ivy eviction where the declared version loses to a transitive version.
     losing_dep = JarDependency('com.google.guava', 'guava', '16.0')
     winning_dep = JarDependency('com.google.guava', 'guava', '16.0.1')
     losing_lib = self.make_target('//:a', JarLibrary, jars=[losing_dep])
     winning_lib = self.make_target('//:b', JarLibrary, jars=[winning_dep])
     # Confirm that the same artifact was added to each target.
     compile_classpath = self.resolve([losing_lib, winning_lib])
     losing_cp = compile_classpath.get_for_target(losing_lib)
     winning_cp = compile_classpath.get_for_target(winning_lib)
     self.assertEquals(losing_cp, winning_cp)
     self.assertEquals(1, len(winning_cp))
예제 #27
0
    def test_jars_field_apidocs(self):
        """apidocs are not properly rolled into the cache key right now.  Is this intentional?"""

        jar1 = JarDependency('com',
                             'foo',
                             '1.0.0',
                             apidocs='pantsbuild.github.io')
        jar2 = JarDependency('com',
                             'foo',
                             '1.0.0',
                             apidocs='someother.pantsbuild.github.io')

        self.assertEqual(
            JarsField([jar1]).fingerprint(),
            JarsField([jar2]).fingerprint(),
        )
예제 #28
0
 def __new__(cls,
             org,
             name,
             rev=None,
             force=False,
             ext=None,
             url=None,
             apidocs=None,
             classifier=None,
             mutable=None,
             intransitive=False,
             excludes=None):
     return JarDependency(
         org,
         name,
         rev=rev,
         force=force,
         ext=ext,
         url=url,
         apidocs=apidocs,
         classifier=classifier,
         mutable=mutable,
         intransitive=intransitive,
         excludes=cls._calc_excludes(org, name, excludes),
     )
예제 #29
0
파일: jar_tool.py 프로젝트: dbentley/pants
 def register_options(cls, register):
   super(JarTool, cls).register_options(register)
   cls.register_jvm_tool(register,
                         'jar-tool',
                         classpath=[
                           JarDependency(org='org.pantsbuild', name='jar-tool', rev='0.0.10'),
                         ])
예제 #30
0
    def test_get_resolved_jars_for_jar_library(self):
        ivy_info = self.parse_ivy_report(
            'ivy_utils_resources/report_with_diamond.xml')
        lib = self.make_target(spec=':org1-name1',
                               target_type=JarLibrary,
                               jars=[
                                   JarDependency(org='org1',
                                                 name='name1',
                                                 rev='0.0.1',
                                                 classifier='tests')
                               ])

        resolved_jars = ivy_info.get_resolved_jars_for_jar_library(lib)

        expected = {
            'ivy2cache_path/org1/name1.jar':
            coord(org='org1', name='name1', classifier='tests'),
            'ivy2cache_path/org2/name2.jar':
            coord(org='org2', name='name2'),
            'ivy2cache_path/org3/name3.tar.gz':
            coord(org='org3', name='name3', ext='tar.gz')
        }
        self.maxDiff = None
        coordinate_by_path = {
            rj.cache_path: rj.coordinate
            for rj in resolved_jars
        }
        self.assertEqual(expected, coordinate_by_path)
예제 #31
0
파일: scalafmt.py 프로젝트: xeno-by/pants
 def register_options(cls, register):
     super(ScalaFmt, cls).register_options(register)
     register('--skip',
              type=bool,
              fingerprint=False,
              help='Skip Scalafmt Check')
     register(
         '--configuration',
         advanced=True,
         type=file_option,
         fingerprint=False,
         help=
         'Path to scalafmt config file, if not specified default scalafmt config used'
     )
     register('--target-types',
              default={'scala_library', 'junit_tests', 'java_tests'},
              advanced=True,
              type=set,
              help='The target types to apply formatting to.')
     cls.register_jvm_tool(register,
                           'scalafmt',
                           classpath=[
                               JarDependency(org='com.geirsson',
                                             name='scalafmt-cli_2.11',
                                             rev='0.2.11')
                           ])