Mercurial > cgi-bin > hgweb.cgi > ImagePrep
annotate build.xml @ 25:a495f9ea498b mac-open
Initial attempts to make it respond to MacOS open message (not working).
author | David Barts <n5jrn@me.com> |
---|---|
date | Sun, 13 Dec 2020 10:29:08 -0800 |
parents | 92afaa27f40a |
children | 9bf3d8de6904 |
rev | line source |
---|---|
0 | 1 <?xml version="1.0" encoding="UTF-8"?> |
2 <project name="ImagePrep" default="help" basedir="."> | |
3 <!-- import all environment variables as env.* --> | |
4 <property environment="env"/> | |
5 | |
6 <!-- ensure required environment variables are set --> | |
7 <macrodef name="env-require"> | |
8 <attribute name="name"/> | |
9 <sequential> | |
10 <fail message="Environment variable @{name} not set!"> | |
11 <condition> | |
12 <not><isset property="env.@{name}"/></not> | |
13 </condition> | |
14 </fail> | |
15 </sequential> | |
16 </macrodef> | |
17 <env-require name="JRE_HOME"/> | |
18 <env-require name="KOTLIN_HOME"/> | |
19 <env-require name="OSDEP_HOME"/> | |
20 | |
21 <!-- cribbed from https://stackoverflow.com/questions/7129672/uppercase-lowercase-capitalize-an-ant-property --> | |
22 <scriptdef language="javascript" name="toLowerCase"> | |
23 <attribute name="value" /> | |
24 <attribute name="target" /> | |
25 <![CDATA[ | |
26 "use strict"; | |
27 project.setProperty( attributes.get( "target" ), | |
28 attributes.get( "value" ).toLowerCase() ); | |
29 ]]> | |
30 </scriptdef> | |
31 | |
32 <!-- Define the properties used by the build --> | |
33 <property name="app.name" value="${ant.project.name}"/> | |
2 | 34 <toLowerCase target="lc.app.name" value="${app.name}"/> |
0 | 35 <property name="app.version" value="1.00"/> |
2 | 36 <property name="app.domain" value="name.blackcap.${lc.app.name}"/> |
0 | 37 <property name="app.entry" value="${app.domain}.MainKt"/> |
38 <property name="app.copyright" value="Copyright © 2020, David W. Barts."/> | |
39 <property name="jar.name" value="${basedir}/${lc.app.name}.jar"/> | |
40 <property name="work.jar" value="${basedir}/work.jar"/> | |
41 <property name="lib.home" value="${basedir}/lib"/> | |
42 <property name="src.home" value="${basedir}/src"/> | |
43 <property name="dist.home" value="${basedir}/dist"/> | |
23 | 44 <property name="pf.home" value="${basedir}/package-files"/> |
0 | 45 <property name="jvm.version" value="1.8"/> |
46 | |
47 <!-- define the kotlin task --> | |
48 <property name="kotlin.lib" value="${env.KOTLIN_HOME}/lib"/> | |
49 <typedef resource="org/jetbrains/kotlin/ant/antlib.xml" | |
50 classpath="${kotlin.lib}/kotlin-ant.jar"/> | |
51 | |
52 <!-- help message --> | |
53 <target name="help"> | |
54 <echo>You can use the following targets:</echo> | |
55 <echo> </echo> | |
56 <echo> help : (default) Prints this message </echo> | |
57 <echo> all : Cleans, compiles, and stages application</echo> | |
58 <echo> clean : Deletes work directories</echo> | |
59 <echo> compile : Compiles servlets into class files</echo> | |
60 <echo> jar : Make JAR file.</echo> | |
61 <echo> </echo> | |
62 <echo>For example, to clean, compile, and package all at once, run:</echo> | |
63 <echo>prompt> ant all </echo> | |
64 </target> | |
65 | |
66 <!-- Define the CLASSPATH --> | |
67 <target name="classpath"> | |
68 <path id="compile.classpath"> | |
69 <pathelement location="${src.home}"/> | |
4
5234e4500d45
Command-line arguments (only partially tested).
David Barts <n5jrn@me.com>
parents:
2
diff
changeset
|
70 <fileset dir="${lib.home}"> |
5234e4500d45
Command-line arguments (only partially tested).
David Barts <n5jrn@me.com>
parents:
2
diff
changeset
|
71 <include name="*.jar"/> |
5234e4500d45
Command-line arguments (only partially tested).
David Barts <n5jrn@me.com>
parents:
2
diff
changeset
|
72 </fileset> |
0 | 73 </path> |
74 </target> | |
75 | |
76 <!-- make needed directories --> | |
77 <target name="mkdirs"> | |
78 <mkdir dir="${dist.home}"/> | |
79 </target> | |
80 | |
81 <!-- remove old cruft --> | |
82 <target name="clean"> | |
83 <delete includeEmptyDirs="true" failonerror="false"> | |
84 <fileset dir="${dist.home}" includes="**/*"/> | |
85 </delete> | |
86 </target> | |
87 | |
88 <!-- rename files containing OS-dependant code --> | |
89 <target name="osdep"> | |
90 <exec executable="${env.JRE_HOME}/bin/java" failonerror="true"> | |
91 <arg value="-jar"/> | |
92 <arg file="${env.OSDEP_HOME}/osdep.jar"/> | |
93 <arg value="${src.home}"/> | |
94 </exec> | |
95 </target> | |
96 | |
97 <!-- do everything but install --> | |
98 <target name="all" depends="jar" | |
99 description="Clean work dirs, compile, make JAR."/> | |
100 | |
101 <!-- compile *.kt to *.class --> | |
102 <target name="compile" depends="mkdirs,osdep,classpath" | |
103 description="Compile Java sources to ${work.home}"> | |
104 <kotlinc src="${src.home}" output="${work.jar}" | |
105 classpathref="compile.classpath"> | |
106 <compilerarg line="-jvm-target ${jvm.version}"/> | |
107 </kotlinc> | |
108 </target> | |
109 | |
110 <!-- make .jar file --> | |
111 <target name="jar" depends="compile" description="Create JAR file."> | |
112 <jar destfile="${jar.name}"> | |
113 <manifest> | |
114 <attribute name="Main-Class" value="${app.entry}"/> | |
115 </manifest> | |
116 <!-- <zipgroupfileset dir="${lib.home}" includes="*.jar"/> --> | |
4
5234e4500d45
Command-line arguments (only partially tested).
David Barts <n5jrn@me.com>
parents:
2
diff
changeset
|
117 <zipgroupfileset dir="${lib.home}" includes="*.jar"/> |
0 | 118 <zipfileset src="${work.jar}"/> |
2 | 119 <zipfileset dir="${src.home}" includes="**/*.properties,**/*.html"/> |
0 | 120 </jar> |
121 </target> | |
122 | |
23 | 123 <target name="macapp" depends="jar" description="Create MacOS app bundle."> |
124 <fail message="Macintosh packages can only be built on a Mac."> | |
125 <condition> | |
126 <not><os family="mac"/></not> | |
127 </condition> | |
128 </fail> | |
129 <sequential> | |
130 <property name="mac.disk.image.filename" | |
131 value="${lc.app.name}_${app.version}.dmg"/> | |
132 <property name="app.bundle" value="${dist.home}/${app.name}.app"/> | |
133 <mkdir dir="${app.bundle}/Contents"/> | |
134 <copy todir="${app.bundle}/Contents" encoding="UTF-8" overwrite="true"> | |
135 <fileset file="${pf.home}/osx/Info.plist"/> | |
136 <!-- XXX will break if any tokens contain <, >, or & --> | |
137 <filterset> | |
138 <filter token="app.copyright" value="${app.copyright}"/> | |
139 <filter token="app.domain" value="${app.domain}"/> | |
140 <filter token="app.entry" value="${app.entry}"/> | |
141 <filter token="app.name" value="${app.name}"/> | |
142 <filter token="app.version" value="${app.version}"/> | |
143 <filter token="jar.filename" value="${lc.app.name}.jar"/> | |
144 <filter token="jvm.version" value="${jvm.version}"/> | |
145 <filter token="lc.app.name" value="${lc.app.name}"/> | |
146 </filterset> | |
147 </copy> | |
148 <mkdir dir="${app.bundle}/Contents/MacOS"/> | |
149 <copy todir="${app.bundle}/Contents/MacOS" encoding="UTF-8" | |
150 overwrite="true"> | |
151 <fileset file="${pf.home}/osx/JavaApplicationStub"/> | |
152 <filterset> | |
153 <filter token="app.domain" value="${app.domain}"/> | |
154 <filter token="app.name" value="${app.name}"/> | |
155 </filterset> | |
156 </copy> | |
157 <chmod file="${app.bundle}/Contents/MacOS/JavaApplicationStub" | |
158 perm="755"/> | |
159 <mkdir dir="${app.bundle}/Contents/Resources"/> | |
160 <copy file="${basedir}/${app.name}.icns" | |
161 todir="${app.bundle}/Contents/Resources"/> | |
162 <mkdir dir="${app.bundle}/Contents/Java"/> | |
163 <copy file="${jar.name}" todir="${app.bundle}/Contents/Java"/> | |
164 <echo file="${app.bundle}/Contents/PkgInfo" message="APPL????"/> | |
165 <exec executable="hdiutil" failonerror="true"> | |
166 <arg value="create"/> | |
167 <arg value="-volname"/> | |
168 <arg value="${app.name}"/> | |
169 <arg value="-srcfolder"/> | |
170 <arg file="${app.bundle}"/> | |
171 <arg file="${dist.home}/orig-${mac.disk.image.filename}"/> | |
172 </exec> | |
173 <exec executable="hdiutil" failonerror="true"> | |
174 <arg value="convert"/> | |
175 <arg file="${dist.home}/orig-${mac.disk.image.filename}"/> | |
176 <arg value="-format"/> | |
177 <arg value="UDRW"/> | |
178 <arg value="-o"/> | |
179 <arg file="${dist.home}/udrw-${mac.disk.image.filename}"/> | |
180 </exec> | |
181 <exec executable="hdiutil" failonerror="true"> | |
182 <arg value="convert"/> | |
183 <arg file="${dist.home}/udrw-${mac.disk.image.filename}"/> | |
184 <arg value="-format"/> | |
185 <arg value="UDZO"/> | |
186 <arg value="-imagekey"/> | |
187 <arg value="zlib-level=9"/> | |
188 <arg value="-o"/> | |
189 <arg file="${dist.home}/${mac.disk.image.filename}"/> | |
190 </exec> | |
191 </sequential> | |
192 </target> | |
193 | |
0 | 194 </project> |