Ejemplo n.º 1
0
    def setUp(self):
        super(BaseGroupTaskTest, self).setUp()
        self.set_options_for_scope('test.RecordingGroupMember',
                                   level='info',
                                   colors='False')

        self.maxDiff = None

        self.recorded_actions = []
        # NB: GroupTask has a cache of tasks by name... use a distinct name
        self.group_task = GroupTask.named(name='jvm-compile-{}'.format(
            uuid.uuid4().hex),
                                          product_type=['runtime_classpath'],
                                          flag_namespace=['test'])

        javac = self.group_member(
            name='javac', selector=lambda t: isinstance(t, self.JavaLibrary))
        self.group_task.add_member(javac)

        scalac = self.group_member(
            name='scalac', selector=lambda t: isinstance(t, self.ScalaLibrary))
        self.group_task.add_member(scalac)

        self._context = self.context(target_roots=self.create_targets(),
                                     for_task_types=[self.group_task])
        self.group_task._prepare(self.options,
                                 round_manager=RoundManager(self._context))

        self.task = self.group_task(self._context, workdir='/not/real')
        self.task.execute()
Ejemplo n.º 2
0
    def setUp(self):
        super(BaseGroupTaskTest, self).setUp()
        self.set_options_for_scope('test.RecordingGroupMember',
                                   level='info',
                                   colors='False')

        self.maxDiff = None

        self._context = self.context(target_roots=self.create_targets())

        self.populate_compile_classpath(self._context)

        self.recorded_actions = []
        # NB: GroupTask has a cache of tasks by name... use a distinct name
        self.group_task = GroupTask.named(
            'jvm-compile-%s' % uuid.uuid4().hex,
            ['classes_by_target', 'classes_by_source'], ['test'])

        javac = self.group_member(
            name='javac', selector=lambda t: isinstance(t, self.JavaLibrary))
        self.group_task.add_member(javac)

        scalac = self.group_member(
            name='scalac', selector=lambda t: isinstance(t, self.ScalaLibrary))
        self.group_task.add_member(scalac)

        self.group_task._prepare(self.options,
                                 round_manager=RoundManager(self._context))

        self.task = self.group_task(self._context, workdir='/not/real')
        self.task.execute()
Ejemplo n.º 3
0
  def setUp(self):
    super(BaseGroupTaskTest, self).setUp()
    self.set_options_for_scope('test.RecordingGroupMember', level='info', colors='False')

    self.maxDiff = None

    self.recorded_actions = []
    # NB: GroupTask has a cache of tasks by name... use a distinct name
    self.group_task = GroupTask.named('jvm-compile-%s' % uuid.uuid4().hex,
                                      ['classes_by_target', 'classes_by_source'],
                                      ['test'])

    javac = self.group_member(name='javac', selector=lambda t: isinstance(t, self.JavaLibrary))
    self.group_task.add_member(javac)

    scalac = self.group_member(name='scalac', selector=lambda t: isinstance(t, self.ScalaLibrary))
    self.group_task.add_member(scalac)

    self._context = self.context(target_roots=self.create_targets(),
                                 for_task_types=[self.group_task])
    self.populate_compile_classpath(self._context)
    self.group_task._prepare(self.options, round_manager=RoundManager(self._context))


    self.task = self.group_task(self._context, workdir='/not/real')
    self.task.execute()
Ejemplo n.º 4
0
    def test_groups(self):
        group_task = GroupTask.named('jvm-compile', 'classes')
        group_task.add_member(self.group_member('javac', lambda t: t.is_java))
        group_task.add_member(self.group_member('scalac',
                                                lambda t: t.is_scala))

        task = group_task(self._context, workdir='/not/real')
        task.prepare()
        task.execute()

        # These items will be executed by GroupTask in order.
        expected_prepare_actions = [
            self.construct_action('javac'),
            self.prepare_action('javac'),
            self.construct_action('scalac'),
            self.prepare_action('scalac')
        ]

        # The ordering of the execution of these items isn't guaranteed:
        #
        #  https://groups.google.com/d/msg/pants-devel/Rer9_ytsyf8/gi8zokWNexYJ
        #
        # So we store these separately, to do a special comparison later on.
        expected_prepare_execute_actions = [
            self.prepare_execute_action('javac',
                                        [[self.a], [self.c], [self.e]]),
            self.prepare_execute_action('scalac', [[self.b], [self.d]])
        ]

        expected_execute_actions = [
            self.execute_chunk_action('javac', targets=[self.a]),
            self.execute_chunk_action('scalac', targets=[self.b]),
            self.execute_chunk_action('javac', targets=[self.c]),
            self.execute_chunk_action('scalac', targets=[self.d]),
            self.execute_chunk_action('javac', targets=[self.e]),
            self.post_execute_action('javac'),
            self.post_execute_action('scalac')
        ]

        recorded_iter = iter(self.recorded_actions)

        # Now, we compare the list of actions executed, with what we expected, in chunks. We first peel
        # off the first 4 items from what was executed, and compare with the "expected_prepare_actions"
        # list.
        actual_prepare_actions = list(
            itertools.islice(recorded_iter, len(expected_prepare_actions)))
        self.assertEqual(expected_prepare_actions, actual_prepare_actions)

        # Next, we slice off the next two elements from the array, store them separately, sort both the
        # recorded elements and the expected elements, and compare.
        actual_prepare_execute_actions = list(
            itertools.islice(recorded_iter,
                             len(expected_prepare_execute_actions)))
        self.assertEqual(sorted(expected_prepare_execute_actions),
                         sorted(actual_prepare_execute_actions))

        # Finally, compare the remaining items.
        self.assertEqual(expected_execute_actions, list(recorded_iter))
Ejemplo n.º 5
0
  def test_groups(self):
    group_task = GroupTask.named('jvm-compile', 'classes')
    group_task.add_member(self.group_member('javac', lambda t: t.is_java))
    group_task.add_member(self.group_member('scalac', lambda t: t.is_scala))

    task = group_task(self._context, workdir='/not/real')
    task.prepare()
    task.execute()

    # These items will be executed by GroupTask in order.
    expected_prepare_actions = [self.construct_action('javac'),
        self.prepare_action('javac'),
        self.construct_action('scalac'),
        self.prepare_action('scalac')]

    # The ordering of the execution of these items isn't guaranteed:
    #
    #  https://groups.google.com/d/msg/pants-devel/Rer9_ytsyf8/gi8zokWNexYJ
    #
    # So we store these separately, to do a special comparison later on.
    expected_prepare_execute_actions = [
        self.prepare_execute_action('javac', [[self.a], [self.c], [self.e]]),
        self.prepare_execute_action('scalac', [[self.b], [self.d]])
    ]

    expected_execute_actions = [self.execute_chunk_action('javac', targets=[self.a]),
        self.execute_chunk_action('scalac', targets=[self.b]),
        self.execute_chunk_action('javac', targets=[self.c]),
        self.execute_chunk_action('scalac', targets=[self.d]),
        self.execute_chunk_action('javac', targets=[self.e]),
        self.post_execute_action('javac'),
        self.post_execute_action('scalac')]

    recorded_iter = iter(self.recorded_actions)

    # Now, we compare the list of actions executed, with what we expected, in chunks. We first peel
    # off the first 4 items from what was executed, and compare with the "expected_prepare_actions"
    # list.
    actual_prepare_actions = list(itertools.islice(recorded_iter, len(expected_prepare_actions)))
    self.assertEqual(expected_prepare_actions, actual_prepare_actions)

    # Next, we slice off the next two elements from the array, store them separately, sort both the
    # recorded elements and the expected elements, and compare.
    actual_prepare_execute_actions = list(itertools.islice(recorded_iter, len(expected_prepare_execute_actions)))
    self.assertEqual(sorted(expected_prepare_execute_actions), sorted(actual_prepare_execute_actions))

    # Finally, compare the remaining items.
    self.assertEqual(expected_execute_actions, list(recorded_iter))
