0

I am trying to host my artifacts on GitHub. I am able to push them following this article: Hosting a Maven repository on github

But now I want to get the artifact in another project and try to add all information in my POM file.

POM.XML

 <?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
     <modelVersion>4.0.0</modelVersion>
 
     <groupId>com.playground</groupId>
     <artifactId>db-service</artifactId>
     <version>1.0-SNAPSHOT</version>
     <name>db-service</name>
     <packaging>war</packaging>
 
     <properties>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <maven.compiler.target>1.8</maven.compiler.target>
         <maven.compiler.source>1.8</maven.compiler.source>
         <junit.version>5.9.1</junit.version>
     </properties>
     <repositories>
         <repository>
             <id>github</id>
             <url>https://github.com/[ORGANISATION]/[PROJECT]/raw/[BRANCH]/</url>
             <snapshots>
                 <enabled>true</enabled>
                 <updatePolicy>always</updatePolicy>
             </snapshots>
         </repository>
     </repositories>
 
     <dependencies>
         <dependency>
             <groupId>javax.enterprise</groupId>
             <artifactId>cdi-api</artifactId>
             <version>2.0.SP1</version>
             <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>javax.ws.rs</groupId>
             <artifactId>javax.ws.rs-api</artifactId>
             <version>2.1.1</version>
             <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>javax.servlet</groupId>
             <artifactId>javax.servlet-api</artifactId>
             <version>4.0.1</version>
             <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>org.junit.jupiter</groupId>
             <artifactId>junit-jupiter-api</artifactId>
             <version>${junit.version}</version>
             <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>org.junit.jupiter</groupId>
             <artifactId>junit-jupiter-engine</artifactId>
             <version>${junit.version}</version>
             <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>org.firebirdsql.jdbc</groupId>
             <artifactId>jaybird</artifactId>
             <version>5.0.0.java8</version>
         </dependency>
         <dependency>
             <groupId>com.fooditsolutions</groupId>
             <artifactId>Util</artifactId>
             <version>1.0</version>
         </dependency>
     </dependencies>
 
     <build>
         <plugins>
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-war-plugin</artifactId>
                 <version>3.3.2</version>
             </plugin>
         </plugins>
     </build>
 </project>

I have a settings.xml file with my login credentials

<settings>
  <servers>
    <server>
      <id>github</id>
      <username>[USERNAME]</username>
      <password>[API_TOKEN]</password>
      <configuration>
        <httpHeaders>
          <property>
            <name>Authorization</name>
            <!-- Base64-encoded username:access_token -->
            <value>Basic [BASE64USERNAME:PASSWORD]==</value>
          </property>
        </httpHeaders>
      </configuration>
    </server>
  </servers>
</settings>

The settings.xml is working for the push of the artifact. But when I try to download it in another project I am getting: \[ERROR\] Failed to execute goal on project db-service: Could not resolve dependencies for project com.playground:db-service:war:1.0-SNAPSHOT: Could not find artifact com.fooditsolutions:Util:jar:1.0 in github (https://github.com/%5C%5C%5C%5BORGANISATION%5C%5C%5C%5D/%5C%5C%5C%5BPROJECT%5C%5C%5C%5D/raw/%5C%5C%5C%5BBRANCH%5C%5C%5C%5D/) -\> \[Help 1\]

I have already tried different URL's.

I have also tried to set the project as public.

Adding extra information in settings.xml

All these things did not help... .

1 Answers1

0

After a good night sleep and some more testing I found the URL that was working. Also I saw I was testing with data that was inconsistent.

The URL is: https://raw.githubusercontent.com/[ORGANISATION]/[Repository name]/mvn-repo/

The artifact I was trying to fetch was a version 1.0-SNAPSHOT . During the build, the SNAPSHOT is translated in a timestamp making that my dependancy had to be

<dependency>
             <groupId>com.fooditsolutions</groupId>
             <artifactId>Util</artifactId>
             <version>1.0.-20230308.203114-2</version>
         </dependency>

instead of

<dependency>
             <groupId>com.fooditsolutions</groupId>
             <artifactId>Util</artifactId>
             <version>1.0.-SNAPSHOT</version>
         </dependency>