Skip to content
This repository has been archived by the owner on Jan 25, 2021. It is now read-only.

android module aar dependency error pom #65

Open
kaiv587hh opened this issue Jan 27, 2018 · 4 comments
Open

android module aar dependency error pom #65

kaiv587hh opened this issue Jan 27, 2018 · 4 comments

Comments

@kaiv587hh
Copy link

kaiv587hh commented Jan 27, 2018

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
Copy link
Author

my version is 1.4.1

@marwanAmeen
Copy link

marwanAmeen commented Feb 15, 2018

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

@kaiv587hh
Copy link
Author

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 !!!

@dsvoronin
Copy link

make sure common module has version specified in gradle build script

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants