提供的范围不适用于eclipse

时间:2015-10-10 03:06:03

标签: gradle

Gradle 2.2.1

我正在尝试将依赖项包含到我将发送给其他用户的jar文件中。我希望他们提供自己的某些依赖项版本,并尝试从maven模拟provided范围。

我已按照教程here进行操作。我能够从命令行成功构建项目(同时仍然在eclipse中找到类未找到的错误)直到eclipse集成部分。从帖子中他说要添加eclipse.classpath.plusConfigurations += configurations.provided,但我得到Could not find property 'provided' on configuration container

apply plugin: 'java'
apply plugin: 'eclipse'

// this causes the error
//eclipse.classpath.plusConfigurations += configurations.provided

sourceCompatibility = 1.8
version = '1.0'
jar {
    manifest {
        attributes 'Implementation-Title': '...',
                   'Implementation-Version': version
    }
}

repositories {
    mavenCentral()
}

configurations {
    provided
}

sourceSets {
    main.compileClasspath += configurations.provided
    test.compileClasspath += configurations.provided
    test.runtimeClasspath += configurations.provided
}

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.+'

    //Jackson
    provided 'com.fasterxml.jackson.core:jackson-core:2.6.2'
    provided 'com.fasterxml.jackson.core:jackson-annotations:2.6.2'
    provided 'com.fasterxml.jackson.core:jackson-databind:2.6.2'
}

test {
    systemProperties 'property': 'value'
}

uploadArchives {
    repositories {
       flatDir {
           dirs 'repos'
       }
    }
}

1 个答案:

答案 0 :(得分:1)

修正了它。

eclipse.classpath.plusConfigurations += configurations.provided

应该是一个数组

eclipse.classpath.plusConfigurations += [configurations.provided]