Check if property has been set in phing - phing

How to check if property ${foo} has been set?
Bonus question: how to escape $ sign in <echo> so I could output ${foo} string (not the foo variable substitution)?
PS: tried to google and read documentation, but couldn't find the answers. It's likely I'm missing something

You need to place an isset element inside the if element.
<if>
<isset property="foo" />
The manual is available here.

If you just need to fail the build if a property is defined or not, check out the fail task:
http://www.phing.info/docs/guide/stable/FailTask.html

Related

BIML: FilySystemTask is missing UseDirectoryIfExists attribute for operation Create Directory

I'm trying to create a directory if it does not exists, using BIML. The SSIS File System Task has an operation Create Directory which has an UseDirectoryIfExists attribute, that can be set to true.
I cannot find that attribute for the <FileSystem> in BIML.
How can I set that property to true?
I havent used FileSystem in BIML yet, however i can give it a shot. Though i havent tested it.
You can also read more about the FileSystemTask properties here. As i can see it doesnt directly have an UseDirectoryIfExists property. However you can try what i have written below this.
This here is how a manuel SSIS-package XML looks like when you create a FileSystemTask with UseDirectoryIFExists = true
<DTS:ObjectData> <FileSystemData TaskOperationType="CreateDirectory" TaskOverwriteDestFile="True" /> </DTS:ObjectData>
If UseDirectoryIfExists = false
Then it looks like this
<DTS:ObjectData> <FileSystemData TaskOperationType="CreateDirectory" /> </DTS:ObjectData>
So i think your BIML should look like this:
<Tasks> <FileSystem Operation="CreateDirectory" OverwriteDestination="true"> </FileSystem> </Tasks>

Setting a default list of items in project_attribute in a GNAT GPS Plugin

