-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
95 lines (83 loc) · 3.49 KB
/
build.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?xml version="1.0" encoding="UTF-8"?>
<project name="MyBatis Migrations" basedir="." default="db:migrate:status">
<property file="build.properties" />
<condition property="environment" value="${ENV}" else="${mybatis.default.environment}">
<isset property="ENV" />
</condition>
<property file="${mybatis.env.dir}/${environment}.properties" />
<path id="mybatis-classpath">
<fileset dir="${mybatis.lib.dir}">
<include name="**/*.jar" />
</fileset>
</path>
<path id="mybatis-drivers-classpath">
<fileset dir="${mybatis.drivers.dir}">
<include name="**/*.jar" />
</fileset>
</path>
<!-- Creates migrate task -->
<macrodef name="migrate">
<attribute name="command" />
<attribute name="environment" default="${mybatis.default.environment}" />
<attribute name="path" default="${mybatis.repository.dir}" />
<element name="extraarguments" optional="true" />
<sequential>
<echo>** Executing "migrate @{command}" on "@{environment}" environment **</echo>
<java classname="org.apache.ibatis.migration.Migrator"
failonerror="true" fork="true" classpathref="mybatis-classpath">
<sysproperty key="file.encoding" value="UTF-8"/>
<arg value="@{command}" />
<arg value="--env=@{environment}" />
<arg value="--path=@{path}" />
<extraarguments />
</java>
</sequential>
</macrodef>
<!-- Simulates the command: -->
<!-- $ migrate init -->
<target name="db:migrate:init" description="Creates (if necessary) and initializes a migration path">
<migrate command="init" path="${mybatis.repository.dir}" />
</target>
<!-- Simulates the command: -->
<!-- $ migrate new <description> -->
<target name="db:migrate:new" description="Creates a new migration with the provided description">
<input addproperty="description" message="Description of the new migration:" />
<migrate command="new" environment="${environment}" path="${mybatis.repository.dir}" >
<extraarguments>
<arg value="${description}" />
</extraarguments>
</migrate>
</target>
<!-- Simulates the command: -->
<!-- $ migrate bootstrap -->
<target name="db:migrate:bootstrap" description="Runs the bootstrap SQL script (see scripts/bootstrap.sql for more)">
<migrate command="bootstrap" environment="${environment}" path="${mybatis.repository.dir}" />
</target>
<!-- Simulates the command: -->
<!-- $ migrate status -->
<target name="db:migrate:status" description="Prints the changelog from the database if the changelog table exists">
<migrate command="status" environment="${environment}" />
</target>
<!-- Simulates the command: -->
<!-- $ migrate up -->
<target name="db:migrate:up" description="Run all unapplied migrations">
<migrate command="up" environment="${environment}" />
</target>
<!-- Simulates the command: -->
<!-- $ migrate up -force -->
<target name="db:migrate:up:force" description="Run all unapplied migrations and forces script to continue even if SQL errors are encountered">
<migrate command="up" environment="${environment}">
<extraarguments>
<arg value="--force" />
</extraarguments>
</migrate>
</target>
<!-- Simulates the command: -->
<!-- $ migrate down -->
<target name="db:migrate:down" description="Undoes the last migration applied to the database">
<migrate command="down" environment="${environment}" />
</target>
<!-- Runs both tasks db:migrate:bootstrap and db:migrate:up -->
<target name="db:migrate:setup" depends="db:migrate:bootstrap, db:migrate:up" description="Runs both tasks db:migrate:bootstrap and db:migrate:up">
</target>
</project>