Ejemplo n.º 6
0
  def setUp(self):
    super(BaseGroupTaskTest, self).setUp()
    self._context = self.context(target_roots=self.create_targets())

    self.populate_compile_classpath(self._context)

    self.recorded_actions = []
    # NB: GroupTask has a cache of tasks by name... use a distinct name
    self.group_task = GroupTask.named('jvm-compile-%s' % uuid.uuid4().hex,
                                      ['classes_by_target', 'classes_by_source'],
                                      ['test'])
    self.group_task.add_member(self.group_member('javac', lambda t: t.is_java))
    self.group_task.add_member(self.group_member('scalac', lambda t: t.is_scala))

    self.task = self.group_task(self._context, workdir='/not/real')
    self.task.prepare(round_manager=RoundManager(self._context))
    self.task.execute()
Ejemplo n.º 7
0
  def setUp(self):
    super(BaseGroupTaskTest, self).setUp()
    self._context = self.context(target_roots=self.create_targets())

    exclusives_mapping = ExclusivesMapping(self._context)
    exclusives_mapping._populate_target_maps(self._context.targets())
    self._context.products.safe_create_data('exclusives_groups', lambda: exclusives_mapping)

    self.recorded_actions = []
    # NB: GroupTask has a cache of tasks by name... use a distinct name
    self.group_task = GroupTask.named('jvm-compile-%s' % uuid.uuid4().hex,
                                      ['classes_by_target', 'classes_by_source'])
    self.group_task.add_member(self.group_member('javac', lambda t: t.is_java))
    self.group_task.add_member(self.group_member('scalac', lambda t: t.is_scala))

    self.task = self.group_task(self._context, workdir='/not/real')
    self.task.prepare(round_manager=RoundManager(self._context))
    self.task.execute()
Ejemplo n.º 8
0
  def setUp(self):
    super(BaseGroupTaskTest, self).setUp()
    self._context = self.context(target_roots=self.create_targets())

    exclusives_mapping = ExclusivesMapping(self._context)
    exclusives_mapping._populate_target_maps(self._context.targets())
    self._context.products.safe_create_data('exclusives_groups', lambda: exclusives_mapping)

    self.recorded_actions = []
    # NB: GroupTask has a cache of tasks by name... use a distinct name
    self.group_task = GroupTask.named('jvm-compile-%s' % uuid.uuid4().hex,
                                      ['classes_by_target', 'classes_by_source'])
    self.group_task.add_member(self.group_member('javac', lambda t: t.is_java))
    self.group_task.add_member(self.group_member('scalac', lambda t: t.is_scala))

    self.task = self.group_task(self._context, workdir='/not/real')
    self.task.prepare(round_manager=RoundManager(self._context))
    self.task.execute()
Ejemplo n.º 9
0
    def setUp(self):
        super(BaseGroupTaskTest, self).setUp()
        self._context = self.context(target_roots=self.create_targets())

        self.populate_compile_classpath(self._context)

        self.recorded_actions = []
        # NB: GroupTask has a cache of tasks by name... use a distinct name
        self.group_task = GroupTask.named(
            'jvm-compile-%s' % uuid.uuid4().hex,
            ['classes_by_target', 'classes_by_source'], ['test'])
        self.group_task.add_member(
            self.group_member('javac', lambda t: t.is_java))
        self.group_task.add_member(
            self.group_member('scalac', lambda t: t.is_scala))

        self.task = self.group_task(self._context, workdir='/not/real')
        self.task.prepare(round_manager=RoundManager(self._context))
        self.task.execute()
Ejemplo n.º 10
0
  def test_groups(self):
    group_task = GroupTask.named('jvm-compile', 'classes')
    group_task.add_member(self.group_member('javac', lambda t: t.is_java))
    group_task.add_member(self.group_member('scalac', lambda t: t.is_scala))

    task = group_task(self._context, workdir='/not/real')
    task.prepare()
    task.execute()

    expected = [self.construct_action('javac'),
                self.prepare_action('javac'),
                self.construct_action('scalac'),
                self.prepare_action('scalac'),
                self.prepare_execute_action('javac', [[self.a], [self.c], [self.e]]),
                self.prepare_execute_action('scalac', [[self.b], [self.d]]),
                self.execute_chunk_action('javac', targets=[self.a]),
                self.execute_chunk_action('scalac', targets=[self.b]),
                self.execute_chunk_action('javac', targets=[self.c]),
                self.execute_chunk_action('scalac', targets=[self.d]),
                self.execute_chunk_action('javac', targets=[self.e]),
                self.post_execute_action('javac'),
                self.post_execute_action('scalac')]
    self.assertEqual(expected, self.recorded_actions)
Ejemplo n.º 11
0
def register_goals():
    ng_killall = task(name='ng-killall', action=NailgunKillall)
    ng_killall.install().with_description('Kill running nailgun servers.')

    Goal.by_name('invalidate').install(ng_killall, first=True)
    Goal.by_name('clean-all').install(ng_killall, first=True)
    Goal.by_name('clean-all-async').install(ng_killall, first=True)

    task(name='jvm-platform-explain',
         action=JvmPlatformExplain).install('jvm-platform-explain')
    task(name='jvm-platform-validate',
         action=JvmPlatformValidate).install('jvm-platform-validate')

    task(name='bootstrap-jvm-tools', action=BootstrapJvmTools).install(
        'bootstrap').with_description('Bootstrap tools needed for building.')

    # Dependency resolution.
    task(name='ivy', action=IvyResolve).install('resolve').with_description(
        'Resolve dependencies and produce dependency reports.')

    task(name='ivy-imports', action=IvyImports).install('imports')

    task(name='unpack-jars', action=UnpackJars).install().with_description(
        'Unpack artifacts specified by unpacked_jars() targets.')

    # Resource preparation.
    task(name='prepare', action=PrepareResources).install('resources')
    task(name='services', action=PrepareServices).install('resources')

    # Compilation.
    # NB: Despite being the only member, ZincCompile should continue to use GroupTask until
    # post engine refactor. It's possible that someone will want to rush in an additional
    # jvm language.
    jvm_compile = GroupTask.named('jvm-compilers',
                                  product_type=[
                                      'runtime_classpath', 'classes_by_source',
                                      'product_deps_by_src'
                                  ],
                                  flag_namespace=['compile'])
    jvm_compile.add_member(ZincCompile)
    task(name='jvm', action=jvm_compile).install('compile').with_description(
        'Compile source code.')

    task(name='jvm-dep-check',
         action=JvmDependencyCheck).install('compile').with_description(
             'Check that used dependencies have been requested.')

    task(name='jvm', action=JvmDependencyUsage).install(
        'dep-usage').with_description('Collect target dependency usage data.')

    # Generate documentation.
    task(name='javadoc', action=JavadocGen).install('doc').with_description(
        'Create documentation.')
    task(name='scaladoc', action=ScaladocGen).install('doc')

    # Bundling.
    task(name='create', action=JarCreate).install('jar')
    detect_duplicates = task(name='dup', action=DuplicateDetector)

    task(name='jvm', action=BinaryCreate).install('binary').with_description(
        'Create a runnable binary.')
    detect_duplicates.install('binary')

    task(name='jvm', action=BundleCreate).install('bundle').with_description(
        'Create an application bundle from binary targets.')
    detect_duplicates.install('bundle')

    task(name='detect-duplicates',
         action=DuplicateDetector).install().with_description(
             'Detect duplicate classes and resources on the classpath.')

    # Publishing.
    task(
        name='check_published_deps',
        action=CheckPublishedDeps,
    ).install('check_published_deps').with_description(
        'Find references to outdated artifacts.')

    task(name='jar', action=JarPublish).install('publish').with_description(
        'Publish artifacts.')

    # Testing.
    task(name='junit', action=JUnitRun).install('test').with_description(
        'Test compiled code.')
    task(name='bench', action=BenchmarkRun).install('bench').with_description(
        'Run benchmark tests.')

    # Running.
    task(name='jvm', action=JvmRun, serialize=False).install(
        'run').with_description('Run a binary target.')
    task(name='jvm-dirty', action=JvmRun,
         serialize=False).install('run-dirty').with_description(
             'Run a binary target, skipping compilation.')

    task(name='scala', action=ScalaRepl,
         serialize=False).install('repl').with_description('Run a REPL.')
    task(name='scala-dirty', action=ScalaRepl, serialize=False).install(
        'repl-dirty').with_description('Run a REPL, skipping compilation.')
