I am trying to add a CSS file to my Docbook HTML output. Most examples say:
xsltproc --stringparam html.stylesheet corpstyle.css chunk.xsl myfile.xml
Ours is a Saxon based toolkit... So accordingly, I changed the build file to:
<java jar="${DocBook}/saxon/saxon.jar" fork="true" dir="${gen.dir}/html-multi">
<arg line="com.icl.saxon.StyleSheet"/>
<arg line="${basedir}/book.xml "/>
<arg line="${DocBook}/html/chunk.xsl "/>
<arg line="html.stylesheet=mycss.css"/>
</java>
When running ant, this results in:
Bad param=value on the command line.
How do I set this up?
That seems more like an Ant problem, try
<java jar="${DocBook}/saxon/saxon.jar" fork="true" dir="${gen.dir}/html-multi">
<arg line="${basedir}/book.xml "/>
<arg line="${DocBook}/html/chunk.xsl "/>
<arg line="html.stylesheet=mycss.css"/>
</java>
as it seems the main class is taken from the jar argument.
Related
I've got an ant build script which I should modify. Specifically I should make a subversion checkout conditional: currently only the trunk gets checked out, the new version should checkout a given branch if needed.
<target name="do-svn-checkout" depends="init"
<property name="branch" value=""/>
<exec executable="svn">
<arg value="checkout"/>
<arg value="-r"/>
<arg value="HEAD"/>
<arg value="http://t01/java/trunk"/>
<arg value="zzz"/>
<arg value="--password"/>
<arg value="xxx"/>
<arg value="--username"/>
<arg value="yyy"/>
</exec>
</target>
The property branch will be set via the command line like for instance -Dbranch=mybranch.
If the property branch is empty, the trunk should be checked out, but if the property has any other value, the respective branch should be checked out, like http://t01/svn/hlfg/HLFG/java/branch/the-value-of-the-property. So depending on the property the respective arg-value of the svn call should be modified.
Is it possible to solve this with basic Ant or would I need to use an inline script?
When using Ant >= 1.9.3 it's a piece of cake with the new if/unless feature introduced with Ant 1.9.1
(but you should at least use Ant 1.9.3 because of bugs in Ant 1.9.1, see this answer for details)
Don't forget the namespaces to activate that feature, f.e. :
<project
xmlns:if="ant:if"
xmlns:unless="ant:unless"
>
<property name="foobar" value=" "/>
<echo if:blank="${foobar}">foobar blank !</echo>
<echo unless:blank="${foobar}">foobar not blank !</echo>
</project>
in your case something like :
<target name="do-svn-checkout" depends="init"
<property name="branch" value=""/>
<exec executable="svn">
<arg value="checkout"/>
<arg value="-r"/>
<arg value="HEAD"/>
<arg value="http://t01/java/trunk" if:blank="${branch}">
<arg value=".." unless:blank="${branch}">
<arg value="zzz"/>
<arg value="--password"/>
<arg value="xxx"/>
<arg value="--username"/>
<arg value="yyy"/>
</exec>
</target>
You could define a wrapper target which depends on two other targets - one of which does trunk checkout, the other of which does branch checkout - and each of which is conditional on existence of your optional branch property.
You could further abstract the exec call into a macrodef to which you pass the trunk or branch url.
For example:
<project name="test" default="do-svn-checkout">
<target name="do-svn-checkout" depends="do-svn-trunk-checkout, do-svn-branch-checkout"/>
<target name="do-svn-trunk-checkout" unless="branch">
<svn-checkout svn-url="http://t01/svn/java/trunk"/>
</target>
<target name="do-svn-branch-checkout" if="branch">
<svn-checkout svn-url="http://t01/svn/hlfg/HLFG/java/branch/${branch}"/>
</target>
<macrodef name="svn-checkout">
<attribute name="svn-url"/>
<sequential>
<echo message="svn-url=#{svn-url}"/>
</sequential>
</macrodef>
</project>
Output with no branch property defined:
do-svn-trunk-checkout:
[echo] svn-url=http://t01/svn/java/trunk
do-svn-branch-checkout:
do-svn-checkout:
Output with branch property defined:
do-svn-trunk-checkout:
do-svn-branch-checkout:
[echo] svn-url=http://t01/svn/hlfg/HLFG/java/branch/mybranch
do-svn-checkout:
I have configured a freestyle Jenkins job to perform build, run some tests, perform code analysis and upload artifacts to Nexus. I will need to create more of such jobs in future and so I want to create a template so that its easy for anyone else to create those jobs in future. Is there a way to convert the freestyle job into template?
You can create generic mechanisms using Ant(In my case NAnt), and use them using a set of imported variables.
My config for web app looks like:
<?xml version="1.0" encoding="utf-8"?>
<webapps>
<add basedir="deploys\JobLocation" deploydir="C:\CIReference\Sites" appname="JobLocation" appid="5" appuri="http/*:8081" apppool.runtineversion="v4.0" />
</webapps>
The add tag has the basic configuration of the webapp
And the generic mechanism to deploy web application is like this
<?xml version="1.0" encoding="utf-8"?>
<project name="webdeploy" xmlns="http://nant.sf.net/release/0.92/nant.xsd">
<include buildfile="baseconfigs.xml" />
<include buildfile="external_tools.xml" />
<call target="baseConfigs" />
<property name="current.environment.path" value="${path::combine(nant.environmentsdir,environment)}"/>
<foreachxml file="${path::combine(current.environment.path,'webapps.xml')}" xpath="/webapps/add" property="basedir,deploydir,appname,appid,appuri,apppool.runtineversion">
<exec program="${appcmd.path}" failonerror="false">
<arg value="delete" />
<arg value="site" />
<arg value="/site.name: ${appname}" />
</exec>
<exec program="${appcmd.path}" failonerror="false">
<arg value="delete" />
<arg value="apppool" />
<arg value="/apppool.name: ${appname}" />
</exec>
<echo message="Deleting directory: ${path::combine(deploydir, appname)}" />
<delete dir="${path::combine(deploydir, appname)}" failonerror="false" />
<echo message="Coping directory to: ${path::combine(deploydir, appname)}" />
<copy todir="${path::combine(deploydir, appname)}" includeemptydirs="true" overwrite="true" verbose="true">
<fileset basedir="${path::combine(directory::get-current-directory(), basedir)}">
<include name="**\*.*" />
</fileset>
</copy>
<exec program="${appcmd.path}">
<arg value="add" />
<arg value="apppool" />
<arg value="/name: ${appname}" />
</exec>
<exec program="${appcmd.path}">
<arg value="set" />
<arg value="apppool" />
<arg value="/name: ${appname}" />
<arg value="/managedRuntimeVersion:${apppool.runtineversion}" />
</exec>
<exec program="${appcmd.path}">
<arg value="add" />
<arg value="site" />
<arg value="/name: ${appname}" />
<arg value="/id: ${appid}" />
<arg value="/bindings: ${appuri}" />
<arg value="/physicalPath: ${path::combine(deploydir, appname)}" />
</exec>
<exec program="${appcmd.path}" failonerror="false">
<arg value="set" />
<arg value="site" />
<arg value="${appname}" />
<arg value="/applicationPool:${appname}" />
</exec>
</foreachxml>
</project>
You can use this tool to create whatever mechanism do you need for your CI solution.
Order files...
baseconfigs.xml
<?xml version="1.0" encoding="utf-8"?>
<project>
<property name="nant.dir" value="" />
<property name="nant.environmentsdir" value="" />
<target name="baseConfigs">
<cd dir="..\..\" />
<property name="nant.dir" value="${path::combine(directory::get-current-directory(),'jenkins\NAnt')}" />
<property name="nant.environmentsdir" value="${path::combine(nant.dir,'environments')}" />
</target>
</project>
external_tools.xml
<?xml version="1.0" encoding="utf-8"?>
<project>
<property name="appcmd.path" value="c:\windows\System32\InetSrv\appcmd.exe" />
<property name="java_path" value="C:\Program Files (x86)\Jenkins\jre\bin"/>
<property name="liquibase_exe_path" value="C:\Program Files (x86)\Jenkins\tools\liquibase\"/>
<loadtasks assembly="C:\Program Files (x86)\Jenkins\tools\nant\nantcontrib\NAnt.Contrib.Tasks.dll" />
<loadtasks assembly="C:\Program Files (x86)\Jenkins\tools\nant\NAnt.GF.Custom.Tasks.dll" />
</project>
I am pretty new in WSO2 ESB and I have the following problem trying to retrieve the value of a property and put into an XML document that I am generating.
So, I have the following situation, in my ESB flow I have defined this property named TRANSACTION and having register as value:
<property name="TRANSACTION" scope="default" type="STRING" value="register"/>
Then in my flow I am generating an XML document (it works fine), using a payloadFactory mediator, in this way:
<payloadFactory media-type="xml">
<format>
<register password="$14" username="$13" xmlns="http://ws.wso2.org/dataservice">
<location>
<wiews>$1</wiews>
<pid>$2</pid>
<name>$3</name>
<address>$4</address>
<country>$5</country>
<lat>$6</lat>
<lon>$7</lon>
</location>
<sampledoi>$8</sampledoi>
<sampleid>$9</sampleid>
<date>$10</date>
<method>$11</method>
<genus>$12</genus>
</register>
</format>
<args>
<arg evaluator="xml" expression="$ctx:sampleData//ds:Sample/ds:hold_wiews/text()" xmlns:ds="http://ws.wso2.org/dataservice"/>
<arg evaluator="xml" expression="$ctx:sampleData//ds:Sample/ds:hold_pid/text()" xmlns:ds="http://ws.wso2.org/dataservice"/>
<arg evaluator="xml" expression="$ctx:sampleData//ds:Sample/ds:hold_name/text()" xmlns:ds="http://ws.wso2.org/dataservice"/>
<arg evaluator="xml" expression="$ctx:sampleData//ds:Sample/ds:hold_address/text()" xmlns:ds="http://ws.wso2.org/dataservice"/>
<arg evaluator="xml" expression="$ctx:sampleData//ds:Sample/ds:hold_country/text()" xmlns:ds="http://ws.wso2.org/dataservice"/>
<arg evaluator="xml" expression="$ctx:sampleData//ds:Sample/ds:hold_lat/text()" xmlns:ds="http://ws.wso2.org/dataservice"/>
<arg evaluator="xml" expression="$ctx:sampleData//ds:Sample/ds:hold_lon/text()" xmlns:ds="http://ws.wso2.org/dataservice"/>
<arg evaluator="xml" expression="$ctx:sampleData//ds:Sample/ds:sample_doi/text()" xmlns:ds="http://ws.wso2.org/dataservice"/>
<arg evaluator="xml" expression="$ctx:sampleData//ds:Sample/ds:sample_id/text()" xmlns:ds="http://ws.wso2.org/dataservice"/>
<arg evaluator="xml" expression="$ctx:sampleData//ds:Sample/ds:date/text()" xmlns:ds="http://ws.wso2.org/dataservice"/>
<arg evaluator="xml" expression="$ctx:sampleData//ds:Sample/ds:method/text()" xmlns:ds="http://ws.wso2.org/dataservice"/>
<arg evaluator="xml" expression="$ctx:sampleData//ds:Sample/ds:genus/text()" xmlns:ds="http://ws.wso2.org/dataservice"/>
<arg evaluator="xml" expression="$ctx:sampleData//ds:Sample/ds:username/text()" xmlns:ds="http://ws.wso2.org/dataservice"/>
<arg evaluator="xml" expression="$ctx:sampleData//ds:Sample/ds:password/text()" xmlns:ds="http://ws.wso2.org/dataservice"/>
</args>
</payloadFactory>
That genetes an XML document like this:
<?xml version="1.0" encoding="UTF-8" ?>
<register username="myUserName" password="myPswd">
<sampleid>CGN00001</sampleid>
<genus>Hordeum2</genus>
...................................
...................................
...................................
I want use the value of my TRANSACTION property to create the name of the first tag of my XML document, in this:
<register password="$14" username="$13" xmlns="http://ws.wso2.org
the register name have to be a $15 variable that use the TRANSACTION property value. I think that I can define it in some way into the ... list but I don't know how. At this time in this list I only have value retrieved from a DSS service output, in this case I think that I have to put the value of my TRANSACTION property, but how?
So, is it possible to something like this:
<$15 password="$14" username="$13" xmlns="http://ws.wso2.org
to dinamically insert the tag name?
As far as I know, you can't do that with payloadFactory but you can use a default name for your root node and just after payloadFactory mediator, add this javascript :
<script language="js"><![CDATA[
mc.getEnvelope().getBody().getFirstElement().setLocalName(mc.getProperty("TRANSACTION"));
]]></script>
An other solution would be to use XSLT
How can I pass give multiple complete types in gdbus introspection xml. Example,
<method name="Frobate">
<arg name="foo" type="ii" direction="in"/>
<annotation name="org.freedesktop.DBus.Deprecated" value="true"/>
</method>
When I tried this format, I am getting the error as
Error org.freedesktop.DBus.Error.InvalidArgs: Type of message, '(ii)',
does not match expected type '(null)'
when I am using
<method name="Frobate">
<arg name="foo" type="(ii)" direction="in"/>
<annotation name="org.freedesktop.DBus.Deprecated" value="true"/>
</method>
the error becomes,
Error org.freedesktop.DBus.Error.InvalidArgs: Type of message, '(ii)',
does not match expected type '((ii))'
By this way you can give multiple complete types,
<method name='YourMethod'>"
<arg type='i' name='name1' direction='in'/>"
<arg type='i' name='name2' direction='in'/>"
</method>
I am extending a DBus interface on a linux build machine using Qt. The existing interface works fine and I need to add another parameter
The XML generation method generation is:
<method name="get_card_info">
<arg type="b" name="success" direction="out" />
<arg type="s" name="version" direction="out" />
<arg type="s" name="serial" direction="out" />
<arg type="s" name="BeginDate" direction="out" />
<arg type="s" name="ExpirationDate" direction="out" />
<arg type="s" name="RenewalDate" direction="out" />
<arg type="s" name="ZipCode" direction="out" />
<arg type="s" name="ZipCodeExtension" direction="out" />
<!-- <arg type="u" name="cardStatus" direction="out" /> -->
</method>
The code works fine until I uncomment the commented out line, at which point qdbusxml2cpp reports:
interface_dbus_p.h:39:103: error: wrong number of template arguments (9, should be 8)
This is even if I comment out all calls to this function; indeed this is before the linking code even gets compiled; this is all from the qdbusxml2cpp call.
The XML will compile if I change this to six, seven or eight items, but if I increase it to nine it crashes.
I've changed no other configuration files except the XML code.
What's wrong? Is there a limit of eight parameters?
Found it; yes there is a limit, thanks to QDBusPendingReply
"The QDBusPendingReply is a template class with up to 8 template parameters. Those parameters are the types that will be used to extract the contents of the reply's data."
So no more than 8 parameters for me :(