-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-common.xml
142 lines (131 loc) · 6.11 KB
/
build-common.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
<!--
~ Copyright (c) 2010-2011 Christopher Cormack
~
~ Permission is hereby granted, free of charge, to any person obtaining a copy
~ of this software and associated documentation files (the "Software"), to deal
~ in the Software without restriction, including without limitation the rights
~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
~ copies of the Software, and to permit persons to whom the Software is
~ furnished to do so, subject to the following conditions:
~
~ The above copyright notice and this permission notice shall be included in
~ all copies or substantial portions of the Software.
~
~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
~ THE SOFTWARE.
-->
<project name="nk4-ant-common">
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath>
<pathelement location="${nk4-ant-suite}/lib/ant-contrib-1.0b3.jar" />
</classpath>
</taskdef>
<property name="repository.address" value="127.0.0.1"/>
<property name="repository.port" value="8039"/>
<property name="push.repository" value="devel"/>
<macrodef name="publish-package">
<attribute name="package.name"/>
<attribute name="package.version"/>
<attribute name="package.location"/>
<sequential>
<sshexec host="${repository.address}"
port="${repository.port}"
username="${user.name}"
keyfile="${user.home}/.ssh/id_rsa"
trust="true"
command="repositoryServer:sshd:version:exists+package@data:text/plain,@{package.name}+version@data:text/plain,@{package.version}"
outputproperty="@{package.name}-is-published-unclean"/>
<propertyregex property="@{package.name}-is-published"
input="${@{package.name}-is-published-unclean}"
regexp="([a-z0-9_]*).*"
select="\1"/>
<if>
<equals arg1="${@{package.name}-is-published}" arg2="true" />
<then>
<echo>@{package.name} @{package.version} is already published on ${repository.address}</echo>
</then>
<elseif>
<equals arg1="${repository.publish}" arg2="true"/>
<then>
<echo>Publishing @{package.name} @{package.version} to ${repository.address}</echo>
<scp port="${repository.port}"
keyfile="${user.home}/.ssh/id_rsa"
trust="true"
file="@{package.location}"
todir="${user.name}@${repository.address}:repositoryServer:sshd:version:upload+package@data:text/plain,@{package.name}+version@data:text/plain,@{package.version}"/>
</then>
</elseif>
<else>
<echo>@{package.name} @{package.version} is not published on ${repository.address}, skipping as $${repository.publish} is not set to 'true'</echo>
</else>
</if>
</sequential>
</macrodef>
<macrodef name="push-package">
<attribute name="package.name"/>
<attribute name="package.version"/>
<sequential>
<sshexec host="${repository.address}"
port="${repository.port}"
username="${user.name}"
keyfile="${user.home}/.ssh/id_rsa"
trust="true"
command="repositoryServer:sshd:version:publish:exists+package@data:text/plain,@{package.name}+version@data:text/plain,@{package.version}+repository@data:text/plain,${push.repository}"
outputproperty="@{package.name}-is-pushed-unclean"/>
<propertyregex property="@{package.name}-is-pushed"
input="${@{package.name}-is-pushed-unclean}"
regexp="([a-z0-9_]*).*"
select="\1"/>
<if>
<equals arg1="${@{package.name}-is-pushed}" arg2="true" />
<then>
<echo>@{package.name} @{package.version} has already been pushed to ${push.repository} on ${repository.address}</echo>
</then>
<elseif>
<equals arg1="${@{package.name}-is-pushed}" arg2="version_does_not_exist"/>
<then>
<echo>@{package.name} @{package.version} cannot be pushed to ${push.repository} on ${repository.address} as it has not been published</echo>
</then>
</elseif>
<elseif>
<equals arg1="${repository.push}" arg2="true"/>
<then>
<echo>Pushing @{package.name} @{package.version} to ${push.repository} on ${repository.address}</echo>
<sshexec host="${repository.address}"
port="${repository.port}"
username="${user.name}"
keyfile="${user.home}/.ssh/id_rsa"
trust="true"
command="repositoryServer:sshd:version:publish+package@data:text/plain,@{package.name}+version@data:text/plain,@{package.version}+repository@data:text/plain,${push.repository}"/>
</then>
</elseif>
<else>
<echo>@{package.name} @{package.version} has not been pushed to ${push.repository} on ${repository.address}, skipping as $${repository.push} is not set to 'true'</echo>
</else>
</if>
</sequential>
</macrodef>
<macrodef name="set-version-number">
<attribute name="srcmodulefile"/>
<attribute name="destmodulefile"/>
<attribute name="version"/>
<sequential>
<xslt classpathref="nk4.anttools.path"
in="@{srcmodulefile}"
out="@{destmodulefile}"
force="true">
<sysproperty key="javax.xml.transform.TransformerFactory"
value="net.sf.saxon.TransformerFactoryImpl"/>
<style>
<javaresource classpathref="nk4.anttools.path" name="set-module-version.xsl"/>
</style>
<param name="version" expression="@{version}"/>
</xslt>
</sequential>
</macrodef>
</project>