Ejemplo n.º 12
0
def register_goals():
  ng_killall = task(name='ng-killall', action=NailgunKillall)
  ng_killall.install().with_description('Kill running nailgun servers.')

  Goal.by_name('invalidate').install(ng_killall, first=True)
  Goal.by_name('clean-all').install(ng_killall, first=True)
  Goal.by_name('clean-all-async').install(ng_killall, first=True)

  task(name='jvm-platform-explain', action=JvmPlatformExplain).install('jvm-platform-explain')
  task(name='jvm-platform-validate', action=JvmPlatformValidate).install('jvm-platform-validate')

  task(name='bootstrap-jvm-tools', action=BootstrapJvmTools).install('bootstrap').with_description(
      'Bootstrap tools needed for building.')

  # Dependency resolution.
  task(name='ivy', action=IvyResolve).install('resolve').with_description(
      'Resolve dependencies and produce dependency reports.')

  task(name='ivy-imports', action=IvyImports).install('imports')

  task(name='unpack-jars', action=UnpackJars).install().with_description(
    'Unpack artifacts specified by unpacked_jars() targets.')

  # Resource preparation.
  task(name='prepare', action=PrepareResources).install('resources')
  task(name='services', action=PrepareServices).install('resources')

  # Compilation.
  jvm_compile = GroupTask.named(
      'jvm-compilers',
      product_type=['runtime_classpath', 'classes_by_source', 'product_deps_by_src'],
      flag_namespace=['compile'])

  # It's important we add AptCompile before other java-compiling tasks since the first selector wins,
  # and apt code is a subset of java code.
  jvm_compile.add_member(AptCompile)
  jvm_compile.add_member(JmakeCompile)
  jvm_compile.add_member(ZincCompile)

  task(name='jvm', action=jvm_compile).install('compile').with_description('Compile source code.')
  task(name='jvm-dep-check', action=JvmDependencyCheck).install('compile').with_description(
      'Check that used dependencies have been requested.')

  task(name='jvm', action=JvmDependencyUsage).install('dep-usage').with_description(
      'Collect target dependency usage data.')

  # Generate documentation.
  task(name='javadoc', action=JavadocGen).install('doc').with_description('Create documentation.')
  task(name='scaladoc', action=ScaladocGen).install('doc')

  # Bundling.
  task(name='jar', action=JarCreate).install('jar')
  detect_duplicates = task(name='dup', action=DuplicateDetector)

  task(name='binary', action=BinaryCreate).install().with_description('Create a runnable binary.')
  detect_duplicates.install('binary')

  task(name='bundle', action=BundleCreate).install().with_description(
      'Create an application bundle from binary targets.')
  detect_duplicates.install('bundle')

  task(name='detect-duplicates', action=DuplicateDetector).install().with_description(
      'Detect duplicate classes and resources on the classpath.')

 # Publishing.
  task(
    name='check_published_deps',
    action=CheckPublishedDeps,
  ).install('check_published_deps').with_description('Find references to outdated artifacts.')

  task(name='jar', action=JarPublish).install('publish').with_description(
      'Publish artifacts.')

  # Testing.
  task(name='junit', action=JUnitRun).install('test').with_description('Test compiled code.')
  task(name='bench', action=BenchmarkRun).install('bench').with_description('Run benchmark tests.')

  # Running.
  task(name='jvm', action=JvmRun, serialize=False).install('run').with_description(
      'Run a binary target.')
  task(name='jvm-dirty', action=JvmRun, serialize=False).install('run-dirty').with_description(
      'Run a binary target, skipping compilation.')

  task(name='scala', action=ScalaRepl, serialize=False).install('repl').with_description(
      'Run a REPL.')
  task(
    name='scala-dirty',
    action=ScalaRepl,
    serialize=False
  ).install('repl-dirty').with_description('Run a REPL, skipping compilation.')
