Conditional Configuration in pom.xml File

Nil Seri
Sep 12, 2021

--

Create Different Profiles in Maven pom.xml

Photo by Pete Godfrey on Unsplash

For my Java project’s obfuscation, I used Zelix as I described in this post.

Later on, while the project continues to evolve, to be able to understand exceptions, logs, etc. better in test environment, I wanted to be able to obfuscate or not based on a config in my pom.xml.

Following this link, I was able to accomplish it by “profiles”:

You can now run “mvn package” command with your profile parameter:

mvn clean package -DskipTests -Dmaven.repo.local=/Users/senoritadev/dev/repository -P obfuscated

“activeByDefault” in pom.xml is used for default configuration where you do not send a profile parameter in your command.

Happy Coding!

--

--

Nil Seri
Nil Seri

Written by Nil Seri

I would love to change the world, but they won’t give me the source code | coding 👩🏻‍💻 | coffee ☕️ | jazz 🎷 | anime 🐲 | books 📚 | drawing 🎨

No responses yet