You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by "Torben S. Giesselmann" <ts...@foogoo.net> on 2009/04/09 15:15:31 UTC

Is it possible to use a build time property for resource filtering?

Hi there,

I am setting a system property "timestamp" in the early stage of my build
by executing a Groovy script. I'd like to use that property later during
resource filtering. Nice idea, but doesn't work, the property is ignored.

My resource file looks like this:

application.timestamp=${timestamp}


Here's how I set the system property:

<build>

	<!-- ENABLE RESOURCE FILTERING -->
	<resources>
		<resource>
			<directory>src/main/resources</directory>
			<filtering>true</filtering>
		</resource>
	</resources>

	<plugins>
      <plugin>
        <groupId>org.codehaus.groovy.maven</groupId>
        <artifactId>gmaven-plugin</artifactId>
        <version>1.0-rc-4</version>
        <executions>
		  <!-- GENERATE TIMESTAMP -->
          <execution>
            <id>generate-timestamp</id>
            <phase>validate</phase>
            <goals>
              <goal>execute</goal>
            </goals>
            <configuration>
              <source>import java.text.SimpleDateFormat;
System.setProperty("timestamp", new
SimpleDateFormat("yyyy-MM-dd HH:mm").format(new
Date()))</source>
            </configuration>
          </execution>

		  <!-- TEST TIMESTAMP -->
          <execution>
            <id>print-timestamp</id>
            <phase>validate</phase>
            <goals>
              <goal>execute</goal>
            </goals>
            <configuration>
              <source>println "Timestamp: " +
System.getProperty("timestamp")</source>
            </configuration>
          </execution>
        </executions>
      </plugin>
	</plugins>
</build>


If you execute this, you'll notice that the property can be read correctly
in the execution "print-timestamp". But still, it gets ignored during
resource filtering.

Am I missing something here? Is it impossible to set new properties at
build time and have those filtered? Thanks in advance!

Best regards,
- Torben


-- 
Torben S. Giesselmann
tsg-swdev@foogoo.net

A clear conscience is usually the sign of a bad memory.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org