具有自定义组id的Gradle插件
梯度6.1 我很难在Gradle中使用来自自定义存储库的自定义插件的新插件配置模式具有自定义组id的Gradle插件,gradle,gradle-plugin,Gradle,Gradle Plugin,梯度6.1 我很难在Gradle中使用来自自定义存储库的自定义插件的新插件配置模式 buildscript { repositories { maven { url = uri("https://custom") } mavenCentral() jcenter() maven { url = uri("https://plugins.gradle.org/m2
buildscript {
repositories {
maven {
url = uri("https://custom")
}
mavenCentral()
jcenter()
maven {
url = uri("https://plugins.gradle.org/m2/")
}
}
}
plugins {
java
idea
id("com.custom.gradle.plugin.myplugin") version "1.1.0"
}
我得到这个错误:
Plugin [id: 'com.custom.gradle.plugin.myplugin', version: '1.1.0'] was not found in any of the following sources:
- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact 'com.custom.gradle.plugin.myplugin:com.custom.gradle.plugin.myplugin:1.1.0')
Searched in the following repositories:
Gradle Central Plugin Repository
Gradle将使用插件id作为其组id
如果我使用旧方法,它会起作用:
buildscript {
repositories {
maven {
url = uri("https://custom")
}
mavenCentral()
jcenter()
maven {
url = uri("https://plugins.gradle.org/m2/")
}
}
dependencies {
classpath("com.custom:com.custom.gradle.plugin.myplugin:1.1.0")
}
}
apply(plugin = "com.custom.gradle.plugin.myplugin")
是否有方法使用“id”命令指定组id?或者我正在破坏插件定义与旧插件的契约?为了使用新的/首选DSL,自定义插件必须发布一个 若自定义插件可以被修改,那个么我建议更新以利用它,它将为您创建标记 如果插件无法更新,则仍然可以使用
plugins{}
块,但需要手动解析插件:
在主build.gradle
中:
plugins {
id("com.custom.gradle.plugin.myplugin") version "1.1.0"
}
pluginManagement {
resolutionStrategy {
eachPlugin {
if (requested.id.id == "com.custom.gradle.plugin.myplugin") {
useModule("com.custom:com.custom.gradle.plugin.myplugin:${requested.version}")
}
}
}
}
然后在设置中手动解析插件。gradle
:
plugins {
id("com.custom.gradle.plugin.myplugin") version "1.1.0"
}
pluginManagement {
resolutionStrategy {
eachPlugin {
if (requested.id.id == "com.custom.gradle.plugin.myplugin") {
useModule("com.custom:com.custom.gradle.plugin.myplugin:${requested.version}")
}
}
}
}
有关更多详细信息,请参阅。感谢您的快速响应。我想,如果我们想继续使用它,我们确实需要改变这一点。可能相关: