Skip to content

Commit

Permalink
codenarc violations
Browse files Browse the repository at this point in the history
  • Loading branch information
Uladzimir Zhuraulevich committed Jan 21, 2019
1 parent 13755df commit 8471518
Showing 1 changed file with 43 additions and 25 deletions.
68 changes: 43 additions & 25 deletions src/main/groovy/com/github/zhurlik/tag/ModuleDependencyTag.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@ import static com.github.zhurlik.Ver.V_1_9
* <xsd:element name="exports" type="filterType" minOccurs="0">
* <annotation xmlns="http://www.w3.org/2001/XMLSchema">
* <documentation>
* A filter used to restrict what packages or directories from this dependency are re-exported by
* this module. See also the "export" and "services" attributes. The default action of this filter
* list is controlled by the value of the "export" attribute. Regardless of the setting of these
* attributes, this filter always behaves as if it has a final entry which rejects META-INF and
* all of its subdirectories.
* A filter used to restrict what packages or directories from this dependency are re-exported
* by this module. See also the "export" and "services" attributes. The default action of this
* filter list is controlled by the value of the "export" attribute. Regardless of the setting
* of these attributes, this filter always behaves as if it has a final entry which rejects
* META-INF and all of its subdirectories.
* </documentation>
* </annotation>
* </xsd:element>
* <xsd:element name="imports" type="filterType" minOccurs="0">
* <annotation xmlns="http://www.w3.org/2001/XMLSchema">
* <documentation>
* A filter used to restrict what packages or directories from this dependency are visible to this
* module. See also the "services" attribute. The default action of this filter list is to reject
* a path if not matched.
* A filter used to restrict what packages or directories from this dependency are visible to
* this module. See also the "services" attribute. The default action of this filter list is to
* reject a path if not matched.
* </documentation>
* </annotation>
* </xsd:element>
Expand All @@ -52,27 +52,28 @@ import static com.github.zhurlik.Ver.V_1_9
* <documentation>
* Specifies whether this module dependency is re-exported by default (default is "false"). Setting
* this attribute to true sets the default action for the export filter list to "accept"; leaving it
* as false sets the default action to "reject". Thus you can still export dependency resources even
* if this attribute is false by listing explicit paths for the export list.
* as false sets the default action to "reject". Thus you can still export dependency resources
* even if this attribute is false by listing explicit paths for the export list.
* </documentation>
* </annotation>
* </xsd:attribute>
* <xsd:attribute name="services" type="serviceDispositionType" default="none">
* <annotation xmlns="http://www.w3.org/2001/XMLSchema">
* <documentation>
* Specifies whether and how services found in this dependency are used (default is "none"). Specifying
* a value of "import" for this attribute is equivalent to adding a filter at the end of the import
* filter list which includes the META-INF/services path from the dependency module. Setting a value
* of "export" for this attribute is equivalent to the same action on the export filter list.
* Specifies whether and how services found in this dependency are used (default is "none").
* Specifying a value of "import" for this attribute is equivalent to adding a filter at the end of
* the import filter list which includes the META-INF/services path from the dependency module.
* Setting a value of "export" for this attribute is equivalent to the same action on the export
* filter list.
* </documentation>
* </annotation>
* </xsd:attribute>
* <xsd:attribute name="optional" type="xsd:boolean" default="false">
* <annotation xmlns="http://www.w3.org/2001/XMLSchema">
* <documentation>
* Specifies whether this dependency is optional (defaults to false). An optional dependency will not
* cause the module to fail to load if not found; however if the module is added later, it will not be
* retroactively linked into this module's dependency list.
* Specifies whether this dependency is optional (defaults to false). An optional dependency will
* not cause the module to fail to load if not found; however if the module is added later, it will
* not be retroactively linked into this module's dependency list.
* </documentation>
* </annotation>
* </xsd:attribute>
Expand Down Expand Up @@ -170,9 +171,17 @@ class ModuleDependencyTag {
jmodule.dependencies.findAll({ !(it instanceof Map && it.type == 'system') }).each { dep ->
// Attribute Type Required? Description
//name: string Yes The name of the module upon which this module depends.
//slot: string No The version slot of the module upon which this module depends; defaults to "main".
//export: boolean No Specify whether this dependency is re-exported by default; if not specified, defaults to "false".
//services; enum No Specify whether this dependency's services* are imported and/or exported. Possible values are "none", "import", or "export"; defaults to "none".
//
//slot: string No The version slot of the module upon which this module depends;
// defaults to "main".
//
//export: boolean No Specify whether this dependency is re-exported by default;
// if not specified, defaults to "false".
//
//services; enum No Specify whether this dependency's services* are imported and/or
// exported. Possible values are "none", "import", or "export";
// defaults to "none".
//
//optional: boolean No Specify whether this dependency is optional; defaults to "false".
if (dep instanceof String) {
xml.module(name: dep)
Expand All @@ -195,13 +204,16 @@ class ModuleDependencyTag {
if (dep.exports == null && dep.imports == null && dep.properties == null) {
xml.module(dep.sort())
} else {
xml.module(dep.findAll() { el -> el.key in ['name', 'export', 'optional', 'services'] + (!(version in [V_1_7, V_1_8, V_1_9]) ? ['slot'] : []) }.sort()) {
xml.module(dep.findAll() { el -> el.key in ['name', 'export', 'optional', 'services'] +
(!(version in [V_1_7, V_1_8, V_1_9]) ? ['slot'] : []) }.sort()) {
// imports
if (dep.imports != null) {
xml.imports() {
// include
if (dep.imports.include != null) {
if (dep.imports.include instanceof String || dep.imports.include instanceof GString || dep.imports.include.size() == 1) {
if (dep.imports.include instanceof String
|| dep.imports.include instanceof GString
|| dep.imports.include.size() == 1) {
xml.'include'(path: dep.imports.include.toString())
} else if (dep.imports.include.size() > 1) {
xml.'include-set'() {
Expand All @@ -212,7 +224,9 @@ class ModuleDependencyTag {

// exclude
if (dep.imports.exclude != null) {
if (dep.imports.exclude instanceof String || dep.imports.exclude instanceof GString || dep.imports.exclude.size() == 1) {
if (dep.imports.exclude instanceof String
|| dep.imports.exclude instanceof GString
|| dep.imports.exclude.size() == 1) {
xml.'exclude'(path: dep.imports.exclude.toString())
} else if (dep.imports.exclude.size() > 1) {
xml.'exclude-set'() {
Expand All @@ -228,7 +242,9 @@ class ModuleDependencyTag {
xml.exports() {
// include
if (dep.exports.include != null) {
if (dep.exports.include instanceof String || dep.exports.include instanceof GString || dep.exports.include.size() == 1) {
if (dep.exports.include instanceof String
|| dep.exports.include instanceof GString
|| dep.exports.include.size() == 1) {
xml.'include'(path: dep.exports.include.toString())
} else if (dep.exports.include.size() > 1) {
xml.'include-set'() {
Expand All @@ -239,7 +255,9 @@ class ModuleDependencyTag {

// exclude
if (dep.exports.exclude != null) {
if (dep.exports.exclude instanceof String || dep.exports.exclude instanceof GString || dep.exports.exclude.size() == 1) {
if (dep.exports.exclude instanceof String
|| dep.exports.exclude instanceof GString
|| dep.exports.exclude.size() == 1) {
xml.'exclude'(path: dep.exports.exclude.toString())
} else if (dep.exports.exclude.size() > 1) {
xml.'exclude-set'() {
Expand Down

0 comments on commit 8471518

Please sign in to comment.