You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Balazs Tothfalussy (JIRA)" <ji...@codehaus.org> on 2009/02/22 16:29:20 UTC

[jira] Commented: (MENFORCER-67) RequiresFileSize rule does not use the confiugred file list

    [ http://jira.codehaus.org/browse/MENFORCER-67?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=166619#action_166619 ] 

Balazs Tothfalussy commented on MENFORCER-67:
---------------------------------------------

Excuse me, but last night it was to late and I did not make a positive test, so the proposed patch is not working, when everything should be OK, as the log private property should be initialized, so the proposed fix is:
if ( files.length == 0 )
{
            try
            {
                MavenProject project = (MavenProject) helper.evaluate( "${project}" );
                files[0] = project.getArtifact().getFile();
            }
            catch ( ExpressionEvaluationException e )
            {
                throw new EnforcerRuleException( "Unable to retrieve the project.", e );
            }
}
this.log = helper.getLog();
super.execute( helper );

> RequiresFileSize rule does not use the confiugred file list
> -----------------------------------------------------------
>
>                 Key: MENFORCER-67
>                 URL: http://jira.codehaus.org/browse/MENFORCER-67
>             Project: Maven 2.x Enforcer Plugin
>          Issue Type: Bug
>          Components: Standard Rules
>    Affects Versions: 1.0-alpha-4
>         Environment: Windows XP, Maven 2.0.9
>            Reporter: Balazs Tothfalussy
>
> I tried to use the requireFilesSize standard rule to validate the filesize of the build output file, my configuration:
> <plugin>
>         <groupId>org.apache.maven.plugins</groupId>
>         <artifactId>maven-enforcer-plugin</artifactId>
>         <version>1.0-alpha-4</version>
>         <executions>
>           <execution>
>             <id>enforce-ear-filesize</id>
>             <!-- Default phase is validate, but we need a verify after the build is done -->
>             <phase>verify</phase>
>             <goals>
>               <goal>enforce</goal>
>             </goals>
>             <configuration>
>               <rules>
> 	              <requireFilesExist>
> 	                  <files>
> 	                   <file>${project.build.directory}/${project.build.finalName}.ear</file>
> 	                  </files>
> 	                </requireFilesExist>
> 	                <requireFilesSize>
> 	                	<!-- Size in bytes -->
> 	                  	<maxsize>5000000</maxsize>
> 	                  	<files>
> 	                   		<file>${project.build.directory}/${project.build.finalName}.ear</file>
> 	                  	</files>
> 	               </requireFilesSize>
>                </rules>
>             </configuration>
>           </execution>
>         </executions>
> </plugin>
> I experienced, that whatever I configure in the pom of my project, nothing happens, although Maven writes out in debug mode, that the rule has been run
> I checked the code in enforcer-rules project, and in the execute method I found:
> if ( files.length == 0 )
>         {
>             try
>             {
>                 MavenProject project = (MavenProject) helper.evaluate( "${project}" );
>                 files[0] = project.getArtifact().getFile();
>                 this.log = helper.getLog();
>                 super.execute( helper );
>             }
>             catch ( ExpressionEvaluationException e )
>             {
>                 throw new EnforcerRuleException( "Unable to retrieve the project.", e );
>             }
>         }
> This code calls super.execute only if the configured file list contains no files, in the above configuration requiresFilesExits works, as the execute of AbstractRequireFiles runs
> So I propose a fix, which implements the else branch to call super.execute(helper) which will call checkFile for every defined file:
>  if ( files.length == 0 )
>         {
>             try
>             {
>                 MavenProject project = (MavenProject) helper.evaluate( "${project}" );
>                 files[0] = project.getArtifact().getFile();
>                 this.log = helper.getLog();
>                 super.execute( helper );
>             }
>             catch ( ExpressionEvaluationException e )
>             {
>                 throw new EnforcerRuleException( "Unable to retrieve the project.", e );
>             }
>         }
>         else {
>         	super.execute(helper);
>         }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira