-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild-package.xml
More file actions
53 lines (47 loc) · 2.12 KB
/
Copy pathbuild-package.xml
File metadata and controls
53 lines (47 loc) · 2.12 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
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:ivy="antlib:org.apache.ivy.ant">
<!-- A little macro we can use to jar a target directory up -->
<macrodef name="macro.package" >
<attribute name="directory"/>
<attribute name="filelabel"/>
<sequential>
<jar destfile="${targetdir}/publish/${ivy.module}@{filelabel}-${ivy.revision}-bin.jar"
basedir="${targetdir}/compile/@{directory}"
excludes="**/*.java"/>
<zip destfile="${targetdir}/publish/${ivy.module}@{filelabel}-${ivy.revision}-src.zip"
basedir="${sourcedir}/@{directory}"/>
</sequential>
</macrodef>
<!-- Use JavaScript to JAR up each directory individually -->
<target name="package"
depends="compile"
unless="task.executed.package"
description="Prepare JAR archives for each compiled source directory">
<property name="task.executed.package" value="true"/>
<!-- Make some room for our publishing directory -->
<mkdir dir="${targetdir}/publish"/>
<!-- Jar binaries and Zip sources using the macro above -->
<script language="javascript">
<![CDATA[
importClass(java.io.File);
// Create a dirset and get the public conf directories from /target/compile
var targetDir = project.getProperty('targetdir');
var dirSet = project.createDataType('dirset');
var configurations = project.getProperty('ivy.public.configurations');
dirSet.setDir(new File(targetDir + '/compile'));
dirSet.setIncludes(configurations);
var scanner = dirSet.getDirectoryScanner(project);
var directories = scanner.getIncludedDirectories();
// Using our macro, package up each directory individually
var task = project.createTask('macro.package');
for (var x = 0; x < directories.length; x ++) {
var directory = directories[x];
var filelabel = directory == 'default' ? '' : '-' + directory;
task.setDynamicAttribute('directory', directory);
task.setDynamicAttribute('filelabel', filelabel);
task.perform();
}
]]>
</script>
</target>
</project>