Skip to content

Coding contributions guide

Rafael Acosta edited this page Sep 9, 2020 · 6 revisions

Standard user don't need to manually download or build our artifacts as they are available at public repositories preconfigured by Android Studio. Just follow the installation instructions in our README to add our dependencies and rebuild your project.

Following instructions are for advanced user who want to apply changes to our source code, test them locally and send us a Pull Request. You will become a proper contributor and our community will be grateful to you for life! From small bug fixing to big new features.

Open an issue (optional)

It's recommended, but not compulsory, to start creating an issue related to your plans, to let us know that you are going to work on it. It allow to sync our efforts and to avoid doing the same task twice. You could also receive helpful tips, recommendations and advises about the areas you are going to modify.

Pull requests

Use a Pull Request to send us your changes and we will integrate them as soon as possible.

Working on your first Pull Request? You can learn how from this free series, How to Contribute to an Open Source Project on GitHub. Feel free to ask for help; everyone is a beginner at first 😸

Building our project

Project structure

All our artifacts are generated from the same Android Studio project hosted in this repo. Each one use a different combinations of Gradle module and variant.

Artifact Module Variant Description Publication
es.rafaco.inappdevtools plugin - IADT plugin for Gradle Gradle Plugin Portal
es.rafaco.inappdevtools:support library support IADT library for Support libraries Bintray / jCenter
es.rafaco.inappdevtools:androidx library androidx IADT library for AndroidX libraries Bintray / jCenter
es.rafaco.inappdevtools:noop noop - IADT library, no operational Bintray / jCenter
es.rafaco.compat:support compat support Compat library for Support libraries Bintray / jCenter
es.rafaco.compat:androidx compat androidx Compat library for AndroidX libraries Bintray / jCenter
es.rafaco.iadt.demo demo androidx/support Demo app Google Play
inappdevtools.org website - Promo website inappdevtools.org

AndroidX/Support artifacts

Our project have predefined "Run Configurations" for AndroidX or Support builds per each module. Use them to automatically switch between AndroidX or Support builds.

In a nutshell, we use a mix of techniques to generate artifacts for both libraries from the same source code:

  • Libraries dependencies are configured per variant
  • AndroidX Gradle properties are set by command line
  • A Java preprocessor change source imports and other source references per variant (Compat module)

This techniques overrides standard switch on Android Studio via "Build Variants" panel, so it doesn't work in our project. To re-enable it and manually build AndroidX variants of any submodule: remove custom command line args and restore AndroidX properties at gradle.properties file (android.useAndroidX=true and android.enableJetifier=true).

Sources at our repo should always be ready to build support variant, as it also works on AndroidX project but not the other way around. Test your build switching to Androidx but perform a last build using Support libraries before committing, to restore support sources.

'Sync' in Android Studio 4.0 or above

Starting from Android Studio 4.0 (May 2020), "Sync Project with Gradle files" feature will not work when called directly on this project and you will see the following error:

This project uses AndroidX dependencies, but the 'android.useAndroidX' property is not enabled. Set this property to true in the gradle.properties file and retry.
The following AndroidX dependencies are detected: ...

You have to use any of our "Run Configurations" and the dependent 'Sync' will work, as they properly setup 'android.useAndroidX' flags before calling 'Sync'.

Publishing to your local repository

To build all our artifacts and publish them to your local Maven repository, use Deploy all to local (DEV) run configuration predefined in our project. Individual run configurations are also available and named like Publish [MODULE] [VARIANT] to LOCAL.

Using your local artifacts

To load locally published artifacts into your app, you have to add local repositories definitions to your project.

On your root build.gradle file, add mavenLocal repository for allprojects:

allprojects {
    repositories {
        mavenLocal()
        ...
    }
}

For the plugin repository it depends on the way you choose to include it in your project. If you use the modern plugins closure, go to your root settings.gradle file and add a pluginManagement closure defining mavenLocal and standard gradlePluginPortal repositories (it should be before any other settings):

pluginManagement {
    repositories {
        mavenLocal()
        gradlePluginPortal()
    }
}

If you use the legacy classpath closure, go to your root build.gradle file, and add mavenLocal to your buildscipt repositories:

buildscript {
    repositories {
        google()
        jcenter()
        mavenLocal()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:X.X.X'
        classpath "es.rafaco.inappdevtools:inappdevtools-plugin:X.X.X"
    }
}

Continuous Integration

We use CircleCi to automatise tests for commit and for PR. We currently perform a build for every artifact and generate some reports. Unit test are not implemented.

  1. Build
    1. Assemble and include PLUGIN
    2. Assemble and local publish COMPAT SupportDebug
    3. Assemble and local publish COMPAT AndroidXDebug
    4. Assemble NOOP Debug
    5. Assemble LIBRARY SupportDebug
    6. Assemble DEMO SupportDebug
    7. Assemble LIBRARY AndroidxDebug
    8. Assemble DEMO AndroidxDebug
  2. Report:
    1. Lint report LIBRARY SupportDebug
    2. Lint report DEMO SupportDebug
    3. Sonar report ALL SupportDebug and upload to SonarCloud
master develop
Circle-Ci build

CircleCI

CircleCI

Sonar Status

Quality Gate Status
Maintainability Rating
Reliability Rating
Security Rating

//TODO

Sonar Issues

Bugs
Code Smells
Vulnerabilities
Technical Debt

//TODO

Sonar Metrics

Coverage
Duplicated Lines (%)
Lines of Code

//TODO

For other branches swap it manually at Circle-Ci or SonarCloud

Coding standards

//TODO