def setUp(self):
     super(JvmPrepCommandTest, self).setUp()
     # This is normally taken care of in RunJvmPrepCommandBase.register_options() when running pants,
     # but these don't get called in testing unless you call `self.create_task()`.
     # Some of these unit tests need to create targets before creating the task.
     JvmPrepCommand.add_goal('test')
     JvmPrepCommand.add_goal('binary')
예제 #2
0
 def setUp(self):
   super(JvmPrepCommandTest, self).setUp()
   # This is normally taken care of in RunJvmPrepCommandBase.register_options() when running pants,
   # but these don't get called in testing unless you call `self.create_task()`.
   # Some of these unit tests need to create targets before creating the task.
   JvmPrepCommand.add_goal('test')
   JvmPrepCommand.add_goal('binary')
예제 #3
0
    def register_options(cls, register):
        """Register options for this optionable.

    In this case, there are no special options, but we want to use this opportunity to setup
    goal validation in JvmPrepCommand before the build graph is parsed.
    """
        super(RunJvmPrepCommandBase, cls).register_options(register)
        JvmPrepCommand.add_goal(cls.goal)
예제 #4
0
  def register_options(cls, register):
    """Register options for this optionable.

    In this case, there are no special options, but we want to use this opportunity to setup
    goal validation in JvmPrepCommand before the build graph is parsed.
    """
    super(RunJvmPrepCommandBase, cls).register_options(register)
    JvmPrepCommand.add_goal(cls.goal)
예제 #5
0
    def execute(self):
        if self.goal not in JvmPrepCommand.goals():
            raise AssertionError(
                'Got goal "{}". Expected goal to be one of {}'.format(
                    self.goal, JvmPrepCommand.goals()))

        targets = self.context.targets(postorder=True,
                                       predicate=self.runnable_prep_cmd)

        compile_classpath = self.context.products.get_data('compile_classpath')
        classpath_products = self.context.products.get_data(
            'runtime_classpath', compile_classpath.copy)

        with self.context.new_workunit(name='jvm_prep_command',
                                       labels=[WorkUnitLabel.PREP
                                               ]) as workunit:
            for target in targets:
                distribution = JvmPlatform.preferred_jvm_distribution(
                    [target.platform])
                executor = SubprocessExecutor(distribution)

                mainclass = target.payload.get_field_value('mainclass')
                args = target.payload.get_field_value('args', [])
                target_jvm_options = target.payload.get_field_value(
                    'jvm_options', [])
                cp = list(
                    ClasspathUtil.classpath(target.closure(),
                                            classpath_products))
                if not cp:
                    raise TaskError(
                        'target {} has no classpath. (Add dependencies= parameter?'
                        .format(target.address.spec))
                self.context.log.info('Running prep command for {}'.format(
                    target.address.spec))
                returncode = distribution.execute_java(
                    executor=executor,
                    classpath=cp,
                    main=mainclass,
                    jvm_options=target_jvm_options,
                    args=args,
                    workunit_factory=self.context.new_workunit,
                    workunit_name='run',
                    workunit_labels=[WorkUnitLabel.PREP],
                )

                workunit.set_outcome(
                    WorkUnit.FAILURE if returncode else WorkUnit.SUCCESS)
                if returncode:
                    raise TaskError(
                        'RunJvmPrepCommand failed to run {}'.format(mainclass))
예제 #6
0
  def execute(self):
    if self.goal not in JvmPrepCommand.goals():
      raise  AssertionError('Got goal "{}". Expected goal to be one of {}'.format(
          self.goal, JvmPrepCommand.goals()))

    targets = self.context.targets(postorder=True,  predicate=self.runnable_prep_cmd)

    compile_classpath = self.context.products.get_data('compile_classpath')
    classpath_products = self.context.products.get_data('runtime_classpath', compile_classpath.copy)

    with self.context.new_workunit(name='jvm_prep_command', labels=[WorkUnitLabel.PREP]) as workunit:
      for target in targets:
        distribution = JvmPlatform.preferred_jvm_distribution([target.platform])
        executor = SubprocessExecutor(distribution)

        mainclass = target.payload.get_field_value('mainclass')
        args = target.payload.get_field_value('args', [])
        target_jvm_options = target.payload.get_field_value('jvm_options', [])
        cp = list(ClasspathUtil.classpath(target.closure(), classpath_products))
        if not cp:
          raise TaskError('target {} has no classpath. (Add dependencies= parameter?'
                          .format(target.address.spec))
        self.context.log.info('Running prep command for {}'.format(target.address.spec))
        returncode = distribution.execute_java(
          executor=executor,
          classpath=cp,
          main=mainclass,
          jvm_options=target_jvm_options,
          args=args,
          workunit_factory=self.context.new_workunit,
          workunit_name='run',
          workunit_labels=[WorkUnitLabel.PREP],
        )

        workunit.set_outcome(WorkUnit.FAILURE if returncode else WorkUnit.SUCCESS)
        if returncode:
          raise TaskError('RunJvmPrepCommand failed to run {}'.format(mainclass))
예제 #7
0
def register_goals():
   JvmPrepCommand.add_goal('jooq')
   task(name='jooq-jvm-prep-command', action=RunJooqJvmPrepCommand).install('jooq', first=True)
예제 #8
0
 def tearDown(self):
   JvmPrepCommand.reset()
 def goals():
   return list(JvmPrepCommand.goals() + ['jooq'])
예제 #10
0
 def __init__(self, context, workdir):
     super(RunJvmPrepCommandBase, self).__init__(context, workdir)
     JvmPrepCommand.add_goal(self.goal)
예제 #11
0
 def tearDown(self):
     JvmPrepCommand.reset()
예제 #12
0
 def __init__(self, context, workdir):
   super(RunJvmPrepCommandBase, self).__init__(context, workdir)
   JvmPrepCommand.add_goal(self.goal)
예제 #13
0
 def goals():
     return list(JvmPrepCommand.goals() + ['jooq'])
예제 #14
0
 def setUp(self):
   super (JvmPrepCommandTest, self).setUp()
   # This is normally taken care of in RunJvmPrepCommandBase.register_options() when running pants,
   # but needs to be manually added for unit testing
   JvmPrepCommand.add_goal('test')
   JvmPrepCommand.add_goal('binary')
예제 #15
0
def register_goals():
    JvmPrepCommand.add_goal('jooq')
    task(name='jooq-jvm-prep-command',
         action=RunJooqJvmPrepCommand).install('jooq', first=True)