Anders Hammar wrote:
> Found this through Google:
> 
http://www.gxdeveloperweb.com/Blogs/Bram-de-Kruijff/Maven-secrets-filtering-sources.htm
>
> Not sure if it's the best way to do it though. Never tried filtering
> java source code.

Thanks Anders for your reply.

Yep, I've been searching with Google as well and I found the same page,
among others. However, I do not need to filter all the sources, just one
specific file, which contains version and build timestamp information.

As an alternative, one could use Ant via maven-antrun-plugin:

      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <phase>process-sources</phase>
            <configuration>
              <tasks>
                <tstamp>
                  <format property="build-time" pattern="d-MMMM-yyyy HH:mm"/>
                </tstamp>
                <copy file="src/main/java/com/.../Version.java.template" 
toFile="src/main/java/com/.../Version.java" overwrite="true">
                  <filterset>
                    <filter token="version-major" value="${version-major}"/>
                    <filter token="version-minor" value="${version-minor}"/>
                    <filter token="version-revision" 
value="${version-revision}"/>
                    <filter token="version-status" value="${version-status}"/>
                    <filter token="version" value="${project.version}"/>
                    <filter token="Name" value="${project.name}"/>
                    <filter token="website" value="${project.url}"/>
                    <filter token="build-time" value="${build-time}"/>
                  </filterset>
                </copy>
              </tasks>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

A similar thing could be done with a property file put in your project
resources.

Are there others and simpler ways to do this?

Paolo



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to