我无法使用gradle导入快照

时间:2018-01-26 09:20:33

标签: java android gradle

我无法解决SNAPSHOT依赖关系。我已经在oss sonatype

上发布了该项目

我的主要课程:

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构建文件:

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'

}

错误

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

2 个答案:

答案 0 :(得分:0)

似乎问题出在java版本上。您的错误表示javac 9.0.1 was used to compile java sources,但您的代码为sourceCompatibility = 1.8。因此,似乎错误可能来自于您在使用java 1.8的项目中使用使用java 1.9构建的快照这一事实。

答案 1 :(得分:0)

我通过在我的build.gradle文件中将sonatype添加到存储库来解决了这个问题。

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'
}