I'm working on a custom GNAT GPS plugin (for GPS 6.1.2).
My plugin XML creates a project attribute "example_list_of_files".
This is a list of strings, that correspond the names of Ada files in the project.
I want to default the entries in that list to "a.adb","b.adb","c.adb". However I've been unable to find the correct syntax for this. Instead i end up with a single string of all the values.
What i want to see is what happens when you manually add three elements, as shown below:
Here is the code for this example:
GPS.parse_xml('<?xml version="1.0" ?>' + """
<my_plugin>
<project_attribute
name="example_list_of_files"
label="example_list_of_files"
description="A description...."
package="MyPackage"
editor_page="MyPage"
editor_section="Build"
hide_in="wizard library_wizard"
omit_if_default="false"
list="true"
base_name_only="true">
<string type="file" filter="project" default="'a.adb','b.adb','c.adb' " />
</project_attribute>
</my_plugin>""");
Notice the string element with the project attribute default. Instead of a list of entries in the project manager it gives me a single entry, containing the string "'a.adb', 'b.adb', 'c.adb'".
Anyone got any ideas? I've also tried multiple string elements, adding brackets, braces, square-brackets, space separators, prefixing with 'array(' with no luck.
thanks
Matt
It seems indeed this is not supported. The standard plug-in projects.py has several list attributes, but all of them have a single value as the default. I'll check what can be done to improve here.
However, your approach might be wrong in the first place. The default you are setting only concerns the project editor. That means that if a user uses a default project (like project default is end default) and never goes through the project editor, your attribute example_list_of_files will in fact not exist (and have a default empty value). So it seems that this should in fact be handled in your plug-in, when you query the value of the attribute (like via GPS.Project.get_attribute_as_list). If that function returns an empty list, then use ("a.adb", "b.adb", "c.adb") instead. That way, things work fine even with a default, unedited project.
From the GPS User's Guide:
The tag accepts the following attributes:
[...]
list (boolean, default false)
If true, the project attribute contains a list of values, as opposed
to a single value. An example is the list of source directories in
standard projects.
In your example:
<string type="file" filter="project" default="'a.adb','b.adb','c.adb' " />
This is a single string value. Instead, you should specify a list of string values, like this:
<string type="file" filter="project" default="a.adb" />
<string type="file" filter="project" default="b.adb" />
<string type="file" filter="project" default="c.adb" />

Alias in OGNL inside MyBatis

I'm programming with MyBatis and I have this code
<if test="#mypackage.verylongname.utilities.MyBatisUtilities#isNotEmpty(recipient)">
and DOCUMENTS.recipient = #{recipient}
</if>
I'd like to have a way to avoid to use the full pathname of my class MyBatisUtilities. Is it there?
Adding an Alias to the mybatis-config file doesn't work
<typeAlias alias="MyBatisUtilities" type="mypackage.verylongname.utilities.MyBatisUtilities"/>
Don't think there is a way no, not unless mybatis provides some special extended functionality for OGNL.
That doesn't mean it ~couldn't~ be done within OGNL somehow with changes to the core library, just don't believe it does currently. (my memory may be bad, but pretty certain #fullclassname#methodname is the only way OGNL knows of to resolve static method invocations)
"bind" lets you make a variable out of an OGNL expression. For more info see : http://mybatis.github.io/mybatis-3/dynamic-sql.html
<select id="selectBlogsLike" parameterType="Blog" resultType="Blog">
<bind name="pattern" value="'%' + _parameter.getTitle() + '%'" />
SELECT * FROM BLOG
WHERE title LIKE #{pattern}
</select>

Can an unused workflow argument be removed/deleted?

I have a TFS 2010 workflow template that I am currently working on that has multiple variables and arguments which are used for my build process, however, at some point whilst adding an argument, I accidentally clicked on the Create Argument cell in the Arguments table. This has created a new and unwanted argument1 that I cannot seem to remove from my workflow. I have tried deleting the name of the argument but this does not remove the argument, just brings up an error message saying that the argument cannot have an empty name. This is really annoying!
Is anyone aware of how to remove an unwanted argument from a workflow template?
Right click on the Workflow Template in Solution Explorer and select "Open with...". Then select "XML (Text) Editor".
You are then presented with the xaml for this template.
Try removing the argument from here:
<Activity mc:Ignorable="sap" ...snip... >
<x:Members>
<x:Property Name="BuildSettings" Type="InArgument(mtbwa:BuildSettings)" />
...more...
<x:Property Name="argument1" Type="InArgument(x:String)" /> <!--Delete this line-->
</x:Members>
...rest of xaml...
</Activity>
The simplest solution should be to mark the row with the argument and then press delete.

Nant property cannot be overwritten eventhough not marked as readonly

I am using nant 0.85 version. I have defined a property in a file and have not specified like'read only=true". But where ever I try to change the value of the property , I get the warning saying that, property cannot be overwritten.
I have tried setting readonly="false" overwrite="true".But nothing seems to work. Any help would be greatly appreciated .
use unless attribute, it works.
<property name="msbuild.path" value="CONFIGURABLE" unless="${property::exists('msbuild.path')}" />
then as usual nant -D:msbuild.path=...
Need more details, especially if you "change the value of the property" from command line.
One thing that I have seen that causes some confusion is that when the property is overridden from command line ( -D:prop=value ), and if the same property is defined in the file (<property name="prop" value="value"/> ) it will say read only property cannot be overridden because the property set from command line is read only and it cannot be overridden by the property defined in the file.
It is not the other way around, which causes some confusion and people thinking that despite having no readonly set to true etc. still saying cannot be overridden.
So try to see if the property you set is actually using the value you wanted, if you are overriding from command line.
You can totally do this in NAnt 0.85. Let's say for example you have a property with the name "myvalue" that you want to be able to be passed in from the command line. You would first define the property in your NAnt script like this:
<property name="myvalue" value="0" overwrite="false" />
When you call NAnt you just need to use the -D parameter to pass in your new value like this:
nant.exe buildfile:myfile.build -logfile:mylog.log -D:myvalue=16
And your new value of "16" will be recognized in your build script which you can test by simply echoing the value like this:
<echo message="myvalue: ${myvalue}" />
For further information you can read the documentation and look at example "iv":
http://nant.sourceforge.net/release/0.85/help/tasks/property.html