问题描述
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>