How to load artifactory plugin from init script - getting plugin not found error

Hi Gradle Forums,

I’m trying to offload build logic using a custom gradle wrapper and init scripts. I’d love to pull artifactory config out of our build in this way, but I can’t seem to get the plugin to load.

jfrog docs Gradle Artifactory Plugin - JFrog - JFrog Documentation show that there is a disconnect between the dependancy and the plugin id. eg

buildscript {
 repositories {
    mavenCentral()
  }
 
  dependencies {
    classpath "org.jfrog.buildinfo:build-info-extractor-gradle:latest.release"
  }
}
 
apply plugin: "com.jfrog.artifactory"

When I follow this pattern in init script I could never see that it was actually adding the dependency to my project when I’d run

./gradlew dependencies --configuration runtimeClasspath

having commented out the apply plugin line.

So I made instead an init script that defines a plugin, which does list the classes from jfrog:

artifactory.gradle

apply plugin: ArtifactoryPlugin

class ArtifactoryPlugin implements Plugin<Gradle> {
	void apply(Gradle gradle) {
		Properties properties = new Properties()
		properties.load(new File(gradle.getGradleUserHomeDir(), 'gradle.properties').newDataInputStream())

		gradle.allprojects { project ->
			project.repositories {
				maven {
					url properties.artifactory_contextUrl + '/gradle-plugins-virtual'
					credentials {
						username = properties.artifactory_user
						password = properties.artifactory_password
					}
				}
			}

                    def configurations = project.getConfigurations() 
			configurations.create('implementation')
			configurations.implementation{
				transitive = true
			}
			project.getDependencies().add('implementation', "org.jfrog.buildinfo:build-info-extractor-gradle:4.17.2")

			// apply plugin: 'org.jfrog.buildinfo' //not found
			// apply plugin: org.jfrog.buildinfo //org not understood			// apply plugin: org.jfrog.buildinfo' //com not understood
			// apply plugin: 'com.jfrog.artifactory //not found
		}
	}
}

running dependency listing shows it’s now loaded:

+--- org.jfrog.buildinfo:build-info-extractor-gradle:4.17.2
|    +--- commons-lang:commons-lang:2.4
|    +--- commons-logging:commons-logging:1.1.1 -> 1.2
|    +--- commons-io:commons-io:2.7
|    +--- org.jfrog.buildinfo:build-info-extractor:2.19.2
|    |    +--- commons-lang:commons-lang:2.4
|    |    +--- commons-logging:commons-logging:1.1.1 -> 1.2
|    |    +--- commons-io:commons-io:2.7
|    |    +--- com.google.guava:guava:27.0.1-jre -> 28.0-jre
|    |    |    +--- com.google.guava:failureaccess:1.0.1
|    |    |    +--- com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava
|    |    |    +--- com.google.code.findbugs:jsr305:3.0.2
|    |    |    +--- org.checkerframework:checker-qual:2.8.1
|    |    |    +--- com.google.errorprone:error_prone_annotations:2.3.2
|    |    |    +--- com.google.j2objc:j2objc-annotations:1.3
|    |    |    \--- org.codehaus.mojo:animal-sniffer-annotations:1.17
|    |    +--- com.thoughtworks.xstream:xstream:1.4.11.1
|    |    |    +--- xmlpull:xmlpull:1.1.3.1
|    |    |    \--- xpp3:xpp3_min:1.1.4c
|    |    \--- org.jfrog.buildinfo:build-info-client:2.19.2
|    |         +--- commons-lang:commons-lang:2.4
|    |         +--- commons-logging:commons-logging:1.1.1 -> 1.2
|    |         +--- commons-io:commons-io:2.7
|    |         +--- com.google.guava:guava:27.0.1-jre -> 28.0-jre (*)
|    |         +--- com.thoughtworks.xstream:xstream:1.4.11.1 (*)
|    |         +--- org.jfrog.buildinfo:build-info-api:2.19.2
|    |         |    +--- commons-lang:commons-lang:2.4
|    |         |    +--- commons-logging:commons-logging:1.1.1 -> 1.2
|    |         |    +--- commons-io:commons-io:2.7
|    |         |    +--- com.google.guava:guava:27.0.1-jre -> 28.0-jre (*)
|    |         |    +--- com.thoughtworks.xstream:xstream:1.4.11.1 (*)
|    |         |    +--- com.fasterxml.jackson.core:jackson-databind:2.10.5
|    |         |    |    +--- com.fasterxml.jackson.core:jackson-annotations:2.10.5
|    |         |    |    \--- com.fasterxml.jackson.core:jackson-core:2.10.5
|    |         |    +--- com.fasterxml.jackson.core:jackson-core:2.10.5
|    |         |    \--- org.apache.commons:commons-compress:1.19
|    |         +--- org.apache.httpcomponents:httpclient:4.5.12
|    |         |    +--- org.apache.httpcomponents:httpcore:4.4.13
|    |         |    \--- commons-logging:commons-logging:1.2
|    |         +--- org.apache.httpcomponents:httpcore:4.4.5 -> 4.4.13
|    |         +--- com.fasterxml.jackson.core:jackson-core:2.10.5
|    |         \--- commons-codec:commons-codec:1.13
|    \--- org.apache.ivy:ivy:2.2.0

Although I’m able to see this, applying the plugin still fails (in the plugin, in build.gradle, with quotes, without)

I’m curious if anyone has any suggestions to apply the plugin successfully.