Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

add plugin to gradle buildscript from a local jar

I'd like to apply the google-services Gradle plugin to a Java project from a local jar, such that my build does not need to connect to jcenter to download the plugin.

I have downloaded the google-services-3.0.0.jar, but I don't know how to tell gradle to load the plugin from the file.

This is my build.gradle

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.2'
        classpath 'com.google.gms:google-services:3.0.0' <---i have the jar

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
    }
}
like image 701
Ahmed na Avatar asked Nov 26 '16 05:11

Ahmed na


People also ask

How do I add plugins to build Gradle?

While creating a custom plugin, you need to write an implementation of plugin. Gradle instantiates the plugin and calls the plugin instance using Plugin. apply() method. The following example contains a greeting plugin, which adds a hello task to the project.

Which task is executed to use Gradle build in plugin?

To use the plugin, simply execute the task named init where you would like to create the Gradle build.


1 Answers

I was able to add the plugin from the jar by adding the jar in my lib folder and call it from the project gradle dependencies like so :

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.2'
        classpath fileTree(include: ['*.jar'], dir: 'app/libs')
        classpath files('app/libs/google-services-3.0.0.jar')

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
like image 55
Ahmed na Avatar answered Sep 25 '22 01:09

Ahmed na