I want to be able to replace specific pattern in .java files on build time. In fact, I just want to replace certain String value to represent build time. (And I also want to leave original source file intact). Is there a way to do it easily (apart from manual way)?
I’m using NetBeans as my IDE.
I want to be able to replace specific pattern in .java files on build
Share
We needed something similar for our product (embed build time, build computer & user name into the compiled application).
We used ant’s
manifesttask to embed a manifest into the jar which contains the information we needed. See http://ant.apache.org/manual/Tasks/manifest.html .The manifest can easily be read from the JAR using tools. If you need the information in your software, you can read it programatically, or put it into a .properties files (generated at build) which you can read from the program.