Skip to content
This repository has been archived by the owner on Dec 13, 2019. It is now read-only.

Commit

Permalink
Merge pull request #23 from slackhappy/fs-nonbeta-warsupport
Browse files Browse the repository at this point in the history
Add .war extension to _map_jar
(sapling split of 608afd7)
  • Loading branch information
benjyw committed Oct 6, 2013
1 parent c1a224c commit 245b070
Show file tree
Hide file tree
Showing 11 changed files with 170 additions and 194 deletions.
1 change: 1 addition & 0 deletions src/java/com/twitter/common/examples/pingpong/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ jvm_binary(name='pingpong',
pants(':pingpong-lib')
]
)

6 changes: 6 additions & 0 deletions src/python/twitter/pants/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,11 @@ def is_codegen(target):
return target.has_label('codegen')


def is_synthetic(target):
"""Returns True if the target is a synthetic target injected by the runtime."""
return target.has_label('synthetic')


def is_jar_library(target):
"""Returns True if the target is an external jar library."""
return target.has_label('jars')
Expand Down Expand Up @@ -316,6 +321,7 @@ def is_jar_dependency(dep):
'is_jvm',
'is_python',
'is_scala',
'is_synthetic',
'is_test',
'jar',
'jar_library',
Expand Down
1 change: 1 addition & 0 deletions src/python/twitter/pants/binary_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
('darwin', '10'): ['mac', '10.6'],
('darwin', '11'): ['mac', '10.7'],
('darwin', '12'): ['mac', '10.8'],
('darwin', '13'): ['mac', '10.9'],
}


Expand Down
65 changes: 19 additions & 46 deletions src/python/twitter/pants/commands/goal.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,38 +451,28 @@ def is_console_task():
if self.options.cleanup_nailguns or self.config.get('nailgun', 'autokill', default = False):
if log:
log.debug('auto-killing nailguns')
if NailgunTask.killall:
NailgunTask.killall(log)
NailgunTask.killall(log)

return ret

def cleanup(self):
# TODO: Make this more selective? Only kill nailguns that affect state? E.g., checkstyle
# may not need to be killed.
if NailgunTask.killall:
NailgunTask.killall(log)
NailgunTask.killall(log)
sys.exit(1)


# Install all default pants provided goals
from twitter.pants import junit_tests
from twitter.pants.targets import (
Benchmark,
JavaLibrary,
JvmBinary,
ScalaLibrary,
ScalaTests,
ScalacPlugin)
from twitter.pants.targets import Benchmark, JvmBinary
from twitter.pants.tasks.antlr_gen import AntlrGen
from twitter.pants.tasks.benchmark_run import BenchmarkRun
from twitter.pants.tasks.binary_create import BinaryCreate
from twitter.pants.tasks.build_lint import BuildLint
from twitter.pants.tasks.bundle_create import BundleCreate
from twitter.pants.tasks.checkstyle import Checkstyle
from twitter.pants.tasks.extract import Extract
from twitter.pants.tasks.check_exclusives import CheckExclusives
from twitter.pants.tasks.filedeps import FileDeps
from twitter.pants.tasks.idl_resolve import IdlResolve
from twitter.pants.tasks.ivy_resolve import IvyResolve
from twitter.pants.tasks.jar_create import JarCreate
from twitter.pants.tasks.java_compile import JavaCompile
Expand Down Expand Up @@ -541,23 +531,21 @@ def async_safe_rmtree(root):
pass


if NailgunTask.killall:
class NailgunKillall(Task):
@classmethod
def setup_parser(cls, option_group, args, mkflag):
option_group.add_option(mkflag("everywhere"), dest="ng_killall_everywhere",
default=False, action="store_true",
help="[%default] Kill all nailguns servers launched by pants for "
"all workspaces on the system.")
class NailgunKillall(Task):
@classmethod
def setup_parser(cls, option_group, args, mkflag):
option_group.add_option(mkflag("everywhere"), dest="ng_killall_everywhere",
default=False, action="store_true",
help="[%default] Kill all nailguns servers launched by pants for "
"all workspaces on the system.")

def execute(self, targets):
if NailgunTask.killall:
NailgunTask.killall(self.context.log, everywhere=self.context.options.ng_killall_everywhere)
def execute(self, targets):
NailgunTask.killall(self.context.log, everywhere=self.context.options.ng_killall_everywhere)

ng_killall = goal(name='ng-killall', action=NailgunKillall)
ng_killall.install().with_description('Kill any running nailgun servers spawned by pants.')
ng_killall = goal(name='ng-killall', action=NailgunKillall)
ng_killall.install().with_description('Kill any running nailgun servers spawned by pants.')

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


def get_port_and_pidfile(context):
Expand Down Expand Up @@ -686,27 +674,12 @@ def execute(self, targets):
action=CheckExclusives).install('check-exclusives').with_description(
'Check exclusives declarations to verify that dependencies are consistent.')


goal(
name='idl',
action=IdlResolve,
).install('resolve-idl').with_description('Resolves idl jar dependencies.')

goal(
name='extract',
action=Extract,
).install('resolve-idl')

