Change By: Mirko Friedenhagen (13/May/13 2:46 PM)
Description: <p> The  {{  <tt> requirePropertyDiverges }} </tt>  enforcer rule from  _extra  <em>extra -enforcer- rules_ rules</em>  fails with a  {{  <tt> NullPointerException }} </tt>  if the rule configuration is placed in an  {{  <tt> execution }} </tt>  section.

</p>

<
h5 . ><a name="Exampleforafailingconfiguration"></a>  Example for a failing configuration

{noformat}
            < plugin /h5 >


                < groupId div class="preformatted panel" style="border-width: 1px;" > <div class="preformattedContent panelContent">
<pre>            &lt;plugin&gt;
                &lt;groupId&gt;
org.apache.maven.plugins < &lt; /groupId >
                <
&gt;
                &lt;
artifactId > &gt; maven-enforcer-plugin < &lt; /artifactId >
                <
&gt;
                &lt;
version > &gt; 1.2 < &lt; /version >
                <
&gt;
                &lt;
dependencies >
                    <
&gt;
                    &lt;
dependency >
                        <
&gt;
                        &lt;
groupId > &gt; org.codehaus.mojo < &lt; /groupId >
                        <
&gt;
                        &lt;
artifactId > &gt; extra-enforcer-rules < &lt; /artifactId >
                        <
&gt;
                        &lt;
version > &gt; 1.0-alpha-4 < &lt; /version >
                    <
&gt;
                    &lt;
/dependency >
                <
&gt;
                &lt;
/dependencies >
                <
&gt;
                &lt;
executions >
                    <
&gt;
                    &lt;
execution >
                        <
&gt;
                        &lt;
id > &gt; enforce-property-diverges < &lt; /id >
                        <
&gt;
                        &lt;
goals >
                            <
&gt;
                            &lt;
goal > &gt; enforce < &lt; /goal >
                        <
&gt;
                        &lt;
/goals >
                        <
&gt;
                        &lt;
configuration >
                            <
&gt;
                            &lt;
rules >
                                <
&gt;
                                &lt;
requirePropertyDiverges >
                                    <
&gt;
                                    &lt;
property > &gt; project.url < &lt; /property >
                                    <
&gt;
                                    &lt;
regex > &gt; http://company/wiki/company-parent-pom/.* < &lt; /regex >
                                <
&gt;
                                &lt;
/requirePropertyDiverges >
                            <
&gt;
                            &lt;
/rules >
                        <
&gt;
                        &lt;
/configuration >
                    <
&gt;
                    &lt;
/execution &gt;
                &lt;/executions&gt;
            &lt;/plugin&gt;
</pre
>

                </ executions div >
            </ plugin div >
{noformat}



<
h5 . ><a name="Stacktrace"></a>  Stack trace

{noformat}
</h5>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:1.2:enforce (enforce-general-project-rules) on project example-project: Execution enforce-general-project-rules of goal org.apache.maven.plugins:maven-enforcer-plugin:1.2:enforce failed. NullPointerException - > &gt;  [Help 1]

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:1.2:enforce (enforce-general-project-rules) on project example-project: Execution enforce-general-project-rules of goal org.apache.maven.plugins:maven-enforcer-plugin:1.2:enforce failed.

        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:225)

[...snip...]

        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)

Caused by: org.apache.maven.plugin.PluginExecutionException: Execution enforce-general-project-rules of goal org.apache.maven.plugins:maven-enforcer-plugin:1.2:enforce failed.

        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:110)

        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)

        ... 19 more

Caused by: java.lang.NullPointerException

        at org.apache.maven.plugins.enforcer.RequirePropertyDiverges.checkAgainstParentValue(RequirePropertyDiverges.java:110)

        at org.apache.maven.plugins.enforcer.RequirePropertyDiverges.execute(RequirePropertyDiverges.java:87)

        at org.apache.maven.plugins.enforcer.EnforceMojo.execute(EnforceMojo.java:178)

        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)

        ... 20 more
{noformat}


</pre>
</div></div>

<
h5 . ><a name="  Patch

"></a>Patch</h5>

<p>
The rule code fails to find the parent POM which contains the rule configuration ( {{ <tt> RequirePropertyDiverges.findDefiningParent }} </tt> ). The attached patch fixes this by including the configuration elements of all executions in  {{  <tt> RequirePropertyDiverges.getRuleConfigurations }} </tt> . </p>
Fix Version/s: extra-enforcer-rules-1.0-alpha-5
Remaining Estimate: 0 minutes
Original Estimate: 0 minutes
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
--------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email

Reply via email to