Maven plugin - pass parameters to a lifecycle phase -


we have custom maven plugin generates code artifacts our project. plugin has configured lifecycle this, 'generate-resources' phase calling our custom class.

<?xml version="1.0" encoding="utf-8"?> <component-set>     <components>         <component>             <role>org.apache.maven.lifecycle.mapping.lifecyclemapping</role>             <role-hint>zip</role-hint>             <implementation>org.apache.maven.lifecycle.mapping.defaultlifecyclemapping</implementation>             <configuration>                 <phases>                     <generate-resources>com.b.e:productconfig-maven-plugin:generate</generate-resources>                     <package>com.b.e:productconfig-maven-plugin:zip</package>                     <install>org.apache.maven.plugins:maven-install-plugin:install</install>                     <deploy>org.apache.maven.plugins:maven-deploy-plugin:deploy</deploy>                 </phases>             </configuration>         </component>     </components> </component-set> 

we've new requirement run 'generate-resources' phase different parameters. had hoped define second phase , passing in mojo custom properties this

<?xml version="1.0" encoding="utf-8"?> <component-set>     <components>         <component>             <role>org.apache.maven.lifecycle.mapping.lifecyclemapping</role>             <role-hint>zip</role-hint>             <implementation>org.apache.maven.lifecycle.mapping.defaultlifecyclemapping</implementation>             <configuration>                 <phases>                     <generate-resources>com.b.e:productconfig-maven-plugin:generate -dmojo.param=a</generate-resources>                     <generate-resources>com.b.e:productconfig-maven-plugin:generate -dmojo.param=b</generate-resources>                     <package>com.b.e:productconfig-maven-plugin:zip</package>                     <install>org.apache.maven.plugins:maven-install-plugin:install</install>                     <deploy>org.apache.maven.plugins:maven-deploy-plugin:deploy</deploy>                 </phases>             </configuration>         </component>     </components> </component-set> 

but throws error.

[error] not find goal 'generate -dmojo.param=a' in plugin com.b.e:productconfig-maven-plugin:1.0.6-snapshot among available goals generate, zip -> [help 1] org.apache.maven.plugin.mojonotfoundexception: not find goal 'generate -doutputfilebasedir=/home/poc/b/product_configuration/productconfig-maven-plugin/target/generated/delta' in plugin com.b.e:productconfig-maven-plugin:1.0.6-snapshot among available goals export, generate     @ org.apache.maven.plugin.internal.defaultmavenpluginmanager.getmojodescriptor(defaultmavenpluginmanager.java:267)     @ org.apache.maven.plugin.defaultbuildpluginmanager.getmojodescriptor(defaultbuildpluginmanager.java:185)     @ org.apache.maven.lifecycle.internal.defaultlifecycleexecutionplancalculator.setupmojoexecution(defaultlifecycleexecutionplancalculator.java:152)     @ org.apache.maven.lifecycle.internal.defaultlifecycleexecutionplancalculator.setupmojoexecutions(defaultlifecycleexecutionplancalculator.java:139)     @ org.apache.maven.lifecycle.internal.defaultlifecycleexecutionplancalculator.calculateexecutionplan(defaultlifecycleexecutionplancalculator.java:116)     @ org.apache.maven.lifecycle.internal.defaultlifecycleexecutionplancalculator.calculateexecutionplan(defaultlifecycleexecutionplancalculator.java:129)     @ org.apache.maven.lifecycle.internal.buildercommon.resolvebuildplan(buildercommon.java:92) 

does know way correctly pass parameters lifecycle phase?

there 2 questions same requirement, none of them answer:

i'm pretty sure "lifecycle mapping property/parameter definition" not going work.

the declarations in component.xml specify goal bound phase of lifecycle, a.k.a. lifecycle mapping. in other words , in understanding:

  • it's what executed if phase passed during build run.
  • it's not how done.

none of references:

mentions:

  1. binding more 1 goal phase.

    since defaultlifecyclemapping.getphases(...) returns map key denotes phase isn't possible @ all.

  2. a goal-to-phase binding property/parameter definition.

    the part could not find goal 'generate -dmojo.param=a' of error message tells me complete string of goal part considered goal name, no further argument extraction applied.


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -