Skip to content

Commit

Permalink
Move Android into contrib and remove android special-casing.
Browse files Browse the repository at this point in the history
This creates the new android contrib module. This commit
includes CR 3530 and 3531 - codependent commits
that were split to aid reviewers.

This moves android from a special-cased backend into
a regular contrib module. It removes all special-casing the
android backend collected over the years.

The '-a' flag for CI to skip android tests is still
available - the OSX CI will not be running the
android tests.

* I created a new xml_test_base python_library.
  It was previously embedded within a python_test. But
  that class is imported in the contrib module. It was
  working before by some transitive magic.

Testing Done:
A Travis run that has both CR 3530 and 3531 is at:
https://travis-ci.org/pantsbuild/pants/builds/113272561

Bugs closed: 3002

Reviewed at https://rbcommons.com/s/twitter/r/3530/
Reviewed at https://rbcommons.com/s/twitter/r/3531/
  • Loading branch information
mateor committed Mar 8, 2016
1 parent 3af2595 commit c898eb2
Show file tree
Hide file tree
Showing 89 changed files with 267 additions and 227 deletions.
2 changes: 1 addition & 1 deletion .travis.osx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ env:
# non-platform fragile lints.
# - CI_FLAGS="-clpnet 'Various pants self checks'" # (fkmsr)
- CI_FLAGS="-fkmsrcn 'Unit tests for pants and pants-plugins'" # (jlp)
- CI_FLAGS="-fkmsrcjlp 'Python contrib tests'" # (n)
- CI_FLAGS="-fkmsrcjlpa 'Python contrib tests'" # (n)
- CI_FLAGS="-fkmsrjlpn -i 0/3 'Python integration tests for pants - shard 1'" # (c)
- CI_FLAGS="-fkmsrjlpn -i 1/3 'Python integration tests for pants - shard 2'"
- CI_FLAGS="-fkmsrjlpn -i 2/3 'Python integration tests for pants - shard 3'"
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ env:
- CI_FLAGS="-cjlpn 'Various pants self checks'" # (fkmsr)
- CI_FLAGS="-fkmsrcn -u 0/2 'Unit tests for pants and pants-plugins - shard 1'" # (jlp)
- CI_FLAGS="-fkmsrcn -u 1/2 'Unit tests for pants and pants-plugins - shard 2'"
- CI_FLAGS="-fkmsrcjlp 'Python contrib tests'" # (n)
- CI_FLAGS="-fkmsrcjlpa 'Python contrib tests'" # (n)
- CI_FLAGS="-fkmsrjlpn -i 0/6 'Python integration tests for pants - shard 1'" # (c)
- CI_FLAGS="-fkmsrjlpn -i 1/6 'Python integration tests for pants - shard 2'"
- CI_FLAGS="-fkmsrjlpn -i 2/6 'Python integration tests for pants - shard 3'"
Expand Down
8 changes: 4 additions & 4 deletions build-support/bin/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ function usage() {
echo " if running core python tests, divide them into"
echo " TOTAL_SHARDS shards and just run those in SHARD_NUMBER"
echo " to run only even tests: '-u 0/2', odd: '-u 1/2'"
echo " -a skip android targets when running tests"
echo " -n skip contrib python tests"
echo " -c skip pants integration tests (includes examples and testprojects)"
echo " -i SHARD_NUMBER/TOTAL_SHARDS"
Expand Down Expand Up @@ -68,6 +69,7 @@ while getopts "hfxbkmsrjlpu:nci:a" opt; do
l) skip_internal_backends="true" ;;
p) skip_python="true" ;;
u) python_unit_shard=${OPTARG} ;;
a) skip_android="true" ;;
n) skip_contrib="true" ;;
c) skip_integration="true" ;;
i) python_intg_shard=${OPTARG} ;;
Expand All @@ -80,9 +82,7 @@ shift $((${OPTIND} - 1))
# Android testing requires the SDK to be installed and configured in Pants.
# Skip if ANDROID_HOME isn't configured in the environment
if [[ -z "${ANDROID_HOME}" || "${skip_android:-false}" == "true" ]] ; then
export SKIP_ANDROID="true"
else
export SKIP_ANDROID="false"
export SKIP_ANDROID_PATTERN='contrib/android'
fi

