Testing plugin configuration


(Lior Harel) #1

I’m trying to write a gradle plugin that will fetch a script file and pack it in the project’s artifact. actually the plugin works fine, I’m having issues trying to write a test for the plugin.

so the plugin looks something like:

project.configurations {
            upstart
        }
        project.dependencies {
            upstart(group: 'com.myorg', name: 'upstart', version: '1.0', ext: 'script')
        }
        project.task('upstart', group: 'Build', type: UpstartTask)

the test looks something like:

given:
            Project project = ProjectBuilder.builder().withProjectDir(baseDir).build()
            project.apply plugin:
'java'
            project.apply plugin: 'my-plugin'
            UpstartTask task = project.tasks['upstart']
        when:
            task.execute()

when running the test, the task execution throws exception: ModuleVersionNotFoundException: Could not find group:com.myorg, module:upstart, version:1.0.

is there any extra configuration needed for this to work in the test environment?


(Lior Harel) #2

solved it, was missing the repo configuration in the test:

project.repositories.mavenRepo([name: 'repo', url: "http://myrepo/artifactory/repo"])