com.mobgen.halo.android.plugin.sdk.HaloPlugin.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of halo-plugin Show documentation
Show all versions of halo-plugin Show documentation
This plugin helps on the configuration of the SDK.
package com.mobgen.halo.android.plugin.sdk
import com.mobgen.halo.android.plugin.sdk.tasks.HaloConfigurationTask
import com.mobgen.halo.android.plugin.sdk.tasks.ProcessPushManifestTask
import com.mobgen.halo.android.plugin.sdk.utils.Utils
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.Task
/**
* Halo plugin that is in charge to manage dependencies and all the configuration that must be
* applied to a project using the M framework.
*/
public class HaloPlugin implements Plugin {
/**
* Halo convention object name.
*/
private static final String EXTENSION_NAME = "halo"
/**
* The current project instance.
*/
private Project project
/**
* The halo extension plugin.
*/
private HaloExtension halo;
@Override
public void apply (Project project) {
this.project = project
if(Utils.isAndroidPlugin(project)){
//Create the extension
halo = project.extensions.create(EXTENSION_NAME, HaloExtension, project)
project.afterEvaluate {
halo.buildHalo()
//Lets ensure that the given environment contains the Android plugin
createConfigurationTask()
createPushManifestTasks()
}
}
}
def createPushManifestTasks() {
Utils.getVariants(project).all { variant ->
//Create push notifications task to add to the manifest the permissions
if(halo.pushModule() && halo.pushModule().isEnabled()){
Task task = project.tasks.create("${variant.getName()}PushManifest", ProcessPushManifestTask, {
androidVariant = variant
pushModule = halo.pushModule()
group = "halo"
description = "Process the manifest to inject the push information for Halo"
})
project.tasks.getByName("process${variant.getName().capitalize()}Manifest") << {
task.execute()
}
}
}
}
def createConfigurationTask(){
String haloTaskName = "createHaloConfig"
HaloConfigurationTask task = project.tasks.create(haloTaskName, HaloConfigurationTask)
task.group = "halo"
task.setExtension(halo)
//Add after pre-build the moment to create the file
project.tasks.findByName("preBuild").dependsOn task
}
}