uklance / gradle-dependency-export

Export maven dependencies from a gradle project to the file system
28 stars 15 forks source link

Apply plugin to android multi-module project #16

Open mtsahakis opened 4 years ago

mtsahakis commented 4 years ago

I have tried to apply your plugin to an Android multi module project, but with no luck.

I have the following:

apply plugin: "com.lazan.dependency-export"

configurations {
    variantNameDebug
}

mavenDependencyExport {
    systemProperties = ['java.version': '1.8']
    exportDir = "${System.properties['user.home']}/.m2" as File
    configuration 'variantNameDebug'
    configuration buildscript.configurations.classpath
}

Any help here would be greatly appreciated.

michelau commented 3 years ago

You didn't list your error message, but you may be having issues with the configuration you're listing not existing at the time this plugin evaluates the DSL above. The Android Gradle Plugin creates the variant configurations dynamically. You might try tinkering with the afterEvaluate lifecycle closure, or just avoiding specifying configurations in the DSL above completely and prune the output later.

michelau commented 3 years ago

In my attempts to make this work for a multi-module Android project (ex: modules A & B where B depends on A), it was failing in subproject B when trying to resolve dependencies on subproject A. It has difficult matching variants using attributes.

I was able to bypass this completely by doing the hack below. There's no need to resolve peer modules within the same project for my needs, because I'm running the plugin separately in each subproject.


configurations.all { Configuration c ->

    println c.name
    def projectDeps = []
    c.dependencies.each { Dependency d ->

        if (d instanceof ProjectDependency) {
            println d
            projectDeps << d
        }
    }
    c.dependencies.removeAll(projectDeps)
}