Mobbeel / fataar-gradle-plugin

Gradle plugin to help embed dependencies in generated AAR artifact
https://plugins.gradle.org/plugin/com.mobbeel.plugin
Apache License 2.0
340 stars 44 forks source link

The plugin may remove duplicated module and maintain only one version #7

Closed shawnlinboy closed 5 years ago

shawnlinboy commented 6 years ago

What are the steps to reproduce this issue?

  1. Followed by README

What happens?

Modules with same name but different versions were added into the aar

What were you expecting to happen?

The plugin may filter out those duplicated same dependencies, or give an option to choose which version should be maintained

Any logs, error output, etc?

External dependency detected -> com.my.library:2.1.7
Artifact: com.my.library-sources.jar
   |--> Exclude for source jar
POM: com.my.library-2.1.7.pom
   |--> Inner dependency: com.squareup.picasso:picasso:2.5.2
   /--> picasso-2.5.2.pom
   |--> Inner dependency: com.squareup.okhttp:okhttp:
   /--> okhttp-2.7.5.pom
   |--> Inner dependency: com.squareup.okio:okio:
   /--> okio-1.6.0.pom
   |--> Inner dependency: org.codehaus.mojo:animal-sniffer-annotations:
   /--> animal-sniffer-annotations-1.14.pom
   /--> okio-1.8.0.pom
   |--> Inner dependency: org.codehaus.mojo:animal-sniffer-annotations:
   /--> animal-sniffer-annotations-1.14.pom
   /--> okio-1.9.0.pom
   |--> Inner dependency: org.codehaus.mojo:animal-sniffer-annotations:
   /--> animal-sniffer-annotations-1.14.pom
   /--> okio-1.0.1.pom
   |--> Inner dependency: org.codehaus.mojo:animal-sniffer-annotations:
   /--> animal-sniffer-annotations-1.14.pom
   /--> okio-1.14.0.pom
   |--> Inner dependency: org.codehaus.mojo:animal-sniffer-annotations:
   /--> animal-sniffer-annotations-1.14.pom
   /--> okio-1.13.0.pom
   |--> Inner dependency: org.codehaus.mojo:animal-sniffer-annotations:
   /--> animal-sniffer-annotations-1.14.pom
   /--> okio-1.3.0.pom
   |--> Inner dependency: org.codehaus.mojo:animal-sniffer-annotations:
   /--> animal-sniffer-annotations-1.14.pom
   /--> okhttp-2.5.0.pom
   |--> Inner dependency: com.squareup.okio:okio:
   /--> okio-1.6.0.pom
   |--> Inner dependency: org.codehaus.mojo:animal-sniffer-annotations:
   /--> animal-sniffer-annotations-1.14.pom
   /--> okio-1.8.0.pom
   |--> Inner dependency: org.codehaus.mojo:animal-sniffer-annotations:
   /--> animal-sniffer-annotations-1.14.pom
   /--> okio-1.9.0.pom
   |--> Inner dependency: org.codehaus.mojo:animal-sniffer-annotations:
   /--> animal-sniffer-annotations-1.14.pom
   /--> okio-1.0.1.pom
   |--> Inner dependency: org.codehaus.mojo:animal-sniffer-annotations:
   /--> animal-sniffer-annotations-1.14.pom
   /--> okio-1.14.0.pom
   |--> Inner dependency: org.codehaus.mojo:animal-sniffer-annotations:
   /--> animal-sniffer-annotations-1.14.pom
   /--> okio-1.13.0.pom
   |--> Inner dependency: org.codehaus.mojo:animal-sniffer-annotations:
   /--> animal-sniffer-annotations-1.14.pom
   /--> okio-1.3.0.pom
   |--> Inner dependency: org.codehaus.mojo:animal-sniffer-annotations:
   /--> animal-sniffer-annotations-1.14.pom
   /--> okhttp-2.3.0.pom
   |--> Inner dependency: com.squareup.okio:okio:
   /--> okio-1.6.0.pom
   |--> Inner dependency: org.codehaus.mojo:animal-sniffer-annotations:
   /--> animal-sniffer-annotations-1.14.pom
   /--> okio-1.8.0.pom
   |--> Inner dependency: org.codehaus.mojo:animal-sniffer-annotations:
   /--> animal-sniffer-annotations-1.14.pom
   /--> okio-1.9.0.pom
   |--> Inner dependency: org.codehaus.mojo:animal-sniffer-annotations:
   /--> animal-sniffer-annotations-1.14.pom
   /--> okio-1.0.1.pom
   |--> Inner dependency: org.codehaus.mojo:animal-sniffer-annotations:
   /--> animal-sniffer-annotations-1.14.pom
   /--> okio-1.14.0.pom
   |--> Inner dependency: org.codehaus.mojo:animal-sniffer-annotations:
   /--> animal-sniffer-annotations-1.14.pom
   /--> okio-1.13.0.pom
   |--> Inner dependency: org.codehaus.mojo:animal-sniffer-annotations:
   /--> animal-sniffer-annotations-1.14.pom
   /--> okio-1.3.0.pom

