From 979b4d3da2bd749e01f52da12df8b6c9a289b4d9 Mon Sep 17 00:00:00 2001 From: Barend Garvelink Date: Tue, 30 Mar 2021 21:24:18 +0200 Subject: [PATCH 01/14] update to SWIFT Registry v89 --- docs/index.md | 14 +++++++++++--- src/main/resources/nl/garvelink/iban/IBAN.yml | 6 +++--- .../iban/CountryCodesParameterizedTest.java | 2 +- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/docs/index.md b/docs/index.md index 9f31c68..74b1f64 100644 --- a/docs/index.md +++ b/docs/index.md @@ -97,8 +97,15 @@ Obtain an `IBAN` instance using one of the static factory methods: `valueOf( )` ### Version History -#### Unreleased -* Removes `@Generated` annotation from `CountryCodesData` class to avoid having a runtime dependency on newer JDK's. +#### 1.9.0: unreleased +* Update to revision 89 of the SWIFT IBAN Registry + * Andorra (AD): is now SEPA +* Update to IBAN.com Experimental List + * No changes +* The project can now be compilead on Adopt-OpenJDK 11 HS. An outdated library used in the code generation step + prevented this. +* The `@javax.annotation.Generated` annotation has been removed from the `CountryCodesData` class. This annotation moved + into a library package in newer Java versions, and does not justify taking on a library dependency. #### 1.8.0: 21 November 2020 * The `IBAN` class implements `java.io.Serializable` ([#23][i23]). The serialized form should stay valid across library @@ -229,8 +236,9 @@ Obtain an `IBAN` instance using one of the static factory methods: `valueOf( )` ### Design Choices I like the Joda-Time library and I try to follow the same design principles. I'm explicitly targetting Android, which -rules out some modern Java language constructs. I'm trying to keep the library as simple as I can. +at the time this library started was still on Java 1.6. I'm trying to keep the library as simple as I can. +* Easy to integrate: don't bring transitive dependencies. * The `IBAN` objects are immutable and the IBAN therein is non-empty and valid. There is no support for partial or invalid IBANs. Note that "valid" isn't as strict as it could be: * It checks that the length is correct (varies per country) and that the check digits are correct. diff --git a/src/main/resources/nl/garvelink/iban/IBAN.yml b/src/main/resources/nl/garvelink/iban/IBAN.yml index 8dd8358..49ff171 100755 --- a/src/main/resources/nl/garvelink/iban/IBAN.yml +++ b/src/main/resources/nl/garvelink/iban/IBAN.yml @@ -13,15 +13,15 @@ # See the License for the specific language governing permissions and # limitations under the License. meta: - iban_registry_version: 88 - last_update: 2020-11-21 + iban_registry_version: 89 + last_update: 2021-03-30 ibans: - name: Andorra country_code: AD length: 24 flags: - sepa_country: no + sepa_country: yes in_swift_registry: yes embeds: bank_code: diff --git a/src/test/java/nl/garvelink/iban/CountryCodesParameterizedTest.java b/src/test/java/nl/garvelink/iban/CountryCodesParameterizedTest.java index 58ade1a..19bb6ae 100644 --- a/src/test/java/nl/garvelink/iban/CountryCodesParameterizedTest.java +++ b/src/test/java/nl/garvelink/iban/CountryCodesParameterizedTest.java @@ -60,7 +60,7 @@ public CountryCodesParameterizedTest(TestData td) { static final List PARAMETERS = Stream.of( // Name SWIFT SEPA Plain Bank Branch Pretty // Countries in the SWIFT reference, sorted by Country Code - td( "Andorra", true , false, "AD1200012030200359100100", "0001" , "2030" , "AD12 0001 2030 2003 5910 0100" ), //SWIFT + td( "Andorra", true , true , "AD1200012030200359100100", "0001" , "2030" , "AD12 0001 2030 2003 5910 0100" ), //SWIFT td( "United Arab Emirates (The)", true , false, "AE070331234567890123456", "033" , null , "AE07 0331 2345 6789 0123 456"), //SWIFT td( "Albania", true , false, "AL47212110090000000235698741", "21211009", "1100" , "AL47 2121 1009 0000 0002 3569 8741"), //SWIFT td( "Austria", true , true , "AT611904300234573201", "19043" , null , "AT61 1904 3002 3457 3201" ), //SWIFT From e366cc4e4643d1a11f844f2ce2ca72f6d857ced9 Mon Sep 17 00:00:00 2001 From: Barend Garvelink Date: Tue, 30 Mar 2021 21:29:05 +0200 Subject: [PATCH 02/14] France (FR): branch ID (fixes #30) --- docs/index.md | 3 +++ src/main/resources/nl/garvelink/iban/IBAN.yml | 3 +++ .../java/nl/garvelink/iban/CountryCodesParameterizedTest.java | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/index.md b/docs/index.md index 74b1f64..30b03bb 100644 --- a/docs/index.md +++ b/docs/index.md @@ -98,6 +98,7 @@ Obtain an `IBAN` instance using one of the static factory methods: `valueOf( )` ### Version History #### 1.9.0: unreleased +* France (FR): add branch identifier ([#30][i30]) * Update to revision 89 of the SWIFT IBAN Registry * Andorra (AD): is now SEPA * Update to IBAN.com Experimental List @@ -107,6 +108,8 @@ Obtain an `IBAN` instance using one of the static factory methods: `valueOf( )` * The `@javax.annotation.Generated` annotation has been removed from the `CountryCodesData` class. This annotation moved into a library package in newer Java versions, and does not justify taking on a library dependency. +[i30]: https://github.com/barend/java-iban/issues/30 + #### 1.8.0: 21 November 2020 * The `IBAN` class implements `java.io.Serializable` ([#23][i23]). The serialized form should stay valid across library version updates. There is one obvious backwards-incompatibility: deserializing after a version downgrade, of an IBAN diff --git a/src/main/resources/nl/garvelink/iban/IBAN.yml b/src/main/resources/nl/garvelink/iban/IBAN.yml index 49ff171..b7eba6d 100755 --- a/src/main/resources/nl/garvelink/iban/IBAN.yml +++ b/src/main/resources/nl/garvelink/iban/IBAN.yml @@ -381,6 +381,9 @@ ibans: bank_code: position: 4 length: 5 + branch_code: + position: 9 + length: 5 - name: Gabon country_code: GA diff --git a/src/test/java/nl/garvelink/iban/CountryCodesParameterizedTest.java b/src/test/java/nl/garvelink/iban/CountryCodesParameterizedTest.java index 19bb6ae..e29055b 100644 --- a/src/test/java/nl/garvelink/iban/CountryCodesParameterizedTest.java +++ b/src/test/java/nl/garvelink/iban/CountryCodesParameterizedTest.java @@ -83,7 +83,7 @@ public CountryCodesParameterizedTest(TestData td) { td( "Spain", true , true , "ES9121000418450200051332", "2100" , "0418" , "ES91 2100 0418 4502 0005 1332" ), //SWIFT td( "Finland", true , true , "FI2112345600000785", "123" , null , "FI21 1234 5600 0007 85" ), //SWIFT td( "Faroe Islands", true , false, "FO6264600001631634", "6460" , null , "FO62 6460 0001 6316 34" ), //SWIFT - td( "France", true , true , "FR1420041010050500013M02606", "20041" , null , "FR14 2004 1010 0505 0001 3M02 606" ), //SWIFT + td( "France", true , true , "FR1420041010050500013M02606", "20041" , "01005" , "FR14 2004 1010 0505 0001 3M02 606" ), //SWIFT td( "United Kingdom", true , true , "GB29NWBK60161331926819", "NWBK" , "601613" , "GB29 NWBK 6016 1331 9268 19" ), //SWIFT td( "Georgia", true , false, "GE29NB0000000101904917", "NB" , null , "GE29 NB00 0000 0101 9049 17"), //SWIFT td( "Gibraltar", true , true , "GI75NWBK000000007099453", "NWBK" , null , "GI75 NWBK 0000 0000 7099 453" ), //SWIFT From 77c282f929a607805f190b230dfdc9fd8985808b Mon Sep 17 00:00:00 2001 From: Barend Garvelink Date: Tue, 30 Mar 2021 21:36:43 +0200 Subject: [PATCH 03/14] CountryCode utility methods now take CharSequence --- docs/index.md | 1 + .../java/nl/garvelink/iban/CountryCodes.java | 16 ++++++++-------- src/main/java/nl/garvelink/iban/IBAN.java | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/docs/index.md b/docs/index.md index 30b03bb..f459035 100644 --- a/docs/index.md +++ b/docs/index.md @@ -98,6 +98,7 @@ Obtain an `IBAN` instance using one of the static factory methods: `valueOf( )` ### Version History #### 1.9.0: unreleased +* Compatible change: utility functions in `CountryCodes` now accept `java.lang.CharSequence` (was String). * France (FR): add branch identifier ([#30][i30]) * Update to revision 89 of the SWIFT IBAN Registry * Andorra (AD): is now SEPA diff --git a/src/main/java/nl/garvelink/iban/CountryCodes.java b/src/main/java/nl/garvelink/iban/CountryCodes.java index afa62f6..e40df5b 100644 --- a/src/main/java/nl/garvelink/iban/CountryCodes.java +++ b/src/main/java/nl/garvelink/iban/CountryCodes.java @@ -100,8 +100,8 @@ static String getBranchIdentifier(IBAN iban) { * @return the IBAN length for the given country, or -1 if the input is not a known, two-character country code. * @throws NullPointerException if the input is null. */ - public static int getLengthForCountryCode(String countryCode) { - int index = indexOf(countryCode); + public static int getLengthForCountryCode(CharSequence countryCode) { + int index = indexOf(countryCode.toString()); if (index > -1) { return COUNTRY_IBAN_LENGTHS[index] & REMOVE_METADATA_MASK; } @@ -114,8 +114,8 @@ public static int getLengthForCountryCode(String countryCode) { * @return true if SEPA, false if not. * @throws NullPointerException if the input is null. */ - public static boolean isSEPACountry(String countryCode) { - int index = indexOf(countryCode); + public static boolean isSEPACountry(CharSequence countryCode) { + int index = indexOf(countryCode.toString()); if (index > -1) { return (COUNTRY_IBAN_LENGTHS[index] & SEPA) == SEPA; } @@ -128,8 +128,8 @@ public static boolean isSEPACountry(String countryCode) { * @return true if our data is from the SWIFT IBAN Registry, false if not. * @throws NullPointerException if the input is null. */ - public static boolean isInSwiftRegistry(String countryCode) { - int index = indexOf(countryCode); + public static boolean isInSwiftRegistry(CharSequence countryCode) { + int index = indexOf(countryCode.toString()); if (index > -1) { return (COUNTRY_IBAN_LENGTHS[index] & SWIFT) == SWIFT; } @@ -149,11 +149,11 @@ public static Collection getKnownCountryCodes() { * @param aCountryCode the string to evaluate. * @return {@code true} if {@code aCountryCode} is a two-letter, uppercase String present in {@link #getKnownCountryCodes()}. */ - public static boolean isKnownCountryCode(String aCountryCode) { + public static boolean isKnownCountryCode(CharSequence aCountryCode) { if (aCountryCode == null || aCountryCode.length() != 2) { return false; } - return indexOf(aCountryCode) >= 0; + return indexOf(aCountryCode.toString()) >= 0; } /** diff --git a/src/main/java/nl/garvelink/iban/IBAN.java b/src/main/java/nl/garvelink/iban/IBAN.java index a0578c4..192c0d6 100644 --- a/src/main/java/nl/garvelink/iban/IBAN.java +++ b/src/main/java/nl/garvelink/iban/IBAN.java @@ -139,7 +139,7 @@ public static IBAN valueOf(CharSequence input) { } /** - * @deprecated invoke {@link CountryCodes#getLengthForCountryCode(String)} instead. + * @deprecated invoke {@link CountryCodes#getLengthForCountryCode(CharSequence)} instead. * @param countryCode the country code for which to return the length. * @return the length of the IBAN for the given country code, or -1 if unknown. */ From a1d9ecabbef25e0185f948e82848cadcebb8535d Mon Sep 17 00:00:00 2001 From: Barend Garvelink Date: Tue, 30 Mar 2021 22:16:27 +0200 Subject: [PATCH 04/14] Add method IBAN.compose(cs, cs) --- docs/index.md | 4 +++ src/main/java/nl/garvelink/iban/IBAN.java | 15 ++++++++ src/test/java/nl/garvelink/iban/IBANTest.java | 36 +++++++++++++++++++ 3 files changed, 55 insertions(+) diff --git a/docs/index.md b/docs/index.md index f459035..64dd247 100644 --- a/docs/index.md +++ b/docs/index.md @@ -73,6 +73,9 @@ Obtain an `IBAN` instance using one of the static factory methods: `valueOf( )` String candidate = "GB29 NWBK 6016 1331 9268 19"; boolean valid = Modulo97.verifyCheckDigits( candidate ); // true + // Compose the IBAN for a country and BBAN + IBAN.compose( "BI", "201011067444" ); // BI43201011067444 + // You can query whether an IBAN is of a SEPA-participating country boolean isSepa = IBAN.parse(candidate).isSEPA(); // true @@ -99,6 +102,7 @@ Obtain an `IBAN` instance using one of the static factory methods: `valueOf( )` #### 1.9.0: unreleased * Compatible change: utility functions in `CountryCodes` now accept `java.lang.CharSequence` (was String). +* New API: `IBAN.compose(CharSequence, CharSequence)`. * France (FR): add branch identifier ([#30][i30]) * Update to revision 89 of the SWIFT IBAN Registry * Andorra (AD): is now SEPA diff --git a/src/main/java/nl/garvelink/iban/IBAN.java b/src/main/java/nl/garvelink/iban/IBAN.java index 192c0d6..186ecfa 100644 --- a/src/main/java/nl/garvelink/iban/IBAN.java +++ b/src/main/java/nl/garvelink/iban/IBAN.java @@ -138,6 +138,21 @@ public static IBAN valueOf(CharSequence input) { return parse(input); } + /** + * Composes an IBAN from the given country code and basic bank account number. + * @param countryCode the country code. + * @param bban the BBAN. + * @return an IBAN object composed from the given parts, if valid. + * @throws IllegalArgumentException if either input is null, if the composed IBAN fails validation. + */ + public static IBAN compose(CharSequence countryCode, CharSequence bban) { + StringBuilder sb = + new StringBuilder(CountryCodes.LONGEST_IBAN_LENGTH).append(countryCode).append("00").append(bban); + int checkDigits = Modulo97.calculateCheckDigits(sb); + sb.replace(2, 4, Integer.toString(checkDigits)); + return parse(sb); + } + /** * @deprecated invoke {@link CountryCodes#getLengthForCountryCode(CharSequence)} instead. * @param countryCode the country code for which to return the length. diff --git a/src/test/java/nl/garvelink/iban/IBANTest.java b/src/test/java/nl/garvelink/iban/IBANTest.java index 78c9a90..193ec0b 100644 --- a/src/test/java/nl/garvelink/iban/IBANTest.java +++ b/src/test/java/nl/garvelink/iban/IBANTest.java @@ -104,6 +104,42 @@ public void parseShouldRejectChecksumFailure() { } } + @Test + public void composeShouldHandleCorrectInput() { + IBAN composed = IBAN.compose(VALID_IBAN.subSequence(0, 2), VALID_IBAN.substring(4)); + assertThat(composed, is(equalTo(IBAN.parse(VALID_IBAN)))); + } + + @Test(expected = IllegalArgumentException.class) + public void composeShouldRejectNullCountryCode() { + IBAN.compose(null, VALID_IBAN.substring(4)); + } + + @Test(expected = IllegalArgumentException.class) + public void composeShouldRejectBlankCountryCode() { + IBAN.compose(" ", VALID_IBAN.substring(4)); + } + + @Test(expected = IllegalArgumentException.class) + public void composeShouldRejectMalformedCountryCode() { + IBAN.compose("potato", VALID_IBAN.substring(4)); + } + + @Test(expected = IllegalArgumentException.class) + public void composeShouldRejectUnknownCountryCode() { + IBAN.compose("XX", VALID_IBAN.substring(4)); + } + + @Test(expected = IllegalArgumentException.class) + public void composeShouldRejectNullBBAN() { + IBAN.compose(VALID_IBAN.substring(0, 2), null); + } + + @Test(expected = IllegalArgumentException.class) + public void composeShouldRejectWrongLengthBBAN() { + IBAN.compose(VALID_IBAN.substring(0, 2), VALID_IBAN.substring(5)); + } + @Test public void testEqualsContract() { IBAN x = IBAN.parse(VALID_IBAN); From 001aae09029d9d64f34dd45914e5fac3441371c7 Mon Sep 17 00:00:00 2001 From: Barend Garvelink Date: Tue, 30 Mar 2021 22:43:30 +0200 Subject: [PATCH 05/14] Add method Modulo97.calculateCheckDigits(cs, cs) --- docs/index.md | 6 +++ src/main/java/nl/garvelink/iban/Modulo97.java | 25 +++++++++++ .../java/nl/garvelink/iban/Modulo97Test.java | 42 +++++++++++++++++++ 3 files changed, 73 insertions(+) diff --git a/docs/index.md b/docs/index.md index 64dd247..8c0a214 100644 --- a/docs/index.md +++ b/docs/index.md @@ -86,6 +86,11 @@ Obtain an `IBAN` instance using one of the static factory methods: `valueOf( )` StringBuilder builder = new StringBuilder( "LU000019400644750000" ); int checkDigits = Modulo97.calculateCheckDigits( builder ); // 28 + // Modulo97 API can calculate check digits, also for non-iban inputs. + // It does assume/require that the check digits are on indices 2 and 3. + Modulo97.calculateCheckDigits( "GB", "NWBK60161331926819" ); // 29 + Modulo97.calculateCheckDigits( "XX", "X" ); // 50 + // Get the expected IBAN length for a country code: int length = CountryCodes.getLengthForCountryCode( "DK" ); @@ -103,6 +108,7 @@ Obtain an `IBAN` instance using one of the static factory methods: `valueOf( )` #### 1.9.0: unreleased * Compatible change: utility functions in `CountryCodes` now accept `java.lang.CharSequence` (was String). * New API: `IBAN.compose(CharSequence, CharSequence)`. +* New API: `Modulo97.calculateCheckDigits(CharSequence, CharSequence)`. * France (FR): add branch identifier ([#30][i30]) * Update to revision 89 of the SWIFT IBAN Registry * Andorra (AD): is now SEPA diff --git a/src/main/java/nl/garvelink/iban/Modulo97.java b/src/main/java/nl/garvelink/iban/Modulo97.java index fba1876..6a8ebe5 100644 --- a/src/main/java/nl/garvelink/iban/Modulo97.java +++ b/src/main/java/nl/garvelink/iban/Modulo97.java @@ -74,6 +74,31 @@ public static int calculateCheckDigits(CharSequence input) { return 98 - checksum(input); } + /** + * Calculates the check digits for a given country code and BBAN. + * @param countryCode the country code. Not validated to be a known country. + * @param bban the country-specific BBAN. Not validated to required length. + * @return the check digits to be used at indices 2 and 3 to make the input MOD97 verifiable. + * @throws IllegalArgumentException if either input is null, or the country code is not two characters. + */ + public static int calculateCheckDigits(CharSequence countryCode, CharSequence bban) { + if (countryCode == null) { + throw new IllegalArgumentException("countryCode is required but is null."); + } + if (bban == null) { + throw new IllegalArgumentException("bban is required but is null."); + } + if (countryCode.length() != 2) { + throw new IllegalArgumentException( + String.format("countryCode should be length 2 but is %d", countryCode.length())); + } + if (countryCode.charAt(0) == ' ' || countryCode.charAt(1) == ' ') { + throw new IllegalArgumentException("countryCode contains space character (0x20)."); + } + StringBuilder sb = new StringBuilder(countryCode).append("00").append(bban); + return calculateCheckDigits(sb); + } + /** * Determines whether the given input has a valid MOD97 checksum. * @param input the input to verify, it must meet the criteria defined in {@link #checksum(CharSequence)}. diff --git a/src/test/java/nl/garvelink/iban/Modulo97Test.java b/src/test/java/nl/garvelink/iban/Modulo97Test.java index c6d4ada..421c88e 100644 --- a/src/test/java/nl/garvelink/iban/Modulo97Test.java +++ b/src/test/java/nl/garvelink/iban/Modulo97Test.java @@ -17,6 +17,7 @@ import org.junit.Test; +import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; @@ -126,4 +127,45 @@ public void itShouldRefuseToCalculateCheckDigitsIfIndex2IsNot0() { public void itShouldRefuseToCalculateCheckDigitsIfIndex3IsNot0() { Modulo97.calculateCheckDigits("MO02A"); } + + private static final String VALID_COUNTRY = "NL"; + private static final String VALID_BBAN = "ABNA0417164300"; + + @Test + public void composeShouldHandleIBANValidInput() { + int checkDigits = Modulo97.calculateCheckDigits(VALID_COUNTRY, VALID_BBAN); + assertThat(checkDigits, is(equalTo(91))); + } + + @Test(expected = IllegalArgumentException.class) + public void composeShouldRejectNullCountryCode() { + Modulo97.calculateCheckDigits(null, VALID_BBAN); + } + + @Test(expected = IllegalArgumentException.class) + public void composeShouldRejectBlankCountryCode() { + Modulo97.calculateCheckDigits(" ", VALID_BBAN); + } + + @Test(expected = IllegalArgumentException.class) + public void composeShouldRejectMalformedCountryCode() { + Modulo97.calculateCheckDigits("potato", VALID_BBAN); + } + + @Test + public void composeShouldAcceptUnknownCountryCode() { + int checkDigits = Modulo97.calculateCheckDigits("XX", "X"); + assertThat(checkDigits, is(equalTo(72))); + } + + @Test(expected = IllegalArgumentException.class) + public void composeShouldRejectNullBBAN() { + Modulo97.calculateCheckDigits(VALID_COUNTRY, null); + } + + @Test + public void composeShouldAcceptWrongLengthBBAN() { + int checkDigits = Modulo97.calculateCheckDigits(VALID_COUNTRY, VALID_BBAN.substring(1)); + assertThat(checkDigits, is(equalTo(50))); + } } From 055457188a5b6ba73f742bccbbc7c46dcaf4a0bd Mon Sep 17 00:00:00 2001 From: Barend Garvelink Date: Tue, 30 Mar 2021 22:48:03 +0200 Subject: [PATCH 06/14] next release will be 1.9.0 --- docs/index.md | 4 ++-- pom.xml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/index.md b/docs/index.md index 8c0a214..abf40f3 100644 --- a/docs/index.md +++ b/docs/index.md @@ -25,7 +25,7 @@ Grab a package [from Github][download] or get it from Maven Central: nl.garvelink.oss iban - 1.8.0 + 1.9.0 ``` @@ -33,7 +33,7 @@ Grab a package [from Github][download] or get it from Maven Central: ```groovy dependencies { - compile 'nl.garvelink.oss:iban:1.8.0' + compile 'nl.garvelink.oss:iban:1.9.0' } ``` diff --git a/pom.xml b/pom.xml index d9d63d9..9c25352 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ nl.garvelink.oss iban - 1.8.1-SNAPSHOT + 1.9.0-SNAPSHOT jar Java IBAN From 685763dcbb63ef12d16c170a3586de7b9b7c7bfd Mon Sep 17 00:00:00 2001 From: Barend Garvelink Date: Sat, 3 Apr 2021 17:56:02 +0200 Subject: [PATCH 07/14] update template-maven-plugin to 2021.4.28 --- pom.xml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index 9c25352..0b90a55 100644 --- a/pom.xml +++ b/pom.xml @@ -100,7 +100,7 @@ template-maven-plugin com.github.terefang.template - 2021.4.19 + 2021.4.28 generate-code @@ -115,13 +115,6 @@ - - - com.hubspot.jinjava - jinjava - 2.5.6 - - org.codehaus.mojo From 90f09b832c7e06baa7b50ae8add8a5a719a4867b Mon Sep 17 00:00:00 2001 From: Barend Garvelink Date: Sat, 3 Apr 2021 18:08:41 +0200 Subject: [PATCH 08/14] GitHub Actions: use default Java action Eliminates the docker pull which might fail. One fewer third-party to rely on. --- .github/workflows/main.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index edbc1c9..cd55113 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -7,9 +7,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout Source - uses: actions/checkout@master - - name: Run Tests - uses: docker://maven:3.6-jdk-8-slim + uses: actions/checkout@v2 + - name: Set up JDK 1.8 + uses: actions/setup-java@v1 with: - entrypoint: /usr/bin/mvn - args: --quiet --strict-checksums verify + java-version: 1.8 + - name: Maven Build + run: mvn --batch-mode --strict-checksums --show-version verify From 5631b3b6628969a982812800893a44cbfa80f13b Mon Sep 17 00:00:00 2001 From: Barend Garvelink Date: Sat, 3 Apr 2021 18:47:40 +0200 Subject: [PATCH 09/14] matrix-build with LTS versions + current --- .github/workflows/main.yml | 22 ++++++++++++++++++---- pom.xml | 4 ++-- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index cd55113..abd2abb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,16 +1,30 @@ +--- name: Automated checks -on: push +"on": push jobs: unittests: name: Run Unit Tests runs-on: ubuntu-latest + strategy: + matrix: + java: + - 1.8 # LTS + - 11 # LTS + - 16 # Current steps: - name: Checkout Source uses: actions/checkout@v2 - - name: Set up JDK 1.8 + - name: Set up JDK ${{ matrix.java }} uses: actions/setup-java@v1 with: - java-version: 1.8 + java-version: ${{ matrix.java }} - name: Maven Build - run: mvn --batch-mode --strict-checksums --show-version verify + run: > + mvn + --batch-mode + --strict-checksums + --show-version + -Dmaven.compiler.source=${{ matrix.java }} + -Dmaven.compiler.target=${{ matrix.java }} + verify diff --git a/pom.xml b/pom.xml index 0b90a55..d3b1a4e 100644 --- a/pom.xml +++ b/pom.xml @@ -79,6 +79,8 @@ UTF-8 + 1.8 + 1.8 @@ -139,8 +141,6 @@ maven-compiler-plugin 3.8.1 - 1.8 - 1.8 UTF-8 true From a421efc00367f80ce6ef6c3cb97e3baca789c2f4 Mon Sep 17 00:00:00 2001 From: Barend Garvelink Date: Sat, 3 Apr 2021 19:06:09 +0200 Subject: [PATCH 10/14] Add badges to README --- .github/workflows/main.yml | 2 +- docs/index.md | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index abd2abb..54bf2d5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,5 +1,5 @@ --- -name: Automated checks +name: Build "on": push jobs: diff --git a/docs/index.md b/docs/index.md index abf40f3..413629e 100644 --- a/docs/index.md +++ b/docs/index.md @@ -15,6 +15,8 @@ version of the IBAN registry, but I don't plan on developing any new features. * [Alternatives](#Alternatives) * [Copyright and License](#Copyright-and-License) +[![Build](https://github.com/barend/java-iban/actions/workflows/main.yml/badge.svg)](https://github.com/barend/java-iban/actions/workflows/main.yml) [![CodeQL](https://github.com/barend/java-iban/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/barend/java-iban/actions/workflows/codeql-analysis.yml) + ### Installation Grab a package [from Github][download] or get it from Maven Central: From d8e88d43cb414facd18991d5dafb792a20a9065f Mon Sep 17 00:00:00 2001 From: Barend Garvelink Date: Sat, 3 Apr 2021 19:39:31 +0200 Subject: [PATCH 11/14] apply --strict-checksums to release builds --- pom.xml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index d3b1a4e..57880e4 100644 --- a/pom.xml +++ b/pom.xml @@ -79,8 +79,8 @@ UTF-8 - 1.8 - 1.8 + 1.8 + 1.8 @@ -180,6 +180,7 @@ maven-release-plugin 2.5.3 + --strict-checksums true deploy false From 98f3cf83932e4692f8aa1a477b99087227161bdf Mon Sep 17 00:00:00 2001 From: Barend Garvelink Date: Sat, 3 Apr 2021 21:28:38 +0200 Subject: [PATCH 12/14] remove unused pom profile --- pom.xml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/pom.xml b/pom.xml index 57880e4..7bada1c 100644 --- a/pom.xml +++ b/pom.xml @@ -240,15 +240,5 @@ - - github - - - github - GitHub Apache Maven Packages - https://maven.pkg.github.com/barend/java-iban - - - From 6f159e9f3127cc30c7d305b6e521cc3dd1fbaeb9 Mon Sep 17 00:00:00 2001 From: Barend Garvelink Date: Sat, 3 Apr 2021 21:07:17 +0200 Subject: [PATCH 13/14] evaluate module-info.java during CI build --- pom.xml | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/pom.xml b/pom.xml index 7bada1c..8bebf9a 100644 --- a/pom.xml +++ b/pom.xml @@ -124,6 +124,7 @@ 3.2.0 + include-extra-sources-dir generate-sources add-source @@ -193,6 +194,57 @@ + + + java11-module + + + + maven.compiler.target + 11 + + + + + + org.codehaus.mojo + build-helper-maven-plugin + 3.2.0 + + + include-extra-sources-dir + generate-sources + + add-source + + + + ${project.basedir}/src/main/java11 + ${project.build.directory}/generated-sources/jinjava + + + + + + + + release @@ -242,3 +294,4 @@ + From 4e5d803fdbff6a1931eb20d76e6226560c9883d5 Mon Sep 17 00:00:00 2001 From: Barend Garvelink Date: Sat, 3 Apr 2021 21:18:02 +0200 Subject: [PATCH 14/14] prevent instantiation of IBANFields{,Compat} class --- src/main/java/nl/garvelink/iban/IBANFields.java | 3 +++ src/main/java/nl/garvelink/iban/IBANFieldsCompat.java | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/main/java/nl/garvelink/iban/IBANFields.java b/src/main/java/nl/garvelink/iban/IBANFields.java index c80bc8f..f95be0b 100644 --- a/src/main/java/nl/garvelink/iban/IBANFields.java +++ b/src/main/java/nl/garvelink/iban/IBANFields.java @@ -58,4 +58,7 @@ public static Optional getBankIdentifier(IBAN iban) { public static Optional getBranchIdentifier(IBAN iban) { return Optional.ofNullable(CountryCodes.getBranchIdentifier(iban)); } + + /** Prevent instantiation of static utility class. */ + private IBANFields() { } } diff --git a/src/main/java/nl/garvelink/iban/IBANFieldsCompat.java b/src/main/java/nl/garvelink/iban/IBANFieldsCompat.java index fcf6757..53a6d7a 100644 --- a/src/main/java/nl/garvelink/iban/IBANFieldsCompat.java +++ b/src/main/java/nl/garvelink/iban/IBANFieldsCompat.java @@ -53,4 +53,7 @@ public static String getBankIdentifier(IBAN iban) { public static String getBranchIdentifier(IBAN iban) { return CountryCodes.getBranchIdentifier(iban); } + + /** Prevent instantiation of static utility class. */ + private IBANFieldsCompat() { } }