Skip to content

Commit

Permalink
Merge pull request #23 from madvay/lib-gson
Browse files Browse the repository at this point in the history
Adds testing scripts and Gson as first library.
  • Loading branch information
advayDev1 committed Sep 28, 2015
2 parents 58d9d40 + 64da574 commit f1c0aef
Show file tree
Hide file tree
Showing 9 changed files with 199 additions and 3 deletions.
14 changes: 11 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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=com.google.code.gson-gson

branches:
only:
Expand All @@ -16,14 +19,19 @@ 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
- ./gradlew dependencies
# 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
48 changes: 48 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
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 HEAD 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.

TODO: [Automate this](https://github.com/j2objc-contrib/j2objc-common-libs-e2e-test/issues/33)

#### 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
pushd libraryBuilds
./prep.sh
./run-all.sh
# Normal Gradle build results will be displayed for each test project.
popd
```

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).
11 changes: 11 additions & 0 deletions libraryBuilds/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Ignore all the wrappers below.
gradle/
gradlew.bat

# local.properties is retained in this directory because
# they are soft links to common/local.properties (below).
!local.properties

# Generated by prep.sh
common/local.properties
localJ2objcDist/
45 changes: 45 additions & 0 deletions libraryBuilds/com.google.code.gson-gson/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* 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 {
jcenter()
}

dependencies {
j2objcTranslation 'com.google.code.gson:gson:2.3.1:sources'
}

j2objcConfig {
// package-info.java exists in multiple packages.
filenameCollisionCheck false

// Almost always there are no tests provided in an external source jar.
testMinExpectedTests 0
finalConfigure()
}
1 change: 1 addition & 0 deletions libraryBuilds/com.google.code.gson-gson/gradlew
1 change: 1 addition & 0 deletions libraryBuilds/com.google.code.gson-gson/local.properties
36 changes: 36 additions & 0 deletions libraryBuilds/prep.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/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

DIST_DIR=j2objc-$J2OBJC_VERSION
DIST_FILE=$DIST_DIR.zip

# For developer local testing, don't keep redownloading the zip file.
if [ ! -e $DIST_FILE ]; then
curl -L https://github.com/google/j2objc/releases/download/$J2OBJC_VERSION/j2objc-$J2OBJC_VERSION.zip > $DIST_FILE
unzip $DIST_FILE
echo j2objc.home=$PWD/$DIST_DIR > ../common/local.properties
fi

popd
20 changes: 20 additions & 0 deletions libraryBuilds/run-all.sh
Original file line number Diff line number Diff line change
@@ -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 com.google.code.gson-gson
26 changes: 26 additions & 0 deletions libraryBuilds/run-test.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit f1c0aef

Please sign in to comment.