Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I can't import a snapshot using gradle

I can't resolve a SNAPSHOT dependency. I already published the project on oss sonatype

My main class:

package com.github.sitrakary.unitconvert.gui;

// import a class from the SNAPSHOT dependencies.
import com.github.sitrakary.unitconvert.Converter; // Can't resolve 'Converter'

public class App {
  public static void main(String args[]) {
    System.out.println();
  }
}

Gradle build file:

group 'com.github.sitrakary'
version '0.1-SNAPSHOT'

apply plugin: 'java'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

dependencies {
    compile group: 'com.github.sitrakary',  name:'unit-converter', version:'1.0-SNAPSHOT', changing: true

    testCompile group: 'junit', name: 'junit', version: '4.12'

}

Error

Information:java: Errors occurred while compiling module 'unit-converter-gui_main'
Information:javac 9.0.1 was used to compile java sources
Information:Module "unit-converter-gui_main" was fully rebuilt due to project configuration/dependencies changes
Information:26/01/2018 12:30 - Compilation completed with 1 error and 0 warnings in 3s 470ms
Error:java: Illegal char <:> at index 84: C:\Users\Sitraka\IdeaProjects\unit-converter-gui\Could not find com.github.sitrakary:unit-converter:1.0-SNAPSHOT.

Image showing the dependencies

like image 834
sitrakay Avatar asked Nov 28 '25 01:11

sitrakay


1 Answers

I solved the issue by adding sonatype to repositories in my build.gradle file.

group 'com.github.sitrakary'
version '0.1-SNAPSHOT'

apply plugin: 'java'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
    // add sonatype repository
    maven {
        url 'https://oss.sonatype.org/content/repositories/snapshots/'
    }
}

dependencies {
    compile group: 'com.github.sitrakary',  name:'unit-converter', version:'1.0-SNAPSHOT', changing: true

    testCompile group: 'junit', name: 'junit', version: '4.12'
}
like image 73
sitrakay Avatar answered Nov 29 '25 15:11

sitrakay