if [[ $# > 0 ]]; then
Expand Down Expand Up @@ -202,7 +202,7 @@ if [[ "${skip_contrib:-false}" == "false" ]]; then
# test (ie: pants_test.contrib) namespace packages.
# TODO(John Sirois): Get to the bottom of the issue and kill --no-fast, see:
# https://github.com/pantsbuild/pants/issues/1149
./pants.pex ${PANTS_ARGS[@]} --exclude-target-regexp='.*/testprojects/.*' test.pytest --fail-slow --no-fast contrib::
./pants.pex ${PANTS_ARGS[@]} --exclude-target-regexp='.*/testprojects/.*' --ignore-patterns=$SKIP_ANDROID_PATTERN test.pytest --fail-slow --no-fast contrib::
) || die "Contrib python test failure"
fi

Expand Down
13 changes: 0 additions & 13 deletions build-support/bin/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,29 +51,16 @@ function pkg_pants_testinfra_install_test() {
python -c "import pants_test"
}

PKG_PANTS_BACKEND_ANDROID=(
"pantsbuild.pants.backend.android"
"//src/python/pants/backend/android:plugin"
"pkg_pants_backend_android_install_test"
)
function pkg_pants_backend_android_install_test() {
execute_packaged_pants_with_internal_backends \
--plugins="['pantsbuild.pants.backend.android==$(local_version)']" \
goals | grep "apk" &> /dev/null
}

# Once an individual (new) package is declared above, insert it into the array below)
RELEASE_PACKAGES=(
PKG_PANTS
PKG_PANTS_BACKEND_ANDROID
PKG_PANTS_TESTINFRA
${CONTRIB_PACKAGES[*]}
)
#
# End of package declarations.
#


function run_local_pants() {
${ROOT}/pants "$@"
}
Expand Down
1 change: 1 addition & 0 deletions build-support/pants-intellij.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

# We don't want to include targets which are used in unit tests in our project so let's exclude them.
./pants export src/python/:: tests/python/pants_test:: contrib/:: \
--exclude-target-regexp='.*android.*' \
--exclude-target-regexp='.*go/examples.*' \
--exclude-target-regexp='.*scrooge/tests/thrift.*' \
--exclude-target-regexp='.*spindle/tests/thrift.*' \
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
android_library(
name='example_library',
manifest='AndroidManifest.xml',
libraries=['3rdparty/android:android-support-v4'],
libraries=['contrib/android/examples/3rdparty/android:android-support-v4'],
include_patterns=[
'android/**/*.class',
],
Expand All @@ -23,7 +23,7 @@ android_resources(

android_library(
name='gms-library',
libraries=['3rdparty/android:google-play-services'],
libraries=['contrib/android/examples/3rdparty/android:google-play-services'],
include_patterns=[
'**/*.class',
],
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ android_binary(
manifest='main/AndroidManifest.xml',
dependencies = [
':resources',
'examples/src/android/example_library',
'contrib/android/examples/src/android/example_library',
':support-library',
],
)
Expand All @@ -21,7 +21,7 @@ android_resources(

android_library(
name='support-library',
libraries=['3rdparty/android:android-support-v4'],
libraries=['contrib/android/examples/3rdparty/android:android-support-v4'],
include_patterns=[
'**/*.class',
],
Expand Down
1 change: 1 addition & 0 deletions contrib/android/src/python/pants/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__import__('pkg_resources').declare_namespace(__name__)
1 change: 1 addition & 0 deletions contrib/android/src/python/pants/contrib/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__import__('pkg_resources').declare_namespace(__name__)
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
# coding=utf-8
# Copyright 2014 Pants project contributors (see CONTRIBUTORS.md).
# Copyright 2015 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

pants_plugin(
contrib_plugin(
name='plugin',
dependencies=[
'src/python/pants/backend/android/targets:android',
'src/python/pants/backend/android/tasks:all',
'contrib/android/src/python/pants/contrib/android/targets:android',
'contrib/android/src/python/pants/contrib/android/tasks:all',
'src/python/pants/build_graph',
'src/python/pants/goal:task_registrar',
],
distribution_name='pantsbuild.pants.backend.android',
description='Support for android projects.',
distribution_name='pantsbuild.pants.contrib.android',
description='Android Pants plugin',
additional_classifiers=[
'Topic :: Software Development :: Code Generators'
],
build_file_aliases=True,
register_goals=True,
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__import__('pkg_resources').declare_namespace(__name__)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__import__('pkg_resources').declare_namespace(__name__)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__import__('pkg_resources').declare_namespace(__name__)
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,20 @@
from __future__ import (absolute_import, division, generators, nested_scopes, print_function,
unicode_literals, with_statement)

from pants.backend.android.targets.android_binary import AndroidBinary
from pants.backend.android.targets.android_dependency import AndroidDependency
from pants.backend.android.targets.android_library import AndroidLibrary
from pants.backend.android.targets.android_resources import AndroidResources
from pants.backend.android.tasks.aapt_builder import AaptBuilder
from pants.backend.android.tasks.aapt_gen import AaptGen
from pants.backend.android.tasks.dx_compile import DxCompile
from pants.backend.android.tasks.sign_apk import SignApkTask
from pants.backend.android.tasks.unpack_libraries import UnpackLibraries
from pants.backend.android.tasks.zipalign import Zipalign
from pants.build_graph.build_file_aliases import BuildFileAliases
from pants.goal.task_registrar import TaskRegistrar as task

from pants.contrib.android.targets.android_binary import AndroidBinary
from pants.contrib.android.targets.android_dependency import AndroidDependency
from pants.contrib.android.targets.android_library import AndroidLibrary
from pants.contrib.android.targets.android_resources import AndroidResources
from pants.contrib.android.tasks.aapt_builder import AaptBuilder
from pants.contrib.android.tasks.aapt_gen import AaptGen
from pants.contrib.android.tasks.dx_compile import DxCompile
from pants.contrib.android.tasks.sign_apk import SignApkTask
from pants.contrib.android.tasks.unpack_libraries import UnpackLibraries
from pants.contrib.android.tasks.zipalign import Zipalign


def build_file_aliases():
return BuildFileAliases(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ python_library(
'android_target.py',
],
dependencies = [
'src/python/pants/backend/android:android_manifest_parser',
'contrib/android/src/python/pants/contrib/android:android_config_util',
'contrib/android/src/python/pants/contrib/android:android_manifest_parser',
'src/python/pants/backend/jvm/targets:jvm',
'src/python/pants/base:build_environment',
'src/python/pants/base:exceptions',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__import__('pkg_resources').declare_namespace(__name__)
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
from __future__ import (absolute_import, division, generators, nested_scopes, print_function,
unicode_literals, with_statement)

from pants.backend.android.targets.android_target import AndroidTarget
from pants.base.exceptions import TargetDefinitionException
from pants.util.memo import memoized_property

from pants.contrib.android.targets.android_target import AndroidTarget


class AndroidBinary(AndroidTarget):
"""An Android binary."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@

import os

from pants.backend.android.android_manifest_parser import AndroidManifestParser
from pants.backend.android.targets.android_target import AndroidTarget
from pants.backend.jvm.targets.import_jars_mixin import ImportJarsMixin
from pants.base.payload import Payload
from pants.base.payload_field import PrimitiveField
from pants.util.memo import memoized_property

from pants.contrib.android.android_manifest_parser import AndroidManifestParser
from pants.contrib.android.targets.android_target import AndroidTarget


class AndroidLibrary(ImportJarsMixin, AndroidTarget):
"""Android library projects that access Android API or Android resources.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@

import os

from pants.backend.android.targets.android_target import AndroidTarget
from pants.base.exceptions import TargetDefinitionException

from pants.contrib.android.targets.android_target import AndroidTarget


class AndroidResources(AndroidTarget):
"""Android resources used to generate R.java."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@

import os

from pants.backend.android.android_manifest_parser import AndroidManifestParser
from pants.backend.jvm.targets.jvm_target import JvmTarget
from pants.base.exceptions import TargetDefinitionException
from pants.util.memo import memoized_property

from pants.contrib.android.android_manifest_parser import AndroidManifestParser


class AndroidTarget(JvmTarget):
"""A base class for all Android targets."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ python_library(
name = 'android_task',
sources = ['android_task.py'],
dependencies = [
'src/python/pants/backend/android:android_distribution',
'contrib/android/src/python/pants/contrib/android:android_distribution',
'src/python/pants/task',
],
)
Expand All @@ -29,8 +29,8 @@ python_library(
name = 'aapt_builder',
sources = ['aapt_builder.py'],
dependencies = [
'src/python/pants/backend/android/targets:android',
'src/python/pants/backend/android/tasks:aapt_task',
'contrib/android/src/python/pants/contrib/android/targets:android',
'contrib/android/src/python/pants/contrib/android/tasks:aapt_task',
'src/python/pants/base:exceptions',
'src/python/pants/base:workunit',
'src/python/pants/util:dirutil',
Expand All @@ -41,8 +41,8 @@ python_library(
name = 'aapt_gen',
sources = ['aapt_gen.py'],
dependencies = [
'src/python/pants/backend/android/targets:android',
'src/python/pants/backend/android/tasks:aapt_task',
'contrib/android/src/python/pants/contrib/android/targets:android',
'contrib/android/src/python/pants/contrib/android/tasks:aapt_task',
'src/python/pants/backend/jvm/targets:java',
'src/python/pants/base:build_environment',
'src/python/pants/base:exceptions',
Expand All @@ -56,8 +56,8 @@ python_library(
name = 'aapt_task',
sources = ['aapt_task.py'],
dependencies = [
'src/python/pants/backend/android/targets:android',
'src/python/pants/backend/android/tasks:android_task',
'contrib/android/src/python/pants/contrib/android/targets:android',
'contrib/android/src/python/pants/contrib/android/tasks:android_task',
],
)

Expand All @@ -66,8 +66,8 @@ python_library(
sources = ['dx_compile.py'],
dependencies = [
'3rdparty/python/twitter/commons:twitter.common.collections',
'src/python/pants/backend/android/targets:android',
'src/python/pants/backend/android/tasks:android_task',
'contrib/android/src/python/pants/contrib/android/targets:android',
'contrib/android/src/python/pants/contrib/android/tasks:android_task',
'src/python/pants/backend/jvm/tasks:classpath_util',
'src/python/pants/backend/jvm/tasks:nailgun_task',
'src/python/pants/backend/jvm/tasks:unpack_jars',
Expand All @@ -79,9 +79,9 @@ python_library(
name = 'sign_apk',
sources = ['sign_apk.py'],
dependencies = [
'src/python/pants/backend/android:android_config_util',
'src/python/pants/backend/android:keystore_resolver',
'src/python/pants/backend/android/targets:android',
'contrib/android/src/python/pants/contrib/android:android_config_util',
'contrib/android/src/python/pants/contrib/android:keystore_resolver',
'contrib/android/src/python/pants/contrib/android/targets:android',
'src/python/pants/base:exceptions',
'src/python/pants/base:workunit',
'src/python/pants/java/distribution:distribution',
Expand All @@ -94,7 +94,7 @@ python_library(
name = 'unpack_libraries',
sources = ['unpack_libraries.py'],
dependencies = [
'src/python/pants/backend/android/targets:android',
'contrib/android/src/python/pants/contrib/android/targets:android',
'src/python/pants/backend/jvm/targets:jvm',
'src/python/pants/backend/jvm/tasks:jar_import_products',
'src/python/pants/backend/jvm:jar_dependency_utils',
Expand All @@ -110,8 +110,8 @@ python_library(
name = 'zipalign',
sources = ['zipalign.py'],
dependencies = [
'src/python/pants/backend/android/targets:android',
'src/python/pants/backend/android/tasks:android_task',
'contrib/android/src/python/pants/contrib/android/targets:android',
'contrib/android/src/python/pants/contrib/android/tasks:android_task',
'src/python/pants/base:exceptions',
'src/python/pants/base:workunit',
'src/python/pants/util:dirutil',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__import__('pkg_resources').declare_namespace(__name__)
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@
import os
import subprocess

from pants.backend.android.targets.android_resources import AndroidResources
from pants.backend.android.tasks.aapt_task import AaptTask
from pants.base.exceptions import TaskError
from pants.base.workunit import WorkUnitLabel
from pants.util.dirutil import safe_mkdir

from pants.contrib.android.targets.android_resources import AndroidResources
from pants.contrib.android.tasks.aapt_task import AaptTask


logger = logging.getLogger(__name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
import os
import subprocess

from pants.backend.android.targets.android_library import AndroidLibrary
from pants.backend.android.targets.android_resources import AndroidResources
from pants.backend.android.tasks.aapt_task import AaptTask
from pants.backend.jvm.targets.jar_dependency import JarDependency
from pants.backend.jvm.targets.jar_library import JarLibrary
from pants.backend.jvm.targets.java_library import JavaLibrary
Expand All @@ -21,6 +18,10 @@
from pants.build_graph.address import Address
from pants.util.dirutil import safe_mkdir

from pants.contrib.android.targets.android_library import AndroidLibrary
from pants.contrib.android.targets.android_resources import AndroidResources
from pants.contrib.android.tasks.aapt_task import AaptTask


logger = logging.getLogger(__name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

import os

from pants.backend.android.targets.android_binary import AndroidBinary
from pants.backend.android.tasks.android_task import AndroidTask
from pants.contrib.android.targets.android_binary import AndroidBinary
from pants.contrib.android.tasks.android_task import AndroidTask


# These are hardcoded into aapt but we added 'BUILD*'. Changes clobber, so we need entire string.
Expand Down
Loading

0 comments on commit c898eb2

Please sign in to comment.