for example, I had a Version.java
public class Version {
private static String VERSION = "${buildNumber}";
public static String getVersion() {
return VERSION;
}
}
I need to set version number when compile, so I use filter to change the
version information in java file.
Rex
On Jan 22, 2008 4:43 PM, <[EMAIL PROTECTED]> wrote:
> This is not going to work. There is a difference between sources and
> resources. And filtering is also not what you want.
>
> Resources are copied to target/classes and never compiled. Filtering is
> used to replace ${variable} kind of things.
>
> This is not easy to accomplish. Maybe you could first answer a question:
> why are you trying to accomplish this?
>
> Hth,
>
> Nick Stolwijk
>
>
> -----Original Message-----
> From: Rex Huang [mailto:[EMAIL PROTECTED]
> Sent: Tue 1/22/2008 4:21 PM
> To: [email protected]
> Subject: how to replace a java file
>
> I want to use filter to generate a src/main/resources/filter/hello.java
> to replace the old one in src/main/java/com/my-company/hello.java
> <resource> in pom.xml
> <resource>
> <directory>src/main/resources/filter/</directory>
> <filtering>true</filtering>
> <includes>
> <include>hello.java</include>
> </includes>
> <targetPath>com/my-company/</targetPath>
> </resource>
>
> the result is:
> hello.class is compiled using the old hello.java,
> the new hello.java source file is in the jar file
>
> does anyone knows how to do it?
>
> BR//Rex
>
>