Upload artifact to gitlab maven repository

2019-08-27 02:13发布

问题:

I tried to used https://docs.gitlab.com/ee/user/project/packages/maven_repository.html to host my aar file, I followed exact same as the documentations yet I failed to upload the aar. I've setting the pom.xml like this :

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <modelVersion>4.0.0</modelVersion>
    <groupId>mygroup.id</groupId>
    <artifactId>myartifact</artifactId>
    <version>0.1.2</version>
    <packaging>aar</packaging>
    <repositories>
        <repository>
            <id>myrepo</id>
            <url>https://gitlab.com/api/v4/projects/1968/packages/maven</url>
        </repository>
    </repositories>
    <distributionManagement>
        <repository>
            <id>myrepo</id>
                       <url>https://gitlab.com/api/v4/projects/1968/packages/maven</url>
        </repository>
        <snapshotRepository>
            <id>myrepo</id>
<url>https://gitlab.com/api/v4/projects/1968/packages/maven</url>
        </snapshotRepository>
    </distributionManagement>
    <dependencies>
        <dependency>
            <groupId>de.greenrobot</groupId>
            <artifactId>eventbus</artifactId>
            <version>2.4.0</version>
        </dependency>
        <dependency>
            <groupId>com.android.support</groupId>
            <artifactId>support-v4</artifactId>
            <version>28.0.0</version>
            <type>pom</type>
        </dependency>
        <dependency>
            <groupId>com.google.dagger</groupId>
            <artifactId>dagger</artifactId>
            <version>2.11</version>
        </dependency>
        <dependency>
            <groupId>com.squareup.retrofit2</groupId>
            <artifactId>retrofit</artifactId>
            <version>2.3.0</version>
        </dependency>
        <dependency>
            <groupId>com.squareup.retrofit2</groupId>
            <artifactId>converter-gson</artifactId>
            <version>2.3.0</version>
        </dependency>
        <dependency>
            <groupId>com.squareup.retrofit2</groupId>
            <artifactId>retrofit-mock</artifactId>
            <version>2.3.0</version>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.7</version>
        </dependency>
        <dependency>
            <groupId>com.squareup.okhttp3</groupId>
            <artifactId>logging-interceptor</artifactId>
            <version>3.8.1</version>
        </dependency>
        <dependency>
            <groupId>android.arch.lifecycle</groupId>
            <artifactId>runtime</artifactId>
            <version>1.1.1</version>
            <type>pom</type>
        </dependency>
        <dependency>
            <groupId>android.arch.lifecycle</groupId>
            <artifactId>extensions</artifactId>
            <version>1.1.1</version>
            <type>pom</type>
        </dependency>
        <dependency>
            <groupId>android.arch.lifecycle</groupId>
            <artifactId>common-java8</artifactId>
            <version>1.1.1</version>
            <type>pom</type>
        </dependency>
        <dependency>
            <groupId>io.nlopez.smartlocation</groupId>
            <artifactId>library</artifactId>
            <version>3.3.1</version>
            <type>pom</type>
        </dependency>
        <dependency>
            <groupId>com.google.android.gms</groupId>
            <artifactId>play-services-location</artifactId>
            <version>16.0.0</version>
            <type>pom</type>
        </dependency>
        <dependency>
            <groupId>android.arch.lifecycle</groupId>
            <artifactId>livedata</artifactId>
            <version>1.1.1</version>
            <type>pom</type>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>com.simpligility.maven.plugins</groupId>
                <artifactId>android-maven-plugin</artifactId>
                <version>4.5.0</version>
                <extensions>true</extensions>
            </plugin>
        </plugins>
    </build>
</project>

and as well my ~/.m2/settings.xml like this :

<settings xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">

  <servers>
    <server>
      <id>myrepo</id>
      <configuration>
        <httpHeaders>
          <property>
            <name>Private-Token</name>
            <value>myprivatetoken</value>
            <scope>api</scope>
          </property>
        </httpHeaders>
      </configuration>
    </server>
  </servers>

By that I got the following error :

Failed to execute goal on project kudosdk: Could not resolve dependencies for project mobile.kudo.kudosdk:kudosdk:aar:0.1.2: The following artifacts could not be resolved: com.android.support:support-v4:pom:28.0.0 ....... and the list goes to all the dependencies who missing pom file. Yet if I remove the dependencies from my pom.xml I got error saying that error during copyManifest and point to the location where my manifest exist.

Also if I change the packaging become pom it can successfully deployed to my gitlab repository but it only pom file, with no aar file deployed and I am not sure how to fetch the dependencies via gradle. I tried using implementation 'groupid:module:version' but it failed saying failed to resolved the dependency which means the dependency didn't exist.

any help would be much appreciated, I've been struggle for 4 days try to resolve this. thank you