I'm trying to DRY some of the JFrog publishing code from my build.gradle
to an external file (the Gradle Script plugin) (which I was duplicating in different Gradle projects).
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.21.0"
}
}
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.artifactory'
publishing {
publications {
wpJFrogMaven(MavenPublication) {
// Code removed for brevity
}
}
}
// Code removed for brevity
I'm using this Gradle script plugin at the end of my main build.gradle
of my actual project-
apply from: "https://raw.githubusercontent.com/wizpanda/gradle-common/main/grails-plugin-jfrog-publish.gradle"
When I run any Gradle task like- ./gradlew artifactoryPublish
, it fails with the error-
FAILURE: Build failed with an exception.
* Where:
Script 'https://raw.githubusercontent.com/wizpanda/gradle-common/06a497b62fb4bb86facd96375bad1d91a67545d1/grails-plugin-jfrog-publish.gradle' line: 14
* What went wrong:
A problem occurred evaluating script.
> Plugin with id 'com.jfrog.artifactory' not found.
But if I define the same buildscript
configuration and plugins in the main build.gradle
file of the project, it works fine.
I already spent 3-4 hours debugging it and read various articles, blogs and documentations-
- https://plugins.gradle.org/plugin/com.jfrog.artifactory
- Gradle with artifactory
- https://github.com/gradle/gradle/issues/14517
- When using custom Gradle plugin :Could not resolve all dependencies for configuration ':classpath'.
- https://docs.gradle.org/current/userguide/tutorial_using_tasks.html#sec:using_methods
- Android Gradle remote scripts using 'apply from:' what does it do
- https://docs.gradle.org/current/userguide/plugins.html#:~:text=Script%20plugins%20are%20automatically%20resolved,applied%20to%20a%20given%20target.
- (Example) https://raw.githubusercontent.com/chrisbanes/gradle-mvn-push/master/gradle-mvn-push.gradle
- How to load Gradle Plugin (with its depenecies) into build.gradle?
- Access classpath dependencies defined in buildscript block in applied external-script
- https://discuss.gradle.org/t/how-do-i-include-buildscript-block-from-external-gradle-script/7016
- https://docs.gradle.org/current/userguide/init_scripts.html?_ga=2.152768569.1473794243.1621063281-1685601076.1621063281
Any stupid thing am I missing?