Ejemplo n.º 13
0
def register_goals():
    goal(name='ng-killall', action=NailgunKillall).install().with_description(
        'Kill running nailgun servers.')

    goal(name='bootstrap-jvm-tools', action=BootstrapJvmTools).install(
        'bootstrap').with_description('Bootstrap tools needed for building.')

    # Dependency resolution.
    goal(name='ivy',
         action=IvyResolve,
         dependencies=[
             'gen', 'check-exclusives', 'bootstrap'
         ]).install('resolve').with_description(
             'Resolve dependencies and produce dependency reports.')

    # Compilation.

    # AnnotationProcessors are java targets, but we need to force them into their own compilation
    # rounds so that they are on classpath of any dependees downstream that may use them. Without
    # forcing a separate member type we could get a java chunk containing a mix of apt processors and
    # code that relied on the un-compiled apt processor in the same javac invocation.  If so, javac
    # would not be smart enough to compile the apt processors 1st and activate them.
    class AptCompile(JavaCompile):
        @classmethod
        def name(cls):
            return 'apt'

        def select(self, target):
            return super(AptCompile, self).select(target) and target.is_apt

    jvm_compile = GroupTask.named('jvm-compilers',
                                  product_type='classes',
                                  flag_namespace=['compile'])

    # At some point ScalaLibrary targets will be able to won mixed scala and java source sets.
    # At that point, the ScalaCompile group member will still only select targets via
    # has_sources('*.scala'); however if the JavaCompile group member were registered earlier, it
    # would claim the ScalaLibrary targets with mixed source sets leaving those targets un-compiled
    # by scalac and resulting in systemic compile errors.
    jvm_compile.add_member(ScalaCompile)

    # Its important we add AptCompile before JavaCompile since it 1st selector wins and apt code is a
    # subset of java code
    jvm_compile.add_member(AptCompile)

    jvm_compile.add_member(JavaCompile)

    goal(name='jvm',
         action=jvm_compile,
         dependencies=[
             'gen', 'resolve', 'check-exclusives', 'bootstrap'
         ]).install('compile').with_description('Compile source code.')

    # Generate documentation.

    class ScaladocJarShim(ScaladocGen):
        def __init__(self, context, workdir, confs=None):
            super(ScaladocJarShim, self).__init__(context,
                                                  workdir,
                                                  confs=confs,
                                                  active=False)

    class JavadocJarShim(JavadocGen):
        def __init__(self, context, workdir, confs=None):
            super(JavadocJarShim, self).__init__(context,
                                                 workdir,
                                                 confs=confs,
                                                 active=False)

    goal(name='javadoc',
         action=JavadocGen,
         dependencies=[
             'compile', 'bootstrap'
         ]).install('doc').with_description('Create documentation.')

    goal(name='scaladoc',
         action=ScaladocGen,
         dependencies=['compile', 'bootstrap']).install('doc')

    goal(name='javadoc_publish', action=JavadocJarShim).install('publish')

    goal(name='scaladoc_publish', action=ScaladocJarShim).install('publish')

    # Bundling and publishing.

    goal(name='jar',
         action=JarCreate,
         dependencies=['compile', 'resources', 'bootstrap']).install('jar')

    goal(name='binary', action=BinaryCreate, dependencies=[
        'jar', 'bootstrap'
    ]).install().with_description('Create a jvm binary jar.')

    goal(name='bundle',
         action=BundleCreate,
         dependencies=['jar', 'bootstrap',
                       'binary']).install().with_description(
                           'Create an application bundle from binary targets.')

    goal(name='check_published_deps', action=CheckPublishedDeps).install(
        'check_published_deps').with_description(
            'Find references to outdated artifacts.')

    goal(name='jar_create_publish',
         action=JarCreate,
         dependencies=['compile', 'resources']).install('publish')

    goal(name='publish', action=JarPublish).install(
        'publish').with_description('Publish artifacts.')

    goal(
        name='dup',
        action=DuplicateDetector,
    ).install('binary')

    goal(name='detect-duplicates',
         action=DuplicateDetector,
         dependencies=['jar']).install().with_description(
             'Detect duplicate classes and resources on the classpath.')

    # Testing.

    goal(name='junit',
         action=JUnitRun,
         dependencies=[
             'compile', 'resources', 'bootstrap'
         ]).install('test').with_description('Test compiled code.')

    goal(name='specs',
         action=SpecsRun,
         dependencies=['compile', 'resources', 'bootstrap']).install('test')

    goal(name='bench',
         action=BenchmarkRun,
         dependencies=['compile', 'resources', 'bootstrap']).install('bench')

    # Running.

    goal(name='jvm-run',
         action=JvmRun,
         dependencies=['compile', 'resources', 'bootstrap'],
         serialize=False).install('run').with_description(
             'Run a (currently JVM only) binary target.')

    goal(name='jvm-run-dirty', action=JvmRun,
         serialize=False).install('run-dirty').with_description(
             'Run a (currently JVM only) binary target, skipping compilation.')

    goal(name='scala-repl',
         action=ScalaRepl,
         dependencies=['compile', 'resources', 'bootstrap'],
         serialize=False).install('repl').with_description(
             'Run a (currently Scala only) REPL.')

    goal(name='scala-repl-dirty', action=ScalaRepl,
         serialize=False).install('repl-dirty').with_description(
             'Run a (currently Scala only) REPL, skipping compilation.')

    # IDE support.

    goal(name='idea', action=IdeaGen,
         dependencies=['jar', 'bootstrap']).install().with_description(
             'Create an IntelliJ IDEA project from the given targets.')

    goal(name='eclipse', action=EclipseGen,
         dependencies=['jar', 'bootstrap']).install().with_description(
             'Create an Eclipse project from the given targets.')

    # Build graph information.

    goal(name='provides', action=Provides,
         dependencies=['jar', 'bootstrap']).install().with_description(
             'Print the symbols provided by the given targets.')

    # XXX(pl): These should be core, but they have dependencies on JVM
    goal(name='depmap', action=Depmap).install().with_description(
        "Depict the target's dependencies.")

    goal(name='dependencies', action=Dependencies).install().with_description(
        "Print the target's dependencies.")

    goal(name='filedeps',
         action=FileDeps).install('filedeps').with_description(
             'Print out the source and BUILD files the target depends on.')
Ejemplo n.º 14
0
def register_goals():
    ng_killall = task(name="ng-killall", action=NailgunKillall)
    ng_killall.install().with_description("Kill running nailgun servers.")

    Goal.by_name("invalidate").install(ng_killall, first=True)
    Goal.by_name("clean-all").install(ng_killall, first=True)
    Goal.by_name("clean-all-async").install(ng_killall, first=True)

    task(name="jvm-platform-explain", action=JvmPlatformExplain).install("jvm-platform-explain")
    task(name="jvm-platform-validate", action=JvmPlatformValidate).install("jvm-platform-validate")

    task(name="bootstrap-jvm-tools", action=BootstrapJvmTools).install("bootstrap").with_description(
        "Bootstrap tools needed for building."
    )

    # Dependency resolution.
    task(name="ivy", action=IvyResolve).install("resolve").with_description(
        "Resolve dependencies and produce dependency reports."
    )

    task(name="ivy-imports", action=IvyImports).install("imports")

    task(name="unpack-jars", action=UnpackJars).install().with_description(
        "Unpack artifacts specified by unpacked_jars() targets."
    )

    # Resource preparation.
    task(name="prepare", action=PrepareResources).install("resources")
    task(name="services", action=PrepareServices).install("resources")

    # Compilation.
    jvm_compile = GroupTask.named(
        "jvm-compilers", product_type=["classes_by_target", "classes_by_source"], flag_namespace=["compile"]
    )

    # It's important we add AptCompile before other java-compiling tasks since the first selector wins,
    # and apt code is a subset of java code.
    jvm_compile.add_member(AptCompile)
    jvm_compile.add_member(JmakeCompile)
    jvm_compile.add_member(ZincCompile)

    task(name="jvm", action=jvm_compile).install("compile").with_description("Compile source code.")

    # Generate documentation.
    task(name="javadoc", action=JavadocGen).install("doc").with_description("Create documentation.")
    task(name="scaladoc", action=ScaladocGen).install("doc")

    # Bundling.
    task(name="jar", action=JarCreate).install("jar")
    detect_duplicates = task(name="dup", action=DuplicateDetector)

    task(name="binary", action=BinaryCreate).install().with_description("Create a runnable binary.")
    detect_duplicates.install("binary")

    task(name="bundle", action=BundleCreate).install().with_description(
        "Create an application bundle from binary targets."
    )
    detect_duplicates.install("bundle")

    task(name="detect-duplicates", action=DuplicateDetector).install().with_description(
        "Detect duplicate classes and resources on the classpath."
    )

    # Publishing.
    task(name="check_published_deps", action=CheckPublishedDeps).install("check_published_deps").with_description(
        "Find references to outdated artifacts."
    )

    task(name="jar", action=JarPublish).install("publish").with_description("Publish artifacts.")

    # Testing.
    task(name="junit", action=JUnitRun).install("test").with_description("Test compiled code.")
    task(name="bench", action=BenchmarkRun).install("bench").with_description("Run benchmark tests.")

    # Running.
    task(name="jvm", action=JvmRun, serialize=False).install("run").with_description("Run a binary target.")
    task(name="jvm-dirty", action=JvmRun, serialize=False).install("run-dirty").with_description(
        "Run a binary target, skipping compilation."
    )

    task(name="scala", action=ScalaRepl, serialize=False).install("repl").with_description("Run a REPL.")
    task(name="scala-dirty", action=ScalaRepl, serialize=False).install("repl-dirty").with_description(
        "Run a REPL, skipping compilation."
    )
