Hooli
Hooli

Reputation: 1195

maven fetching dependency from incorrect location

Using this tutorial, I am trying to host a dependency on GitHub and then use the dependency in a separate application.

The dependency is located at:

https://github.com/user/repo/raw/master/release/tld/company/app/1.0.0/app-1.0.0.jar

However. maven keeps going to:

https://github.com/user/repo/raw/master/release/tld/company/app/app/1.0.0/app-1.0.0.pom

In my pom where I'm calling the dependency, I have:

<repositories>
    <repository>
        <id>tld.company</id>
        <name>app</name>
        <url>https://github.com/user/repo/raw/master/release/</url>
    </repository>
</repositories>

and:

<dependency>
    <groupId>tld.company.app</groupId>
    <artifactId>app</artifactId>
    <version>1.0.0</version>
</dependency>

In /master/company/release/tld/company/app/maven-metadata-local.xml I have:

<?xml version="1.0" encoding="UTF-8"?>
<metadata>
  <groupId>tld.company.app</groupId>
  <artifactId>app</artifactId>
  <versioning>
    <release>1.0.0</release>
    <versions>
      <version>1.0.0</version>
    </versions>
    <lastUpdated>20160233354414</lastUpdated>
  </versioning>
</metadata>

In /master/company/release/tld/company/app/1.0.0/app-1.0.0.pom I have:

<?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>tld.company.app</groupId>
  <artifactId>app</artifactId>
  <version>1.0.0</version>
  <description>POM was created from install:install-file</description>
</project>

What is the reason for the additional /app in the dependency download URL?

Upvotes: 0

Views: 46

Answers (1)

Tunaki
Tunaki

Reputation: 137084

The group id should be tld.company, not tld.company.app. This explains your second app.

<dependency>
    <groupId>tld.company</groupId>
    <artifactId>app</artifactId>
    <version>1.0.0</version>
</dependency>

Basically, when you have a URL from a repository of the following form, this is how it is understood by Maven:

https://someserver.com/.../tld/company/app/1.0.0/app-1.0.0.jar
                           ^---------^ ^-^ ^---^ ^-----------^
                              groupId   | version   file name
                                     artifactId
  • The last part if the file name which is ${artifactId}-${version}.
  • Before that is the version.
  • Before that is the artifact id.
  • And all the path before that are the group id, where slashes are replaced by dots.

Upvotes: 1

Related Questions