What method am I missing? MissingMethodException on project.apply plugin: 'customPlugin'

582 Views Asked by At

What method am I missing? I am getting a MissingMethodException on

project.apply plugin: 'env'

Here is my code:

--EnvPluginTest.groovy

package com.gradle.env;

import static org.junit.Assert.*
import org.junit.Test
import org.gradle.api.*
import org.gradle.testfixtures.*

class EnvPluginTest {

    @Test
    public void EnvPluginAddsEnvPluginExtensionToProject() {
        Project project =  ProjectBuilder.builder().build()
        project.apply plugin: 'env'

        assertTrue(project.extensions.getByName('env')  
            instanceof  EnvPluginExtension)
    }
}

--env.properties

implementation-class=com.gradle.env.EnvPlugin

--EnvPlugin.groovy

package com.gradle.env

import org.gradle.api.*;

class EnvPlugin implements Plugin<Project> {
    void apply(Project project) {
        project.configure {
            extensions.create("env",  
                EnvPluginExtension) 
        }
    }
}

class EnvPluginExtension {
    def env = EnvSingleton.instance
}

class EnvSingleton {

    String tcserverHome
    String javaHome

    private static final INSTANCE = new EnvSingleton()

    private EnvSingleton() {}

    static getInstance() {
        return INSTANCE
    }
}
1

There are 1 best solutions below

3
Peter Niederwieser On

The full stack trace should tell you where the problem is. You can get it from Gradle's HTML test report, from your IDE, or by reconfiguring test.testLogging.

PS: Please don't double-post here and on http://forums.gradle.org.