In my cspex I have action that creates product
<public name="create.product" actor="ant">
<actorProperties>
<property key="buildFile" value="build/product.ant" />
<property key="targets" value="create.product" />
</actorProperties>
<properties>
<property key="profile" value="iitProfile" />
<property key="iu" value="iit.product" />
</properties>
<prerequisites alias="repository">
<attribute name="site.p2" />
</prerequisites>
<products alias="destination" base="${buckminster.output}">
<path path="product.${target.ws}.${target.os}.${target.arch}/" />
</products>
</public>
When the final product is being build, folder created looks like this product.${target.ws}.${target.os}.${target.arch}. How can I append qualifier replacement that I set via qualifier.replacement property? I thought I could do something like product.${target.ws}.${target.os}.${target.arch}_{qualifier.replacement} where qualifier.replacement is the property that was set during execution of buckminster.versionQualifier.
I know when I execute action site.p2.zip qualifier replacement is being appended to the name of the file, so how can I use this in my other actions? Do I have execute buckminster.versionQualifier task myself?
thanks!
Opened enhancement about this on eclipse bugzilla: https://bugs.eclipse.org/bugs/show_bug.cgi?id=321753
Related
At the moment I'm calling findstr and storing the output in a property to check afterwards - I'm sure there must be a better solution.
<exec program="findstr.exe"
workingdir="${workspaceDir}"
commandline='/i /c:"someText" ${fileName}'
failonerror="false"
output="${coverageExcludeLog}"
resultproperty="foundFile"
/>
Is this really the best way of doing this?
<loadfile file="${fileName}" property="MyFileContents" />
<property name="Mystring" value="someText" />
<property name="search.file" value="${string::contains(MyFileContents, Mystring)}" />
<if test="${bool::parse(search.file)}" > <!-- true or false-->
<echo message="Found the string ${Mystring} in the file ${fileName}" />
</if>
I am using spring-2.5 (cannot upgrade, product dependency) and I notice a strange behaviour of the Eclipse formatter when I am using the p-namespace notation and some value expression:
If I use the standard way (without p-namespace) like this:
<bean id="ldapConfig" class="org.mycompany.project.config.LDAPConfig">
<property name="ldapServer" value="${ldap.server}" />
<property name="ldapPort" value="${ldap.port}" />
<property name="ldapBindDn" value="${ldap.bindDn}" />
<property name="ldapPass" value="${ldap.password}" />
</bean>
and press the key combination: Ctrl-Shift-F the formatting (e.g indentation) works very well.
Now if I use the p-namespace notation like this:
<bean id="ldapConfig" class="org.mycompany.project.config.LDAPConfig">
<p:ldapServer="${ldap.server}" />
<p:ldapPort="${ldap.port}" />
<p:ldapBindDn="${ldap.bindDn}" />
<p:ldapPass="${ldap.password}"/>
</bean>
When I press the key combination: Ctrl-Shift-F the formatting (e.g indentation)
removed some part of the code
<bean id="ldapConfig" class="org.mycompany.project.config.LDAPConfig">
<p:ldapServer = ldap.server } />
<p:ldapPort = ldap.port } />
<p:ldapBindDn = ldap.bindDn } />
<p:ldapPass = ldap.password } />
</bean>
Is there any incompatibility between the value expressions ( ${variable} ) and the p-namespace, or it is just an Eclipse bug on the XML formatting part?
Bean definition of ldapConfig when using p-namespace is not correct. By using the p-namespace you can use attributes as part of the bean element that describe your property values, instead of using nested elements. More details can be found here.
Assuming you have declared namespace as xmlns:p="http://www.springframework.org/schema/p"
The correct way to use it is:
<bean id="ldapConfig" class="org.mycompany.project.config.LDAPConfig"
p:ldapServer="${ldap.server}"
p:ldapPort="${ldap.port}"
p:ldapBindDn="${ldap.bindDn}"
p:ldapPass="${ldap.password}">
</bean>
Now try CTRL-SHIFT-F
Here is my Script:
<?xml version="1.0"?>
<project name="createAndPopulateDB" default="deploy">
<property name="sql.connstring" value="Provider=SQLOLEDB;Server=G-PC\sqlexpress;Integrated Security=SSPI" />
<property name="createDB" value="BuildTestDatabase.sql" />
<property name="populateDB" value="CreateTables.sql"/>
<target name="deploy">
<echo message="* Connecting to ${sql.connstring}"/>
<foreach item="File" property="sql.script">
<in>
<items>
<include name="${createDB}" />
<include name="${populateDB}" />
</items>
</in>
<do>
<echo message="* Executing ${path::get-file-name(sql.script)}"/>
<sql connstring="${sql.connstring}" delimiter="go" delimstyle="Line" batch="false" source="${sql.script}"/>
</do>
</foreach>
</target>
</project>
The NAnt script is supposed to call two tsql programs. The first tsql is designed to drop a database if it is present, and if it isn't, create it. The second checks to see if a table is present, and if so, delete it. Similarly if it isn't, it populates the created database with a simple table.
My question is why does it run the populateDB script first?
I found that the best way to determine the order in which the tsql programs are run is through a depends attribute attached to separate targets. This will run them in a predetermined order and is extremely easy to follow logically if the NAnt script is a part of a repository.
As part of a CI process I am trying to create a buildlabel which consists of the content of an xml element within an xml structure. For this purpose I am using nant and xmlpeek. My problem is that I get an odd error stating:
"Nodeindex '0' is out of range"
This is only the case if the xml file I am xmlpeeking contains a namespace definition in the root node.
Removing the namespace from the xml file gives me the output I expect.
The nant target that generates the error can be boild down to:
<target name="TDSLabel">
<property name="element" value=""/>
<echo message="Getting element" />
<xmlpeek file="C:\xxx\test1.xml" xpath="//Project/PropertyGroup/ProductVersion" property="element"/>
<echo message="The found element value was: ${element}" />
</target>
and the test1.xml file looks like this:
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProductVersion>9.0.21022</ProductVersion>
</PropertyGroup>
</Project>
You already gave the right hint yourself. It's about the namespace. This should fix it:
<target name="TDSLabel">
<property name="element" value=""/>
<echo message="Getting element" />
<xmlpeek
file="C:\xxx\test1.xml"
xpath="//x:Project/x:PropertyGroup/x:ProductVersion"
property="element"
verbose="true">
<namespaces>
<namespace prefix="x" uri="http://schemas.microsoft.com/developer/msbuild/2003" />
</namespaces>
</xmlpeek>
<echo message="The found element value was: ${element}" />
</target>
Found a similar problem and the anwser to my problem here: XmlPoke and unique nodes. The problem was that I did not include the namespace definition within the xmlpeek element and afterwards omitted the necessary reference to the namespace in my xpath statement:
<xmlpeek file="C:\xxx\test1.xml" xpath="//x:Project/x:PropertyGroup/x:ProductVersion" property="element">
<namespaces>
<namespace prefix="x" uri="http://schemas.microsoft.com/developer/msbuild/2003" />
</namespaces>
</xmlpeek>
Summary:
How do I expand a property with value "download\${bulidmode}\project\setup.msi" to "download\Debug\project\setup.msi" if the property buildmode contained debug so I can use it as the file="" part of < copy >
Detail:
I have a bit of a requirement to be able to expand properties within a string in nant.
For example I have a target that is copying file A to B. A and B both come from a simple two field CSV file which I'm iterating through using
<foreach item="Line" in="filelist.csv" delim="," property="source.file,target.file">
<property name="sourcefile" value="${path::combine(source.dir,source)}" />
<property name="targetfile" value="${path::combine(download.dir,destination)}" />
<echo message="Copy ${sourcefile} to ${targetfile}" />
<copy file="${sourcefile" tofile="${destination}" />
</foreach>
and the filelist.csv will be
build\manifest.xml
solutiondirectory\setup-proj-directory\Release\setupproj.msi,ProductA\ProductA.msi
solutiondirectory\another-proj-dir\Release\setupproj.msi,ProductB\ProductB.msi
(The reason we split these out is that we write multi-tiered applications and deploy by MSI to each tier - so one product has multiple msi's all built with the same version numbers)
Anyway - I want to change this to that I no longer have "Release" in the filelist.csv file but something like ${build.mode}. I would wrap the above code with a
<foreach item="String" in="Release,Debug" delim="," property="build.mode">
....as above
</foreach>
and the property embedded within the string in the file gets expanded.
I've been beating my head against a brick wall for a few hours, but just can't figure it out.
Thanks
It is possible with a custom function :
<?xml version="1.0"?>
<project>
<script language="C#" prefix="vbfox" >
<code>
<![CDATA[
[Function("expand")]
public string ExpandString(string str)
{
return Project.Properties.ExpandProperties(str, Location.UnknownLocation);
}
]]>
</code>
</script>
<property name="hello" value="{path::combine('_hello_', '_world_')}" />
<property name="hello" value="${'$' + hello}" />
<echo message="${hello}" />
<echo message="${vbfox::expand(hello)}" />
</project>