Update Gradle plugin to use convert_mapping_to_xml function

Change-Id: Ice59a5c42c47690c3b0fcf5a37c63bd9e99bae1f
Signed-off-by: Umesh Singla <umeshksingla@gmail.com>
This commit is contained in:
Umesh Singla 2017-01-04 03:58:53 +05:30
parent ce758e2dd0
commit d7a205be81
3 changed files with 20 additions and 17 deletions

View File

@ -1044,7 +1044,7 @@ def gradle(registry, xml_parent, data):
<Gradle+Plugin>`. <Gradle+Plugin>`.
:arg str tasks: List of tasks to execute :arg str tasks: List of tasks to execute
:arg str gradle-name: Use a custom gradle name (optional) :arg str gradle-name: Use a custom gradle name (default '')
:arg bool wrapper: use gradle wrapper (default false) :arg bool wrapper: use gradle wrapper (default false)
:arg bool executable: make gradlew executable (default false) :arg bool executable: make gradlew executable (default false)
:arg list switches: Switches for gradle, can have multiples :arg list switches: Switches for gradle, can have multiples
@ -1055,6 +1055,7 @@ def gradle(registry, xml_parent, data):
root directory, specify the path (relative to the module root directory, specify the path (relative to the module
root) here, such as ${workspace}/parent/ instead of just root) here, such as ${workspace}/parent/ instead of just
${workspace}. ${workspace}.
:arg str build-file: name of gradle build script (default 'build.gradle')
Example: Example:
@ -1062,21 +1063,22 @@ def gradle(registry, xml_parent, data):
:language: yaml :language: yaml
""" """
gradle = XML.SubElement(xml_parent, 'hudson.plugins.gradle.Gradle') gradle = XML.SubElement(xml_parent, 'hudson.plugins.gradle.Gradle')
XML.SubElement(gradle, 'description').text = '' XML.SubElement(gradle, 'description').text = ''
XML.SubElement(gradle, 'tasks').text = data['tasks']
XML.SubElement(gradle, 'buildFile').text = '' mappings = [
XML.SubElement(gradle, 'rootBuildScriptDir').text = data.get( ('build-file', 'buildFile', 'build.gradle'),
'root-build-script-dir', '') ('tasks', 'tasks', None),
XML.SubElement(gradle, 'gradleName').text = data.get( ('root-build-script-dir', 'rootBuildScriptDir', ''),
'gradle-name', '') ('gradle-name', 'gradleName', ''),
XML.SubElement(gradle, 'useWrapper').text = str(data.get( ('wrapper', 'useWrapper', False),
'wrapper', False)).lower() ('executable', 'makeExecutable', False),
XML.SubElement(gradle, 'makeExecutable').text = str(data.get( ('use-root-dir', 'fromRootBuildScriptDir', False),
'executable', False)).lower() ]
switch_string = '\n'.join(data.get('switches', [])) convert_mapping_to_xml(gradle, data, mappings, fail_required=True)
XML.SubElement(gradle, 'switches').text = switch_string
XML.SubElement(gradle, 'fromRootBuildScriptDir').text = str(data.get( XML.SubElement(gradle, 'switches').text = '\n'.join(
'use-root-dir', False)).lower() data.get('switches', []))
def _groovy_common_scriptSource(data): def _groovy_common_scriptSource(data):

View File

@ -3,18 +3,18 @@
<builders> <builders>
<hudson.plugins.gradle.Gradle> <hudson.plugins.gradle.Gradle>
<description/> <description/>
<buildFile>build.gradle</buildFile>
<tasks>init <tasks>init
build build
tests tests
</tasks> </tasks>
<buildFile/>
<rootBuildScriptDir>${workspace}/tests</rootBuildScriptDir> <rootBuildScriptDir>${workspace}/tests</rootBuildScriptDir>
<gradleName>gradle-1.2</gradleName> <gradleName>gradle-1.2</gradleName>
<useWrapper>true</useWrapper> <useWrapper>true</useWrapper>
<makeExecutable>true</makeExecutable> <makeExecutable>true</makeExecutable>
<fromRootBuildScriptDir>true</fromRootBuildScriptDir>
<switches>-g /foo/bar/.gradle <switches>-g /foo/bar/.gradle
-PmavenUserName=foobar</switches> -PmavenUserName=foobar</switches>
<fromRootBuildScriptDir>true</fromRootBuildScriptDir>
</hudson.plugins.gradle.Gradle> </hudson.plugins.gradle.Gradle>
</builders> </builders>
</project> </project>

View File

@ -1,5 +1,6 @@
builders: builders:
- gradle: - gradle:
build-file: "build.gradle"
gradle-name: "gradle-1.2" gradle-name: "gradle-1.2"
wrapper: true wrapper: true
executable: true executable: true