Ejemplo n.º 15
0
def register_goals():
    ng_killall = task(name='ng-killall', action=NailgunKillall)
    ng_killall.install().with_description('Kill running nailgun servers.')

    Goal.by_name('invalidate').install(ng_killall, first=True)
    Goal.by_name('clean-all').install(ng_killall, first=True)
    Goal.by_name('clean-all-async').install(ng_killall, first=True)

    task(name='bootstrap-jvm-tools', action=BootstrapJvmTools).install(
        'bootstrap').with_description('Bootstrap tools needed for building.')

    # Dependency resolution.
    task(name='ivy', action=IvyResolve).install('resolve').with_description(
        'Resolve dependencies and produce dependency reports.')

    task(name='ivy-imports', action=IvyImports).install('imports')

    task(name='unpack-jars', action=UnpackJars).install().with_description(
        'Unpack artifacts specified by unpacked_jars() targets.')

    # Resource preparation.
    task(name='prepare', action=PrepareResources).install('resources')
    task(name='services', action=PrepareServices).install('resources')

    # Compilation.
    jvm_compile = GroupTask.named(
        'jvm-compilers',
        product_type=['classes_by_target', 'classes_by_source'],
        flag_namespace=['compile'])

    # Here we register the ScalaCompile group member before the java group members very deliberately.
    # At some point ScalaLibrary targets will be able to own mixed scala and java source sets. At that
    # point, the ScalaCompile group member will still only select targets via has_sources('*.scala');
    # however if the JavaCompile group member were registered earlier, it would claim the ScalaLibrary
    # targets with mixed source sets leaving those targets un-compiled by scalac and resulting in
    # systemic compile errors.
    jvm_compile.add_member(ScalaZincCompile)

    # Its important we add AptCompile before JavaCompile since it 1st selector wins and apt code is a
    # subset of java code
    jvm_compile.add_member(AptCompile)

    jvm_compile.add_member(JavaZincCompile)
    jvm_compile.add_member(JavaCompile)

    task(name='jvm', action=jvm_compile).install('compile').with_description(
        'Compile source code.')

    # Generate documentation.
    task(name='javadoc', action=JavadocGen).install('doc').with_description(
        'Create documentation.')
    task(name='scaladoc', action=ScaladocGen).install('doc')

    # Bundling.
    task(name='jar', action=JarCreate).install('jar')
    detect_duplicates = task(name='dup', action=DuplicateDetector)

    task(name='binary', action=BinaryCreate).install().with_description(
        'Create a runnable binary.')
    detect_duplicates.install('binary')

    task(name='bundle', action=BundleCreate).install().with_description(
        'Create an application bundle from binary targets.')
    detect_duplicates.install('bundle')

    task(name='detect-duplicates',
         action=DuplicateDetector).install().with_description(
             'Detect duplicate classes and resources on the classpath.')

    # Publishing.
    task(
        name='check_published_deps',
        action=CheckPublishedDeps,
    ).install('check_published_deps').with_description(
        'Find references to outdated artifacts.')

    task(name='jar', action=JarPublish).install('publish').with_description(
        'Publish artifacts.')

    # Testing.
    task(name='junit', action=JUnitRun).install('test').with_description(
        'Test compiled code.')
    task(name='bench', action=BenchmarkRun).install('bench').with_description(
        'Run benchmark tests.')

    # Running.
    task(name='jvm', action=JvmRun, serialize=False).install(
        'run').with_description('Run a binary target.')
    task(name='jvm-dirty', action=JvmRun,
         serialize=False).install('run-dirty').with_description(
             'Run a binary target, skipping compilation.')

    task(name='scala', action=ScalaRepl,
         serialize=False).install('repl').with_description('Run a REPL.')
    task(name='scala-dirty', action=ScalaRepl, serialize=False).install(
        'repl-dirty').with_description('Run a REPL, skipping compilation.')
