Cannot apply an external plugin in a gradle init s

2019-07-28 19:04发布

问题:

First off, I created a project to illustrate the issue I'm having:

GitHub project removed, see edit for effective file contents. If you want the sample project PM me

Try to run the project with the following command:

$./gradlew -I deploy.gradle tasks

I get an error like so:

Failed to notify action.
> Plugin with id 'artifactory' not found.

But when I include the contents of deploy.gradle in build.gradle it builds just fine. For the record it's the artifactory plugin, and it appears to only be in the jfrog repository. I'm sure I must be missing how to specify the classpath in the init script.

Any help is appreciated. Thanks in advance!

EDIT

I was able to get it to work thanks to @erdi's answer. Here are the effective contents of the two files:

deploy.gradle

initscript {
    repositories {
        maven { url 'http://repo.jfrog.org/artifactory/gradle-plugins' }
    }

    dependencies {
        classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:2.0.16'
    }
}

allprojects {
    apply plugin: org.jfrog.gradle.plugin.artifactory.ArtifactoryPlugin
}

// vim:ft=groovy:tw=0

build.gradle

println 'Hello, world!'
// wrapper task omitted

回答1:

According to this thread you cannot use plugin IDs in plugins scripts. Instead, the fully qualified class name has to be used.



标签: gradle