Gradle分为脚本插件和插件存储库,找不到插件



在规章制度严格的公司团队中工作时,有了本地访问控制的artifactory(镜像和发布(和防火墙中阻止的官方镜像,我们需要一个通用的init.gradle。我有一个真正的问题,就是将URL(应该是环境的一部分,而不是项目的一部分(硬编码到构建脚本中,然后在100个不同项目中重复相同的URL。我越来越多地看到这种情况,它似乎在gradle/android应用程序和nodejs开发圈子里特别流行。

这个init.gradle在应用程序依赖性方面工作得很好,而在插件方面则不太好(为了演示的目的,所包含的版本保持简单(。特别是,将构建拆分为单独的脚本插件(不是buildSrc或模块化构建(,我们不能使用插件{}部分;我们必须使用";应用插件";在每个脚本中,因此我们还需要将插件添加到每个脚本的buildscript部分的类路径中。

好吧,它仍然不起作用。如果我使用带有版本的插件部分将所有内容放在一个根build.gradle文件中,并跳过类路径,那么它确实有效。那么我做错了什么

请参阅https://github.com/devminded/gradlebuild例如。

build.gradle

plugins {
id 'nebula.info' version '8.3.1'
id 'nebula.lint' version '16.9.0'
}
apply from: 'gradle/build-package.gradle'
apply from: 'gradle/build-docker.gradle'
apply from: 'gradle/publish.gradle'
apply from: 'gradle/release.gradle'

gradle/build docker.gradle

buildscript {
dependencies {
classpath 'com.bmuschko:gradle-docker-plugin:6.4.0'
}
}
apply plugin: 'com.bmuschko.docker-remote-api'
// ...

渐变/释放。渐变

buildscript {
dependencies {
classpath 'net.researchgate:gradle-release:2.8.1'
}
}
apply plugin: 'net.researchgate.release'
release {
// ...
}
afterReleaseBuild.dependsOn publish

结果

$> ./gradlew
Build file '.....gradlebuildbuild.gradle' line: 7
A problem occurred evaluating root project 'myapp'.
> Could not resolve all artifacts for configuration 'classpath'.
> Cannot resolve external dependency com.bmuschko:gradle-docker-plugin:6.4.0 because no repositories are defined.
Required by:
unspecified:unspecified:unspecified

使用

apply plugin: com.bmuschko.gradle.docker.DockerRemoteApiPlugin

而不是

apply plugin: 'com.bmuschko.docker-remote-api'

你可以在的存储库中找到插件的类路径

最新更新