2017-02-22 23 views
1

我想从gradle构建文件中调用一个定制的groovy插件。但是我在解决ssh的类时遇到了错误。下面是构建文件,定制groovy插件和错误的一部分。无法解析gradle.build中的ssh类

的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

你在混合两件事。通过使用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' 
} 
+0

感谢马丁......我试过,但我得到了follwoing错误: *什么出错了: 无法解析配置':compileClasspath'的所有依赖关系。 >无法解析外部依赖关系org.hidetake:groovy-ssh:1.1.6,因为没有定义存储库。 必需: 项目: – ghost0806

+0

相同的版本2.8.0 – ghost0806

+0

现在你缺少存储库声明。 添加 '{库 mavenCentral() }' 你'build.gradle' –

相关问题