BTW, the plugin really saved my life, thanks for your contribution!

oscarcpozas commented 6 years ago

But why com.my.library-2.1.7.pom define multiple times the same dependencies? Can you paste the pom.xml? Maybe I could look at which dependency the dependency resolver is staying with.

shawnlinboy commented 6 years ago

@oscarcpozas I've looked up the The com.my:library:2.1.7 pom file, it did not define multiple times the same dependencies explicitly, but its sub-module did.

Here is the pom file:(I've renamed some private info to dummy texts, sorry.)

<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.my.library</groupId>
  <artifactId>BALABALA</artifactId>
  <version>2.1.7</version>
  <packaging>aar</packaging>
  <dependencies>
    <dependency>
      <groupId>com.my.company.unit</groupId>
      <artifactId>weixin-sdk-wrapper</artifactId>
      <version>1.1</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>com.squareup.picasso</groupId>
      <artifactId>picasso</artifactId>
      <version>2.5.2</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>com.my.company.unit</groupId>
      <artifactId>alipay-sdk-wrapper</artifactId>
      <version>3.0.0</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>com.android.support</groupId>
      <artifactId>appcompat-v7</artifactId>
      <version>25.3.1</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>com.my.company.unit</groupId>
      <artifactId>unionpay-sdk-all-wrapper</artifactId>
      <version>2.0.2</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>com.my.company.unit</groupId>
      <artifactId>wxh5-sdk-wrapper</artifactId>
      <version>1.0.2</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>com.my.company.unit</groupId>
      <artifactId>nowpay-sdk-all-wrapper</artifactId>
      <version>1.5</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>com.my.company.unit</groupId>
      <artifactId>XXThirdPartyChannelInternal</artifactId>
      <version>3.0.5</version>
      <scope>compile</scope>
    </dependency>
  </dependencies>
</project>

Actually the hierarchy can be simplified like this:

+---com.my:library:2.1.7
|    +--- com.my.a:library:XXX
|    |    +--- com.balaba.library:okio:1.7
|    +--- com.my.b:library:XXX
|    |    +--- com.balaba.library:okio:1.8
|    +--- com.my.c:library:XXX
|    |    +--- com.my.c1:library:XXX
|    |     |    +--- com.balaba.library:okio:1.9
|    +--- com.my.d:library:XXX
|    |    +--- com.balaba.library:okio:2.0

And in this time, the problem may occur, all of the depencendies from com.balaba.library:okio:1.7 to com.balaba.library:okio:2.0 may be assembled into the final aar.

oscarcpozas commented 6 years ago

Sorry for late response, I'm working hard for release 2.0.0 version with new improvements and fixes. Each library in turn defines other dependencies and these are repeating, I note and try to get the correction in this next version.

shawnlinboy commented 6 years ago

@oscarcpozas Thx, can't wait for the next release!

oscarcpozas commented 5 years ago

Can you check if the issue continues in version 2.0.1? Thx

shawnlinboy commented 5 years ago

Solved, thanks for your great work.