Author: ymartel Date: 2010-09-24 12:25:11 +0200 (Fri, 24 Sep 2010) New Revision: 1821 Url: http://nuiton.org/repositories/revision/maven-license-plugin/1821 Log: re-think the usage of boolean :p Modified: trunk/src/main/java/org/nuiton/license/plugin/AddThirdPartyMojo.java Modified: trunk/src/main/java/org/nuiton/license/plugin/AddThirdPartyMojo.java =================================================================== --- trunk/src/main/java/org/nuiton/license/plugin/AddThirdPartyMojo.java 2010-09-24 09:30:43 UTC (rev 1820) +++ trunk/src/main/java/org/nuiton/license/plugin/AddThirdPartyMojo.java 2010-09-24 10:25:11 UTC (rev 1821) @@ -105,26 +105,28 @@ LicenseMap licenseMap = new LicenseMap(this.getProjectFilter()); licenseMap.setLog(log); - boolean noIncludedGroups = StringUtils.isEmpty(includedGroups); - boolean noExcludedGroups = StringUtils.isEmpty(excludedGroups); - boolean noIncludedArtifacts = StringUtils.isEmpty(includedArtifacts); - boolean noExcludedArtifacts = StringUtils.isEmpty(excludedArtifacts); + boolean haveNoIncludedGroups = StringUtils.isEmpty(includedGroups); + boolean haveNoIncludedArtifacts = StringUtils.isEmpty(includedArtifacts); + boolean haveExcludedGroups = StringUtils.isNotEmpty(excludedGroups); + boolean haveExcludedArtifacts = StringUtils.isNotEmpty(excludedArtifacts); + boolean haveExclusions = haveExcludedGroups || haveExcludedArtifacts; + Pattern includedGroupPattern = null; Pattern includedArtifactPattern = null; Pattern excludedGroupPattern = null; Pattern excludedArtifactPattern = null; - if (!noIncludedGroups) { + if (!haveNoIncludedGroups) { includedGroupPattern = Pattern.compile(includedGroups); } - if (!noIncludedArtifacts) { + if (!haveNoIncludedArtifacts) { includedArtifactPattern = Pattern.compile(includedArtifacts); } - if (!noExcludedGroups) { + if (haveExcludedGroups) { excludedGroupPattern = Pattern.compile(excludedGroups); } - if (!noExcludedArtifacts) { + if (haveExcludedArtifacts) { excludedArtifactPattern = Pattern.compile(excludedArtifacts); } @@ -143,11 +145,14 @@ MavenProject project = addArtifact(id, artifact); // Check if the project should be included - boolean isToInclude = noIncludedArtifacts && noIncludedGroups + // If there is no specified artifacts and group to include, include all + boolean isToInclude = haveNoIncludedArtifacts && haveNoIncludedGroups || isIncludable(project, includedGroupPattern, includedArtifactPattern); // Check if the project should be excluded - boolean isToExclude = isExcludable(project, excludedGroupPattern, excludedArtifactPattern); + boolean isToExclude = isToInclude + && haveExclusions + && isExcludable(project, excludedGroupPattern, excludedArtifactPattern); if (isToInclude && !isToExclude) { licenseMap.addLicense(project, project.getLicenses());