JetBrains/gradle-idea-ext-plugin

Customising Android IDE settings

Takhion opened this issue ยท 5 comments

Can we get access to workspace settings by their identifiers?
This way one could customise almost any 3rd party plugin! ๐Ÿ™

Example issue

When compiling an Android project (right after import) in the IDE, with Gradle 4.6+, one gets the following failure:

Executing tasks: [:android:generateDebugSources, :android:generateDebugAndroidTestSources, :android:mockableAndroidJar]

Configuration on demand is an incubating feature.

FAILURE: Build failed with an exception.

...

* What went wrong:
An exception occurred applying plugin request [id: 'com.android.library']
> Failed to apply plugin [id 'com.android.library']
   > Configuration on demand is not supported by the current version of the Android Gradle plugin since you are using Gradle version 4.6 or above. Suggestion: disable configuration on demand by setting org.gradle.configureondemand=false in your gradle.properties file or use a Gradle version less than 4.6.

...

Despite what the error message says, the only way to fix it is to uncheck Configure on demand in the settings:

which adds the following to .idea/workspace.xml:

<component name="AndroidGradleBuildConfiguration">
  <option name="USE_CONFIGURATION_ON_DEMAND" value="false" />
</component>

Note that compiling directly from Gradle always works, this is an IDE-specific issue!

I see your point, but there is no immediate plan to grant low-level storage access you are asking for.

You particular problem is caused (and solved) by using Android Studio-specific settings, maintained by Google. Please, report it using their manual

Oww, but it would immediately solve so many "edge" use-cases that will never get proper official support ๐Ÿ˜ž

Instead of relying solely on official support, you could implement missing bits yourself.
The Gradle DSL model is extensible, serialization protocol is almost automatic and there is an extension point on Intellij Idea side, where you could get access to results of Gradle DSL serialization.

Would you be interested in a guide?

@nskvortsov I would happily do this myself, but from my understanding the plugin is only used for interacting with the user, and every feature needs to be implemented inside IDEA...Am I wrong? Is there a generic, low-level hook where one could interact with IDEA and ask it to perform any action?

Indeed, there should be an implementation on Idea side. But it can easely be provided by a plugin. If you are willing to invest some time, I would be happy to help with set up and guidance. We can start next week.