[
https://issues.apache.org/jira/browse/MENFORCER-285?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16643971#comment-16643971
]
Karl Heinz Marbaise commented on MENFORCER-285:
-----------------------------------------------
If you call {{mvn enforcer:enforce}} than no life cycle is started. This means
that no configuration is used which is defined in the above pom file.
If you like to run {{mvn enforcer:enforcer}} and get the above configuration
you can use ([starting with Maven
3.3.1+|http://maven.apache.org/docs/3.3.1/release-notes.html]) it like this:
{{mvn enforcer:enforce@enforce}} which will use the configuration given by the
{{<id>enforcer</id>}}.
The position of the {{configuration}} tag has it's meaning and nothing to do
with {{old syntax}}. If you define the configuration as given in the above
example. The configuration is only applied for the execution block in which it
is contained. If you locate the {{configuration}} tag outside the execution
block it is applied globally for all executions including the execution via
command line. There exists a special id for execution from command line which
is named {{default-cli}} which can be used to make different configurations for
command line and life cycle which was the only possibility to have different
configurations before Maven 3.3.1... By using Maven 3.3.1+ you can have
multiple configurations defined in your pom file which you can select on
command line if you need.
The different locations for the configuration block gives you also the option
to define globally some common configurations for a plugin and in the
executions with another configuration tag you can overwrite or enhance
configurations.
So in the end this is no bug it's only a misunderstand how configuration of
plugins/life cycle works. So I close this issue.
> error parameters 'rules' are missing or invalid
> -------------------------------------------------
>
> Key: MENFORCER-285
> URL: https://issues.apache.org/jira/browse/MENFORCER-285
> Project: Maven Enforcer Plugin
> Issue Type: Bug
> Components: Plugin
> Affects Versions: 3.0.0-M1
> Environment: linux
> Reporter: Ernst Reissner
> Priority: Major
>
> I have the following config under build.plugins:
> {code:xml}
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-enforcer-plugin</artifactId>
> <version>3.0.0-M1</version>
> <executions>
> <execution>
> <id>enforce</id>
> <goals>
> <goal>enforce</goal>
> </goals>
> <configuration>
> <rules>
> <!--version>${versionMvn}</version-->
> <requireMavenVersion>
> <version>3.5.0</version>
> </requireMavenVersion>
> <!--requireJavaVersion>
> <version>1.8</version>
> </requireJavaVersion-->
> </rules>
> <!--alwaysFail>true</alwaysFail-->
> <fail>true</fail>
> <ignoreCache>true</ignoreCache>
> </configuration>
> </execution>
> </executions>
> </plugin>
> {code}
> Then
> {{mvn enforcer:enforce}}
> yields
> {code}
> [ERROR] Failed to execute goal
> org.apache.maven.plugins:maven-enforcer-plugin:3.0.0-M1:enforce (default-cli)
> on project Relana: The parameters 'rules' for goal
> org.apache.maven.plugins:maven-enforcer-plugin:3.0.0-M1:enforce are missing
> or invalid -> [Help 1]
> org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute
> goal org.apache.maven.plugins:maven-enforcer-plugin:3.0.0-M1:enforce
> (default-cli) on project Relana: The parameters 'rules' for goal
> org.apache.maven.plugins:maven-enforcer-plugin:3.0.0-M1:enforce are missing
> or invalid
> at
> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)
> at
> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
> at
> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
> at
> org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
> at
> org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
> at
> org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
> at
> org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
> at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:309)
> at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:194)
> at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:107)
> at org.apache.maven.cli.MavenCli.execute(MavenCli.java:993)
> at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:345)
> at org.apache.maven.cli.MavenCli.main(MavenCli.java:191)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:498)
> at
> org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
> at
> org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
> at
> org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
> at
> org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
> Caused by: org.apache.maven.plugin.PluginParameterException: The parameters
> 'rules' for goal
> org.apache.maven.plugins:maven-enforcer-plugin:3.0.0-M1:enforce are missing
> or invalid
> at
> org.apache.maven.plugin.internal.DefaultMavenPluginManager.populatePluginFields(DefaultMavenPluginManager.java:643)
> at
> org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:596)
> at
> org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:121)
> at
> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
> ... 20 more
> [ERROR]
> [ERROR]
> [ERROR] For more information about the errors and possible solutions, please
> read the following articles:
> [ERROR] [Help 1]
> http://cwiki.apache.org/confluence/display/MAVEN/PluginParameterException
> {code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)