Ejemplo n.º 16
0
def register_goals():
    ng_killall = task(name="ng-killall", action=NailgunKillall)
    ng_killall.install().with_description("Kill running nailgun servers.")

    Goal.by_name("invalidate").install(ng_killall, first=True)
    Goal.by_name("clean-all").install(ng_killall, first=True)
    Goal.by_name("clean-all-async").install(ng_killall, first=True)

    task(name="bootstrap-jvm-tools", action=BootstrapJvmTools).install("bootstrap").with_description(
        "Bootstrap tools needed for building."
    )

    # Dependency resolution.
    task(name="ivy", action=IvyResolve, dependencies=["gen", "check-exclusives", "bootstrap"]).install(
        "resolve"
    ).with_description("Resolve dependencies and produce dependency reports.")

    task(name="ivy-imports", action=IvyImports, dependencies=["bootstrap"]).install("imports")

    # Compilation.

    # AnnotationProcessors are java targets, but we need to force them into their own compilation
    # rounds so that they are on classpath of any dependees downstream that may use them. Without
    # forcing a separate member type we could get a java chunk containing a mix of apt processors and
    # code that relied on the un-compiled apt processor in the same javac invocation.  If so, javac
    # would not be smart enough to compile the apt processors 1st and activate them.
    class AptCompile(JavaCompile):
        @classmethod
        def name(cls):
            return "apt"

        def select(self, target):
            return super(AptCompile, self).select(target) and target.is_apt

    jvm_compile = GroupTask.named(
        "jvm-compilers", product_type=["classes_by_target", "classes_by_source"], flag_namespace=["compile"]
    )

    # Here we register the ScalaCompile group member before the java group members very deliberately.
    # At some point ScalaLibrary targets will be able to own mixed scala and java source sets. At that
    # point, the ScalaCompile group member will still only select targets via has_sources('*.scala');
    # however if the JavaCompile group member were registered earlier, it would claim the ScalaLibrary
    # targets with mixed source sets leaving those targets un-compiled by scalac and resulting in
    # systemic compile errors.
    jvm_compile.add_member(ScalaCompile)

    # Its important we add AptCompile before JavaCompile since it 1st selector wins and apt code is a
    # subset of java code
    jvm_compile.add_member(AptCompile)

    jvm_compile.add_member(JavaCompile)

    task(name="jvm", action=jvm_compile, dependencies=["gen", "resolve", "check-exclusives", "bootstrap"]).install(
        "compile"
    ).with_description("Compile source code.")

    # Generate documentation.

    task(name="javadoc", action=JavadocGen, dependencies=["compile", "bootstrap"]).install("doc").with_description(
        "Create documentation."
    )

    task(name="scaladoc", action=ScaladocGen, dependencies=["compile", "bootstrap"]).install("doc")

    # Bundling.

    task(name="jar", action=JarCreate, dependencies=["compile", "resources", "bootstrap"]).install("jar")

    detect_duplicates = task(name="dup", action=DuplicateDetector, dependencies=["compile", "resources"])

    task(
        name="binary", action=BinaryCreate, dependencies=["compile", "resources", "bootstrap"]
    ).install().with_description("Create a jvm binary jar.")

    detect_duplicates.install("binary")

    task(
        name="bundle", action=BundleCreate, dependencies=["compile", "resources", "bootstrap"]
    ).install().with_description("Create an application bundle from binary targets.")

    detect_duplicates.install("bundle")

    task(
        name="detect-duplicates", action=DuplicateDetector, dependencies=["compile", "resources"]
    ).install().with_description("Detect duplicate classes and resources on the classpath.")

    # Publishing.

    task(name="check_published_deps", action=CheckPublishedDeps).install("check_published_deps").with_description(
        "Find references to outdated artifacts."
    )

    task(name="publish", action=JarPublish, dependencies=["jar", "doc"]).install("publish").with_description(
        "Publish artifacts."
    )

    # Testing.

    task(name="junit", action=JUnitRun, dependencies=["compile", "resources", "bootstrap"]).install(
        "test"
    ).with_description("Test compiled code.")

    task(name="specs", action=SpecsRun, dependencies=["compile", "resources", "bootstrap"]).install("test")

    task(name="bench", action=BenchmarkRun, dependencies=["compile", "resources", "bootstrap"]).install("bench")

    # Running.

    task(name="jvm-run", action=JvmRun, dependencies=["compile", "resources", "bootstrap"], serialize=False).install(
        "run"
    ).with_description("Run a binary target.")

    task(name="jvm-run-dirty", action=JvmRun, serialize=False).install("run-dirty").with_description(
        "Run a binary target, skipping compilation."
    )

    task(
        name="scala-repl", action=ScalaRepl, dependencies=["compile", "resources", "bootstrap"], serialize=False
    ).install("repl").with_description("Run a REPL.")

    task(name="scala-repl-dirty", action=ScalaRepl, serialize=False).install("repl-dirty").with_description(
        "Run a REPL, skipping compilation."
    )

    # IDE support.

    task(name="idea", action=IdeaGen, dependencies=["bootstrap", "resolve"]).install().with_description(
        "Create an IntelliJ IDEA project from the given targets."
    )

    task(name="eclipse", action=EclipseGen, dependencies=["jar", "bootstrap"]).install().with_description(
        "Create an Eclipse project from the given targets."
    )

    task(name="ensime", action=EnsimeGen, dependencies=["jar", "bootstrap"]).install().with_description(
        "Create an Ensime project from the given targets."
    )

    # Build graph information.

    task(name="provides", action=Provides, dependencies=["jar", "bootstrap"]).install().with_description(
        "Print the symbols provided by the given targets."
    )

    # XXX(pl): These should be core, but they have dependencies on JVM
    task(name="depmap", action=Depmap).install().with_description("Depict the target's dependencies.")

    task(name="dependencies", action=Dependencies).install().with_description("Print the target's dependencies.")

    task(name="filedeps", action=FileDeps).install("filedeps").with_description(
        "Print out the source and BUILD files the target depends on."
    )
Ejemplo n.º 17
0
def register_goals():
  ng_killall = goal(name='ng-killall', action=NailgunKillall)
  ng_killall.install().with_description('Kill running nailgun servers.')

  Phase('invalidate').install(ng_killall, first=True)
  Phase('clean-all').install(ng_killall, first=True)
  Phase('clean-all-async').install(ng_killall, first=True)

  goal(name='bootstrap-jvm-tools', action=BootstrapJvmTools
  ).install('bootstrap').with_description('Bootstrap tools needed for building.')

  # Dependency resolution.
  goal(name='ivy', action=IvyResolve,
       dependencies=['gen', 'check-exclusives', 'bootstrap']
  ).install('resolve').with_description('Resolve dependencies and produce dependency reports.')

  goal(name='ivy-imports', action=IvyImports,
       dependencies=['bootstrap']
  ).install('imports')

  # Compilation.

  # AnnotationProcessors are java targets, but we need to force them into their own compilation
  # rounds so that they are on classpath of any dependees downstream that may use them. Without
  # forcing a separate member type we could get a java chunk containing a mix of apt processors and
  # code that relied on the un-compiled apt processor in the same javac invocation.  If so, javac
  # would not be smart enough to compile the apt processors 1st and activate them.
  class AptCompile(JavaCompile):
    @classmethod
    def name(cls):
      return 'apt'

    def select(self, target):
      return super(AptCompile, self).select(target) and target.is_apt


  jvm_compile = GroupTask.named(
    'jvm-compilers',
    product_type=['classes_by_target', 'classes_by_source'],
    flag_namespace=['compile'])

  # Here we register the ScalaCompile group member before the java group members very deliberately.
  # At some point ScalaLibrary targets will be able to own mixed scala and java source sets. At that
  # point, the ScalaCompile group member will still only select targets via has_sources('*.scala');
  # however if the JavaCompile group member were registered earlier, it would claim the ScalaLibrary
  # targets with mixed source sets leaving those targets un-compiled by scalac and resulting in
  # systemic compile errors.
  jvm_compile.add_member(ScalaCompile)

  # Its important we add AptCompile before JavaCompile since it 1st selector wins and apt code is a
  # subset of java code
  jvm_compile.add_member(AptCompile)

  jvm_compile.add_member(JavaCompile)

  goal(name='jvm', action=jvm_compile,
       dependencies=['gen', 'resolve', 'check-exclusives', 'bootstrap']
  ).install('compile').with_description('Compile source code.')

  # Generate documentation.

  goal(name='javadoc', action=JavadocGen,
       dependencies=['compile', 'bootstrap']
  ).install('doc').with_description('Create documentation.')

  goal(name='scaladoc', action=ScaladocGen,
       dependencies=['compile', 'bootstrap']
  ).install('doc')

  # Bundling.

  goal(name='jar', action=JarCreate,
       dependencies=['compile', 'resources', 'bootstrap']
  ).install('jar')

  detect_duplicates = goal(name='dup', action=DuplicateDetector,
                           dependencies=['compile', 'resources'])

  goal(name='binary', action=BinaryCreate,
       dependencies=['compile', 'resources', 'bootstrap']
  ).install().with_description('Create a jvm binary jar.')

  detect_duplicates.install('binary')

  goal(name='bundle', action=BundleCreate,
       dependencies=['compile', 'resources', 'bootstrap']
  ).install().with_description('Create an application bundle from binary targets.')

  detect_duplicates.install('bundle')

  goal(name='detect-duplicates', action=DuplicateDetector,
       dependencies=['compile', 'resources'],
  ).install().with_description('Detect duplicate classes and resources on the classpath.')

 # Publishing.

  goal(name='check_published_deps', action=CheckPublishedDeps
  ).install('check_published_deps').with_description('Find references to outdated artifacts.')

  goal(name='publish', action=JarPublish,
       dependencies=['jar', 'doc']
  ).install('publish').with_description('Publish artifacts.')

  # Testing.

  goal(name='junit', action=JUnitRun,
       dependencies=['compile', 'resources', 'bootstrap']
  ).install('test').with_description('Test compiled code.')

  goal(name='specs', action=SpecsRun,
       dependencies=['compile', 'resources', 'bootstrap']
  ).install('test')

  goal(name='bench', action=BenchmarkRun,
       dependencies=['compile', 'resources', 'bootstrap']
  ).install('bench')

  # Running.

  goal(name='jvm-run', action=JvmRun,
       dependencies=['compile', 'resources', 'bootstrap'], serialize=False
  ).install('run').with_description('Run a binary target.')

  goal(name='jvm-run-dirty', action=JvmRun,
       serialize=False
  ).install('run-dirty').with_description('Run a binary target, skipping compilation.')

  goal(name='scala-repl', action=ScalaRepl,
       dependencies=['compile', 'resources', 'bootstrap'], serialize=False
  ).install('repl').with_description('Run a REPL.')

  goal(name='scala-repl-dirty', action=ScalaRepl,
       serialize=False
  ).install('repl-dirty').with_description('Run a REPL, skipping compilation.')

  # IDE support.

  goal(name='idea', action=IdeaGen, dependencies=['bootstrap', 'resolve']
  ).install().with_description('Create an IntelliJ IDEA project from the given targets.')

  goal(name='eclipse', action=EclipseGen,
       dependencies=['jar', 'bootstrap']
  ).install().with_description('Create an Eclipse project from the given targets.')

  # Build graph information.

  goal(name='provides', action=Provides,
       dependencies=['jar', 'bootstrap']
  ).install().with_description('Print the symbols provided by the given targets.')

  # XXX(pl): These should be core, but they have dependencies on JVM
  goal(name='depmap', action=Depmap
  ).install().with_description("Depict the target's dependencies.")

  goal(name='dependencies', action=Dependencies
  ).install().with_description("Print the target's dependencies.")

  goal(name='filedeps', action=FileDeps
  ).install('filedeps').with_description(
      'Print out the source and BUILD files the target depends on.')
