Using Alfred to Switch Maven Settings with One Click
Since company projects require using internal Maven resources, which aren’t needed at home, switching settings back and forth is time-consuming. Inspired by automation, I considered creating a script to switch sources.
Script-Based Initial Solution
I came across an article by a fellow developer about script-based switching, which gave me an idea. Here’s the script:
1 |
|
The script allows interactive execution to switch settings. However, this method still requires running the script each time. Is there a way to achieve one-click switching? Yes! Alfred can do it.
How can we achieve this?
Adding an Input Keyword
Adding a List Filter
Adding Script Execution
The above script was slightly modified as follows:
1 | base_dir=~/.m2 |
Default Maven Settings Configuration
Here’s a link to the default settings.xml
configuration:
Click here
Adding Notifications
To enhance the experience, add a notification after each successful switch.
Screenshots
With this setup, you can switch Maven settings with one click. Perfect.