June 27, 2015

IntelliJ IDEA / Android Studio plugin: Save action Groovy scripts



So I accidentally created a new IntelliJ IDEA / Android Studio plugin. This came to existence out of necessity as I was working on an upcoming blog post with Android Studio.

TL;DR? Check out the plugin on GitHub!

What it is

From the plugin’s description: This IntelliJ IDEA / Android Studio plugin allows the user to automatically run custom Groovy scripts when a file is saved / synchronized. Any valid Groovy script is supported; moreover, the plugin exposes a simple API to make file handling especially easy, allowing to simply implement source code formatting, file backups, file transformations, and more. Groovy script execution can be conditionally enabled / disabled based on a regex check on the path of the file which is saved.

Motivation

When working with Android Studio, this plugin allows to convert values/strings.xml file back and forth to values/strings.properties files.

Yes, Android Studio has built-in support to make XML editing easier. Still I prefer having my message bundles in the simplistic properties file format, just as it’s standard in Java EE projects. Using the plugin, I can write bundles in the properties file format without caring about the xml file. This is just one piece in the puzzle to make Android development less painful. I elaborate more on that in the next blog post.

Use it!

Thanks to the highly customizable nature of the plugin, you can use it to virtually do anything in a project file structure on file save!

If you ever felt the need for writing customized “on save” macros in IntelliJ in Java / Groovy, please take a look at the plugin’s GitHub page. Its usage is thoroughly explained in the accompanying README.

No comments:

Post a Comment