You are a little suspicious of this approach, but you are not quite sure why, after all, it is quite convenient. In any case, this is what I feel about this: I really do not know why, but it seems a little strange.
Consider two questions: a) what are the profiles for? b) What alternative approaches should we compare with your approach?
Regarding a), I think the profiles are for different build or runtime environments. You may depend on locally installed software, where you must use a profile to determine the path to the executable in the respective environments. Or you may have profiles for different runtime configurations, such as development, test, production. More information about this can be found at http://maven.apache.org/guides/mini/guide-building-for-different-environments.html and http://maven.apache.org/guides/introduction/introduction-to- profiles.html .
As for b), the ideas that come to my mind:
- running plugins with command line properties. For example, mvn -Dfitnesse = true. As is well known, -DdownloadSources = true for the eclipse plugin, or -Dmaven.test.skip = true for certainty. But this requires the plugin to have a flag to run execution. Not all plugins you need can have this.
- Challenge goals explicitly. You can invoke multiple targets on the same command line, for example, "mvn clean package war: exploded". When fitness is performed automatically (using the appropriate profile), it means that its implementation is tied to the phase of the life cycle. That is, whenever this phase in the life cycle is reached, the plugin is executed. Instead of tying the execution of plugins to the stages of the life cycle, you should be able to include the plugin, but execute it only when explicitly called. Thus, your call will look like this: "mvn fitnesse: run source: jar deploy".
The answer to question a) may explain the "strangeness". This is simply not what profiles are for.
Therefore, I believe that alternative 2 could be better. The use of profiles can become problematic when "real" profiles for different execution or assembly conditions take effect. You will probably have a confusing mix of profiles where profiles mean very different things (for example, “test” means the environment, while “fitness” will mean the goal). If you just name the goals explicitly, I think it will be very clear and flexible. Remembering the names of the plugins / goals should not be harder if you remember the names of the profiles.
lutzh source share