Home | History | Annotate | Download | only in databinding
      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 
     17 package android.databinding
     18 
     19 import org.apache.maven.repository.internal.MavenRepositorySystemUtils
     20 import org.eclipse.aether.DefaultRepositorySystemSession
     21 import org.eclipse.aether.RepositorySystem
     22 import org.eclipse.aether.RepositorySystemSession
     23 import org.eclipse.aether.artifact.Artifact
     24 import org.eclipse.aether.artifact.DefaultArtifact
     25 import org.eclipse.aether.connector.basic.BasicRepositoryConnectorFactory
     26 import org.eclipse.aether.graph.Dependency
     27 import org.eclipse.aether.impl.DefaultServiceLocator
     28 import org.eclipse.aether.repository.LocalRepository
     29 import org.eclipse.aether.repository.RemoteRepository
     30 import org.eclipse.aether.resolution.ArtifactDescriptorRequest
     31 import org.eclipse.aether.resolution.ArtifactDescriptorResult
     32 import org.eclipse.aether.resolution.ArtifactRequest
     33 import org.eclipse.aether.spi.connector.RepositoryConnectorFactory
     34 import org.eclipse.aether.spi.connector.transport.TransporterFactory
     35 import org.eclipse.aether.transport.file.FileTransporterFactory
     36 import org.eclipse.aether.transport.http.HttpTransporterFactory
     37 import org.gradle.api.DefaultTask
     38 import org.gradle.api.Project
     39 import org.gradle.api.artifacts.Configuration
     40 import org.gradle.api.artifacts.ModuleVersionIdentifier
     41 import org.gradle.api.tasks.Input
     42 import org.gradle.api.tasks.TaskAction
     43 
     44 class 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