How to get value from gradle.properties in intelliJ?

Answered

Want to get some values from gradle.properties in Intellij, such as the value of pluginName. The gradle.properties is as follow:

pluginName = a.b.c.d

I tried to use library method getProperty(), but it gets null value. Any answer will be very helpful. Thanks a lot. 

2 comments
Comment actions Permalink

Hi,

Please be more specific when describing issues. I assume you want to access your plugin name in running IDE instance with your plugin installed. Use com.intellij.ide.plugins.PluginManagerCore.getPlugin():

com.intellij.ide.plugins.PluginManagerCore.getPlugin(PluginId.getId("your plugin ID")).getName();

Also, your Gradle properties are used only during Gradle build tasks. Some of them are persisted in plugin.xml descriptor or in other places, but running IDE and plugin don't know anything about Gradle properties you built your project with.

0
Comment actions Permalink

Hi Karol,

Thank you for you answer. Yes, I want to access my plugin name when running my plugin. Your answer solved my question!

0

Please sign in to leave a comment.