1

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
    }
}
Eric Francis
  • 23,039
  • 31
  • 88
  • 122

1 Answers1

0

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.

Peter Niederwieser
  • 121,412
  • 21
  • 324
  • 259