无法解决gradle.build中的ssh类

时间:2017-02-22 09:53:32

标签: gradle groovy gradle-plugin

我正在尝试从gradle构建文件调用自定义groovy插件。但我在解决ssh的类时遇到错误。下面是构建文件,自定义groovy插件的一部分和错误。

的build.gradle

plugins {
  id 'org.sonarqube' version '2.0.1'
  id 'groovy'
  id 'org.hidetake.ssh' version'2.7.0'
}

dependencies {
    compile gradleApi()
    compile localGroovy()
}

CustPlugin.groovy

package com.nielsen.gradle

import org.slf4j.Logger
import org.slf4j.LoggerFactory

import java.text.SimpleDateFormat

import org.gradle.api.Project
import org.gradle.api.Plugin
import org.gradle.api.GradleException
import org.gradle.api.plugins.BasePlugin
import org.gradle.api.tasks.bundling.Zip

import org.hidetake.groovy.ssh.Ssh.*
import org.hidetake.groovy.ssh.core.Service

import com.nielsen.gradle.cmRegistry.CMRegistryPlugin

错误

C:\Users\528302\Documents\gradle_all\projectf1>gradle build
:compileJava UP-TO-DATE
:compileGroovy
startup failed:
C:\Users\528302\Documents\gradle_all\projectf1\src\main\groovy\com\nielsen\gradle\CustPlugin.groovy: 14: unable to resolve class org.hidetake.groovy.ssh.Ssh
 @ line 14, column 1.
   import org.hidetake.groovy.ssh.Ssh
   ^

C:\Users\528302\Documents\gradle_all\projectf1\src\main\groovy\com\nielsen\gradle\CustPlugin.groovy: 15: unable to resolve class org.hidetake.groovy.ssh.core.Service

 @ line 15, column 1.
   import org.hidetake.groovy.ssh.core.Service
   ^

C:\Users\528302\Documents\gradle_all\projectf1\src\main\groovy\com\nielsen\gradle\CustPlugin.groovy: 17: unable to resolve class com.nielsen.gradle.cmRegistry.CMRegi
stryPlugin
 @ line 17, column 1.
   import com.nielsen.gradle.cmRegistry.CMRegistryPlugin
   ^

请帮忙解决这个问题......谢谢。

1 个答案:

答案 0 :(得分:1)

你混合了两件事。通过使用plugins { }闭包,您将为buildscript本身添加依赖项。但在这种情况下,您构建的代码依赖于某些库,而不是构建脚本。

尝试将以下内容添加到dependencies { }

compile group: 'org.hidetake', name: 'groovy-ssh', version: '2.8.0'

所以你最终有了

plugins {
  id 'org.sonarqube' version '2.0.1'
  id 'groovy'
  id 'org.hidetake.ssh' version'2.7.0'
}

dependencies {
    compile gradleApi()
    compile localGroovy()
    compile group: 'org.hidetake', name: 'groovy-ssh', version: '2.8.0'
}
相关问题