Skip to content

Commit a4f1971

Browse files
committed
Make waf use maven for building (build target and install targets are working)
1 parent 3054537 commit a4f1971

2 files changed

Lines changed: 36 additions & 17 deletions

File tree

wscript

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,26 @@ def runant(tsk):
307307
return ret
308308
Utils.runant = runant
309309

310+
def runmvn(tsk):
311+
environ = dict(os.environ)
312+
environ["CATALINA_HOME"] = tsk.env.TOMCATHOME
313+
if not "M2_HOME" in environ:
314+
raise Utils.WafError("Maven not installed or M2_HOME not set")
315+
if tsk.generator.env.DISTRO == "Windows":
316+
stanzas = [
317+
_join(environ["M2_HOME"],"bin","mvn.bat")
318+
]
319+
else:
320+
stanzas = [
321+
_join(environ["M2_HOME"],"bin","mvn")
322+
]
323+
#stanzas += tsk.generator.mvnargs
324+
ret = Utils.exec_command(" ".join(stanzas),cwd=tsk.generator.bld.srcnode.abspath(),env=environ,log=True)
325+
if ret != 0: raise Utils.WafError("Maven phase %s failed with error value %s"%(stanzas,ret))
326+
return ret
327+
Utils.runmvn = runmvn
328+
329+
310330
@throws_command_errors
311331
def run_java(classname,classpath,options=None,arguments=None):
312332
if not options: options = []

wscript_build

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -105,31 +105,30 @@ def build_jars ():
105105
Implementation_Version = bld.env.VERSION
106106

107107
# this is to trigger recompilation / cache avoidance if the relevant environment for ant changes
108-
ant_args = [
109-
"build-all",
108+
mvn_args = [
109+
"package",
110110
"-Dimpl.version=%s" % Implementation_Version,
111111
"-Dtarget.dir=%s" % targetdir,
112112
"-Ddist.dir=%s" % distdir,
113-
"-Dbase.dir=%s" % sourcedir,
114-
"-f %s" % Utils.relpath (_join(sourcedir, "build.xml")),
113+
"-Dbase.dir=%s" % sourcedir
115114
]
116115

117116
if buildpremium:
118-
ant_args.append("-Dbuild.premium=true")
117+
mvn_args.append("-Dbuild.premium=true")
119118

120119
tgen = bld(features='subst', name='version-info', source="version-info.in", target="version-info")
121-
tgen.dict = { "Implementation_Version":Implementation_Version,"ant_args":ant_args }
120+
tgen.dict = { "Implementation_Version":Implementation_Version,"mvn_args":mvn_args }
122121
bld.install_files("${DOCDIR}","version-info")
123122

124123
bld.srcnode.ensure_dir_node_from_path("target/jar")
125124
bld.srcnode.ensure_dir_node_from_path("dist")
126125

127-
tgen = bld.new_task_gen (rule = Utils.runant,
128-
name = "runant",
129-
antargs = ant_args)
126+
tgen = bld.new_task_gen (rule = Utils.runmvn,
127+
name = "runmvn",
128+
mvnargs = mvn_args)
130129

131-
jarnode = bld.srcnode.find_dir ('target/jar')
132-
jars_str = jarnode.ant_glob ('*.jar').split ()
130+
jarnode = bld.srcnode.find_dir ('.')
131+
jars_str = jarnode.ant_glob ('**/target/*.jar').split ()
133132
ant_jars = []
134133
excludes = ["cloud-xstream-1.3.1.jar", "cloud-commons-dbcp-1.2.2.jar",
135134
"cloud-commons-httpclient-3.1.jar", "cloud-commons-pool-1.4.jar",
@@ -146,7 +145,6 @@ def build_jars ():
146145

147146
bld.install_files ('${JAVADIR}', ant_jars)
148147

149-
150148
def build_premium ():
151149
if buildpremium: bld.recurse(["cloudstack-proprietary/"],'build')
152150

@@ -201,9 +199,9 @@ def build_patches ():
201199
def build_systemvm_patch ():
202200
if bld.env.DISTRO not in ["Windows","Mac"]:
203201
# patch creation
204-
bld.install_files ("${AGENTLIBDIR}/vms", "%s/systemvm.zip" % distdir)
202+
bld.install_files ("${AGENTLIBDIR}/vms", "console-proxy/dist/systemvm.zip" )
205203
# ISO creation
206-
bld.install_as("${AGENTLIBDIR}/vms/systemvm.iso", "%s/systemvm.iso" % distdir)
204+
bld.install_as("${AGENTLIBDIR}/vms/systemvm.iso", "console-proxy/dist/systemvm.iso" )
207205

208206
def build_systemvm_iso ():
209207
if buildpremium:
@@ -361,13 +359,14 @@ def build_xml_api_description ():
361359
relationship = Utils.relpath(sourcedir,os.getcwd())
362360
cp = [ _join(relationship,x) for x in task.generator.env.CLASSPATH.split(pathsep) ]
363361

364-
jarnames = ['utils','server','core', 'api', 'server-extras']
362+
jarnames = ['utils','server','core', 'api']
365363
props = ["client/tomcatconf/commands.properties.in"]
366364

367365
sources = []
368366
for i in jarnames:
369-
str = 'target/jar/cloud-%s.jar' % i
370-
sources.append (str)
367+
str = _glob("../%s/target/*jar" % i )
368+
for j in str:
369+
sources.append ("%s/target/%s" % (i, os.path.basename(j)))
371370
sources.append ("client/tomcatconf/commands.properties.in")
372371
if buildpremium:
373372
sources.append("client/tomcatconf/commands-ext.properties.in")

0 commit comments

Comments
 (0)