Example #1
0
    def test_if_not_all_symlinked_files_exist_after_successful_fetch_fail(self):
        fetch = IvyFetchStep(["default"], "hash_name", False, None, "ivy_cache_dir", "global_ivy_workdir")

        # Stub resolving and creating the result, returning one missing artifacts.
        fetch._do_fetch = do_nothing
        fetch._load_from_fetch = return_resolve_result_missing_artifacts

        with self.assertRaises(IvyResolveMappingError):
            fetch.exec_and_load(None, None, [], None, None, None)
Example #2
0
  def test_if_not_all_hardlinked_files_exist_after_successful_fetch_fail(self):
    fetch = IvyFetchStep(['default'],
                         'hash_name',
                         False,
                         None,
                         'ivy_resolution_cache_dir',
                         'ivy_repository_cache_dir',
                         'ivy_workdir')

    # Stub resolving and creating the result, returning one missing artifacts.
    fetch._do_fetch = do_nothing
    fetch._load_from_fetch = return_resolve_result_missing_artifacts

    with self.assertRaises(IvyResolveMappingError):
      fetch.exec_and_load(None, None, [], None, None, None)
Example #3
0
 def _create_ivy_fetch_step(self,
                            confs,
                            resolve_hash_name,
                            pinned_artifacts,
                            soft_excludes,
                            ivy_cache_dir,
                            global_ivy_workdir):
   return IvyFetchStep(confs,
                       resolve_hash_name,
                       pinned_artifacts,
                       soft_excludes,
                       ivy_cache_dir,
                       global_ivy_workdir)
Example #4
0
    def test_if_not_all_symlinked_files_exist_after_successful_fetch_fail(
            self):
        fetch = IvyFetchStep(['default'], 'hash_name', False, None,
                             'ivy_cache_dir', 'global_ivy_workdir')

        # Stub resolving and creating the result, returning one missing artifacts.
        fetch._do_fetch = do_nothing
        fetch._load_from_fetch = return_resolve_result_missing_artifacts

        with self.assertRaises(IvyResolveMappingError):
            fetch.exec_and_load(None, None, [], None, None, None)
Example #5
0
    def test_if_not_all_hardlinked_files_exist_after_successful_fetch_fail(self):
        fetch = IvyFetchStep(
            ["default"],
            "hash_name",
            False,
            None,
            "ivy_resolution_cache_dir",
            "ivy_repository_cache_dir",
            "ivy_workdir",
        )

        # Stub resolving and creating the result, returning one missing artifacts.
        fetch._do_fetch = do_nothing
        fetch._load_from_fetch = return_resolve_result_missing_artifacts

        with self.assertRaises(IvyResolveMappingError):
            fetch.exec_and_load(None, None, [], None, None, None)
Example #6
0
  def _ivy_resolve(self,
                   targets,
                   executor=None,
                   silent=False,
                   workunit_name=None,
                   confs=None,
                   extra_args=None,
                   invalidate_dependents=False,
                   pinned_artifacts=None):
    """Resolves external dependencies for the given targets.

    If there are no targets suitable for jvm transitive dependency resolution, an empty result is
    returned.

    :param targets: The targets to resolve jvm dependencies for.
    :type targets: :class:`collections.Iterable` of :class:`pants.build_graph.target.Target`
    :param executor: A java executor to run ivy with.
    :type executor: :class:`pants.java.executor.Executor`

    :param confs: The ivy configurations to resolve; ('default',) by default.
    :type confs: :class:`collections.Iterable` of string
    :param extra_args: Any extra command line arguments to pass to ivy.
    :type extra_args: list of string
    :param bool invalidate_dependents: `True` to invalidate dependents of targets that needed to be
                                        resolved.
    :returns: The result of the resolve.
    :rtype: IvyResolveResult
    """
    # If there are no targets, we don't need to do a resolve.
    if not targets:
      return NO_RESOLVE_RUN_RESULT

    confs = confs or ('default',)

    fingerprint_strategy = IvyResolveFingerprintStrategy(confs)

    with self.invalidated(targets,
                          invalidate_dependents=invalidate_dependents,
                          silent=silent,
                          fingerprint_strategy=fingerprint_strategy) as invalidation_check:
      # In case all the targets were filtered out because they didn't participate in fingerprinting.
      if not invalidation_check.all_vts:
        return NO_RESOLVE_RUN_RESULT

      resolve_vts = VersionedTargetSet.from_versioned_targets(invalidation_check.all_vts)

      resolve_hash_name = resolve_vts.cache_key.hash
      # NB: This used to be a global directory, but is now specific to each task that includes
      # this mixin.
      ivy_workdir = os.path.join(self.versioned_workdir, 'ivy')
      targets = resolve_vts.targets

      fetch = IvyFetchStep(confs,
                           resolve_hash_name,
                           pinned_artifacts,
                           self.get_options().soft_excludes,
                           self.ivy_resolution_cache_dir,
                           self.ivy_repository_cache_dir,
                           ivy_workdir)
      resolve = IvyResolveStep(confs,
                               resolve_hash_name,
                               pinned_artifacts,
                               self.get_options().soft_excludes,
                               self.ivy_resolution_cache_dir,
                               self.ivy_repository_cache_dir,
                               ivy_workdir)

      return self._perform_resolution(fetch, resolve, executor, extra_args, invalidation_check,
                                      resolve_vts, targets, workunit_name)