MavenDependencyCollectorTask.groovy revision 24bec1cc542de69e0e21cc774469f20d34811ad9
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.apache.maven.repository.internal.MavenRepositorySystemUtils
20import org.eclipse.aether.DefaultRepositorySystemSession
21import org.eclipse.aether.RepositorySystem
22import org.eclipse.aether.RepositorySystemSession
23import org.eclipse.aether.artifact.Artifact
24import org.eclipse.aether.artifact.DefaultArtifact
25import org.eclipse.aether.connector.basic.BasicRepositoryConnectorFactory
26import org.eclipse.aether.graph.Dependency
27import org.eclipse.aether.impl.DefaultServiceLocator
28import org.eclipse.aether.repository.LocalRepository
29import org.eclipse.aether.repository.RemoteRepository
30import org.eclipse.aether.resolution.ArtifactDescriptorRequest
31import org.eclipse.aether.resolution.ArtifactDescriptorResult
32import org.eclipse.aether.resolution.ArtifactRequest
33import org.eclipse.aether.spi.connector.RepositoryConnectorFactory
34import org.eclipse.aether.spi.connector.transport.TransporterFactory
35import org.eclipse.aether.transport.file.FileTransporterFactory
36import org.eclipse.aether.transport.http.HttpTransporterFactory
37import org.gradle.api.DefaultTask
38import org.gradle.api.Project
39import org.gradle.api.artifacts.Configuration
40import org.gradle.api.artifacts.ModuleVersionIdentifier
41import org.gradle.api.tasks.Input
42import org.gradle.api.tasks.TaskAction
43
44class MavenDependencyCollectorTask extends DefaultTask {
45    @Input
46    LocalizeDependenciesTask localizeTask
47
48    @TaskAction
49    public void doIt() {
50        project.configurations.each { conf ->
51            resolveDirectDependencies(conf)
52        }
53        project.buildscript.configurations.each { conf ->
54            resolveDirectDependencies(conf)
55        }
56    }
57
58    void resolveDirectDependencies(Configuration conf) {
59        conf.getResolvedConfiguration().getResolvedArtifacts().each {
60            localizeTask.add(this, it.getModuleVersion().id, conf)
61        }
62    }
63}
64