[ http://jira.codehaus.org/browse/MAVEN-1623?page=comments#action_54000 ] 

Laird Nelson commented on MAVEN-1623:
-------------------------------------

For those who care, here is a port of the copyResources tag in jelly with the 
added setPreserveLastModified() call thrown in there.  Stand back.  You'll need 
to set a jelly variable named "todir" to the destination directory name.

    <j:forEach var="resource" items="${pom.build.resources}">
      <j:set var="directoryName" value="${resource.directory}"/>
      <j:new var="directory" className="java.io.File">
        <j:arg value="${directoryName}"/>
      </j:new>
      <j:choose>
        <j:when test="${directory.exists() and directory.isDirectory() and 
directory.canRead()}">
          <j:new var="targetDirectoryBuffer" className="java.lang.StringBuffer">
            <j:arg value="${todir}"/>
          </j:new>
          <j:set var="targetPath" value="${resource.targetPath}"/>
          <j:if test="${targetPath != null and targetPath.trim().length() != 
0}">
            <j:mute>
              <j:expr 
value="${targetDirectoryBuffer.append('/').append(targetPath)}"/>
            </j:mute>
          </j:if>
          <j:new var="targetDirectory" className="java.io.File">
            <j:arg value="${targetDirectoryBuffer.toString()}"/>
          </j:new>
          <j:new var="copyTask" className="org.apache.tools.ant.taskdefs.Copy"/>
          <j:expr value="${copyTask.setProject(context.getAntProject())}"/>
          <j:expr value="${copyTask.setTodir(targetDirectory)}"/>
          <j:expr value="${copyTask.setFiltering(resource.isFiltering())}"/>
          <j:expr value="${copyTask.setOverwrite(resource.isFiltering())}"/>
          <j:expr value="${copyTask.setPreserveLastModified(true)}"/>
          <j:new var="fileSet" className="org.apache.tools.ant.types.FileSet"/>
          <j:expr value="${fileSet.setDir(directory)}"/>
          <j:if test="${resource.includes.isEmpty()}">
            <j:set var="entry" value="${fileSet.createInclude()}"/>
            <j:set var="starStarSlashStarStar" value="**/**"/>
            <j:expr value="${entry.setName(starStarSlashStarStar)}"/>
          </j:if>
          <j:forEach var="includeString" items="${resource.includes}">
            <j:set var="entry" value="${fileSet.createInclude()}"/>
            <j:expr value="${entry.setName(includeString)}"/>
          </j:forEach>
          <j:forEach var="excludeString" items="${resource.excludes}">
            <j:set var="entry" value="${fileSet.createExclude()}"/>
            <j:expr value="${entry.setName(excludeString)}"/>
          </j:forEach>
          <j:expr value="${copyTask.addFileset(fileSet)}"/>
          <j:expr value="${copyTask.execute()}"/>
        </j:when>
        <j:otherwise>
          <ant:echo message="${targetDirectory} is either not a directory, not 
readable, or nonexistent."/>
        </j:otherwise>
      </j:choose>
    </j:forEach>

Cheers,
Laird ([EMAIL PROTECTED])

> copyResources does not preservelastmodified
> -------------------------------------------
>
>          Key: MAVEN-1623
>          URL: http://jira.codehaus.org/browse/MAVEN-1623
>      Project: Maven
>         Type: Bug

>  Environment: maven-1.0rc3
>     Reporter: Matthias Kerkhoff
>     Priority: Minor
>      Fix For: 1.1-beta-3

>
>
> I noticed that whenever files are copied with the help of maven:copyResources 
> the lastModified time is updated.
> This happens because the underlying ant copyTask is not
> called with preserveLastModified=true.
> (org.apache.maven.jelly.tags.maven.CopyResources, lines 109-137)
> While this is only annoying for me, I can easily imagine situations in which 
> this behaviour will cause real problems.
> For example, commercial software often checks the last
> modified timestamp of some files. 
> Actually, I digged into this because I tried to understand why some ears and 
> rars in our project are constantly rebuild - even if we didn't change 
> anything between the builds. So, fixing this (or adding an additional 
> parameter to the tag) may also result in a performance gain.

-- 
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


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to