Showing posts with label Ant. Show all posts
Showing posts with label Ant. Show all posts

Monday, November 17, 2014

How to replace HTML tag with ant

To replace a word or character with Ant,
we can use the following command.

<replaceregexp file="{FILE_TO_REPLACE}"
    match="{WORD_TO_REPLACE}"
    replace="{WORD}" flags="g" byline="true" />

But the above command can use to replace words withouth xml/html reserved characters only.
To replace words with xml/html reserved characters,

Steps:
1. encode the xml/html reserved words before putting into the the <replaceregexp /> command.
eg, <a>link</link>  =>  &lt;a&gt;link&lt;/a&gt;

2. put the encoded words into <replaceregexp />
eg,

<replaceregexp file="{FILE_TO_REPLACE}"
    match="&lt;a&gt;link&lt;/a&gt;"
    replace="&lt;a&gt;new_link&lt;/a&gt;" flags="g" byline="true" />


Done!!

Wednesday, January 1, 2014

EclipseLink Static weaving with Ant

<?xml version="1.0"?>
<!DOCTYPE project>

<project name="staticWeaving" default="weaving">  

<target name="define.task"
description="New task definition for EclipseLink static weaving" >
<taskdef
name="weave"
classname="org.eclipse.persistence.tools.weaving.jpa.StaticWeaveAntTask">
<classpath refid="project.class.path" />
</taskdef>
</target>

<target name="weaving" description="perform weaving." depends="define.task">
<weave
source="original-jpa.jar"
target="weaved-jpa.jar"
persistenceinfo="${jpaProjectHome}\classes">
<classpath refid="project.class.path" />
</weave>
</target>

<path id="project.class.path">
   <pathelement path="eclipselink.jar/"/>
  <pathelement path="hibernate-jpa-2.0-api-1.0.1.Final.jar"/>
</path>

</project>

Tuesday, August 13, 2013

Obfuscation with yGuard and Ant

Obfuscation is the action to create source code that is difficult for human to understand.
It is very important for enterprise java applications to protect project's source code easily viewed by others.

After trying ProGuard and yGuard, found that yGuard is pretty simple compare to ProGuard.

Below are the simplest steps to obfuscate a JAR with with yGuard.
1. download yGuard here.

2. extract and locate the yguard.jar at the same folder with Ant build.xml.

3. add the following target into the Ant build file.
<target depends="pakage-jar" name="yguard">
  <taskdef name="yguard" classname="com.yworks.yguard.YGuardTask"
  classpath="yguard.jar"/>
  <yguard>
    <inoutpair in="PROJECT_NAME.jar" out="PROJECT_NAME_OBJ.jar"/>
     <shrink />
  </yguard>
</target>

change the PROJECT_NAME.jar that generated from the package-jar.
change the PROJECT_NAME_OBJ.jar to target destination.

4. more complicated example could refer yguard_ant_howto.html that comes with the yguard download.


Done!!

LinkWithin

Related Posts Plugin for WordPress, Blogger...