无法在 gradle.build 中解析 ssh class
unable to resolve ssh class in gradle.build
我正在尝试从 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:\Users8302\Documents\gradle_all\projectf1>gradle build
:compileJava UP-TO-DATE
:compileGroovy
startup failed:
C:\Users8302\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:\Users8302\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:\Users8302\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
^
请帮助解决这个问题...谢谢。
你在混合两种东西。通过使用 plugins { }
闭包,您可以为构建脚本本身添加依赖项。但在这种情况下,您正在构建的代码依赖于某些库,而不是构建脚本。
尝试将以下内容添加到 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'
}
我正在尝试从 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:\Users8302\Documents\gradle_all\projectf1>gradle build
:compileJava UP-TO-DATE
:compileGroovy
startup failed:
C:\Users8302\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:\Users8302\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:\Users8302\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
^
请帮助解决这个问题...谢谢。
你在混合两种东西。通过使用 plugins { }
闭包,您可以为构建脚本本身添加依赖项。但在这种情况下,您正在构建的代码依赖于某些库,而不是构建脚本。
尝试将以下内容添加到 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'
}