diff --git a/.travis.yml b/.travis.yml index 072f8da..c8ce000 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,8 +2,11 @@ language: objective-c os: osx +# Add a TEST_DIR=[directory] row for each library (or group of libraries) to test +# Each will be run as an independent, hermetic test (in parallel when resources permit) +# on Traivs. env: - - USING_OS=osx USING_XCODE=6.1 + - TEST_DIR=gson branches: only: @@ -16,7 +19,8 @@ sudo: false install: - export TERM=dumb - env - - if [ "$USING_OS" = "osx" ]; then (/usr/libexec/java_home -v 1.7 -F -V); fi + - xcrun clang -v + - /usr/libexec/java_home -v 1.7 -F -V - java -Xmx32m -version && javac -J-Xmx32m -version - pushd j2objc-gradle - ./gradlew wrapper @@ -24,6 +28,10 @@ install: # In this repo, building of the j2objc-gradle plugin is just preperation. - ./gradlew build - popd + - pushd libraryBuilds + # Downloads and configures j2objc distribution. + - ./prep.sh +# Note the install prep leaves us in the libraryBuilds directory. script: - - echo TODO Run some e2e tests. + - ./run-test.sh $TEST_DIR diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..38c24f2 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,49 @@ +Please keep in mind that your "Contribution(s)" are submitted under +the [Apache 2.0 License](LICENSE). + +#### Updating j2objc-gradle +The version of j2objc-gradle in this repo is not automatically kept up +to date with master of https://github.com/j2objc-contrib/j2objc-gradle. + +As a submodule, you can update j2objc-gradle by doing: + +```shell +# (start with a clean git working directory) +# (from your local repo for this project) +git checkout -b update-plugin +pushd j2objc-gradle +git pull +popd +git add . +git commit -m 'Updating j2objc-gradle to HEAD' +# (submit the update-plugin branch as a PR to the repo) +``` + +Make sure this PR is seperate from any other work. If a library you want +to build depends on the update, work in a new branch parented to the commit +above. + +#### Library build verification + +On OS X we have system tests under the `libraryBuilds` directory. Each test directory +has one root Gradle project (and zero or more subprojects), some or all of which apply the +`j2objc-gradle` plugin. Locally you can run them as follows: + +```sh +# Once per git repository and/or new release of j2objc, run prep. +pushd libraryBuilds && ./prep.sh && popd +# This downloads j2objc and prepares the environment. + +# Every time you want to run the build tests: +./gradlew build && pushd systemTests && ./run-all.sh && popd +# Normal Gradle build results will be displayed for each test project. +``` + +These system tests are also run as part of OS X continuous integration builds on Travis. +You are not required to run the system tests locally before creating a PR (they can take +time and processing power), however if the tests fail on Travis you will need to update +the PR until they pass. + +When you add a new library to build, make sure it is referenced in run-all.sh (for +human contributors) and in .travis.yml (for continuous builds). + diff --git a/libraryBuilds/.gitignore b/libraryBuilds/.gitignore new file mode 100644 index 0000000..9723eb9 --- /dev/null +++ b/libraryBuilds/.gitignore @@ -0,0 +1,8 @@ +# Ignore all the wrappers below. +gradle/ +gradlew.bat +# Under this directory, we do in fact need to preserve local.properties! +!local.properties +# Generated by prep.sh +common/local.properties +localJ2objcDist/ diff --git a/libraryBuilds/gson/build.gradle b/libraryBuilds/gson/build.gradle new file mode 100644 index 0000000..657321f --- /dev/null +++ b/libraryBuilds/gson/build.gradle @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2015 the authors of j2objc-common-libs-e2e-test + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +buildscript { + repositories { + jcenter() + } + dependencies { + // This is the build output of the plugin itself. + classpath fileTree(dir: '../../j2objc-gradle/build/libs', include: ['*.jar']) + } +} + +apply plugin: 'java' +apply plugin: 'com.github.j2objccontrib.j2objcgradle' + +repositories { + mavenCentral() +} + +dependencies { + j2objcTranslation 'com.google.code.gson:gson:2.3.1:sources' +} + +j2objcConfig { + filenameCollisionCheck false + + // Almost always there are no tests provided in an external source jar. + testMinExpectedTests 0 + finalConfigure() +} diff --git a/libraryBuilds/gson/gradlew b/libraryBuilds/gson/gradlew new file mode 120000 index 0000000..bde144b --- /dev/null +++ b/libraryBuilds/gson/gradlew @@ -0,0 +1 @@ +../../j2objc-gradle/gradlew \ No newline at end of file diff --git a/libraryBuilds/gson/local.properties b/libraryBuilds/gson/local.properties new file mode 120000 index 0000000..217624b --- /dev/null +++ b/libraryBuilds/gson/local.properties @@ -0,0 +1 @@ +../common/local.properties \ No newline at end of file diff --git a/libraryBuilds/prep.sh b/libraryBuilds/prep.sh new file mode 100755 index 0000000..c974a2d --- /dev/null +++ b/libraryBuilds/prep.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# +# Copyright (c) 2015 the authors of j2objc-common-libs-e2e-test +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +J2OBJC_VERSION=0.9.8.1 +mkdir localJ2objcDist +mkdir common + +# Fail if any command fails +set -ev + +pushd localJ2objcDist + +# For developer local testing, don't keep redownloading the zip file. +if [ ! -e j2objcDist.zip ]; then + curl -L https://github.com/google/j2objc/releases/download/$J2OBJC_VERSION/j2objc-$J2OBJC_VERSION.zip > j2objcDist.zip + unzip j2objcDist.zip + mv j2objc-$J2OBJC_VERSION j2objcDist + echo j2objc.home=$PWD/j2objcDist > ../common/local.properties +fi + +popd diff --git a/libraryBuilds/run-all.sh b/libraryBuilds/run-all.sh new file mode 100755 index 0000000..019e216 --- /dev/null +++ b/libraryBuilds/run-all.sh @@ -0,0 +1,20 @@ +#!/bin/bash +# +# Copyright (c) 2015 the authors of j2objc-common-libs-e2e-test +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Fail if anything fails. +set -ev + +./run-test.sh gson diff --git a/libraryBuilds/run-test.sh b/libraryBuilds/run-test.sh new file mode 100755 index 0000000..9fb30d1 --- /dev/null +++ b/libraryBuilds/run-test.sh @@ -0,0 +1,26 @@ +#!/bin/bash +# +# Copyright (c) 2015 the authors of j2objc-common-libs-e2e-test +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Fail if anything fails. +set -ev + +TEST_DIR=$1 +echo Running test $TEST_DIR +pushd $TEST_DIR +./gradlew wrapper +./gradlew clean +./gradlew build +popd