def exec_ivy(self, target_workdir, targets, args, confs=None, ivy=None, workunit_name='ivy', workunit_factory=None, symlink_ivyxml=False): ivy = ivy or Bootstrapper.default_ivy() if not isinstance(ivy, Ivy): raise ValueError( 'The ivy argument supplied must be an Ivy instance, given %s of type %s' % (ivy, type(ivy))) ivyxml = os.path.join(target_workdir, 'ivy.xml') jars, excludes = self._calculate_classpath(targets) ivy_args = ['-ivy', ivyxml] confs_to_resolve = confs or ['default'] ivy_args.append('-confs') ivy_args.extend(confs_to_resolve) ivy_args.extend(args) if not self._transitive: ivy_args.append('-notransitive') ivy_args.extend(self._args) def safe_link(src, dest): if os.path.exists(dest): os.unlink(dest) os.symlink(src, dest) with IvyUtils.ivy_lock: self._generate_ivy(targets, jars, excludes, ivyxml, confs_to_resolve) runner = ivy.runner(jvm_options=self._jvm_options, args=ivy_args) try: result = util.execute_runner(runner, workunit_factory=workunit_factory, workunit_name=workunit_name) # Symlink to the current ivy.xml file (useful for IDEs that read it). if symlink_ivyxml: ivyxml_symlink = os.path.join(self._work_dir, 'ivy.xml') safe_link(ivyxml, ivyxml_symlink) if result != 0: raise TaskError('Ivy returned %d' % result) except runner.executor.Error as e: raise TaskError(e)
def exec_ivy(self, target_workdir, targets, args, confs=None, ivy=None, workunit_name='ivy', workunit_factory=None, symlink_ivyxml=False): ivy = ivy or Bootstrapper.default_ivy() if not isinstance(ivy, Ivy): raise ValueError('The ivy argument supplied must be an Ivy instance, given %s of type %s' % (ivy, type(ivy))) ivyxml = os.path.join(target_workdir, 'ivy.xml') jars, excludes = self._calculate_classpath(targets) ivy_args = ['-ivy', ivyxml] confs_to_resolve = confs or ['default'] ivy_args.append('-confs') ivy_args.extend(confs_to_resolve) ivy_args.extend(args) if not self._transitive: ivy_args.append('-notransitive') ivy_args.extend(self._args) def safe_link(src, dest): if os.path.exists(dest): os.unlink(dest) os.symlink(src, dest) with IvyUtils.ivy_lock: self._generate_ivy(targets, jars, excludes, ivyxml, confs_to_resolve) runner = ivy.runner(jvm_options=self._jvm_options, args=ivy_args) try: result = util.execute_runner(runner, workunit_factory=workunit_factory, workunit_name=workunit_name) # Symlink to the current ivy.xml file (useful for IDEs that read it). if symlink_ivyxml: ivyxml_symlink = os.path.join(self._work_dir, 'ivy.xml') safe_link(ivyxml, ivyxml_symlink) if result != 0: raise TaskError('Ivy returned %d' % result) except runner.executor.Error as e: raise TaskError(e)
def execute(self, jvm_options=None, args=None, executor=None, workunit_factory=None, workunit_name=None, workunit_labels=None): """Executes the ivy commandline client with the given args. Raises Ivy.Error if the command fails for any reason. """ runner = self.runner(jvm_options=jvm_options, args=args, executor=executor) try: result = util.execute_runner(runner, workunit_factory, workunit_name, workunit_labels) if result != 0: raise self.Error('Ivy command failed with exit code %d%s' % (result, ': ' + ' '.join(args) if args else '')) except self._java.Error as e: raise self.Error('Problem executing ivy: %s' % e)