Properties File Variable Concatenation - properties

I have a properties file where I'd like to define a file path as a variable and then reference it. This is causing a file not found exception:
test.folder=C:/code/
file={test.folder}File.csv
But this works:
file=C:/code/File.csv
What am I doing wrong?

This should works:
test.folder=C:/code/
file=${test.folder}File.csv

In properties file i didn't think that you can concatenate the variable but you can do something like the following:
config.properties
test.folder=C:/code/
file=File.csv
Then in your java code concatenate two variable:
filePath = folder + file;
and if you are using spring xml file you can use:
<property name="filePath" value=${test.folder}${file} />

Related

String variables in GAMS

How can I define a string variable in GAMS. I want to use it as a reference to including files as shown below
set file = "myfile.inc"; (i have no idea how to do this part)
$include file;
istead of
$include "myfile.inc"
$set file file_name_here
$include %file%.inc
File is being replaced by your desired filename.
Note that if you want to use this string variable in other included files too you have to use $setglobal instead of $set

WebStorm's Safe Delete doesn't check XML file

I'm deleting a CSS file that is referenced in an XML file. I select "Safe delete (with usage search)" and "Search in comments and strings" but the reference in the XML file is not found.
The XML file is in a directory included in the project. The XML file contains the complete file name in a string.
Are there some settings for Safe Delete somewhere or something more general that might exclude XML files?
Thanks for any help.
<resourceSet name="HeaderStylesCss" type="css">
<resource path="~/Legacy/Content/Css/HeaderStyles.css"/>
</resourceSet>
path value is treated as simple string, so CSS file usage is not found and thus not taken into account when deleting a file.
You can try injecting File reference language in path="" value manually via Alt+Enter, Inject language or reference:
but paths starting with ~ won't work there, I'd suggest using relative paths rather than absolute

Command-line properties file reference overriding mule-app.xml

I have placed variables in a few .properties files and have successfully created a mule.env variable in mule's mule-app.properties file to reference which of those files to use. I am trying to allow a command-line argument override the mule.env variable so that a specified properties file can be used. I also like having the mule.env variable exist in mule-app.properties file as a default value in case nothing is set via the command-line. But it seems that the existing mule-app.properties file overrides the command-line argument.
The mule-app.parameters file contains a variable like this:
mule.env=dev
While a command-line argument looks like this:
-Dmule.env=prod
A property placeholder looks for the properties file like so:
<context:property-placeholder location="classpath:${mule.env}.properties" />
The result that I prefer is that the property placeholder finds the prod.properties file rather than the dev.properties file when the mule app starts with the command line argument; however, it still uses the dev.properties file.
If I remove the variable from the mule-app.properties file, the command-line argument works fine.
I prefer that the command-line overrides the what is in the mule-app.properties file. Is that possible? What have I done incorrectly?
For this purpose You have to set the property in the Mule wrapper.conf:
Navigate to [Mule standalone]/conf folder.
Open wrapper.conf in a any text editor.
Add the following script under # GC settings: wrapper.java.additional.15=-­Denv=prod
Notes: make sure the number is correct. In this example the last number in that file is: wrapper.java.additional.14

msbuild -p:outputdir=c:\mydir being ignored

I'm running msbuild from the command line with the following:
msbuild mysolution.sln -p:outputdir=c:\mydir
When I run this, the outputdir is being ignored and the default specified in the csproj file is being used.
The MSDN doc for this tool says that I should be able to override the build directory using this parameter. What am I doing wrong?
You should use OutputPath and more important you should use the right syntax :
msbuild mysolution.sln /p:OutputPath=c:\mydir
Note that OutputPath is preferred over OutDir. The documentation used to be wrong about this, but I see that they've finally fixed it.
Beyond that, it's difficult to say exactly what the problem is, since you didn't show the exact path that you're passing as a parameter. There are two possible problems that I can imagine:
The OutputPath option specifies the path to the output directory relative to the project directory. That means you can't set it to a global path like C:\mydir. I assume it is unable to find the path you specified, and so it defaults to the one specified in your project file.
If the path that you're actually specifying as a parameter contains spaces, the command is likely to fail. I believe you need to wrap the path in quotes and append an extra backslash to the end of the path string.
I believe you should be using OutputPath.

MSBuild: ReadLinesFromFile query

I am using ReadLinesFromFile for reading multiple lines from a txt file and appending it to the path in sql.execute. The problem is its reading all the lines and appending them at once:
Text File Contents:
a.sql
b.sql
Sql.Execute ServerName="$(ServerName)" DatabaseName="CDRCntroller" path="..\DB\CDRController\BROKER\#(Prop1).
MSBuild is taking the path as : .....\BROKER\a.sql;b.sql
Any way I can use Prop1 as an array and refer the contents in the file one by one?
I tried using StringToItemList also but no luck :(
Thanks.
You should try this
Sql.Execute ServerName="$(ServerName)" DatabaseName="CDRCntroller" path="..\DB\CDRController\BROKER\%(Prop1.Identity)
The % tells Msbuild to repeat the task for each item. Identity is a Metadata containing the item itself.
Hope it helps !
Use metadata notation instead. Like this :
Sql.Execute ServerName="$(ServerName)" DatabaseName="CDRCntroller" path="..\DB\CDRController\BROKER\%(Prop1.Identity)