コード例 #1
0
  def test_validate_live(self):
    with pytest.raises(Distribution.Error):
      Distribution(bin_path=os.path.dirname(self.JAVA), minimum_version='999.9.9').validate()

    Distribution(bin_path=os.path.dirname(self.JAVA)).validate()
    Distribution(bin_path=os.path.dirname(self.JAVA), minimum_version='1.3.1').validate()
    Distribution.locate(jdk=False)
コード例 #2
0
ファイル: test_distribution.py プロジェクト: ejconlon/pants
    def test_validated_binary(self):
        with pytest.raises(Distribution.Error):
            with self.distribution(files='jar',
                                   executables=self.exe('java')) as jdk:
                Distribution(bin_path=jdk).binary('jar')

        with self.distribution(executables=[self.exe('java'),
                                            self.exe('jar')]) as jdk:
            Distribution(bin_path=jdk).binary('jar')
コード例 #3
0
ファイル: test_distribution.py プロジェクト: ejconlon/pants
    def test_validate_jdk(self):
        with pytest.raises(Distribution.Error):
            with self.distribution(executables=self.exe('java')) as jdk:
                Distribution(bin_path=jdk, jdk=True).validate()

        with self.distribution(
                executables=[self.exe('java'),
                             self.exe('javac')]) as jdk:
            Distribution(bin_path=jdk, jdk=True).validate()
コード例 #4
0
ファイル: test_distribution.py プロジェクト: ejconlon/pants
    def test_validate_basic(self):
        with pytest.raises(Distribution.Error):
            with self.distribution() as jdk:
                Distribution(bin_path=jdk).validate()

        with pytest.raises(Distribution.Error):
            with self.distribution(files='java') as jdk:
                Distribution(bin_path=jdk).validate()

        with self.distribution(executables=self.exe('java')) as jdk:
            Distribution(bin_path=jdk).validate()
コード例 #5
0
ファイル: test_distribution.py プロジェクト: ejconlon/pants
    def test_validate_version(self):
        with pytest.raises(Distribution.Error):
            with self.distribution(
                    executables=self.exe('java', '1.7.0_25')) as jdk:
                Distribution(bin_path=jdk,
                             minimum_version='1.7.0_45').validate()
        with pytest.raises(Distribution.Error):
            with self.distribution(
                    executables=self.exe('java', '1.8.0_1')) as jdk:
                Distribution(bin_path=jdk,
                             maximum_version='1.7.9999').validate()

        with self.distribution(
                executables=self.exe('java', '1.7.0_25')) as jdk:
            Distribution(bin_path=jdk, minimum_version='1.7.0_25').validate()
            Distribution(bin_path=jdk,
                         minimum_version=Revision.semver('1.6.0')).validate()
            Distribution(bin_path=jdk,
                         minimum_version='1.7.0_25',
                         maximum_version='1.7.999').validate()
コード例 #6
0
ファイル: jaxb_gen.py プロジェクト: aoen/pants
 def __init__(self, context, workdir):
   """
   :param context: inherited parameter from Task
   :param workdir: inherited parameter from Task
   """
   super(JaxbGen, self).__init__(context, workdir)
   self.gen_langs = set()
   lang = 'java'
   if self.context.products.isrequired(lang):
     self.gen_langs.add(lang)
   self.jar_location = os.path.join(Distribution.cached().home, '..', 'lib', 'tools.jar')
コード例 #7
0
 def __init__(self, context, workdir):
     """
 :param context: inherited parameter from Task
 :param workdir: inherited parameter from Task
 """
     super(JaxbGen, self).__init__(context, workdir)
     self.gen_langs = set()
     lang = 'java'
     if self.context.products.isrequired(lang):
         self.gen_langs.add(lang)
     self.jar_location = os.path.join(Distribution.cached().home, '..',
                                      'lib', 'tools.jar')
コード例 #8
0
ファイル: nailgun_task.py プロジェクト: ejconlon/pants
  def __init__(self, context, workdir, minimum_version=None, maximum_version=None, jdk=False):
    super(NailgunTask, self).__init__(context, workdir)
    self._executor_workdir = os.path.join(context.config.getdefault('pants_workdir'), 'ng',
                                          self.__class__.__name__)
    self._nailgun_bootstrap_key = 'nailgun'
    self.register_jvm_tool(self._nailgun_bootstrap_key, [':nailgun-server'])

    with self.context.new_workunit(name='jvm-locate'):
      try:
        self._dist = Distribution.cached(minimum_version=minimum_version,
                                         maximum_version=maximum_version, jdk=jdk)
      except Distribution.Error as e:
        raise TaskError(e)
