-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathbuild.xml
More file actions
286 lines (217 loc) · 10.2 KB
/
build.xml
File metadata and controls
286 lines (217 loc) · 10.2 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
<?xml version="1.0" encoding="UTF-8"?>
<project name="Bundle the Java into Mac App" default="build" >
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath>
<pathelement location="lib/ant/ant-contrib-1.0b3.jar"/>
</classpath>
</taskdef>
<!-- version number , also change in UI.java -->
<property name="AppVersion" value="1.4.1"/>
<property name="repository.dir" value="~/repository"/>
<!-- set the operating system test properties -->
<condition property="isMac">
<os family="mac" />
</condition>
<condition property="isWindows">
<os family="windows" />
</condition>
<condition property="isUnix">
<os family="unix" />
</condition>
<property environment="env"/>
<macrodef name="maven">
<attribute name="argline"/>
<attribute name="dir"/>
<sequential>
<echo message="****************************************************************************************** @{dir} @{argline}"/>
<echo message="MAVEN_HOME=${env.MAVEN_HOME}"/>
<exec executable="${env.MAVEN_HOME}/bin/mvn.cmd" osfamily="windows" dir="@{dir}" failonerror="true">
<arg line="@{argline} -T 1C -Ddev=true -ff"/>
</exec>
<!--<exec executable="/Users/i831964/bin/maven/bin/mvn" dir="@{dir}" failonerror="true">-->
<exec executable="${env.MAVEN_HOME}/bin/mvn" osfamily="mac" dir="@{dir}" failonerror="true">
<arg line="@{argline} -o -T 1C -P dev -Ddev=true -ff"/>
</exec>
</sequential>
</macrodef>
<!-- build calls package -->
<target name="build" description="make the full build, package the jars into dist/ folder">
<delete dir="dist" includes="*.jar, *.exe"/>
<!-- even maven does not compile now. relies on the IDE to make the build. -->
<echo>Running tests once...</echo>
<maven dir="." argline="test"/>
<echo>Packaging JARs (skipping tests)...</echo>
<maven dir="." argline="-P fastcopy-ui package -DskipTests"/>
<maven dir="." argline="-P fastcopy-console package -DskipTests"/>
<!--copy the jar to the dist folder -->
<!--copy the jar to the dist folder -->
<copy file="target/fastcopy-ui.jar" todir="dist" overwrite="true"/>
<copy file="target/fastcopy-console.jar" todir="dist" overwrite="true"/>
<antcall target="package"/>
</target>
<target name="package">
<if>
<equals arg1="${isWindows}" arg2="true"/>
<then>
<antcall target="package-fastcopy-console"/>
<antcall target="package-fastcopy-ui"/>
</then>
</if>
<antcall target="bundle-mac-app"/>
<delete dir="${launch4j.dir}"/>
</target>
<target name="rebuild-ui-jar" description="Rebuild just the UI JAR without clean - validates IntelliJ compilation first">
<echo>========================================</echo>
<echo>Validating IntelliJ compilation...</echo>
<echo>========================================</echo>
<maven dir="." argline="-P fastcopy-ui validate"/>
<echo>========================================</echo>
<echo>Validation passed! Packaging JAR...</echo>
<echo>========================================</echo>
<maven dir="." argline="-P fastcopy-ui package -DskipTests"/>
<copy file="target/fastcopy-ui.jar" todir="dist" overwrite="true"/>
<echo>========================================</echo>
<echo>✓ fastcopy-ui.jar built and copied to dist/</echo>
<echo>========================================</echo>
</target>
<target name="release" description="make the release zip ">
<delete dir="dist" includes="*.jar, *.exe"/>
<antcall target="build"/>
<delete file="mhisoft-fastcopy-v${AppVersion}-binaries.zip"/>
<zip destfile="mhisoft-fastcopy-v${AppVersion}-binaries.zip" basedir="dist"/>
</target>
<target name="bundle-mac-app">
<delete includeEmptyDirs="true" failonerror="false">
<fileset dir="dist/Fastcopy(${AppVersion}).app" includes="**"/>
</delete>
<property name="sourceJar" value="fastcopy-ui.jar"/>
<property name="launch4jFinalJar" value="fastcopy-ui-combined.jar"/>
<property name="AppMainClass" value="org.mhisoft.fc.ui.FastCopyMainForm"/>
<antcall target="_make-one-jar"/>
<bundleapp outputdirectory="./dist"
name="Fastcopy(${AppVersion})"
displayname="Fastcopy UI"
identifier="${AppMainClass}"
mainclassname="${AppMainClass}">
<classpath dir="dist" includes="fastcopy-ui.jar,lib/*.jar"/>
<option value="-Xmx512m"/>
</bundleapp>
<!-- Create custom launcher script to fix Java runtime loading issues -->
<property name="app.macos.dir" value="dist/Fastcopy(${AppVersion}).app/Contents/MacOS"/>
<echo file="${app.macos.dir}/FastCopy">#!/bin/bash
# FastCopy Mac App Launcher
# Get the directory where this script is located (MacOS directory)
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
# Go up one level to Contents directory
CONTENTS_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
JAVA_DIR="$CONTENTS_DIR/Java"
# Find Java
if [ -n "$JAVA_HOME" ]; then
JAVA="$JAVA_HOME/bin/java"
elif [ -x /usr/libexec/java_home ]; then
JAVA_HOME=$(/usr/libexec/java_home 2>/dev/null)
if [ -n "$JAVA_HOME" ]; then
JAVA="$JAVA_HOME/bin/java"
fi
fi
# Fallback to system java
if [ -z "$JAVA" ] || [ ! -x "$JAVA" ]; then
JAVA=$(which java 2>/dev/null)
fi
# Check if Java was found
if [ -z "$JAVA" ] || [ ! -x "$JAVA" ]; then
osascript -e 'display dialog "Java is not installed. Please install Java 8 or later." buttons {"OK"} default button "OK" with icon stop with title "FastCopy"'
exit 1
fi
# Build classpath from all JARs in the Java directory
CLASSPATH=""
for jar in "$JAVA_DIR"/*.jar; do
if [ -f "$jar" ]; then
if [ -z "$CLASSPATH" ]; then
CLASSPATH="$jar"
else
CLASSPATH="$CLASSPATH:$jar"
fi
fi
done
# Launch the application
cd "$JAVA_DIR"
exec "$JAVA" -Xmx512m -Xdock:name="FastCopy" -Xdock:icon="$CONTENTS_DIR/Resources/GenericApp.icns" -cp "$CLASSPATH" org.mhisoft.fc.ui.FastCopyMainForm "$@"
</echo>
<chmod file="${app.macos.dir}/FastCopy" perm="755"/>
<!-- Update Info.plist to use the custom launcher -->
<replace file="dist/Fastcopy(${AppVersion}).app/Contents/Info.plist"
token="<string>JavaAppLauncher</string>"
value="<string>FastCopy</string>"/>
</target>
<!-- =======================================
launch 4j package the exe
======================================= -->
<property name="application.title" value="FastCopy"/>
<property name="launch4j.dir" value="dist/tmp_make_exe"/>
<property name="launch4jexe.dir" location="s:\bin\Launch4j" />
<if>
<equals arg1="${isWindows}" arg2="true"/>
<then>
<taskdef name="launch4j"
classname="net.sf.launch4j.ant.Launch4jTask"
classpath="${launch4jexe.dir}/launch4j.jar:${launch4jexe.dir}/lib/xstream.jar" />
</then>
</if>
<!--https://java.net/downloads/appbundler/appbundler.html-->
<taskdef name="bundleapp"
classname="com.oracle.appbundler.AppBundlerTask"
classpath="lib/ant/appbundler-1.0.jar" />
<target name="package-fastcopy-ui">
<property name="sourceJar" value="fastcopy-ui.jar"/>
<property name="launch4jFinalJar" value="fastcopy-ui-combined.jar"/>
<property name="AppMainClass" value="org.mhisoft.fc.ui.FastCopyMainForm"/>
<antcall target="_make-one-jar"/>
<launch4j configFile="launch4j/fastcopy-ui-launch4j-config.xml" />
<!--clean up-->
<!--<delete dir="${launch4j.dir}" failonerror="false"/>-->
</target>
<target name="package-fastcopy-console">
<property name="sourceJar" value="fastcopy-console.jar"/>
<property name="launch4jFinalJar" value="fastcopy-console-combined.jar"/>
<property name="AppMainClass" value="org.mhisoft.fc.FastCopy"/>
<antcall target="_make-one-jar"/>
<launch4j configFile="launch4j/fastcopy-console-launch4j-config.xml" />
<!--clean up-->
<!--<delete dir="${launch4j.dir}" failonerror="false"/>-->
</target>
<target name="_make-one-jar" description="make the Win Exe Bundle" >
<property name="launch4j.jar" value="${launch4j.dir}/${launch4jFinalJar}"/>
<echo message=" --> Packaging ${application.title} into a single JAR at ${launch4j.jar}"/>
<delete dir="${launch4j.dir}" failonerror="false"/>
<mkdir dir="${launch4j.dir}"/>
<!--make the temp_final.jar-->
<if>
<equals arg1="${sourceJar}" arg2="fastcopy-ui.jar"/>
<then>
<jar destfile="${launch4j.dir}/temp_final.jar" filesetmanifest="skip">
<zipgroupfileset dir="dist" includes="${sourceJar}"/>
<zipgroupfileset dir="dist/lib" includes="*.jar"/>
<manifest>
<attribute name="Main-Class" value="${AppMainClass}"/>
</manifest>
</jar>
</then>
<else>
<echo message=" -->use source jar: ${sourceJar}"/>
<jar destfile="${launch4j.dir}/temp_final.jar" filesetmanifest="skip">
<zipgroupfileset dir="dist" includes="${sourceJar}"/>
<manifest>
<attribute name="Main-Class" value="${AppMainClass}"/>
</manifest>
</jar>
</else>
</if>
<!--make the combined jar-->
<echo message=" --> make the ${launch4j.jar}}"/>
<zip destfile="${launch4j.jar}">
<zipfileset src="${launch4j.dir}/temp_final.jar"
excludes="META-INF/*.SF, META-INF/*.DSA, META-INF/*.RSA, META-INF/maven/*, META-INF/jb/*"/>
</zip>
</target>
</project>