Why isn't my pom being executed correctly when using Android Studio/IntelliJ?

IntelliJ has it's own internal build system much like any other IDE and is able to build projects without the help of external tools. Intellij also integrates with Maven by interpreting the pom.xml from your project and intructing it to build based on the configuration you have defined. This works pretty well with most compilation tasks but starts to fall over when you bring in more complex plugins such as the buildnumber-maven-plugin. Unfortunately IntelliJ has no internal equivilent to handle this plugin so the ${buildNumber} property is never populated.

The possible workarounds are:

  1. Don't build your project with IntelliJ's built in system, use the "Maven Projects" panel which you can show by going to "View" > "Tool Windows" > "Maven Projects". This gives you access to all of the standard Maven phases and other features.

  2. In your IntelliJ "run configuration" add an environment variable called "buildNumber" and give it any value you like, for example: buildNumber=DEV. This will make the the buildNumber property available during the build process and populate the property, it won't however update from your SCM.

We use the first workaround on a multi-module maven project as we too have hit similar limitations with the buildnumber-maven-plugin. We also use solution 2 when we need to run an integration test in IntelliJ as the buildNumber property is required by our code to display version information, as long as we give it any value it's happy.

I hope this is somewhat useful to you, the only real solution would be for IntelliJ's internal build system to have some understanding of the buildnumber-maven-plugin and expose the correct properties to the environment during the build process.