コード例 #9
0
ファイル: executor.py プロジェクト: Docworld/pants
  def __init__(self, distribution=None):
    """Constructs an Executor that can be used to launch java programs.

    :param distribution: an optional validated java distribution to use when launching java
      programs
    """
    if distribution:
      if not isinstance(distribution, Distribution):
        raise ValueError('A valid distribution is required, given: %s' % distribution)
      distribution.validate()
    else:
      distribution = Distribution.cached()

    self._distribution = distribution
コード例 #10
0
ファイル: test_distribution.py プロジェクト: ejconlon/pants
    def test_validate_live(self):
        with pytest.raises(Distribution.Error):
            Distribution(bin_path=os.path.dirname(self.JAVA),
                         minimum_version='999.9.9').validate()
        with pytest.raises(Distribution.Error):
            Distribution(bin_path=os.path.dirname(self.JAVA),
                         maximum_version='0.0.1').validate()

        Distribution(bin_path=os.path.dirname(self.JAVA)).validate()
        Distribution(bin_path=os.path.dirname(self.JAVA),
                     minimum_version='1.3.1').validate()
        Distribution(bin_path=os.path.dirname(self.JAVA),
                     maximum_version='999.999.999').validate()
        Distribution(bin_path=os.path.dirname(self.JAVA),
                     minimum_version='1.3.1',
                     maximum_version='999.999.999').validate()
        Distribution.locate(jdk=False)
コード例 #11
0
ファイル: executor.py プロジェクト: ejconlon/pants
    def __init__(self, distribution=None):
        """Constructs an Executor that can be used to launch java programs.

    :param distribution: an optional validated java distribution to use when launching java
      programs
    """
        if distribution:
            if not isinstance(distribution, Distribution):
                raise ValueError(
                    'A valid distribution is required, given: %s' %
                    distribution)
            distribution.validate()
        else:
            distribution = Distribution.cached()

        self._distribution = distribution
コード例 #12
0
ファイル: nailgun_task.py プロジェクト: govindkabra/pants
  def __init__(self, context, minimum_version=None, jdk=False):
    super(NailgunTask, self).__init__(context)

    default_workdir_root = os.path.join(context.config.getdefault('pants_workdir'), 'ng')
    self._workdir = os.path.join(
        context.config.get('nailgun', 'workdir', default=default_workdir_root),
        self.__class__.__name__)

    self._nailgun_bootstrap_key = 'nailgun'
    self._jvm_tool_bootstrapper.register_jvm_tool(self._nailgun_bootstrap_key, [':nailgun-server'])

    start = time.time()
    try:
      self._dist = Distribution.cached(minimum_version=minimum_version, jdk=jdk)
      # TODO(John Sirois): Use a context timer when AWESOME-1265 gets merged.
      context.log.debug('Located java distribution in %.3fs' % (time.time() - start))
    except Distribution.Error as e:
      raise TaskError(e)
コード例 #13
0
ファイル: nailgun_task.py プロジェクト: ejconlon/pants
    def __init__(self,
                 context,
                 workdir,
                 minimum_version=None,
                 maximum_version=None,
                 jdk=False):
        super(NailgunTask, self).__init__(context, workdir)
        self._executor_workdir = os.path.join(
            context.config.getdefault('pants_workdir'), 'ng',
            self.__class__.__name__)
        self._nailgun_bootstrap_key = 'nailgun'
        self.register_jvm_tool(self._nailgun_bootstrap_key,
                               [':nailgun-server'])

        with self.context.new_workunit(name='jvm-locate'):
            try:
                self._dist = Distribution.cached(
                    minimum_version=minimum_version,
                    maximum_version=maximum_version,
                    jdk=jdk)
            except Distribution.Error as e:
                raise TaskError(e)
