|
| 1 | +<?xml version="1.0"?> |
| 2 | +<!-- |
| 3 | + Copyright 2010-2013 the original author or authors. |
| 4 | +
|
| 5 | + Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | + you may not use this file except in compliance with the License. |
| 7 | + You may obtain a copy of the License at |
| 8 | +
|
| 9 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +
|
| 11 | + Unless required by applicable law or agreed to in writing, software |
| 12 | + distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + See the License for the specific language governing permissions and |
| 15 | + limitations under the License. |
| 16 | +--> |
| 17 | +<project name="migrate to mybatis3" basedir="." default="migrateToMyBatis3"> |
| 18 | + <target name="migrateToMyBatis3"> |
| 19 | + <!-- delete possible results from previous run --> |
| 20 | + <delete> |
| 21 | + <fileset dir="destination" includes="*.xml"/> |
| 22 | + </delete> |
| 23 | + <!-- xslt convert sqlMaps 2 to mybatis 3 --> |
| 24 | + <xslt basedir="source" style="migrate.xslt" includes="*.xml" destdir="destination" extension=".xml"/> |
| 25 | + <!-- replace #id:NUMERIC# to #id,jdbcType=NUMERIC# etc. --> |
| 26 | + <replace dir="destination" includes="*.xml" token=":NUMERIC#" value=",jdbcType=NUMERIC#" encoding="UTF8"/> |
| 27 | + <replace dir="destination" includes="*.xml" token=":TIMESTAMP#" value=",jdbcType=TIMESTAMP#" encoding="UTF8"/> |
| 28 | + <replace dir="destination" includes="*.xml" token=":VARCHAR#" value=",jdbcType=VARCHAR#" encoding="UTF8"/> |
| 29 | + <replace dir="destination" includes="*.xml" token=":BLOB#" value=",jdbcType=BLOB#" encoding="UTF8"/> |
| 30 | + <!-- add any needed jdbc type here (for example :CLOB#, :FLOAT#, :REAL#, :BIT#, :INTEGER#, :DECIMAL#, :DATE#, :TIME#, .... ) |
| 31 | + <replace dir="destination" includes="*.xml" token=":???#" value=",jdbcType=???#" encoding="UTF8"/> |
| 32 | + --> |
| 33 | + <!-- replace $id$ with ${id} --> |
| 34 | + <replaceregexp match="\$([a-zA-Z0-9.\[\]_]+)\$" replace="$\{\1}" flags="mg" byline="false" encoding="UTF8"> |
| 35 | + <fileset dir="destination" includes="*.xml" /> |
| 36 | + </replaceregexp> |
| 37 | + <!-- replace #id# with #{id} --> |
| 38 | + <replaceregexp match="#([a-zA-Z0-9,_.=\[\]]{2,})#" replace="#{\1}" flags="mg" byline="false" encoding="UTF8"> |
| 39 | + <fileset dir="destination" includes="*.xml" /> |
| 40 | + </replaceregexp> |
| 41 | + <!-- replace xyz[] with item for use in iterators--> |
| 42 | + <replaceregexp match="[a-z.]{2,}\[\]" replace="item" flags="ig" encoding="UTF8"> |
| 43 | + <fileset dir="destination" includes="*.xml" /> |
| 44 | + </replaceregexp> |
| 45 | + |
| 46 | + <xmlvalidate failonerror="yes" lenient="false" warn="yes"> |
| 47 | + <attribute name="http://apache.org/xml/features/validation/schema" value="false" /> |
| 48 | + <attribute name="http://xml.org/sax/features/namespaces" value="false" /> |
| 49 | + <fileset dir="destination" includes="*.xml" /> |
| 50 | + <dtd publicId="-//mybatis.org//DTD SQL Map Config 3.0//EN" location="mybatis-3-config.dtd" /> |
| 51 | + <dtd publicId="-//mybatis.org//DTD Mapper 3.0//EN" location="mybatis-3-mapper.dtd" /> |
| 52 | + </xmlvalidate> |
| 53 | + |
| 54 | + </target> |
| 55 | +</project> |
0 commit comments