enable setting of jvm properties from the maven-build command

This commit is contained in:
Mike Bonnet 2008-03-12 18:34:11 -04:00
parent 74547053b8
commit faea981ce3
3 changed files with 41 additions and 11 deletions

View file

@ -588,12 +588,15 @@ class BuildRoot(object):
return packages
def mavenBuild(self, sourcedir, outputdir, repodir, settingsfile):
def mavenBuild(self, sourcedir, outputdir, repodir, settingsfile, props=None):
session.host.setBuildRootState(self.id, 'BUILDING')
rv = self.mock(['--no-clean', '--chroot', '--unpriv', '--cwd', sourcedir[len(self.rootdir()):], '--',
'/usr/bin/mvn', '-s', settingsfile, 'deploy',
'-DaltDeploymentRepository=koji-output::default::file://%s' % outputdir[len(self.rootdir()):]],
skip_setarch=True)
cmd = ['--no-clean', '--chroot', '--unpriv', '--cwd', sourcedir[len(self.rootdir()):], '--',
'/usr/bin/mvn', '-s', settingsfile]
if props:
for name, value in props.items():
cmd.append('-D%s=%s' % (name, value))
cmd.extend(['deploy', '-DaltDeploymentRepository=koji-output::default::file://%s' % outputdir[len(self.rootdir()):]])
rv = self.mock(cmd, skip_setarch=True)
# ignore newly-built archives we find in the repo, we'll import them soon
session.host.updateMavenBuildRootList(self.id, self.getMavenPackageList(repodir),
@ -1910,8 +1913,12 @@ class MavenTask(BaseTaskHandler):
dest_tag = session.getTag(target_info['dest_tag'], strict=True)
build_tag = session.getTag(target_info['build_tag'], strict=True)
build_opts = {}
if opts.get('properties'):
build_opts['properties'] = opts['properties']
self.build_task_id = session.host.subtask(method='buildMaven',
arglist=[url, build_tag],
arglist=[url, build_tag, build_opts],
label='build',
parent=self.id,
arch='noarch')
@ -1986,7 +1993,11 @@ class BuildMavenTask(BaseTaskHandler):
_taskWeight = 1.5
def handler(self, url, build_tag):
def handler(self, url, build_tag, opts=None):
if opts is None:
opts = {}
self.opts = opts
scm = SCM(url)
scm.assert_allowed(options.allowed_scms)
@ -2033,7 +2044,7 @@ class BuildMavenTask(BaseTaskHandler):
settingsfile = '/maven/settings.xml'
buildroot.writeMavenSettings(repodir, settingsfile)
buildroot.mavenBuild(sourcedir, outputdir, repodir, settingsfile)
buildroot.mavenBuild(sourcedir, outputdir, repodir, settingsfile, props=self.opts.get('properties'))
pom_extensions = ['.' + ext for ext in session.getArchiveType(type_name='pom')['extensions'].split()]
jar_extensions = ['.' + ext for ext in session.getArchiveType(type_name='zip')['extensions'].split()]

View file

@ -796,6 +796,9 @@ def handle_maven_build(options, session, args):
help=_("Do not display progress of the upload"))
parser.add_option("--background", action="store_true",
help=_("Run the build at a lower priority"))
parser.add_option("--property", action="append",
dest="properties", metavar="NAME=VALUE", default=[],
help=_("Pass a system property to the Maven build"))
(build_opts, args) = parser.parse_args(args)
if len(args) != 2:
parser.error(_("Exactly two arguments (a build target and a SCM URL) are required"))
@ -817,6 +820,15 @@ def handle_maven_build(options, session, args):
opts = {}
for key in ('skip_tag', 'scratch', 'specfile'):
opts[key] = getattr(build_opts, key)
props = {}
for prop in build_opts.properties:
fields = prop.split('=', 1)
if len(fields) != 2:
parser.error(_("Properties must be in name=value format"))
assert False
props[fields[0]] = fields[1]
if props:
opts['properties'] = props
priority = None
if build_opts.background:
#relative to koji.PRIO_DEFAULT

View file

@ -6,8 +6,12 @@
#def printValue($key, $value, $sep=', ')
#if $key in ('brootid', 'buildroot_id')
<a href="buildrootinfo?buildrootID=$value">$value</a>
#else
#if $isinstance($value, list) then $sep.join([$str($val) for $val in $value]) else $value#
#elif $isinstance($value, list)
$sep.join([$str($val) for $val in $value])
#elif $isinstance($value, dict)
$sep.join(['%s=%s' % ($n, $v) for $n, $v in $value.items()])
#else
$value
#end if
#end def
@ -109,7 +113,10 @@
$printOpts($params[2])
#elif $task.method == 'buildMaven'
<strong>SCM URL:</strong> $params[0]<br/>
<strong>Build Tag:</strong> <a href="taginfo?tagID=$buildTag.id">$buildTag.name</a>
<strong>Build Tag:</strong> <a href="taginfo?tagID=$buildTag.id">$buildTag.name</a><br/>
#if $len($params) > 2
$printOpts($params[2])
#end if
#elif $task.method == 'wrapperRPM'
<strong>Spec File URL:</strong> $params[0]<br/>
<strong>Build Tag:</strong> <a href="taginfo?tagID=$buildTag.id">$buildTag.name</a><br/>