-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.xml
131 lines (114 loc) · 4.11 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
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
<?xml version="1.0" encoding="UTF-8"?>
<project name="Neptus Plugin" default="jar">
<loadproperties srcfile="plugin.properties"/>
<path id="neptus.libs">
<fileset dir="${NeptusDir}/lib" casesensitive="false">
<include name="**/*.jar" />
<include name="**/*.zip" />
</fileset>
<fileset dir="${NeptusDir}/bin">
<include name="neptus.jar"/>
</fileset>
</path>
<path id="neptus.run">
<path refid="neptus.libs"/>
<fileset dir="${NeptusDir}/plugins" casesensitive="false">
<include name="**/*.jar"/>
<include name="**/*.zip" />
</fileset>
</path>
<target name="compile">
<delete dir="build"/>
<mkdir dir="build"/>
<javac classpathref="neptus.libs"
srcdir="${PluginSources}"
destdir="build"
includes="**/*.java"
/>
</target>
<target name="createLstFile">
<script language="javascript">
arr = project.getProperty('PluginClasses').split(',');
pluginSrc = project.getProperty('PluginSources');
var fwriter = java.io.FileWriter;
var writer = java.io.BufferedWriter;
var out = new writer(new fwriter(pluginSrc+'/plugins.lst'));
out.write("#Plug-in classes (extracted from plugin.properties):\n");
for (k in arr) {
out.write(arr[k].trim()+"\n");
}
out.close();
</script>
</target>
<target name="jar" depends="compile, createLstFile">
<jar destfile="${PluginName}.jar" basedir="build" includes="**/*">
</jar>
</target>
<target name="deploy" depends="jar">
<description>Generate jar and deploy it to the Neptus plugins dir.</description>
<copy tofile="${NeptusDir}/plugins/${JarFileName}" file="${JarFileName}"/>
</target>
<target name="undeploy">
<description>Remove previously deployed jar from Neptus plugins dir.</description>
<delete file="${NeptusDir}/plugins/${JarFileName}"/>
</target>
<target name="clean">
<delete dir="build"/>
<delete file="${PluginName}.jar"/>
<delete file="${PluginSources}/plugins.lst"/>
</target>
<target name="test" depends="deploy">
<java fork="true" dir="${NeptusDir}" classpathref="neptus.run" classname="pt.lsts.neptus.loader.NeptusMain"/>
</target>
<target name="GenerateEclipseProject">
<script language="javascript"><![CDATA[
importPackage(java.io);
pluginName = project.getProperty('PluginName');
pluginSrc = project.getProperty('PluginSources');
neptusSrc = project.getProperty('NeptusDir');
// Create .project file
var out = new BufferedWriter(new FileWriter(".project"));
out.write('<?xml version="1.0" encoding="UTF-8"?>\n');
out.write('<projectDescription>\n');
out.write(' <name>'+pluginName+'</name>\n');
out.write(' <comment></comment>\n');
out.write(' <projects>\n');
out.write(' </projects>\n');
out.write(' <buildSpec>\n');
out.write(' <buildCommand>\n');
out.write(' <name>org.eclipse.jdt.core.javabuilder</name>\n');
out.write(' <arguments>\n');
out.write(' </arguments>\n');
out.write(' </buildCommand>\n');
out.write(' </buildSpec>\n');
out.write(' <natures>\n');
out.write(' <nature>org.eclipse.jdt.core.javanature</nature>\n');
out.write(' </natures>\n');
out.write('</projectDescription>\n');
out.close();
// Create .classpath file
out = new BufferedWriter(new FileWriter(".classpath"));
out.write('<?xml version="1.0" encoding="UTF-8"?>\n');
out.write('<classpath>\n');
out.write(' <classpathentry kind="src" path="'+pluginSrc+'"/>\n');
out.write(' <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>\n');
out.write(' <classpathentry kind="lib" path="'+neptusSrc+'/bin/neptus.jar"/>\n');
var libDirs = [new File(neptusSrc+'/lib')];
var tmp = new File(neptusSrc+'/lib').listFiles();
for (f in tmp) {
if (tmp[f].isDirectory())
libDirs.push(tmp[f]);
}
for (dir in libDirs) {
var files = libDirs[dir].listFiles();
for (f in files) {
if (files[f].isFile() && files[f].getName().endsWith(".jar"))
out.write(' <classpathentry kind="lib" path="'+files[f]+'"/>\n');
}
}
out.write(' <classpathentry kind="output" path="bin"/>\n');
out.write('</classpath>\n');
out.close();
]]></script>
</target>
</project>