-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbootstrap.xml
More file actions
133 lines (110 loc) · 4.86 KB
/
Copy pathbootstrap.xml
File metadata and controls
133 lines (110 loc) · 4.86 KB
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?xml version="1.0" encoding="UTF-8"?>
<project name="bootstrap" default="bootstrap">
<!-- Create properties for Ivy, Ant and Eclipse files, check if they exist -->
<property name="antfile" location="${user.dir}/build.xml"/>
<property name="ivyfile" location="${user.dir}/ivy.xml"/>
<property name="prjfile" location="${user.dir}/.project"/>
<property name="gitfile" location="${user.dir}/.gitignore"/>
<available file="${antfile}" property="antfile.found"/>
<available file="${ivyfile}" property="ivyfile.found"/>
<available file="${prjfile}" property="prjfile.found"/>
<available file="${gitfile}" property="gitfile.found"/>
<!-- Bootstrap the project, tasks below -->
<target name="bootstrap"
description="Bootstrap a project"
depends="-check,-ask,-create">
<ant antfile="${antfile}"
target="eclipse"
dir="${projectdir}"
inheritAll="false"/>
<echo message="All done!"/>
</target>
<!--+ ================================================================== +
| FAILURES: Things to check before continuing |
+ ================================================================== + -->
<target name="-check" depends="-check:ant,-check:ivy"/>
<!-- Gracefully fail if the Ant build file exists -->
<target name="-check:ant" if="antfile.found">
<fail message="Ant build '${antfile}' already exists"/>
</target>
<!-- Gracefully fail if the Ivy descriptor file exists -->
<target name="-check:ivy" if="ivyfile.found">
<fail message="Ivy file '${ivyfile}' already exists"/>
</target>
<!--+ ================================================================== +
| QUESTIONS: Things to know before we continue |
+ ================================================================== + -->
<target name="-ask" depends="-check">
<!-- Basic locations -->
<property name="projectdir"
location="${user.dir}"/>
<property name="builddir"
basedir="${projectdir}"
location="${basedir}"
relative="true"/>
<!-- The base name of the project directory becomes our default module -->
<basename property="module.default" file="${projectdir}"/>
<!-- Details about what we're doing -->
<echo message="Bootstrapping project in '${projectdir}'"/>
<echo message=" build directory in '${builddir}'"/>
<echo message=""/>
<!-- Organization name -->
<input message="Enter organisation name, defaults to"
defaultvalue="com.github.pfumagalli"
addproperty="organisation"/>
<!-- Module name (required, no default) -->
<input message="Enter project module, defaults to"
defaultvalue="${module.default}"
addproperty="module"/>
</target>
<!--+ ================================================================== +
| CREATIONS: Files to create if they do not exist |
+ ================================================================== + -->
<target name="-create" depends="-create:ant,-create:ivy,-create:prj,-create:git"/>
<!-- Create the Ant build file if it doesn't exist -->
<target name="-create:ant" unless="antfile.found">
<echoxml file="${antfile}">
<project name="${module}" default="dist">
<property name="builddir" value="${builddir}"/>
<import file="$${builddir}/build.xml"/>
</project>
</echoxml>
</target>
<!-- Create the Ivy descriptor file if it doesn't exist -->
<target name="-create:ivy" unless="ivyfile.found">
<echoxml file="${ivyfile}">
<ivy-module version="2.0">
<info organisation="${organisation}" module="${module}" revision="0.0.0"/>
<configurations>
<conf name="default" visibility="public"/>
</configurations>
<dependencies/>
</ivy-module>
</echoxml>
</target>
<!-- Create the Eclipse project file if it doesn't exist -->
<target name="-create:prj" unless="prjfile.found">
<echoxml file="${prjfile}">
<projectDescription>
<name>${module}</name>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
</echoxml>
</target>
<!-- Create the Git ignore file if it doesn't exist -->
<target name="-create:git" unless="gitfile.found">
<echo file="${gitfile}" append="false">.DS_Store </echo>
<echo file="${gitfile}" append="true" >.classpath </echo>
<echo file="${gitfile}" append="true" >.ivycache/* </echo>
<echo file="${gitfile}" append="true" >.project </echo>
<echo file="${gitfile}" append="true" >lib/* </echo>
<echo file="${gitfile}" append="true" >target/* </echo>
</target>
</project>