Call Jython Method from wsadmin ant task - websphere

I created a method in Jython to add shared library to the installed application. I save the script file in {was.install.dir}/bin directory with name "addSharedLib.py". I am using ant to install the application on the cluster. My question is how do I call this jython method from ant script to get desired result? I am using websphere 8.5.5 ND.
def setSharedLibrary(appName,editionNo,saredLibName):

Have looked into the WAS provided ant environment?
There is ws_ant utility - ws_ant docs.

You can obtain one of the jython standalone jars from http://www.jython.org/downloads.html and just run the Ant java task like this ...
<?xml version="1.0" encoding="windows-1252" ?>
<project default="install">
<target name="install">
<java classname="org.python.util.jython" fork="true" failonerror="true">
<arg line="addSharedLib.py"/>
<classpath>
<pathelement location='D:\work\jython\jython2.5.3\jython-standalone-2.5.3.jar' />
</classpath>
</java>
</target>
</project>

Related

srcdir attributes must be set

Im trying to migrate my code from ant to gradle and imported my build.xml in build.gradle and some of my tasks work fine.
However there are some tasks when i run them it says
Execution failed for task ':compile'.
srcdir attribute must be set!
Pasting a snippet of my Build.xml and the compile task below is failing.
<project basedir="." default="deploy" name="FitNesse">
<property name="fitnesse.target" value="/build/test-fitnesse"/>
<patternset id="test.patternset">
<include name="**/*Test*.java"/>
</patternset>
<propertyset id="test.propertyset">
<propertyref name="basedir"/>
<propertyref name="test.patternset"/>
</propertyset>
<fileset id="classpath.fitnesse" dir="./libs">
<include name="antlr-2.7.7.jar"/>
<include name="asm-4.1.jar"/>
<include name="asm-analysis-4.1.jar"/>
<include name="asm-commons-4.1.jar"/>
<include name="asm-tree-4.1.jar"/
><target name="compile" description="Compile java sources" depends="clean">
<mkdir dir="build/classes"/>
<javac includeantruntime="false"/>
<javac srcdir="src/main/java" destdir="build/classes" debug="on">
<classpath refid="classpath.compile"/>
<compilerarg value="-processorpath"/>
<compilerarg value="-AmethodConstraintsSupported=true"/>
</javac>
</target>
Source folder structure
/src/main/java/com/xebia/inc/xeb
I had changed my src folder structure from ant "src" to a gradle project "/src/main/java/com/xebia/incubator/xebium". and lib folder to libs
Please help. I'm kind of novice to this.
Thanks,
The full error message should give you the line number and it's most probably the line that contains
<javac includeantruntime="false"/>
which looks like a copy-paste error.

How to create sitemap.xml from docbook source

I need to generate sitemap.xml in the standard Google acceptable format from my docbook source. I'm currently using gradle to power the build process.
Is there an existing tool out there to generate sitemap.xml automatically as part of the build?
By Using Ant from Gradle is seams to be possible as there is an Apache Ant Task for generating a XML Sitemap. Read the manual at GitHub, for the usage details.
<target name="generate_sitemap" description="generates the sitemap">
<taskdef classname="uk.co.arjones.ant.task.Sitemap" name="sitemap"></taskdef>
<sitemap url="http://organisation.org" gzip="yes" lastmod="now" destdir="${BUILD_DIR}">
<fileset dir="${BUILD_DIR}">
<include name="**.docbook"></include>
<include name="**.dbx"></include>
<exclude name="google*"></exclude>
</fileset>
</sitemap>
</target>

How to run a SQL script in Jenkins by invoking ANT?

I am trying to use Jenkins to execute a SQL script that is in my source control. To do this, I created a build task to invoke ANT. My ANT version is 1.9.4.
Here is the build file that I am calling
<project name="VResources-Reset">
<sql
driver="com.microsoft.sqlserver.jdbc.SQLServerDriver"
url="jdbc:sqlserver://SERVER_NAME:1433;databaseName=Automation"
userid="USERID"
password="PWD"
src="C:\\SvyDeploy\\DEV\\Sprint\\Automation\\Database\\Viewpoint\\View Resources\\VResources - Reset Users.sql"/>
<classpath>
<pathelement location="C:\\SvyDeploy\\DEV\\Sprint\\Automation\\libs\\sqljdbc4.jar"/>
</classpath>
</project>
I have also tried using org.database.jdbcDriver as the driver.
When I try to build my project in Jenkins, I am always getting the below error and can't figure out why. ANT and Jenkins are very new to me, so I'm sure I'm missing something simple. Can someone please point out what that is?
Class Not Found: JDBC driver com.microsoft.sqlserver.jdbc.SQLServerDriver could not be loaded
Hope classPath should be passed inside sql element.
Please try this..
<project name="VResources-Reset">
<sql driver="com.microsoft.sqlserver.jdbc.SQLServerDriver" url="jdbc:sqlserver://SERVER_NAME:1433;databaseName=Automation"
userid="USERID"
password="PWD"
src="C:\\SvyDeploy\\DEV\\Sprint\\Automation\\Database\\Viewpoint\\View Resources\\VResources - Reset Users.sql">
<classpath>
<pathelement location="C:\\SvyDeploy\\DEV\\Sprint\\Automation\\libs\\sqljdbc4.jar"/>
</classpath>
</sql>
</project>

