使用Gradle设置基本插件

时间:2019-01-19 22:54:15

标签: elasticsearch gradle build.gradle elasticsearch-plugin

我正在尝试使用遵循this示例的gradle设置基本的Elasticsearch插件。我意识到回购中的build.gradle文件是不够的(由于某种原因),所以这是我当前的build.gradle文件

 plugins {
    id 'java'
}

group 'test'
version '1.0-SNAPSHOT'

sourceCompatibility = 1.8


repositories {
    mavenCentral()
}

dependencies {
    classpath "org.elasticsearch.gradle:build-tools:6.5.4"
    testCompile group: 'junit', name: 'junit', version: '4.12'
}

apply plugin: 'elasticsearch.esplugin'

esplugin {
    name 'script-expert-scoring'
    description 'An example script engine to use low level Lucene internals for expert scoring'
    classname 'org.elasticsearch.example.expertscript.ExpertScriptPlugin'
    licenseFile rootProject.file('licenses/APACHE-LICENSE-2.0.txt')
    noticeFile rootProject.file('NOTICE.txt')
}

unitTest.enabled = false

我自己添加了类路径依赖项,因为我意识到自己可能需要它。但是现在我说

时出现错误
  

找不到用于参数[org.elasticsearch.gradle:build-tools:6.5.4]的方法classpath()

我错过了什么吗?或者这是完全错误的吗?

1 个答案:

答案 0 :(得分:0)

尝试将其放入这样的buildscript块中:

buildscript {
    repositories {
        mavenLocal()
        mavenCentral()
        jcenter()
    }

    dependencies {
        classpath "org.elasticsearch.gradle:build-tools:6.5.4"
    }
}

Here是一个更好的示例,如果需要更完整的方法,请使用here