diff --git a/jenkins_jobs/modules/builders.py b/jenkins_jobs/modules/builders.py index 2d61c811c..fbd90962a 100644 --- a/jenkins_jobs/modules/builders.py +++ b/jenkins_jobs/modules/builders.py @@ -1889,21 +1889,21 @@ def grails(parser, xml_parent, data): Plugin `. :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' first (default false) :arg bool non-interactive: append --non-interactive to all build targets (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 - property (optional) + property (default '') :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 - system property (optional) + system property (default '') :arg str base-dir: Specify a path to the root of the Grails - project (optional) - :arg str properties: Additional system properties to set (optional) + project (default '') + :arg str properties: Additional system properties to set (default '') :arg bool plain-output: append --plain-output to all build targets (default false) :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 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 """ grails = XML.SubElement(xml_parent, 'com.g2one.hudson.grails.' 'GrailsBuilder') - XML.SubElement(grails, 'targets').text = data['targets'] - XML.SubElement(grails, 'name').text = data.get( - 'name', '(Default)') - XML.SubElement(grails, 'grailsWorkDir').text = data.get( - 'work-dir', '') - XML.SubElement(grails, 'projectWorkDir').text = data.get( - 'project-dir', '') - XML.SubElement(grails, 'projectBaseDir').text = data.get( - 'base-dir', '') - XML.SubElement(grails, 'serverPort').text = data.get( - 'server-port', '') - XML.SubElement(grails, 'properties').text = data.get( - 'properties', '') - XML.SubElement(grails, 'forceUpgrade').text = str( - data.get('force-upgrade', False)).lower() - XML.SubElement(grails, 'nonInteractive').text = str( - data.get('non-interactive', False)).lower() - XML.SubElement(grails, 'useWrapper').text = str( - data.get('use-wrapper', False)).lower() - 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() + grails.set('plugin', 'grails') + + mappings = [ + ('targets', 'targets', None), + ('name', 'name', '(Default)'), + ('work-dir', 'grailsWorkDir', ''), + ('project-dir', 'projectWorkDir', ''), + ('base-dir', 'projectBaseDir', ''), + ('server-port', 'serverPort', ''), + ('properties', 'properties', ''), + ('force-upgrade', 'forceUpgrade', False), + ('non-interactive', 'nonInteractive', False), + ('use-wrapper', 'useWrapper', False), + ('plain-output', 'plainOutput', False), + ('stack-trace', 'stackTrace', False), + ('verbose', 'verbose', False), + ('refresh-dependencies', 'refreshDependencies', False), + ] + convert_mapping_to_xml(grails, data, mappings, fail_required=True) def sbt(parser, xml_parent, data): diff --git a/tests/builders/fixtures/grails.xml b/tests/builders/fixtures/grails-full.xml similarity index 92% rename from tests/builders/fixtures/grails.xml rename to tests/builders/fixtures/grails-full.xml index e209aff6a..d558d789d 100644 --- a/tests/builders/fixtures/grails.xml +++ b/tests/builders/fixtures/grails-full.xml @@ -1,7 +1,7 @@ - + war ear grails-2.2.2 ./grails-work diff --git a/tests/builders/fixtures/grails-full.yaml b/tests/builders/fixtures/grails-full.yaml new file mode 100644 index 000000000..0b7ef8d94 --- /dev/null +++ b/tests/builders/fixtures/grails-full.yaml @@ -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 diff --git a/tests/builders/fixtures/grails-minimal.xml b/tests/builders/fixtures/grails-minimal.xml new file mode 100644 index 000000000..cc4198251 --- /dev/null +++ b/tests/builders/fixtures/grails-minimal.xml @@ -0,0 +1,21 @@ + + + + + foo + (Default) + + + + + + false + false + false + false + false + false + false + + + diff --git a/tests/builders/fixtures/grails-minimal.yaml b/tests/builders/fixtures/grails-minimal.yaml new file mode 100644 index 000000000..9d888b94f --- /dev/null +++ b/tests/builders/fixtures/grails-minimal.yaml @@ -0,0 +1,3 @@ +builders: + - grails: + targets: foo diff --git a/tests/builders/fixtures/grails.yaml b/tests/builders/fixtures/grails.yaml deleted file mode 100644 index 8cd9be08d..000000000 --- a/tests/builders/fixtures/grails.yaml +++ /dev/null @@ -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"