What you want to do is called filtering. You can read about it here. As you can see, you will have to change the way you perform certain actions. Variables are defined differently. You will want to rename the file to .java.
But then you have one more problem: it will take the source file and replace the variables with literals, but it will not compile the .java file for you when creating your project. Assuming you want to do this, here's a tutorial on how. I am going to include part of this tutorial in case it disappears once:
An example of the source file:
public static final String DOMAIN = "${pom.groupId}"; public static final String WCB_ID = "${pom.artifactId}";
Filtration:
<project...> ... <build> ... <resources> <resource> <directory>src/main/java</directory> <filtering>true</filtering> <targetPath>../filtered-sources/java</targetPath> </resource> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> </resource> </resources> ... </build> ... </project>
Now change the directory where maven finds the source files to compile:
<project...> ... <build> ... <sourceDirectory>target/filtered-sources/java</sourceDirectory> ... </build> ... </project>
source share