Writing the Ant script output into a seprate log file

Hi

It is very easy to redirect the output of the Ant script into a separate a file using DOS command utility.

Just follow the basic simple steps.

Step 1: Goto Command Prompt

Step2: Run the Ant script(build.xml) e.g.
c:\myProject\build>ant < buildLog.log

Thanks
R Vashi

Advertisements

Creating a Connection Pool using ANT in Weblogic

Hi

Managing weblogic through ANT is very easy and handy sometimes, Few days back I was just trying Connection pool creation using Apache ANT, So wants to share with you all.

Steps 1:
On Windows set the weblogic env using setWLSEnv.cmd(bea/wlseerverx.x/servers/bin), if you dont have Weblogic, Try putting weblogic.jar in the classpath

Step 2

Create a ANT Script.

<target name=”createPool”>
<wlconfig url=”t3://localhost:6001″ username=”weblogic” password=”weblogic”>
<query domain=”admin_domain” type=”Server” name=”AdminServer” property=”AdminServer”/>
<create type=”JDBCConnectionPool” name=”OneSourceConnectionPool”>
<set attribute=”DriverName”    value=”oracle.jdbc.OracleDriver”/>
<set attribute=”InitialCapacity” value=”15″/>
<set attribute=”MaxCapacity” value=”50″/>
<set attribute=”StatementTimeout” value=”600″/> OR Leave it to default -1
<set attribute=”Password” value=”PASSWORD”/>
<set attribute=”Properties” value=”user=USER_NAME”/>
<set attribute=”RefreshMinutes” value=”0″/>
<set attribute=”StatementCacheSize” value=”0″/>
<set attribute=”ShrinkPeriodMinutes” value=”15″/>
<set attribute=”ShrinkingEnabled” value=”true”/>
<set attribute=”TestConnectionsOnRelease” value=”true”/>
<set attribute=”TestConnectionsOnReserve” value=”true”/>
<set attribute=”TestConnectionsOnCreate” value=”true”/>
<set attribute=”TestTableName” value=”SQL SELECT 1 FROM DUAL”/>
<set attribute=”URL” value=”DB_URL”/>
<set attribute=”Targets” value=”${AdminServer}”/>
</create>
</wlconfig>
</target>

After running the ANT Task you will see the following output in the console.

If you want to configure some other types of Connection pool, Do check the MBean associated with that type(if you have weblogic access, see the right side info, and click on<> link,  a new pop up will open and see the MBean name for that type.

Note: Always use t3 protocol instead of HTTP while connecting Weblogic using ANT.


Thanks
R Vashi

Creating builds with build version in ANT

Hi All,

We can generate builds with the build version information using ANT, All we have to do is to create a separte properties files, save it parallel to the Build.xml.

Step 1: Load the properties file from outside
<property file=”build.properties”/> [inside the prop define key/value pair build_version=version 1.2.4]

Step 2: Specify the Vesrion information in the META-INF of the WAR/EAR using the below code.

<jar destfile=”build/war_name.war”>

<zipfileset dir=”${dist}”/>

<manifest>

<attribute name=”Built-By” value=”Date-${DATE_TIME}- Vesrion-${build_version}”/>

</manifest>

</jar>

Thanks
R Vashi

Creating a WAR/EAR with current date and time

Hi All,

Sometime when we are building war/ear very frequently using ANT specially during product pre release days then it become very difficult to maintain which dist has been generated when. To track that we can add the details in the META-INF of the war/ear using ANT.

<jar destfile=”build/war_name.war”>
<zipfileset dir=”${dist}”/>
<manifest>
<attribute name=”Built-By” value=”Date-${DATE_TIME}- Vesrion-${build_version}”/>
</manifest>
</jar>

Thanks

R Vashi

Checkout a code from StarTeam using Apace Ant

Hi All,

Checking out a code from Starteam is very simple in Ant, First of all add the starteam related jars in the classpath.
and then write down a Ant task in build.xml.

<target name=”checkoutFromStarteam”>
<taskdef name=”stcheckout”
classname=”org.apache.tools.ant.taskdefs.optional.scm.AntStarTeamCheckOut”/>
<stcheckout servername=”SERVER_IP_ADDRESS”
serverport=”SERVER_PORT”
projectname=”PROJECT_NAME”
viewname=”BRANCH_NAME”
username=”USER_NAME”
password=”PASSWORD”
targetFolder=”C:\Checkout\codeBase\”
folderName =”VIEW/Java”
force=”true”
verbose=”true”
/>
</target>

If you are accessing the Starteam over firewall, then dont forgot to break the firewall and then try this task.

Thanks
R Vashi