Apply from: file() works differently than including the file content in-situ

(Mark Petrovic) #1

I have successfully applied the jacoco plugin to my build thusly:

apply plugin: 'jacoco'
  buildscript {
    repositories {
       maven {
          url "http://${nexusHost}/nexus/content/groups/public"
    dependencies {
        classpath 'org.ajoberstar:gradle-jacoco:0.2.0'

but when I put that snippet in a file named gradle/jacoco.gradle and try to apply like this

apply from: file("gradle/jacoco.gradle")

I get this when I build:

pathToProject/gradle/jacoco.gradle' line: 1
  * What went wrong:
A problem occurred evaluating script.
> Plugin with id 'jacoco' not found.

Why do I get different results when I have the literal snippet applying the plugin vs when I apply the snippet via apply from: file() ?


(Luke Daley) #2

Hi Mark,

It’s a known shortcoming that you can’t bring in plugins via buildscript {} in a script plugin. You’ll need to move the buildscript {} block back to build.gradle.