Skip to content

Latest commit

 

History

History
150 lines (94 loc) · 4.55 KB

HACKING.md

File metadata and controls

150 lines (94 loc) · 4.55 KB

Developer Guide

This file contains instructions that apply to developers only.

Automated Testing

Unit Tests

Unit tests can be run on your development PC and do not require an Android device or emulator. Run them frequently!

./gradlew clean assembleDebug assembleRelease test

Instrumentation Tests

These tests are designed to run on an Android device or emulator. You can build, install and execute the Android integration tests with the connectedAndroidTest Gradle command. You need a nearby Bean that the Android device can connect to.

Run the tests

Example: Run the tests against a Bean with the strongest RSSI.

./gradlew connectedAndroidTest -i

Example: Run the tests against a Bean with a specific name.`

./gradlew -PbeanName=\"TESTBEAN\" connectedAndroidTest -i

Example: Run the tests against a Bean with a specific address.

./gradlew -PbeanAddress=\"C4:BE:84:49:BD:3C\" connectedAndroidTest -i

Note: The beanName and beanAddress variables are Gradle properties, so they can be set in a .properties file, command-line argument, or an environment variable.

Look at results

firefox sdk/build/outputs/reports/androidTests/connected/index.html

Build and Release

This project is built using Gradle and hosted on Maven Central.

Build Process

Here is a high-level description of the build process.

  1. Compile code
  2. Generate (build) artifacts
  3. Digitally sign the artifacts
  4. Upload staging artifacts to Sonatype Nexus
  5. Promote staging artifacts to production

Start by configuring your build environment (see Build Environment Configuration below). Once that's done, you can automate steps 1-4 by running a single command:

./gradlew uploadArchives

If that command completes without error, you can view the Staging Repository that was just published by the build script on the Nexus Dashboard. Find the repository that was just published in the list and click "Close" which will automatically promote it as an official release!

Build Environment Configuration

Create a configuration file at ~/.gradle/gradle.properties and fill it with the following:

systemProp.nexusUsername=punchthrough
systemProp.nexusPassword=PUNCH_THROUGH_NEXUS_PASSWORD
signing.keyId=YOUR_RSA_KEY_ID
signing.password=YOUR_RSA_KEY_PASSPHRASE
signing.secretKeyRingFile=/Users/YOUR_USERNAME/.gnupg/secring.gpg

Replace the placeholder values with the appropriate information. This information can be given to you by a project administrator (Stephen Stack and Matthew Lewis).

Javadocs

Building

./gradlew -q buildDocs

Now look at the new Javadocs!

firefox build/javadoc/index.html

Deploying to GitHub Pages

Building and deploying Javadocs to GitHub Pages is an automated process.

First, cd into docs/ and install the script dependencies:

npm install

Then deploy to gh-pages!

npm run gulp deploy

SDK Local Dependency

This section will tell you how to use the SDK as a local dependency in another project. This is useful during development when you want to test out SDK changes in a different application before a new version of the SDK is released to Maven Central.

This process has two steps...

  1. Setup your application to consume the SDK as a local dependency in the form of a .jar file.
  2. Build the SDK as a .jar file and put it somewhere your application can find it.

Step 1

Edit your applications app/build.gradle file so that it contains the following line in the dependecies{} block:

dependencies {
    ...
    
    compile fileTree(dir: 'libs', include: ['*.jar'])
}

This tells Gradle to compile all .jar files in the folder app/libs. Make sure this folder exists! To be clear, this step is not talking about the SDK project, we are referring to a different project (application) in which you want to include the SDK as a local dependency.

Step 2

Run the export_jars.py script in the SDK project. It takes one argument, which is the path to your applications app/libs folder from step 1.

Example:

./export_jars.py /my/android/project/app/libs

Helpful Gradle Tasks

  • ./gradlew tasks - lists all available gradle tasks w/ short description
  • ./gradlew -q help --task <task> - detailed information about a specific task