android-maven-gradle-plugin icon indicating copy to clipboard operation
android-maven-gradle-plugin copied to clipboard

Depending on specific configurations does not work

Open ansman opened this issue 9 years ago • 8 comments

I'm writing a library with multiple modules that depend on each other.

My dependencies are set up like this:

dependencies {
  debugCompile project(path: ":submodule", configuration: "debug")
  releaseCompile project(path: ":submodule", configuration: "release")
}

This results in an empty <dependencies /> tag in the resulting .pom

I tried adding this to all modules' build.gradle:

android {
    defaultPublishConfig "release"
    publishNonDefault true
}

This might be related to #11 and #32, I'm not sure but is there anything I can do about this?

ansman avatar Jun 30 '16 15:06 ansman

I believe the problem comes from https://github.com/dcendents/android-maven-gradle-plugin/blob/master/src/main/java/org/gradle/api/plugins/AndroidMavenPlugin.java#L189

Only the dependencies from the compile configuration is considered. When I tried to add releaseCompile and debugCompile too it sort of works, though I get a duplicate dependency which is also lacking the configuration.

ansman avatar Jul 01 '16 08:07 ansman

@dcendents Any thoughts on this?

ansman avatar Aug 24 '16 06:08 ansman

this might be related to #50.

bpappin avatar Sep 14 '16 19:09 bpappin

Is your project public so I get look at your configuration?

dcendents avatar Sep 15 '16 01:09 dcendents

Not really, but it can be reproduced using a project with two modules with the main module having this:

dependencies {
  debugCompile project(path: ":submodule", configuration: "debug")
  releaseCompile project(path: ":submodule", configuration: "release")
}

and the submodule this:

android {
    defaultPublishConfig "release"
    publishNonDefault true
}

The problem is that android-maven-gradle-plugin simply doesn't look for debugCompile and releaseCompile dependencies.

ansman avatar Sep 15 '16 06:09 ansman

Please read my comment on issue #50 , I feel you are also trying to do something that is not natural in a maven repository.

Maven expects a single set of dependencies for all classifiers. If I include compile, debugCompile, releaseCompile and any other configuration you might define through flavors it will end up with a pom that contains everything, so it will also be wrong.

It's probably safer to keep using compile only, as it is the "default" configuration to use. Then if you have particular needs for a library, you might need to write a custom handler: https://docs.gradle.org/current/userguide/maven_plugin.html#sub:dependency_mapping

dcendents avatar Sep 15 '16 17:09 dcendents

Well, releaseCompile might be nice for having different artifacts for debug and release (which is our use case). It would result in two different artifact (one debug and one release) so the same artifact would never conflict.

ansman avatar Sep 15 '16 18:09 ansman

@ansman is is the plugin or the build that doesn't look for the dependencies? in ticket #50 I reference a bug that apparently impacts this.

bpappin avatar Sep 15 '16 18:09 bpappin