Ejemplo n.º 18
0
def register_goals():
  ng_killall = task(name='ng-killall', action=NailgunKillall)
  ng_killall.install().with_description('Kill running nailgun servers.')

  Goal.by_name('invalidate').install(ng_killall, first=True)
  Goal.by_name('clean-all').install(ng_killall, first=True)
  Goal.by_name('clean-all-async').install(ng_killall, first=True)

  task(name='bootstrap-jvm-tools', action=BootstrapJvmTools).install('bootstrap').with_description(
      'Bootstrap tools needed for building.')

  # Dependency resolution.
  task(name='ivy', action=IvyResolve).install('resolve').with_description(
      'Resolve dependencies and produce dependency reports.')

  task(name='ivy-imports', action=IvyImports).install('imports')

  task(name='unpack-jars', action=UnpackJars).install().with_description(
    'Unpack artifacts specified by unpacked_jars() targets.')

  # Resource preparation.
  task(name='prepare', action=PrepareResources).install('resources')
  task(name='services', action=PrepareServices).install('resources')

  # Compilation.
  jvm_compile = GroupTask.named(
      'jvm-compilers',
      product_type=['classes_by_target', 'classes_by_source'],
      flag_namespace=['compile'])

  # Here we register the ScalaCompile group member before the java group members very deliberately.
  # At some point ScalaLibrary targets will be able to own mixed scala and java source sets. At that
  # point, the ScalaCompile group member will still only select targets via has_sources('*.scala');
  # however if the JavaCompile group member were registered earlier, it would claim the ScalaLibrary
  # targets with mixed source sets leaving those targets un-compiled by scalac and resulting in
  # systemic compile errors.
  jvm_compile.add_member(ScalaZincCompile)

  # Its important we add AptCompile before JavaCompile since it 1st selector wins and apt code is a
  # subset of java code
  jvm_compile.add_member(AptCompile)

  jvm_compile.add_member(JavaZincCompile)
  jvm_compile.add_member(JavaCompile)

  task(name='jvm', action=jvm_compile).install('compile').with_description('Compile source code.')

  # Generate documentation.
  task(name='javadoc', action=JavadocGen).install('doc').with_description('Create documentation.')
  task(name='scaladoc', action=ScaladocGen).install('doc')

  # Bundling.
  task(name='jar', action=JarCreate).install('jar')
  detect_duplicates = task(name='dup', action=DuplicateDetector)

  task(name='binary', action=BinaryCreate).install().with_description('Create a runnable binary.')
  detect_duplicates.install('binary')

  task(name='bundle', action=BundleCreate).install().with_description(
      'Create an application bundle from binary targets.')
  detect_duplicates.install('bundle')

  task(name='detect-duplicates', action=DuplicateDetector).install().with_description(
      'Detect duplicate classes and resources on the classpath.')

 # Publishing.
  task(
    name='check_published_deps',
    action=CheckPublishedDeps,
  ).install('check_published_deps').with_description('Find references to outdated artifacts.')

  task(name='jar', action=JarPublish).install('publish').with_description(
      'Publish artifacts.')

  # Testing.
  task(name='junit', action=JUnitRun).install('test').with_description('Test compiled code.')
  task(name='bench', action=BenchmarkRun).install('bench')

  # Running.
  task(name='jvm', action=JvmRun, serialize=False).install('run').with_description(
      'Run a binary target.')
  task(name='jvm-dirty', action=JvmRun, serialize=False).install('run-dirty').with_description(
      'Run a binary target, skipping compilation.')

  task(name='scala', action=ScalaRepl, serialize=False).install('repl').with_description(
      'Run a REPL.')
  task(
    name='scala-dirty',
    action=ScalaRepl,
    serialize=False
  ).install('repl-dirty').with_description('Run a REPL, skipping compilation.')
