Я хочу создать собственный плагин Gradle, но он всегда терпел неудачу, когда я позволяю корневому проектору применить плагин.
ERROR: Unable to load class 'com.ucloud.android.plugin.UpluginImpl'.
Possible causes for this unexpected error include:
Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)
The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart)
Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.
In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
Мой класс плагинов:
package com.ucloud.android.uplugin
import org.gradle.api.Plugin
import org.gradle.api.Project
class UpluginImpl implements Plugin<Project> {
@Override
void apply(Project project) {
project.task("Test Ucloud Task") << {
println("********************* Task *********************")
}
}
}
МойФайл build.gradle модуля плагина:
apply plugin: 'groovy'
apply plugin: 'maven'
repositories {
google()
jcenter()
mavenLocal()
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation gradleApi()
implementation localGroovy()
implementation 'com.android.tools.build:gradle:3.5.0'
}
sourceCompatibility = "8"
targetCompatibility = "8"
group = 'com.ucloud.android.plugin'
version = '1.0.2'
archivesBaseName='ucloud-plugin'
uploadArchives { //当前项目可以发布到本地文件夹中
repositories {
mavenDeployer {
repository(url: uri('/Users/joshua/.m2/repository/')) //定义本地maven仓库的地址
}
}
}
Мой модуль / resources / META-INF / gradle-plugins / ***. properties
implementation-class = com.ucloud.android.plugin.UpluginImpl
Я даже пытался удалить AndroidСтудия полностью, удалите все кешированные каталоги студии. И удалите мой .gradle dir。 Ошибка все еще здесь ...