我试图创建一个像这样设置的Gradle插件:
plugins {
id 'java-gradle-plugin'
id 'groovy'
}
repositories {
mavenCentral()
jcenter()
// note the custom maven repo
maven { url = "https://maven.gentics.com/maven2" }
}
dependencies {
implementation gradleApi(),
localGroovy(),
"com.gentics.mesh:mesh-rest-client:${MESH_VER}"
testImplementation gradleTestKit()
testImplementation("org.spockframework:spock-core:${SPOCK_VER}") {
exclude module : 'groovy-all'
}
}
// the rest...
但是,如果我尝试在另一个项目中使用includeBuild "./gradle-mesh"
中的settings.gradle
使用此插件,则会收到以下错误:A problem occurred configuring root project 'functionalTest'.
> Could not resolve all artifacts for configuration ':classpath'.
> Could not find com.gentics.mesh:mesh-rest-client:1.7.1.
Searched in the following locations:
- https://plugins.gradle.org/m2/com/gentics/mesh/mesh-rest-client/1.7.1/mesh-rest-client-1.7.1.pom
If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
Required by:
project : > project :gradle-mesh
但是,我可以在实际的插件测试中执行functionalTest
,而不会出现问题。删除settings.gradle
中的该行并将文件夹重命名为buildSrc
也可以。有没有一种方法可以从插件入口点配置
buildscript
依赖关系?我尝试了以下方法,但没有任何区别。class GradleMeshPlugin implements Plugin<Project> {
public void apply(Project project) {
project.buildscript.repositories.configure {
mavenLocal()
jcenter()
maven { url = "https://maven.gentics.com/maven2" }
}
// dependency is referenced here...
}
}
任何想法如何去做?完整项目:https://github.com/wawebio/gradle-mesh
系统:
------------------------------------------------------------
Gradle 6.6.1
------------------------------------------------------------
Build time: 2020-08-25 16:29:12 UTC
Revision: f2d1fb54a951d8b11d25748e4711bec8d128d7e3
Kotlin: 1.3.72
Groovy: 2.5.12
Ant: Apache Ant(TM) version 1.10.8 compiled on May 10 2020
JVM: 11.0.8 (Ubuntu 11.0.8+10-post-Ubuntu-0ubuntu120.04)
OS: Linux 5.4.0-47-generic amd64
更新我还可以通过在消耗项目的
settings.gradle
中添加以下内容来使其工作pluginManagement {
repositories {
mavenCentral()
jcenter()
maven { url = "https://maven.gentics.com/maven2" }
}
}
rootProject.name = 'website'
includeBuild "./gradle-mesh"
有没有办法从插件应用程序本身执行此操作?
最佳答案
您需要以其他方式指定mvn程序包,这是第一个程序包。
<configuring-project>
关于gradle - 麻烦的Gradle插件项目与第三方Maven存储库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63963334/