コード例 #14
0
ファイル: test_distribution.py プロジェクト: ejconlon/pants
    def test_locate(self):
        @contextmanager
        def env(**kwargs):
            environment = dict(JDK_HOME=None, JAVA_HOME=None, PATH=None)
            environment.update(**kwargs)
            with environment_as(**environment):
                yield

        with pytest.raises(Distribution.Error):
            with env():
                Distribution.locate()

        with pytest.raises(Distribution.Error):
            with self.distribution(files='java') as jdk:
                with env(PATH=jdk):
                    Distribution.locate()

        with pytest.raises(Distribution.Error):
            with self.distribution(executables=self.exe('java')) as jdk:
                with env(PATH=jdk):
                    Distribution.locate(jdk=True)

        with pytest.raises(Distribution.Error):
            with self.distribution(
                    executables=self.exe('java', '1.6.0')) as jdk:
                with env(PATH=jdk):
                    Distribution.locate(minimum_version='1.7.0')
            with self.distribution(
                    executables=self.exe('java', '1.8.0')) as jdk:
                with env(PATH=jdk):
                    Distribution.locate(maximum_version='1.7.999')

        with pytest.raises(Distribution.Error):
            with self.distribution(executables=self.exe('java')) as jdk:
                with env(JDK_HOME=jdk):
                    Distribution.locate()

        with pytest.raises(Distribution.Error):
            with self.distribution(executables=self.exe('java')) as jdk:
                with env(JAVA_HOME=jdk):
                    Distribution.locate()

        with self.distribution(executables=self.exe('java')) as jdk:
            with env(PATH=jdk):
                Distribution.locate()

        with self.distribution(
                executables=[self.exe('java'),
                             self.exe('javac')]) as jdk:
            with env(PATH=jdk):
                Distribution.locate(jdk=True)

        with self.distribution(executables=self.exe('java', '1.7.0')) as jdk:
            with env(PATH=jdk):
                Distribution.locate(minimum_version='1.6.0')
            with env(PATH=jdk):
                Distribution.locate(maximum_version='1.7.999')
            with env(PATH=jdk):
                Distribution.locate(minimum_version='1.6.0',
                                    maximum_version='1.7.999')

        with self.distribution(executables=self.exe('bin/java')) as jdk:
            with env(JDK_HOME=jdk):
                Distribution.locate()

        with self.distribution(executables=self.exe('bin/java')) as jdk:
            with env(JAVA_HOME=jdk):
                Distribution.locate()
コード例 #15
0
 def test_validate_live_jdk(self):
   Distribution(bin_path=os.path.dirname(self.JAVAC), jdk=True).validate()
   Distribution(bin_path=os.path.dirname(self.JAVAC), jdk=True).binary('javap')
   Distribution.locate(jdk=True)
コード例 #16
0
ファイル: test_distribution.py プロジェクト: ejconlon/pants
 def test_validate_live_jdk(self):
     Distribution(bin_path=os.path.dirname(self.JAVAC), jdk=True).validate()
     Distribution(bin_path=os.path.dirname(self.JAVAC),
                  jdk=True).binary('javap')
     Distribution.locate(jdk=True)
コード例 #17
0
  def test_locate(self):
    @contextmanager
    def env(**kwargs):
      environment = dict(JDK_HOME=None, JAVA_HOME=None, PATH=None)
      environment.update(**kwargs)
      with environment_as(**environment):
        yield

    with pytest.raises(Distribution.Error):
      with env():
        Distribution.locate()

    with pytest.raises(Distribution.Error):
      with self.distribution(files='java') as jdk:
        with env(PATH=jdk):
          Distribution.locate()

    with pytest.raises(Distribution.Error):
      with self.distribution(executables=self.exe('java')) as jdk:
        with env(PATH=jdk):
          Distribution.locate(jdk=True)

    with pytest.raises(Distribution.Error):
      with self.distribution(executables=self.exe('java', '1.6.0')) as jdk:
        with env(PATH=jdk):
          Distribution.locate(minimum_version='1.7.0')

    with pytest.raises(Distribution.Error):
      with self.distribution(executables=self.exe('java')) as jdk:
        with env(JDK_HOME=jdk):
          Distribution.locate()

    with pytest.raises(Distribution.Error):
      with self.distribution(executables=self.exe('java')) as jdk:
        with env(JAVA_HOME=jdk):
          Distribution.locate()

    with self.distribution(executables=self.exe('java')) as jdk:
      with env(PATH=jdk):
        Distribution.locate()

    with self.distribution(executables=[self.exe('java'), self.exe('javac')]) as jdk:
      with env(PATH=jdk):
        Distribution.locate(jdk=True)

    with self.distribution(executables=self.exe('java', '1.7.0')) as jdk:
      with env(PATH=jdk):
        Distribution.locate(minimum_version='1.6.0')

    with self.distribution(executables=self.exe('bin/java')) as jdk:
      with env(JDK_HOME=jdk):
        Distribution.locate()

    with self.distribution(executables=self.exe('bin/java')) as jdk:
      with env(JAVA_HOME=jdk):
        Distribution.locate()