Applying plugin with plugin block fails


I do not understand why this fails:

plugins {
    id 'groovy'
    id 'com.github.hauner.jarTest' version '1.0.1'


An exception occurred applying plugin request [id: 'com.github.hauner.jarTest', version: '1.0.1'] 
> Failed to apply plugin [id 'com.github.hauner.jarTest']
    > Could not find property 'testClasses' on project ':SubB'.

When using apply plugin: there is no problem.

The plugin creates a task that dependsOn: testClasses. It looks like groovy is not yet applied when gradle applies the plugin. This is surprising…

I can probably apply java from the plugin to avoid the problem.

Still it would be nice to understand why it fails using plugin. :slightly_smiling:

is it applying them in alphabetical order maybe?

alphabetical? I would not expect that :grinning:

trying… ZZZ changing the order gives the same error, so not alphabetically.

The plugins should be applied in the order listed. When I test this locally that is the behavior I see. In any case, clearly this plugin depends on the ‘java’ plugin so it should apply it in order to avoid having to apply plugins in an explicit order.