Project.configuration.runtime not accessible, when the new plugin mechanism is used

Consider simple gradle script:

plugins {
  id 'java'
  id 'org.akhikhl.gretty' version '1.1.4'
}

it produces [groovy.lang.MissingPropertyException: Could not find property ‘runtime’ on configuration container.] during evaluation phase. The relevant code in Gretty plugin tries and fails to access project.configurations.runtime. My question is: is there legitimate way to access other plugin’s properties in Plugin.apply, when applying with new plugin mechanism?

If your plugin depends on the Java plugin, it should apply it in its apply() method. If it doesn’t strictly depend on it, but integrates with it, you need to write it defensively to cater for it potentially not being there.

Hi Luke, Thank you for an explanation. It solves my problem.

Andrey,

I really like gretty and the gradle plugin (https://plugins.gradle.org/plugin/org.akhikhl.gretty/1.1.4).

However, it currently does not even work with a very simple build.gradle:

plugins {
    id 'java'
    id "org.akhikhl.gretty" version "1.1.4"
}

Produces:

* Where:
Build file '/private/tmp/gretty-test/build.gradle' line: 3
  * What went wrong:
An exception occurred applying plugin request [id: 'org.akhikhl.gretty', version: '1.1.4']
> Could not find property 'runtime' on configuration container.

Would you mind fixing that and provide a new version?

Thx,

Gerd