For a project I have a set of old .properties files, some are templates with
${placerholder} values and some are the "real" properties files that have key-value settings.
Depending on the start parameter, the .properties template files have to be filled with the real values.
The placeholder can be written with one or more dot annotations such as ${acount.money.euro} etc.
I cant seem to find a gradle way of filling those properties if:
the value is missing or should just be empty or have the placeholder
the value is written in dot annotation
I can do it in ANT but cant find a way to do it in gradle. Either the value cant be found for the dot annotations or the values are not filled at all or the missing value for the placeholder is making the script crash.
Anyone knows the right way to configurate .properties in gradle style? There are no real tutorials for it.
Did you try to use ant task? or write a custom task or a groovy class? or search on stack overflow? at least google? there are millions of answers on this, its one of the most common questions I think.
What do you mean:
There are no real tutorials for it.
Please check those links, try something show us your effort and then come back if you are stuck.
How can I transform a .properties file during a Gradle build?
Different ways to set properties
Gradle write properties
Groovy Reading a writing to properties file
and on, and on, and on....
Related
I am creating a plugin for Eclipse, which contains tools for creating a custom type of project. These projects have a custom nature and builder. My builder (implements IncrementalProjectBuilder) takes a single input file, and generates a few (usually between 3 and 5) output files. When I run Clean Project, I need to remove the files the builder has previously generated.
Problem 1: The names of the generated files are not known exactly, but I do know the sort of files I expect to find (e.g. I know the extensions, and partial file names).
Problem 2: The user may add their own files to the project, which should not be affected by my build / clean steps.
My initial attempt was naive: remove every file except from the input file. This works, but has obvious problems.
My second attempt was better: I came up with a list of possible file names that may be generated, see if any of them exist and remove them.
By only knowing partial file names and matching them, I may inadvertently delete a user's file. E.g. I know I will generate a file called *_file.py. If the file I generate is called abc_file.py and the user has added their own xyz_file.py, I want to clean (remove) abc_file.py but leave xyz_file.py untouched.
The program which generates the output files from the input is constantly changing, and I don't want to rely on a concrete list of files that would need constant maintenance.
So, my question comes down to this. What methods exist for identifying the files generated by my custom builder, so I can remove them during a clean?
I've spent a couple of days Googling this one with not much to show for it. I am vaguely aware of a file system watcher in Java (Java7 WatchService?), but I don't know if that's the best solution to this problem.
Any information, advice or ideas appreciated.
One brute force approach would be to compare the project before and after the other program is invoked to get the list of files that were created/generated. Of course, it would be ideal if that program could somehow tell you which files it created. Once you have that list, you could iterate over those files as IFile's as use the setDerived() method to mark them as not being source files. When it comes time to clean the directory, you could use the derived setting to decide which files can be deleted.
I have been coding for about a month and I have found ways to adapt around ever problem but one. The problem as you can probably see by the title is how to make a way to make game saves. I am currently creating a very simple game that has about 5 classes of my code and maybe 2 of Java Swing GUI.
I know how I would like to go about the saving process but I have no idea how to do it in my code. How I would like to go about doing this is by making the code print a Number or Integer to a file to represent a Level. For example if you completed level 1 the number in the file would be 1. I have tried some templates for this but none of them work.
I understand how to write to a file but my problem is reading it from a jar or even creating a file then reading it from a place on the computer. I need to know how to find a file URL for different computers because some use Docs and Settings and other Users. Please could someone help.
Since the jar is read only, it can only contain the 'default settings'. See this answer for the general strategy to deal with such a embedded-resource.
Speaking of which (embedded resources) see the info. page for more details on how to access them.
Here is an example of storing and reading a Properties file from the 'current directory'.
As mentioned by #MadProgrammer though, it is safest to put the settings file into a (sub-directory) of user.home, as seen in this answer.
But a properties file is just one option. You might also serialize an object, or write the file in a custom format that your app. knows how to read, for the first two off the top of my head.
Besides 'serialize (in some form) in a File', there is also the Preferences API, or for desktop applications launched using Java Web Start, the PersistenceService. Here is a demo. of the service.
I need to know how to find a file url for different computers because
some use Docs and Settings and other Users
The System property user.home points to the user's home directory
File userHome = new File(System.getProperty("user.home"));
I am attempting to add .properties files to Pootle and am trying to get it to recognize the English properties file as the template file. For some reason Pootle is failing to do this and I am not sure why. I can successfully add all of my properties files in whatever languages I want to Pootle, but then when I try to start translating Pootle fails to match the keys and show the English template strings in the translation interface. Just wondering if anyone else has come across this or has any ideas.
Thanks!
I actually figured this out on my own already. In case anyone else comes across this and still needs an answer, you simply have to change Project Tree Style to "GNU style: files named by language code" under the Administration/Projects tabs.
I want to use the Clear Parser for extract semantic role label of the input sentence. I downloaded the jar file here but I don't know how to use this jar file.
I search on the web but there isn't good guideline for using it.
Please help me to solve this problem (My project is in eclipse on windows).
Mind that Clearparser is now ClearNLP. For an idea how to use the ClearNLP API, check out the DemoNLPDecoder linked from their project page. In fact, that's a small runnable application to which you pass all the models as command line arguments, along with an input and a output file.
I'm making a program that needs to be able to let Clients change a setting, and using what I'm calling a "Builder", create a .jar that replaces some constants in a class with their settings.
In other words, I have a GUI that has a few textfields so that when they press the JButton labeled Build, it creates a new Runnable Jar that in a Constants class whose settings are changed with what was in the textfields.
Is this possible? I've heard about ANT Scripts, but I'm not really sure if that's what I'm looking for here.
Thanks
have you considered using a .properties files or something similar instead? You can use ant scripts for what you are describing (check out http://ant.apache.org/manual/Tasks/replaceregexp.html, you could use this task in your build.xml to dynamically change the .java files but it seems a little kludgy) but it might not be the best solution.
Check this page: http://www.mkyong.com/java/java-properties-file-examples/ which has some detail about saving to/loading from a properties file. You could set up your constants class to load it's state variables from this file, and set up the Build JButton to create that properties file.
I'm trying to think of a use case where you would want to modify the class source itself rather than use a properties file, but to be honest I can't. So I suppose you may have some special circumstance where this is not a tenable solution for you, but 99% of the time this is how I would suggest you go about it.