forked from pantsbuild/pants
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into dmcclanahan/python-dist-c++-sources
- Loading branch information
Showing
186 changed files
with
5,342 additions
and
4,369 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__import__('pkg_resources').declare_namespace(__name__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__import__('pkg_resources').declare_namespace(__name__) |
18 changes: 18 additions & 0 deletions
18
contrib/googlejavaformat/src/python/pants/contrib/googlejavaformat/BUILD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Copyright 2018 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
python_library(sources=['googlejavaformat.py']) | ||
|
||
contrib_plugin( | ||
name='plugin', | ||
dependencies=[ | ||
':googlejavaformat', | ||
'src/python/pants/goal:task_registrar', | ||
], | ||
distribution_name='pantsbuild.pants.contrib.googlejavaformat', | ||
description='Google Java Format code formatter pants plugins.', | ||
additional_classifiers=[ | ||
'Topic :: Software Development :: Pre-processors' | ||
], | ||
register_goals=True, | ||
) |
Empty file.
80 changes: 80 additions & 0 deletions
80
contrib/googlejavaformat/src/python/pants/contrib/googlejavaformat/googlejavaformat.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# coding=utf-8 | ||
# Copyright 2018 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
from __future__ import (absolute_import, division, generators, nested_scopes, print_function, | ||
unicode_literals, with_statement) | ||
|
||
from abc import abstractproperty | ||
|
||
from pants.backend.jvm.tasks.rewrite_base import RewriteBase | ||
from pants.base.exceptions import TaskError | ||
from pants.java.jar.jar_dependency import JarDependency | ||
from pants.task.fmt_task_mixin import FmtTaskMixin | ||
from pants.task.lint_task_mixin import LintTaskMixin | ||
|
||
|
||
class GoogleJavaFormatBase(RewriteBase): | ||
|
||
@classmethod | ||
def register_options(cls, register): | ||
super(GoogleJavaFormatBase, cls).register_options(register) | ||
cls.register_jvm_tool(register, | ||
'google-java-format', | ||
classpath=[ | ||
JarDependency(org='com.google.googlejavaformat', | ||
name='google-java-format', | ||
rev='1.5') | ||
]) | ||
|
||
@classmethod | ||
def implementation_version(cls): | ||
return super(GoogleJavaFormatBase, cls).implementation_version() + [('GoogleJavaFormatBase', 1)] | ||
|
||
@classmethod | ||
def target_types(cls): | ||
return ['java_library', 'junit_tests', 'java_tests'] | ||
|
||
@classmethod | ||
def source_extension(cls): | ||
return '.java' | ||
|
||
def invoke_tool(self, _, target_sources): | ||
args = list(self.additional_args) | ||
args.extend([source for target, source in target_sources]) | ||
return self.runjava(classpath=self.tool_classpath('google-java-format'), | ||
main='com.google.googlejavaformat.java.Main', | ||
args=args, | ||
workunit_name='google-java-format', | ||
jvm_options=self.get_options().jvm_options) | ||
|
||
@abstractproperty | ||
def additional_args(self): | ||
"""List of additional args to supply on the tool command-line.""" | ||
|
||
|
||
class GoogleJavaFormatCheckFormat(LintTaskMixin, GoogleJavaFormatBase): | ||
"""Check if Java source code complies with Google Java Style. | ||
If the files are not formatted correctly an error is raised | ||
including the command to run to format the files correctly | ||
""" | ||
|
||
sideeffecting = False | ||
additional_args = ['--set-exit-if-changed'] | ||
|
||
def process_result(self, result): | ||
if result != 0: | ||
raise TaskError('google-java-format failed with exit code {}; to fix run: ' | ||
'`./pants fmt <targets>`'.format(result), exit_code=result) | ||
|
||
|
||
class GoogleJavaFormat(FmtTaskMixin, GoogleJavaFormatBase): | ||
"""Reformat Java source code to comply with Google Java Style.""" | ||
|
||
sideeffecting = True | ||
additional_args = ['-i'] | ||
|
||
def process_result(self, result): | ||
if result != 0: | ||
raise TaskError('google-java-format failed to format files', exit_code=result) |
16 changes: 16 additions & 0 deletions
16
contrib/googlejavaformat/src/python/pants/contrib/googlejavaformat/register.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# coding=utf-8 | ||
# Copyright 2018 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
from __future__ import (absolute_import, division, generators, nested_scopes, print_function, | ||
unicode_literals, with_statement) | ||
|
||
from pants.goal.task_registrar import TaskRegistrar as task | ||
|
||
from pants.contrib.googlejavaformat.googlejavaformat import (GoogleJavaFormat, | ||
GoogleJavaFormatCheckFormat) | ||
|
||
|
||
def register_goals(): | ||
task(name='google-java-format', action=GoogleJavaFormat).install('fmt') | ||
task(name='google-java-format', action=GoogleJavaFormatCheckFormat).install('lint') |
Empty file.
Empty file.
10 changes: 10 additions & 0 deletions
10
contrib/googlejavaformat/tests/python/pants_test/contrib/googlejavaformat/BUILD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
python_tests( | ||
dependencies = [ | ||
'contrib/googlejavaformat/src/python/pants/contrib/googlejavaformat', | ||
'src/python/pants/backend/jvm:plugin', | ||
'src/python/pants/backend/jvm/targets:java', | ||
'src/python/pants/base:exceptions', | ||
'src/python/pants/build_graph', | ||
'tests/python/pants_test/jvm:nailgun_task_test_base', | ||
], | ||
) |
Empty file.
Oops, something went wrong.