Update Grails plugin to use convert xml

- Update docs of options to have default values
- Add minimal test

Change-Id: I8c542bfa42cc568b127eca6737deaf13c3ae0652
Signed-off-by: Kien Ha <kienha9922@gmail.com>
This commit is contained in:
Kien Ha 2016-07-06 18:28:31 -04:00
parent 6fd2b0a433
commit 5deb204c5f
6 changed files with 74 additions and 53 deletions

View File

@ -1889,21 +1889,21 @@ def grails(parser, xml_parent, data):
Plugin <Grails+Plugin>`. Plugin <Grails+Plugin>`.
:arg bool use-wrapper: Use a grails wrapper (default false) :arg bool use-wrapper: Use a grails wrapper (default false)
:arg str name: Select a grails installation to use (optional) :arg str name: Select a grails installation to use (default '(Default)')
:arg bool force-upgrade: Run 'grails upgrade --non-interactive' :arg bool force-upgrade: Run 'grails upgrade --non-interactive'
first (default false) first (default false)
:arg bool non-interactive: append --non-interactive to all build targets :arg bool non-interactive: append --non-interactive to all build targets
(default false) (default false)
:arg str targets: Specify target(s) to run separated by spaces :arg str targets: Specify target(s) to run separated by spaces (required)
:arg str server-port: Specify a value for the server.port system :arg str server-port: Specify a value for the server.port system
property (optional) property (default '')
:arg str work-dir: Specify a value for the grails.work.dir system :arg str work-dir: Specify a value for the grails.work.dir system
property (optional) property (default '')
:arg str project-dir: Specify a value for the grails.project.work.dir :arg str project-dir: Specify a value for the grails.project.work.dir
system property (optional) system property (default '')
:arg str base-dir: Specify a path to the root of the Grails :arg str base-dir: Specify a path to the root of the Grails
project (optional) project (default '')
:arg str properties: Additional system properties to set (optional) :arg str properties: Additional system properties to set (default '')
:arg bool plain-output: append --plain-output to all build targets :arg bool plain-output: append --plain-output to all build targets
(default false) (default false)
:arg bool stack-trace: append --stack-trace to all build targets :arg bool stack-trace: append --stack-trace to all build targets
@ -1913,40 +1913,37 @@ def grails(parser, xml_parent, data):
:arg bool refresh-dependencies: append --refresh-dependencies to all :arg bool refresh-dependencies: append --refresh-dependencies to all
build targets (default false) build targets (default false)
Example: Full Example:
.. literalinclude:: ../../tests/builders/fixtures/grails.yaml .. literalinclude:: ../../tests/builders/fixtures/grails-full.yaml
:language: yaml
Minimal Example:
.. literalinclude:: ../../tests/builders/fixtures/grails-minimal.yaml
:language: yaml :language: yaml
""" """
grails = XML.SubElement(xml_parent, 'com.g2one.hudson.grails.' grails = XML.SubElement(xml_parent, 'com.g2one.hudson.grails.'
'GrailsBuilder') 'GrailsBuilder')
XML.SubElement(grails, 'targets').text = data['targets'] grails.set('plugin', 'grails')
XML.SubElement(grails, 'name').text = data.get(
'name', '(Default)') mappings = [
XML.SubElement(grails, 'grailsWorkDir').text = data.get( ('targets', 'targets', None),
'work-dir', '') ('name', 'name', '(Default)'),
XML.SubElement(grails, 'projectWorkDir').text = data.get( ('work-dir', 'grailsWorkDir', ''),
'project-dir', '') ('project-dir', 'projectWorkDir', ''),
XML.SubElement(grails, 'projectBaseDir').text = data.get( ('base-dir', 'projectBaseDir', ''),
'base-dir', '') ('server-port', 'serverPort', ''),
XML.SubElement(grails, 'serverPort').text = data.get( ('properties', 'properties', ''),
'server-port', '') ('force-upgrade', 'forceUpgrade', False),
XML.SubElement(grails, 'properties').text = data.get( ('non-interactive', 'nonInteractive', False),
'properties', '') ('use-wrapper', 'useWrapper', False),
XML.SubElement(grails, 'forceUpgrade').text = str( ('plain-output', 'plainOutput', False),
data.get('force-upgrade', False)).lower() ('stack-trace', 'stackTrace', False),
XML.SubElement(grails, 'nonInteractive').text = str( ('verbose', 'verbose', False),
data.get('non-interactive', False)).lower() ('refresh-dependencies', 'refreshDependencies', False),
XML.SubElement(grails, 'useWrapper').text = str( ]
data.get('use-wrapper', False)).lower() convert_mapping_to_xml(grails, data, mappings, fail_required=True)
XML.SubElement(grails, 'plainOutput').text = str(
data.get('plain-output', False)).lower()
XML.SubElement(grails, 'stackTrace').text = str(
data.get('stack-trace', False)).lower()
XML.SubElement(grails, 'verbose').text = str(
data.get('verbose', False)).lower()
XML.SubElement(grails, 'refreshDependencies').text = str(
data.get('refresh-dependencies', False)).lower()
def sbt(parser, xml_parent, data): def sbt(parser, xml_parent, data):

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<project> <project>
<builders> <builders>
<com.g2one.hudson.grails.GrailsBuilder> <com.g2one.hudson.grails.GrailsBuilder plugin="grails">
<targets>war ear</targets> <targets>war ear</targets>
<name>grails-2.2.2</name> <name>grails-2.2.2</name>
<grailsWorkDir>./grails-work</grailsWorkDir> <grailsWorkDir>./grails-work</grailsWorkDir>

View File

@ -0,0 +1,16 @@
builders:
- grails:
use-wrapper: true
name: grails-2.2.2
force-upgrade: true
non-interactive: true
targets: war ear
server-port: 8003
work-dir: ./grails-work
project-dir: ./project-work
base-dir: ./grails/project
properties: program.name=foo
plain-output: true
stack-trace: true
verbose: true
refresh-dependencies: true

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<builders>
<com.g2one.hudson.grails.GrailsBuilder plugin="grails">
<targets>foo</targets>
<name>(Default)</name>
<grailsWorkDir/>
<projectWorkDir/>
<projectBaseDir/>
<serverPort/>
<properties/>
<forceUpgrade>false</forceUpgrade>
<nonInteractive>false</nonInteractive>
<useWrapper>false</useWrapper>
<plainOutput>false</plainOutput>
<stackTrace>false</stackTrace>
<verbose>false</verbose>
<refreshDependencies>false</refreshDependencies>
</com.g2one.hudson.grails.GrailsBuilder>
</builders>
</project>

View File

@ -0,0 +1,3 @@
builders:
- grails:
targets: foo

View File

@ -1,16 +0,0 @@
builders:
- grails:
use-wrapper: "true"
name: "grails-2.2.2"
force-upgrade: "true"
non-interactive: "true"
targets: "war ear"
server-port: "8003"
work-dir: "./grails-work"
project-dir: "./project-work"
base-dir: "./grails/project"
properties: "program.name=foo"
plain-output: "true"
stack-trace: "true"
verbose: "true"
refresh-dependencies: "true"