# TODO(John Sirois): gen attempted as the sole Goal should gen for all known gen types but
# recognize flags to narrow the gen set
goal(name='thrift', action=ThriftGen,
dependencies=['resolve-idl']).install('gen').with_description('Generate code.')
goal(name='scrooge', action=ScroogeGen,
dependencies=['resolve-idl']).install('gen')
goal(name='protoc', action=ProtobufGen,
dependencies=['resolve-idl']).install('gen')
goal(name='antlr', action=AntlrGen,
dependencies=['resolve-idl']).install('gen')
goal(name='thrift', action=ThriftGen).install('gen').with_description('Generate code.')
goal(name='scrooge', action=ScroogeGen).install('gen')
goal(name='protoc', action=ProtobufGen).install('gen')
goal(name='antlr', action=AntlrGen).install('gen')

goal(
name='checkstyle',
Expand Down
4 changes: 2 additions & 2 deletions src/python/twitter/pants/targets/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ class WithLegacyResources(TargetWithSources):
"""Collects resources whether they are specified using globs against an assumed parallel
'resources' directory or they are Resources targets
"""
def __init__(self, name, sources=None, resources=None):
TargetWithSources.__init__(self, name, sources=sources)
def __init__(self, name, sources=None, resources=None, exclusives=None):
TargetWithSources.__init__(self, name, sources=sources, exclusives=exclusives)

if resources is not None:
def is_resources(item):
Expand Down
20 changes: 9 additions & 11 deletions src/python/twitter/pants/tasks/check_exclusives.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@

from collections import defaultdict
from copy import copy
from itertools import chain
import string
import sys
from twitter.pants.base import Target
from twitter.pants.tasks import Task, TaskError
from twitter.pants.targets import InternalTarget


class CheckExclusives(Task):
"""Task for computing transitive exclusive maps.
Expand Down Expand Up @@ -53,7 +51,6 @@ class CheckExclusives(Task):
ExclusivesMapping object will be created.
"""


@classmethod
def setup_parser(cls, option_group, args, mkflag):
Task.setup_parser(option_group, args, mkflag)
Expand Down Expand Up @@ -152,15 +149,14 @@ def get_group_key_for_target(self, target):
return self.target_to_key[target]

def get_group_keys(self):
"""Get the set of keys for all exclusives groups in the current build.
"""
"""Get the set of keys for all exclusives groups in the current build."""
if len(self.conflicting_exclusives) == 0:
return ["<none>"]
else:
return self.key_to_targets.keys()

def get_ordered_group_keys(self):
""" Compute the correct order in which to compile exclusives groups.
"""Compute the correct order in which to compile exclusives groups.
In group, we already do group-based ordering. But that ordering is done separately on
each exclusives group. If we have a grouping:
Expand All @@ -175,7 +171,7 @@ def get_ordered_group_keys(self):
def number_of_emptys(key):
if key == "<none>":
return len(self.conflicting_keys)
return string.count(key, "<none>")
return key.count("<none>")

if self.ordering is not None:
return self.ordering
Expand Down Expand Up @@ -216,7 +212,7 @@ def _get_exclusives_key(self, target):
return ','.join(target_key)

def _populate_target_maps(self, targets):
""" Populates maps of exclusive keys to targets, and vice versa."""
"""Populates maps of exclusive keys to targets, and vice versa."""
all_targets = set()
workqueue = copy(targets)
while len(workqueue) > 0:
Expand All @@ -236,7 +232,7 @@ def _populate_target_maps(self, targets):
self.target_to_key[t] = key

def get_classpath_for_group(self, group_key):
""" Get the classpath to use for jvm compilations of a group.
"""Get the classpath to use for jvm compilations of a group.
Each exclusives group requires a distinct classpath. We maintain
them here as a map from the exclusives key to a classpath. The
Expand Down Expand Up @@ -275,7 +271,9 @@ def _is_compatible(self, mod_key, other_key):
return True

def update_compatible_classpaths(self, group_key, path_additions):
""" Update the classpath of all groups compatible with group_key, adding path_additions to their classpath."""
"""Update the classpath of all groups compatible with group_key, adding path_additions to their
classpath.
"""
for key in self._group_classpaths:
if group_key is None or self._is_compatible(group_key, key):
group_classpath = self._group_classpaths[key]
Expand Down
4 changes: 2 additions & 2 deletions src/python/twitter/pants/tasks/checkstyle.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import os

from twitter.common.dirutil import safe_open
from twitter.pants import is_codegen, is_java
from twitter.pants import is_java, is_synthetic
from twitter.pants.tasks import TaskError
from twitter.pants.tasks.nailgun_task import NailgunTask

Expand All @@ -28,7 +28,7 @@
class Checkstyle(NailgunTask):
@staticmethod
def _is_checked(target):
return is_java(target) and not is_codegen(target)
return is_java(target) and not is_synthetic(target)

@classmethod
def setup_parser(cls, option_group, args, mkflag):
Expand Down
5 changes: 2 additions & 3 deletions src/python/twitter/pants/tasks/jvm_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@

class JvmTask(Task):
def get_base_classpath_for_target(self, target):
"""Note: to use this method, the exclusives_groups data product
must be available. This should have been set by the prerequisite
java/scala compile."""
"""Note: to use this method, the exclusives_groups data product must be available. This should
have been set by the prerequisite java/scala compile."""
egroups = self.context.products.get_data('exclusives_groups')
group_key = egroups.get_group_key_for_target(target)
return egroups.get_classpath_for_group(group_key)
Expand Down
Loading

0 comments on commit 245b070

Please sign in to comment.