我正在关注这个guide我已经按照他们的说明设置了 build.gradle,但是当我运行“grade build”时,出现以下错误。
'No such property: spec for class:org.gradle.api.internal.project.DefaultProject_Decorated'
我认为它指的是构建文件中的行 'dataTemplateCompile spec.product.pegasus.data' 但我无法确定为什么?
apply plugin: 'idea'
apply plugin: 'eclipse'
def pegasusVersion = "1.24.1"
spec = [
"product": [
"pegasus": [
"data" : "com.linkedin.pegasus:data:" + pegasusVersion,
"generator" : "com.linkedin.pegasus:generator:" + pegasusVersion,
"restliClient" : "com.linkedin.pegasus:restli-client:" + pegasusVersion,
"restliServer" : "com.linkedin.pegasus:restli-server:" + pegasusVersion,
"restliTools" : "com.linkedin.pegasus:restli-tools:" + pegasusVersion,
"pegasusCommon" : "com.linkedin.pegasus:pegasus-common:" + pegasusVersion,
"restliCommon" : "com.linkedin.pegasus:restli-common:" + pegasusVersion,
"r2" : "com.linkedin.pegasus:r2:" + pegasusVersion,
"restliNettyStandalone": "com.linkedin.pegasus:restli-netty-standalone:" + pegasusVersion
]
]
]
buildscript {
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
classpath group: 'com.linkedin.pegasus', name: 'gradle-plugins', version: '1.15.9'
}
}
subprojects {
apply plugin: 'maven'
apply plugin: 'idea'
apply plugin: 'eclipse'
sourceCompatibility = JavaVersion.VERSION_1_6 // or 1_7
afterEvaluate {
// add the standard pegasus dependencies wherever the plugin is used
if (project.plugins.hasPlugin('pegasus')) {
dependencies {
dataTemplateCompile spec.product.pegasus.data
restClientCompile spec.product.pegasus.restliClient
}
}
}
}
最佳答案
他们在 git 中有更新到最新的示例 https://github.com/linkedin/rest.li/tree/master/examples/quickstart 将build.gradle文件替换为以下代码
// add rest.li's gradle plugins so they can be used throughout project
buildscript {
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath 'com.linkedin.pegasus:gradle-plugins:1.15.9'
}
}
task wrapper(type: Wrapper) {
gradleVersion = '1.12'
}
final pegasusVersion = '1.15.9'
ext.spec = [
'product' : [
'pegasus' : [
'data' : 'com.linkedin.pegasus:data:' + pegasusVersion,
'generator' : 'com.linkedin.pegasus:generator:' + pegasusVersion,
'restliCommon' : 'com.linkedin.pegasus:restli-common:' + pegasusVersion,
'restliClient' : 'com.linkedin.pegasus:restli-client:' + pegasusVersion,
'restliServer' : 'com.linkedin.pegasus:restli-server:' + pegasusVersion,
'restliTools' : 'com.linkedin.pegasus:restli-tools:' + pegasusVersion,
'gradlePlugins' : 'com.linkedin.pegasus:gradle-plugins:' + pegasusVersion,
'restliNettyStandalone' : 'com.linkedin.pegasus:restli-netty-standalone:' + pegasusVersion,
'restliServerStandalone' : 'com.linkedin.pegasus:restli-server-standalone:' + pegasusVersion
]
]
]
allprojects {
apply plugin: 'idea'
apply plugin: 'eclipse'
}
subprojects {
apply plugin: 'maven'
afterEvaluate {
if (project.plugins.hasPlugin('java')) {
sourceCompatibility = JavaVersion.VERSION_1_6
}
// add the standard pegasus dependencies wherever the plugin is used
if (project.plugins.hasPlugin('pegasus')) {
dependencies {
dataTemplateCompile spec.product.pegasus.data
restClientCompile spec.product.pegasus.restliClient
// needed for Gradle 1.9+
restClientCompile spec.product.pegasus.restliCommon
}
}
}
repositories {
mavenLocal()
mavenCentral()
}
}
关于java - Rest.li gradle 配置错误规范未知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29787552/