Create property file using ant


















This is the file that will be included in the JAR output of your project. Using appinfo. You can either roll-your-own, or use a pre-existing library I created. Roll-Your-Own Rolling your own is not to bad. Simply open the appinfo. Accessing the values can be done using the props. Using Pre-Existing Library To save me time, I created a simple library that will get more tools added over time that has much of this already setup.

If you are interested, see stoken -utils. There is a class within the project all AppInfo that you can hand props from above. It has some simple static accessors you can use for getting the key values you need. As per as we have define targets in the above file have dependencies such as a makejar target may have a dependency on the compile target and compile target may have dependency on the init target and init target may have dependency on the clean target.

To run the ant build file, open up command prompt and navigate to the folder where the build. Dinesh Rajput is the chief editor of a website Dineshonjava, a technical blog dedicated to the Spring and Java technologies. It has a series of articles related to Java technologies.

Dinesh has been a Spring enthusiast since and is a Pivotal Certified Spring Professional, an author of a book Spring 5 Design Pattern, and a blogger. I confirmed the parent folder where the property files needs to be created exists. I created a build file with your snippet and couldn't see an issue. If the directory specified by the path property doesn't exist an exception is thrown but this seems like the correct behaviour.

I suggest you add some tests to confirm the actual value of the path property. Maybe it doesn't hold the value you expect. EDIT: Sorry didn't read the section mentioning that the parent folder exists. For me the given snippet works in Eclipse. What does your path variable contains and which environment you use exactly?

All folders specified by your path variable must exist before Ant can create the property file, even before any target is executed. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? The slashes conform to the expectations of the Properties class.

The file will be stored in a manner so that each character is examined and escaped if necessary. The layout and comment of the original file is preserved. New properties are added at the end of the file. Existing properties are overwritten in place.



0コメント

  • 1000 / 1000