forked from LSTS/neptus-plugin-skeleton
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
175 lines (152 loc) · 5.51 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
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
<?xml version="1.0" encoding="UTF-8"?>
<project name="Neptus Plugin" default="jar">
<loadproperties srcfile="plugin.properties"/>
<property name="resources.copied" value="**/*.xml,**/*.properties,**/*.res,images/**/*.*,models/**/*.*,schemas/**/*.xsd,**/*.png,**/*.jpg,**/*.gif"/>
<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>
<path id="build.classpath">
<fileset dir="${PluginSources}/lib">
<include name="**/*.jar"/>
<include name="**/*.zip"/>
</fileset>
</path>
<property name="plugin.libs" refid="build.classpath" />
<target name="compile">
<delete dir="build"/>
<mkdir dir="build"/>
<javac includeantruntime="false" classpathref="neptus.libs"
srcdir="${PluginSources}"
destdir="build"
includes="**/*.java"
>
<classpath refid="build.classpath"/>
</javac>
</target>
<target name="createLstFile">
<script language="javascript">
load("nashorn:mozilla_compat.js");
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('build/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">
<script language="javascript">
load("nashorn:mozilla_compat.js");
jarList = project.getProperty("plugin.libs");
if (!"".equals(jarList)) {
if (project.getProperty("os.name").toLowerCase().contains("windows"))
libs = jarList.split(";");
else
libs = jarList.split(":");
for (index in libs) {
unzip = project.createTask("unzip");
unzip.setDest(new java.io.File("build"));
unzip.setSrc(new java.io.File(libs[index]));
unzip.perform();
}
}
</script>
<copy todir="build" overwrite="true">
<fileset dir="${PluginSources}" excludes="${exclude-defaults},**/Thumbs.db,**/thumbs.db"
includes="${resources.copied}" />
</copy>
<jar destfile="${PluginName}.jar" basedir="build" includes="**/*">
</jar>
<copy todir="${NeptusDir}/conf" overwrite="true">
<fileset dir="${PluginSources}/conf">
<include name="**/*"/>
</fileset>
</copy>
</target>
<target name="deploy" depends="jar">
<description>Generate jar and deploy it to the Neptus plugins dir.</description>
<copy tofile="${NeptusDir}/plugins/${PluginName}.jar" file="${PluginName}.jar" />
</target>
<target name="undeploy">
<description>Remove previously deployed jar from Neptus plugins dir.</description>
<delete file="${NeptusDir}/plugins/${JarFileName}"/>
<delete dir="${NeptusDir}/conf/${PluginName}" />
</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[
load("nashorn:mozilla_compat.js");
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>