-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.xml
More file actions
156 lines (141 loc) · 5.61 KB
/
build.xml
File metadata and controls
156 lines (141 loc) · 5.61 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
<project name="plugins" default="package" basedir=".">
<property environment="env"/>
<fail message="Environment variable QUICKBUILD_HOME need to be defined to point to QuickBuild installation directory."
unless="env.QUICKBUILD_HOME"/>
<available file="${env.QUICKBUILD_HOME}/framework" property="quickbuildHome.correct"/>
<fail message="Please make sure environment variable QUICKBUILD_HOME is pointing to the correct QuickBuild installation directory (the directory containing sub folders such as "bin", "conf", "framework", etc)." unless="quickbuildHome.correct"/>
<target name="package">
<mkdir dir="stage"/>
<unzip dest="stage/jars">
<fileset dir="${env.QUICKBUILD_HOME}/plugins" includes="*.jar"/>
<patternset>
<include name="**/*.jar"/>
</patternset>
</unzip>
<taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy">
<classpath>
<fileset dir="stage/jars" includes="**/groovy*.jar"/>
</classpath>
</taskdef>
<groovy>
def pluginDependencies = new HashMap()
def pluginDirs = new HashMap()
def pluginVersions = new HashMap()
for (each in new File(properties["basedir"]).listFiles()) {
def manifestFile = new File(each, "META-INF/MANIFEST.MF")
if (manifestFile.exists()) {
def attrs
manifestFile.withInputStream {
stream -> attrs = new java.util.jar.Manifest(stream).getMainAttributes()
}
def pluginId = attrs.getValue("Bundle-SymbolicName")
if (pluginId != null)
if (pluginId.trim().length() != 0) {
def pos = pluginId.indexOf(';')
if (pos != -1)
pluginId = pluginId.substring(0, pos)
pluginDirs.put(pluginId, each)
pluginVersions.put(pluginId, attrs.getValue("Bundle-Version"))
def dependencies = new HashSet()
if (new File(each, "build.properties").exists()) {
String required = attrs.getValue("Require-Bundle")
if (required != null) {
for (partial in required.split(",")) {
partial = partial.trim()
if (partial.length() == 0)
continue;
pos = partial.indexOf(';')
if (pos != -1)
partial = partial.substring(0, pos).trim()
dependencies.add(partial);
}
}
}
pluginDependencies.put(pluginId, dependencies)
}
}
}
for (pluginId in pluginDependencies.keySet()) {
def nonExistants = new ArrayList()
for (dependency in pluginDependencies.get(pluginId)) {
if (!pluginDependencies.containsKey(dependency))
nonExistants.add(dependency)
}
pluginDependencies.get(pluginId).removeAll(nonExistants)
}
def sortedPlugins = new ArrayList()
def dependencyIds = new HashMap()
for (entry in pluginDependencies.entrySet())
dependencyIds.put(entry.getKey(), new HashSet(entry.getValue()))
while (!dependencyIds.isEmpty()) {
Set leafs = new HashSet()
for (key in dependencyIds.keySet()) {
if (dependencyIds.get(key).isEmpty()) {
leafs.add(key)
sortedPlugins.add(key)
}
}
if (leafs.isEmpty()) {
Set unprocessed = new HashSet()
for (id in dependencyIds.keySet())
unprocessed.add(id);
throw new RuntimeException("Unable to process dependencies: " + unprocessed
+ ". This is either because circular exists in these dependencies, or because "
+ "some of these dependencies depends on non-existent dependencies.")
}
for (key in leafs)
dependencyIds.remove(key)
for (value in dependencyIds.values())
value.removeAll(leafs)
}
for (pluginId in sortedPlugins) {
properties["pluginDir"] = pluginDirs.get(pluginId).name
if (new File(pluginDirs.get(pluginId), "build.properties").exists()) {
ant.project.executeTarget("stage.plugin")
if (new File(pluginDirs.get(pluginId), "src").exists())
ant.project.executeTarget("compile.plugin")
properties["pluginId"] = pluginId
properties["pluginVersion"] = pluginVersions.get(pluginId)
ant.project.executeTarget("jar.plugin")
}
}
</groovy>
</target>
<target name="stage.plugin">
<mkdir dir="stage/plugins/${pluginDir}"/>
<copy todir="stage/plugins/${pluginDir}">
<fileset dir="${pluginDir}" excludes=".project, .classpath, build.properties, .settings/**,
src/**, bin/**, test/**, test-src/**, test-out/**, testout/**, testbin/**, test-bin/**,
test-result/**, **/*.java, **/*.class"/>
</copy>
<copy todir="stage/jars" flatten="true">
<fileset dir="stage/plugins/${pluginDir}" includes="**/*.jar"/>
</copy>
</target>
<target name="compile.plugin">
<javac destdir="stage/plugins/${pluginDir}" debug="on" source="1.6" target="1.6" includeAntRuntime="false">
<src path="${pluginDir}/src"/>
<classpath>
<fileset dir="stage/jars" includes="**/*.jar"/>
<fileset dir="${env.QUICKBUILD_HOME}/plugins" includes="**/*.jar"/>
<pathelement location="stage/classes"/>
<pathelement location="${env.QUICKBUILD_HOME}/plugins/com.pmease.quickbuild.bootstrap"/>
</classpath>
</javac>
<copy todir="stage/plugins/${pluginDir}">
<fileset dir="${pluginDir}/src" excludes="**/*.java"/>
</copy>
<copy todir="stage/classes">
<fileset dir="stage/plugins/${pluginDir}" includes="**/*.class"/>
</copy>
</target>
<target name="jar.plugin">
<jar destfile="stage/plugins/${pluginId}_${pluginVersion}.jar" manifest="stage/plugins/${pluginDir}/META-INF/MANIFEST.MF">
<fileset dir="stage/plugins/${pluginDir}"/>
</jar>
<delete dir="stage/plugins/${pluginDir}"/>
</target>
<target name="clean">
<delete dir="stage"/>
</target>
</project>