Maven - dynamic pom file?

I'm using the Maven plugin was6-maven-plugin to deploy to websphere. When installing an application, there's a configuration value named "updateExisting" that should be false if I am installing a new application, and true if I am updating an existing application. I don't like having to manually toggle this value if I am fresh-installing/updating the application.

The way I see it, I can either add an uninstallApp goal to always uninstall the application before installing it, but this seems a rather silly way to do it.

I've noticed that this plugin also has a goal wsListApps that outputs all applications installed on the server. The output looks like this:

[INFO]   [wsadmin] WASX7209I: Connected to process "server1" on node 1234Node02 using SOAP connector;  The type of process is: UnManagedProcess
[INFO]   [wsadmin] DefaultApplication
[INFO]   [wsadmin] IBMUTC
[INFO]   [wsadmin] MyApplicationEAR
[INFO]   [wsadmin] ivtApp
[INFO]   [wsadmin] query

Is it possible for Maven to scan this output for the string "MyApplicationEAR" and set "updateExisting" to "true" if it is found, and leave it "false" otherwise?

Upvotes: 0

Views: 248

Answers (1)

ben75
ben75

Reputation: 28726

What you need is to be able to update a maven property during the life-cycle, before the phase binded with your was6-maven-plugin. (and using this property as a value for <updateExisting>)

Unfortunately, maven properties are static and cannot be changed at runtime. So at first sight it's impossible to do.

But, there is a plugin : properties-maven-plugin you can use to define new properties at runtime. The value of the property can be defined by a groovy script. Now the question is more about how can you write a groovy script telling if your app is already there or not.

Honestly, I don't know if it's a good idea to use it. I think running the uninstall goal everytime with failOnError set to false is probably the simplest way (and so probably the best, but maybe I am missing something ?)

Upvotes: 2

Related Questions