Nant property cannot be overwritten eventhough not marked as readonly - nant

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

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>

In Struts2 named variable not getting cleared when redirected to another action

I am having a weird problem when redirecting to an action from another action. In short the named variable captured in the first action (from which I am redirecting) is still preserved somehow in the value stack and it is overwriting the same named variable in the second action. I will explain via some code.
<action name="r/{seoURL}" class="ReportsAction"
method="displayReport">
...
<result name="REDIRECT_TO_NEXT_ACTION" type="redirectAction">
<param name="actionName">s/${seoURLForRedirect}</param>
<param name="namespace">/reports</param>
</result>
...
</action>
I am setting the variable ${seoURLForRedirect} in ReportsAction before returning.
I have the following mapping for the second action.
<action name="s/{seoURL}" class="ReportSeriesAction"
method="displayReportSeries">
...
</action>
As you can see I have same named variable in my second action seoURL. This value is set to the value as found in the first action. I fail to understand why is the value stack still maintaining seoURL value set in the first action. Especially since I am over writing it in my redirect result params.
Any help appreciated.
Based on your class action attribute, I'm assuming you're using the Spring plugin.
Actions must be declared as scope="prototype"/non-singleton to be instantiated per-request.
If they're not, you're using a singleton, and properties will be maintained across requests.
I've never tried to set a redirectAction's actionName to a wildcard that points to another wildcarded action, so I'm not sure about the second part of the question.

How to use org.jboss.varia.property.SystemPropertiesService and org.jboss.util.property.PropertyListener

All
I have seen the jboss-service.xml which use an extended SystemPropertiesService class to reference to custom property file. But I didn't totally understood this kind of usage yet.
Could someone please give me some help to understand how to use these two class? thanks.
The SystemPropertiesService is very useful to define properties that then can be accessed from your application, it's usually used to parametrize the application without having to change to code, or even the application package (provided you place the jboss-service.xml outside de war / ear / jar structure). For example, you can create a myapp-service.xml file with the following content:
<server>
<mbean code="org.jboss.varia.property.SystemPropertiesService" name="jboss:type=Service,name=MyAppProperties">
<!-- Define the properties directly in the service.xml file-->
<attribute name="Properties">
myapp.property1=property1Value
myapp.property2=property2Value
</attribute>
<!-- You can also specify a route to another file where you define properties-->
<attribute name="URLList">
/home/myuser/txtlist.properties
</attribute>
</mbean>
</server>
Then you can deploy this file directly in JBoss, the properties defined will be visible to all the applications deployed in the same JBoss and you'll be able to access them with the static method:
String System.getProperty(String propertyName)
So if you want to access to the value of myapp.property1 from your application you'd do:
String property = System.getProperty("myapp.property");
On the other hand the PropertyListener is really an interface that defines a listener that will be triggered when any event occurs with a property. The org.jboss.util.property.PropertyAdapter is an abstract implementation of this interface. To use it you've to implement its three methods (propertyAdded, propertyChanged, propertyRemoved), that will be called by the container when a property is added, changed or removed respectively. Those methods have a PropertyEvent object as parameter, which let you know the property affected.
This interface/class is useful when you want your application to do something every time a property changes (a bad implementation would be that you check every certain time for a property change), this way, when JBoss detects that a property has changed its value, it will call the respective method (that you should implement with the behaviour you want).
For example, if you want to print the new property value everytime it's changed you could implement the propertyChanged method this way:
void propertyChanged (PropertyEvent pe){
// check the property that has changed
if (pe.getPropertyName().equals("myapp.property1")){
System.out.println("The value of " + pe.getPropertyName() + " has changed to " + pe.getPropertyValue());
}
}
Look for more information in the API, and for PropertyAdapter and PropertyEvent.
In JBOSS 5.1 it only works when you put the properties or URL in properties-service.xml and this file should go under jboss.home/server/default/deploy directory.

Check if property has been set in 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

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.