From a571826150db011febf22925c7fb030018f3922e Mon Sep 17 00:00:00 2001 From: Vitalij Berdinskih Date: Thu, 14 Nov 2024 08:44:44 +0200 Subject: [PATCH 1/3] licenseName is required --- .../java/org/codehaus/mojo/license/AbstractLicenseNameMojo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/codehaus/mojo/license/AbstractLicenseNameMojo.java b/src/main/java/org/codehaus/mojo/license/AbstractLicenseNameMojo.java index 433236be..d4966870 100644 --- a/src/main/java/org/codehaus/mojo/license/AbstractLicenseNameMojo.java +++ b/src/main/java/org/codehaus/mojo/license/AbstractLicenseNameMojo.java @@ -114,7 +114,7 @@ public abstract class AbstractLicenseNameMojo extends AbstractLicenseMojo { * @parameter property="license.licenseName" * @since 1.0 */ - @Parameter(property = "license.licenseName") + @Parameter(property = "license.licenseName", required = true) private String licenseName; /** From e0aa3677453ff2667afb98e9c3d18ae79c5b1f48 Mon Sep 17 00:00:00 2001 From: Vitalij Berdinskih Date: Thu, 14 Nov 2024 13:50:01 +0200 Subject: [PATCH 2/3] Check license name: it fails not empty but blank --- .../org/codehaus/mojo/license/AbstractLicenseNameMojo.java | 3 --- .../org/codehaus/mojo/license/model/LicenseRepository.java | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/codehaus/mojo/license/AbstractLicenseNameMojo.java b/src/main/java/org/codehaus/mojo/license/AbstractLicenseNameMojo.java index d4966870..1813493c 100644 --- a/src/main/java/org/codehaus/mojo/license/AbstractLicenseNameMojo.java +++ b/src/main/java/org/codehaus/mojo/license/AbstractLicenseNameMojo.java @@ -227,9 +227,6 @@ protected void init() throws Exception { // ---------------------------------------------------------------------- protected License getLicense(String licenseName, boolean checkIfExists) { - if (StringUtils.isEmpty(licenseName)) { - throw new IllegalArgumentException("licenseName can not be null, nor empty"); - } if (licenseStore == null) { throw new IllegalStateException("No license store initialized!"); } diff --git a/src/main/java/org/codehaus/mojo/license/model/LicenseRepository.java b/src/main/java/org/codehaus/mojo/license/model/LicenseRepository.java index 234911e0..9f2466fe 100644 --- a/src/main/java/org/codehaus/mojo/license/model/LicenseRepository.java +++ b/src/main/java/org/codehaus/mojo/license/model/LicenseRepository.java @@ -165,8 +165,8 @@ public License[] getLicenses() { public License getLicense(String licenseName) { checkInit("getLicense"); - if (StringUtils.isEmpty(licenseName)) { - throw new IllegalArgumentException("licenceName can not be null, nor empty"); + if (StringUtils.isBlank(licenseName)) { + throw new IllegalArgumentException("licenceName can not be null, nor blank"); } License license = null; From a0b6cc0e53e8a688299ec1723f70e5ce91ee0990 Mon Sep 17 00:00:00 2001 From: Vitalij Berdinskih Date: Sat, 16 Nov 2024 19:45:44 +0200 Subject: [PATCH 3/3] Remove an unnecessary check --- .../org/codehaus/mojo/license/model/LicenseRepository.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/java/org/codehaus/mojo/license/model/LicenseRepository.java b/src/main/java/org/codehaus/mojo/license/model/LicenseRepository.java index 9f2466fe..6ad14b00 100644 --- a/src/main/java/org/codehaus/mojo/license/model/LicenseRepository.java +++ b/src/main/java/org/codehaus/mojo/license/model/LicenseRepository.java @@ -165,9 +165,6 @@ public License[] getLicenses() { public License getLicense(String licenseName) { checkInit("getLicense"); - if (StringUtils.isBlank(licenseName)) { - throw new IllegalArgumentException("licenceName can not be null, nor blank"); - } License license = null; for (License l : this) {