Compatibility support for older maven project plugins
Enable testing of project modules to receive plugin info and ensure that versions of the Maven project plugin older than 2.0.1 continue to receive the required XML setting. Change-Id: I2669052d0ef31c0b766e9cde24c842136c172b6c
This commit is contained in:
parent
1ad790ff13
commit
bafc09598f
@ -43,6 +43,8 @@ in the :ref:`Job` definition.
|
||||
documentation artifact archiving (default true).
|
||||
* **automatic-fingerprinting** (`bool`): Activate automatic fingerprinting
|
||||
of consumed and produced artifacts (default true).
|
||||
* **per-module-email** (`bool`): Send an e-mail for each failed module
|
||||
(default true).
|
||||
* **parallel-build-modules** (`bool`): Build modules in parallel
|
||||
(default false)
|
||||
* **resolve-dependencies** (`bool`): Resolve Dependencies during Pom
|
||||
@ -78,7 +80,7 @@ CFP Example:
|
||||
|
||||
.. literalinclude:: /../../tests/general/fixtures/project-maven003.yaml
|
||||
"""
|
||||
|
||||
import pkg_resources
|
||||
import xml.etree.ElementTree as XML
|
||||
|
||||
from jenkins_jobs.errors import InvalidAttributeError
|
||||
@ -103,6 +105,11 @@ class Maven(jenkins_jobs.modules.base.Base):
|
||||
xml_parent = XML.Element('maven2-moduleset')
|
||||
if 'maven' not in data:
|
||||
return xml_parent
|
||||
|
||||
# determine version of plugin
|
||||
plugin_info = self.registry.get_plugin_info("Maven Integration plugin")
|
||||
version = pkg_resources.parse_version(plugin_info.get('version', '0'))
|
||||
|
||||
if 'root-module' in data['maven']:
|
||||
root_module = XML.SubElement(xml_parent, 'rootModule')
|
||||
XML.SubElement(root_module, 'groupId').text = \
|
||||
@ -144,6 +151,10 @@ class Maven(jenkins_jobs.modules.base.Base):
|
||||
not data['maven'].get('automatic-site-archiving', True)).lower()
|
||||
XML.SubElement(xml_parent, 'fingerprintingDisabled').text = str(
|
||||
not data['maven'].get('automatic-fingerprinting', True)).lower()
|
||||
if (version > pkg_resources.parse_version('0') and
|
||||
version < pkg_resources.parse_version('2.0.1')):
|
||||
XML.SubElement(xml_parent, 'perModuleEmail').text = str(
|
||||
data.get('per-module-email', True)).lower()
|
||||
XML.SubElement(xml_parent, 'archivingDisabled').text = str(
|
||||
not data['maven'].get('automatic-archiving', True)).lower()
|
||||
XML.SubElement(xml_parent, 'resolveDependencies').text = str(
|
||||
|
@ -146,23 +146,6 @@ class BaseTestCase(LoggingFixture):
|
||||
|
||||
expected_xml = self._read_utf8_content()
|
||||
yaml_content = self._read_yaml_content(self.in_filename)
|
||||
project = None
|
||||
if ('project-type' in yaml_content):
|
||||
if (yaml_content['project-type'] == "maven"):
|
||||
project = project_maven.Maven(None)
|
||||
elif (yaml_content['project-type'] == "matrix"):
|
||||
project = project_matrix.Matrix(None)
|
||||
elif (yaml_content['project-type'] == "flow"):
|
||||
project = project_flow.Flow(None)
|
||||
elif (yaml_content['project-type'] == "multijob"):
|
||||
project = project_multijob.MultiJob(None)
|
||||
elif (yaml_content['project-type'] == "externaljob"):
|
||||
project = project_externaljob.ExternalJob(None)
|
||||
|
||||
if project:
|
||||
xml_project = project.root_xml(yaml_content)
|
||||
else:
|
||||
xml_project = XML.Element('project')
|
||||
|
||||
plugins_info = None
|
||||
if self.plugins_info_filename is not None:
|
||||
@ -176,6 +159,24 @@ class BaseTestCase(LoggingFixture):
|
||||
|
||||
pub = self.klass(parser.registry)
|
||||
|
||||
project = None
|
||||
if ('project-type' in yaml_content):
|
||||
if (yaml_content['project-type'] == "maven"):
|
||||
project = project_maven.Maven(parser.registry)
|
||||
elif (yaml_content['project-type'] == "matrix"):
|
||||
project = project_matrix.Matrix(parser.registry)
|
||||
elif (yaml_content['project-type'] == "flow"):
|
||||
project = project_flow.Flow(parser.registry)
|
||||
elif (yaml_content['project-type'] == "multijob"):
|
||||
project = project_multijob.MultiJob(parser.registry)
|
||||
elif (yaml_content['project-type'] == "externaljob"):
|
||||
project = project_externaljob.ExternalJob(parser.registry)
|
||||
|
||||
if project:
|
||||
xml_project = project.root_xml(yaml_content)
|
||||
else:
|
||||
xml_project = XML.Element('project')
|
||||
|
||||
# Generate the XML tree directly with modules/general
|
||||
pub.gen_xml(parser, xml_project, yaml_content)
|
||||
|
||||
|
@ -0,0 +1,3 @@
|
||||
- longName: 'Maven Integration plugin'
|
||||
shortName: 'maven-plugin'
|
||||
version: "2.0.0"
|
@ -11,6 +11,7 @@
|
||||
<incrementalBuild>true</incrementalBuild>
|
||||
<siteArchivingDisabled>true</siteArchivingDisabled>
|
||||
<fingerprintingDisabled>false</fingerprintingDisabled>
|
||||
<perModuleEmail>true</perModuleEmail>
|
||||
<archivingDisabled>true</archivingDisabled>
|
||||
<resolveDependencies>true</resolveDependencies>
|
||||
<processPlugins>true</processPlugins>
|
||||
|
Loading…
Reference in New Issue
Block a user