1/* 2 * Copyright (C) 2015 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package android.databinding 18 19import org.gradle.api.Plugin 20import org.gradle.api.Project 21 22public class MavenDependencyCollectorPlugin implements Plugin<Project> { 23 private static final String DEFAULT_TASK_NAME = "localizeDependencies" 24 static final String EXTENSION_NAME = "localizeMaven" 25 @Override 26 void apply(Project project) { 27 Project parent = project.getRootProject(); 28 def localizeDependenciesTask = parent.tasks.findByName(DEFAULT_TASK_NAME) 29 if (localizeDependenciesTask == null) { 30 localizeDependenciesTask = parent.tasks. 31 create(DEFAULT_TASK_NAME, LocalizeDependenciesTask) 32 parent.extensions.create(EXTENSION_NAME, LocalizePluginExtension) 33 } 34 35 project.allprojects { 36 afterEvaluate { p -> 37 if (!p.name.equals("dataBinding")) { 38 project.tasks.create("collectDependenciesOf${it.getName().capitalize()}", MavenDependencyCollectorTask, { 39 it.localizeTask = localizeDependenciesTask 40 localizeDependenciesTask.dependsOn it 41 }) 42 } 43 } 44 } 45 project.tasks.create("buildLicenseNotice", ExportLicensesTask) { 46 47 } 48 } 49}