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

android module aar dependency error pom

Open kaiv587hh opened this issue 6 years ago • 4 comments

I have a project such like a client-server structure. It has 3 modules : app (my server to provide some service) -- apk module sdk (my sdk to provide some API to communicate with my app) -- aar module common (something which should include both in my app module and sdk module ,such as utils,beans,etc. --aar module

because I do not want to write it in my both app and sdk module ,debugging and modifying should work twice.) so my project looks like as below: image

and in my app module and sdk module has one line looks like :

 compile project(':common')

and I have wrote as below

install {
    repositories.mavenInstaller {
        // This generates POM.xml with proper parameters
        pom {
            project {
                groupId _groupId
                artifactId _artifactId
                version _versionName
                name _name
            }
        }
    }
}

but my generated sdk's pom-default.xml looks like:

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId>xxx</groupId>
  <artifactId>xxx</artifactId>
  <version>xxx</version>
  <packaging>aar</packaging>
  <name>xxx</name>
  <dependencies>
    <dependency>
      <groupId>com.android.support</groupId>
      <artifactId>support-annotations</artifactId>
      <version>25.3.1</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>com.google.code.gson</groupId>
      <artifactId>gson</artifactId>
      <version>2.8.2</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
<!--this is wrong as I want -->
      <groupId>MyProjectName</groupId>
      <artifactId>common</artifactId>
      <version>unspecified</version>
      <scope>compile</scope>
<!--end wrong something-->
    </dependency>
  </dependencies>
</project>

And my sdk module's aar do not include anything about common module's file ,so when I archive to maven,it can not find the common module's dependency what I want.

Simply, when an aar module dependency other aar module in one project ,the plugin cannot work and cannot transmit the dependency . I want the wrong area use the common module's maven info.

kaiv587hh avatar Jan 27 '18 10:01 kaiv587hh

my version is 1.4.1

kaiv587hh avatar Jan 27 '18 10:01 kaiv587hh

I having the same issue with the same scenario, where i have multiple modules ,

marwanAmeen avatar Feb 15 '18 10:02 marwanAmeen

my one solution is using a script to rewrite the pom.xml as below

#!/bin/bash

echo "project is $1"
path=sdk/build/poms/pom-default.xml
sysOS=`uname -s`
echo "system is $sysOS"
if [ $sysOS == "Darwin" ]; then
        # Mac OSX
    sed -i '' -e  "s/<groupId>$1<\/groupId>/<groupId>${GROUP_ID}<\/groupId>/g" $path
    sed -i '' -e  "s/<artifactId>common<\/artifactId>/<artifactId>${ARTIFACT_ID}-common<\/artifactId>/g" $path
    sed -i '' -e  "s/<version>unspecified<\/version>/<version>${VERSION_NAME}<\/version>/g" $path
else
    sed -i "s/<groupId>$1<\/groupId>/<groupId>${GROUP_ID}<\/groupId>/g" $path
    sed -i "s/<artifactId>common<\/artifactId>/<artifactId>${ARTIFACT_ID}-common<\/artifactId>/g" $path
    sed -i "s/<version>unspecified<\/version>/<version>${VERSION_NAME}<\/version>/g" $path

fi

but it's a very very bad idea, is there any support ? thanks a lot !!!

kaiv587hh avatar Feb 21 '18 03:02 kaiv587hh

make sure common module has version specified in gradle build script

dsvoronin avatar Apr 13 '18 17:04 dsvoronin