Running Ruby tests (Rspec and Cucumber) through Ant

I'm currently looking at TeamCity and how to get our Ruby tests running. I can run the tests just fine when using the Command line or Rake builders. The question I'm trying to solve right now is two fold:
In one of my previous jobs, we also relied on TeamCity to run our .NET tests. We used Nant for this and we had means of tracking the amount of queries that were ran during tests as well as the average execution time for these queries.
I'm trying to do the same right now with my Ruby project. So the first logical step I want to tackle is, How do I run for example RSpec or Cucumber tests using Ant?
I tried looking at Ant itself and grasp it a little bit, but all the examples I find are for jRuby, which we don't use. We rely on RVM and a normal Ruby installation.
The second part of the question is, How can I track the amount of queries ran and their execution time? I'm guessing there is probably a gem for it or some sort of global variable to track. Would love to output this information back to TeamCity somehow.
EDIT
Ok, so I managed to get things running with Ant for my TeamCity server.
This is the XML i'm using atm:
<?xml version="1.0"?>
<project name="rubycas" default="init">
<description>
This buildfile is used to build the RubyCAS project under TeamCity and run the required tasks to validated
whether the project is stable and fully functional.
</description>
<property name="test_type" value="cucumber" />
<target name="init">
<echo message="##teamcity[testStarted name='Rubycas']" />
<condition property="cucumberBool">
<equals arg1="${test_type}" arg2="cucumber" />
</condition>
<condition property="rspecBool">
<equals arg1="${test_type}" arg2="rspec" />
</condition>
</target>
<target name="rspec" if="rspecBool" depends="init">
<exec executable="rspec" outputproperty="result">
<arg value="--require teamcity/spec/runner/formatter/teamcity/formatter" /> <arg value="--format Spec::Runner::Formatter::TeamcityFormatter" />
</exec>
<echo message="${result}" />
</target>
<target name="cucumber" if="cucumberBool" depends="init">
<exec executable="cucumber" outputproperty="result">
<arg value="--format junit" />
<arg value="--out results" />
<arg value="features" />
</exec>
<echo message="${result}" />
</target>
</project>
Problem now is, I cannot get the output from RSpec into TeamCity to recognize the tests.
You can use ant's exec task to run arbitrary system calls, which in your case might be rspec:
https://ant.apache.org/manual/Tasks/exec.html
Something along the lines of
<target name="rspec">
<exec executable="rake">
<arg value="spec"/>
</exec>
</target>
I don't know if your tracking stuff will work with this though, because it's really executing the commands outside of ant.

Using jarbundler ant task to add dependencies to the app

I have a Netbeans Java project. When I build my project it create a directory dist and dist/lib. It stores the Jar of the file in dist and other jar files on which the main jar file depends, in the lib directory.
Now I want to create a release for OSX. For that I am using the jarbundler ant task like this
<target name="mac">
<mkdir dir="release"/>
<taskdef name="jarbundler"
classname="net.sourceforge.jarbundler.JarBundler" />
<jarbundler dir="release"
name="MyApp"
mainClass="controller.MyApp"
jar="dist/MyApp.jar" />
</target>
This creates the app with the jar, but how do I add the dependent libraries to the app.
This is what is needed
The jar attribute should be replaced with jarfileset like this.
<target name="mac">
<mkdir dir="release"/>
<taskdef name="jarbundler"
classname="net.sourceforge.jarbundler.JarBundler" />
<jarbundler dir="release"
name="MyApp"
mainClass="controller.MyApp">
<jarfileset dir="dist">
<include name="**/*.jar" />
</jarfileset>
</jarbundler>
</target>

Resources