Florian Baierl
Florian Baierl

Reputation: 2481

Publish artifact to local maven repo with SBT and use it in Gradle project

Here is what I want to do:

Here is where I struggle:

organization := "com.example"
name := "my.messaging"
version := "0.1"
scalaVersion := "2.12.8"
publishMavenStyle := true

This generates the artifact here:

C:\Users\BAIERLF\.m2\repository\com\example\my-messaging_2.12\0.1

The POM file looks like this:

<?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:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.example</groupId>
    <artifactId>my-messaging_2.12</artifactId>
    <packaging>jar</packaging>
    <description>my.messaging</description>
    <version>0.1</version>
    <name>my.messaging</name>
    <organization>
        <name>com.example</name>
    </organization>
    <dependencies>
        <dependency>
            <groupId>org.scala-lang</groupId>
            <artifactId>scala-library</artifactId>
            <version>2.12.8</version>
        </dependency>
    </dependencies>
    <repositories>
        <repository>
            <id>ArtimaMavenRepository</id>
            <name>Artima Maven Repository</name>
            <url>http://repo.artima.com/releases/</url>
            <layout>default</layout>
        </repository>
    </repositories>
</project>

I find myself unable to successfully use this artifact in my Gradle project. This is how I tried to link it:

dependencies {
   compile group: 'com.example', name: 'my-messaging_2.12', version: '0.1'
}

I feel like I am doing multiple things wrong here, but if anyone could give me a hint that would be great.

Edit: I tried it again with a slightly different result, so I updated my answer.

Upvotes: 1

Views: 1471

Answers (1)

jwismar
jwismar

Reputation: 12258

I had a similar problem recently, and solved it by adding a mavenLocal() command to my build.gradle file. I don'y know if you have the same issue, but it might be worth doing a build of your gradle project with full debug output and confirm it's attempting to pull from your local repo.

Upvotes: 4

Related Questions