java - Rest.li gradle 配置错误规范未知

标签 java intellij-idea gradle rest.li

我正在关注这个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/

相关文章:

java - 在Java中,Spring无需任何脚本即可维护数据库

java - IntelliJ Android - 调试前删除应用程序

java - Intellij Idea 运行/调试配置和 Gradle 任务中的 SSH 隧道

java - Gradle 无法检测到 osdetector 插件

Android Gradle 问题?

android - 在Android Studio中以离线模式编译时无法解析播放服务

java - intellij 中的 Ifield、Itype 等效项

java - Kotlin + Spring Boot请求编码

java - 如何从文件中获取信息并使用它来生成 boolean 值 true 或 false?

intellij-idea - 关闭 Intellij 自动添加到 VCS/Git