Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
src
CHANGELOG.md
README.md
build.gradle.kts

README.md

Mozilla Android gradle-plugin

The org.mozilla.android gradle plugin, hosted on plugins.gradle.org, is used to share build code across Mozilla's Android projects like Firefox for Fire TV.

Using the plugin

To use the plugin, you must first apply it and then configure specific tasks you want to run. To apply the plugin, use the legacy plugin application method.

In <project-root>/build.gradle:

buildscript {
  repositories {
    maven {
      url "https://plugins.gradle.org/m2/"
    }
  }
  dependencies {
    classpath "org.mozilla.android:gradle-plugin:0.2"
  }
}

In the module to use the plugin, e.g. <project-root>/app/build.gradle:

apply plugin: "org.mozilla.android"

Applying the plugin via the modern plugins DSL syntax is currently broken (#37).

Tasks

The following tasks can be imported from org.mozilla.android.tasks (click the links for more details):

Repository injection

Application of this plugin to a project will inject shared Mozilla repositories. Currently injected repositories are:

  • appservices: https://dl.bintray.com/ncalexander/application-services

Adding a task to your project

After applying the plugin, you can apply a task, like ValidateAndroidAppReleaseConfiguration, by:

import org.mozilla.android.tasks.*

task taskName(type: ValidateAndroidAppReleaseConfiguration) {
    // Configure the task...
}

Developing the gradle-plugin

To work on the gradle-plugin, start by importing the android-automation-tools repository into Android Studio.

Developing the plugin against local repositories

Like the android components suggest, it's preferable to avoid depending on apps outside of the repository. Instead:

  • Write unit tests
  • Work against the sample app (TODO: add sample app :)

If you wish to develop against local repositories anyway, see below.

Set a version number

Append -SNAPSHOT to the end of the version number in this project's build.gradle.kts. If you don't, your imports may conflict with those from remote repositories and you can end up polluting your local maven cache.

Publish to your local maven repository

To publish the gradle plugin:

./gradlew gradle-plugin:publishToMavenLocal

Import your local plugin changes into the local repository

In the top level gradle file, you have to add the dependencies (using your own version number):

buildscript {
    repositories {
        mavenLocal()
    }

    dependencies {
        classpath "org.mozilla.android:gradle-plugin:0.1-SNAPSHOT"
    }
}

apply plugin: org.mozilla.android.MozillaPlugin

And again in buildSrc/build.gradle:

repositories {
    mavenLocal()
}

dependencies {
    implementation("org.mozilla.android:gradle-plugin:0.1-SNAPSHOT")
}

If your project applies the plugin from a remote maven repository, be sure to remove that application.

Publishing to plugins.gradle.org

To publish the plugin to the gradle plugin portal, first create credentials. After making your changes and bumping the version, run the following from the root directory:

./gradlew gradle-plugin:publishPlugins
You can’t perform that action at this time.