Ejemplo n.º 19
0
def register_goals():
    ng_killall = task(name='ng-killall', action=NailgunKillall)
    ng_killall.install().with_description('Kill running nailgun servers.')

    Goal.by_name('invalidate').install(ng_killall, first=True)
    Goal.by_name('clean-all').install(ng_killall, first=True)
    Goal.by_name('clean-all-async').install(ng_killall, first=True)

    task(name='bootstrap-jvm-tools', action=BootstrapJvmTools).install(
        'bootstrap').with_description('Bootstrap tools needed for building.')

    # Dependency resolution.
    task(name='ivy', action=IvyResolve).install('resolve').with_description(
        'Resolve dependencies and produce dependency reports.')

    task(name='ivy-imports', action=IvyImports).install('imports')

    task(name='unpack-jars', action=UnpackJars).install().with_description(
        'Unpack artifacts specified by unpacked_jars() targets.')

    # Compilation.

    # AnnotationProcessors are java targets, but we need to force them into their own compilation
    # rounds so that they are on classpath of any dependees downstream that may use them. Without
    # forcing a separate member type we could get a java chunk containing a mix of apt processors and
    # code that relied on the un-compiled apt processor in the same javac invocation.  If so, javac
    # would not be smart enough to compile the apt processors 1st and activate them.
    class AptCompile(JavaCompile):
        @classmethod
        def name(cls):
            return 'apt'

        def select(self, target):
            return super(AptCompile, self).select(target) and isinstance(
                target, AnnotationProcessor)

    jvm_compile = GroupTask.named(
        'jvm-compilers',
        product_type=['classes_by_target', 'classes_by_source'],
        flag_namespace=['compile'])

    # Here we register the ScalaCompile group member before the java group members very deliberately.
    # At some point ScalaLibrary targets will be able to own mixed scala and java source sets. At that
    # point, the ScalaCompile group member will still only select targets via has_sources('*.scala');
    # however if the JavaCompile group member were registered earlier, it would claim the ScalaLibrary
    # targets with mixed source sets leaving those targets un-compiled by scalac and resulting in
    # systemic compile errors.
    jvm_compile.add_member(ScalaCompile)

    # Its important we add AptCompile before JavaCompile since it 1st selector wins and apt code is a
    # subset of java code
    jvm_compile.add_member(AptCompile)

    jvm_compile.add_member(JavaCompile)

    task(name='jvm', action=jvm_compile).install('compile').with_description(
        'Compile source code.')

    # Generate documentation.
    task(name='javadoc', action=JavadocGen).install('doc').with_description(
        'Create documentation.')
    task(name='scaladoc', action=ScaladocGen).install('doc')

    # Bundling.
    task(name='jar', action=JarCreate).install('jar')
    detect_duplicates = task(name='dup', action=DuplicateDetector)

    task(name='binary', action=BinaryCreate).install().with_description(
        'Create a runnable binary.')
    detect_duplicates.install('binary')

    task(name='bundle', action=BundleCreate).install().with_description(
        'Create an application bundle from binary targets.')
    detect_duplicates.install('bundle')

    task(name='detect-duplicates',
         action=DuplicateDetector).install().with_description(
             'Detect duplicate classes and resources on the classpath.')

    # Publishing.
    task(
        name='check_published_deps',
        action=CheckPublishedDeps,
    ).install('check_published_deps').with_description(
        'Find references to outdated artifacts.')

    task(name='publish', action=JarPublish).install(
        'publish').with_description('Publish artifacts.')

    # Testing.
    task(name='junit', action=JUnitRun).install('test').with_description(
        'Test compiled code.')
    task(name='specs', action=SpecsRun).install('test')
    task(name='bench', action=BenchmarkRun).install('bench')

    # Running.
    task(name='jvm', action=JvmRun, serialize=False).install(
        'run').with_description('Run a binary target.')
    task(name='jvm-dirty', action=JvmRun,
         serialize=False).install('run-dirty').with_description(
             'Run a binary target, skipping compilation.')

    task(name='scala', action=ScalaRepl,
         serialize=False).install('repl').with_description('Run a REPL.')
    task(name='scala-dirty', action=ScalaRepl, serialize=False).install(
        'repl-dirty').with_description('Run a REPL, skipping compilation.')

    # IDE support.
    task(name='idea', action=IdeaGen).install().with_description(
        'Create an IntelliJ IDEA project from the given targets.')

    task(name='eclipse', action=EclipseGen).install().with_description(
        'Create an Eclipse project from the given targets.')

    task(name='ensime', action=EnsimeGen).install().with_description(
        'Create an Ensime project from the given targets.')

    # Build graph information.
    task(name='provides', action=Provides).install().with_description(
        'Print the symbols provided by the given targets.')

    # XXX(pl): These should be core, but they have dependencies on JVM
    task(name='depmap', action=Depmap).install().with_description(
        "Depict the target's dependencies.")

    task(name='dependencies', action=Dependencies).install().with_description(
        "Print the target's dependencies.")

    task(name='filedeps',
         action=FileDeps).install('filedeps').with_description(
             'Print out the source and BUILD files the target depends on.')
Ejemplo n.º 20
0
def register_goals():
  ng_killall = task(name='ng-killall', action=NailgunKillall)
  ng_killall.install().with_description('Kill running nailgun servers.')

  Goal.by_name('invalidate').install(ng_killall, first=True)
  Goal.by_name('clean-all').install(ng_killall, first=True)
  Goal.by_name('clean-all-async').install(ng_killall, first=True)

  task(name='jvm-platform-explain', action=JvmPlatformExplain).install('jvm-platform-explain')
  task(name='jvm-platform-validate', action=JvmPlatformValidate).install('jvm-platform-validate')

  task(name='bootstrap-jvm-tools', action=BootstrapJvmTools).install('bootstrap').with_description(
      'Bootstrap tools needed for building.')

  # Dependency resolution.
  task(name='ivy', action=IvyResolve).install('resolve').with_description(
      'Resolve dependencies and produce dependency reports.')

  task(name='ivy-imports', action=IvyImports).install('imports')

  task(name='unpack-jars', action=UnpackJars).install().with_description(
    'Unpack artifacts specified by unpacked_jars() targets.')

  # Resource preparation.
  task(name='prepare', action=PrepareResources).install('resources')
  task(name='services', action=PrepareServices).install('resources')

  # Compilation.
  jvm_compile = GroupTask.named(
      'jvm-compilers',
      product_type=['classes_by_target', 'classes_by_source'],
      flag_namespace=['compile'])

  # It's important we add AptCompile before other java-compiling tasks since the first selector wins,
  # and apt code is a subset of java code.
  jvm_compile.add_member(AptCompile)
  jvm_compile.add_member(JmakeCompile)
  jvm_compile.add_member(ZincCompile)

  task(name='jvm', action=jvm_compile).install('compile').with_description('Compile source code.')

  # Generate documentation.
  task(name='javadoc', action=JavadocGen).install('doc').with_description('Create documentation.')
  task(name='scaladoc', action=ScaladocGen).install('doc')

  # Bundling.
  task(name='jar', action=JarCreate).install('jar')
  detect_duplicates = task(name='dup', action=DuplicateDetector)

  task(name='binary', action=BinaryCreate).install().with_description('Create a runnable binary.')
  detect_duplicates.install('binary')

  task(name='bundle', action=BundleCreate).install().with_description(
      'Create an application bundle from binary targets.')
  detect_duplicates.install('bundle')

  task(name='detect-duplicates', action=DuplicateDetector).install().with_description(
      'Detect duplicate classes and resources on the classpath.')

 # Publishing.
  task(
    name='check_published_deps',
    action=CheckPublishedDeps,
  ).install('check_published_deps').with_description('Find references to outdated artifacts.')

  task(name='jar', action=JarPublish).install('publish').with_description(
      'Publish artifacts.')

  # Testing.
  task(name='junit', action=JUnitRun).install('test').with_description('Test compiled code.')
  task(name='bench', action=BenchmarkRun).install('bench').with_description('Run benchmark tests.')

  # Running.
  task(name='jvm', action=JvmRun, serialize=False).install('run').with_description(
      'Run a binary target.')
  task(name='jvm-dirty', action=JvmRun, serialize=False).install('run-dirty').with_description(
      'Run a binary target, skipping compilation.')

  task(name='scala', action=ScalaRepl, serialize=False).install('repl').with_description(
      'Run a REPL.')
  task(
    name='scala-dirty',
    action=ScalaRepl,
    serialize=False
  ).install('repl-dirty').with_description('Run a REPL, skipping compilation.')