gradle-dependency-export icon indicating copy to clipboard operation
gradle-dependency-export copied to clipboard

Apply plugin to android multi-module project

Open mtsahakis opened this issue 4 years ago • 2 comments

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.

mtsahakis avatar Sep 02 '20 15:09 mtsahakis

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 avatar Apr 26 '21 15:04 michelau

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)
}

michelau avatar Apr 26 '21 19:04 michelau