branch jdk11 created (now 5e29e2f)
This is an automated email from the git hooks/post-receive script. New change to branch jdk11 in repository i18n. See https://gitlab.nuiton.org/nuiton/i18n.git at 5e29e2f Use ClassGraph to iterate through classpath This branch includes the following new commits: new 5e29e2f Use ClassGraph to iterate through classpath The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 5e29e2f913108ba2b2f123bc94b50a6ac4fac1f2 Author: jcouteau <couteau@codelutin.com> Date: Mon Jul 4 09:55:08 2022 +0200 Use ClassGraph to iterate through classpath -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch jdk11 in repository i18n. See https://gitlab.nuiton.org/nuiton/i18n.git commit 5e29e2f913108ba2b2f123bc94b50a6ac4fac1f2 Author: jcouteau <couteau@codelutin.com> Date: Mon Jul 4 09:55:08 2022 +0200 Use ClassGraph to iterate through classpath --- nuiton-i18n/pom.xml | 5 +++++ .../org/nuiton/i18n/init/ClassPathI18nInitializer.java | 13 ++----------- .../src/test/java/org/nuiton/i18n/I18nTest.java | 18 ++---------------- pom.xml | 8 +++++++- 4 files changed, 16 insertions(+), 28 deletions(-) diff --git a/nuiton-i18n/pom.xml b/nuiton-i18n/pom.xml index bb9700a..8edb62f 100644 --- a/nuiton-i18n/pom.xml +++ b/nuiton-i18n/pom.xml @@ -84,6 +84,11 @@ <scope>test</scope> </dependency> + <dependency> + <groupId>io.github.classgraph</groupId> + <artifactId>classgraph</artifactId> + </dependency> + </dependencies> <profiles> diff --git a/nuiton-i18n/src/main/java/org/nuiton/i18n/init/ClassPathI18nInitializer.java b/nuiton-i18n/src/main/java/org/nuiton/i18n/init/ClassPathI18nInitializer.java index 4b6bcde..cb73d94 100644 --- a/nuiton-i18n/src/main/java/org/nuiton/i18n/init/ClassPathI18nInitializer.java +++ b/nuiton-i18n/src/main/java/org/nuiton/i18n/init/ClassPathI18nInitializer.java @@ -25,6 +25,7 @@ package org.nuiton.i18n.init; +import io.github.classgraph.ClassGraph; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.i18n.I18nUtil; @@ -32,9 +33,6 @@ import org.nuiton.i18n.bundle.I18nBundle; import org.nuiton.i18n.bundle.I18nBundleUtil; import java.net.URL; -import java.net.URLClassLoader; -import java.util.ArrayList; -import java.util.Arrays; import java.util.Iterator; import java.util.List; @@ -77,14 +75,7 @@ public class ClassPathI18nInitializer extends I18nInitializer { } public URL[] resolvURLs() throws Exception { - - // on calcule toutes les urls utilisable dans le classloader donnee - if (!(loader instanceof URLClassLoader)) { - throw new IllegalStateException("This instance of I18nInitializer is only compatible with URLClassLoader"); - } - URLClassLoader urlClassLoader = (URLClassLoader) loader; - URL[] deepURLs = I18nUtil.getDeepURLs(urlClassLoader); - List<URL> urlToSeek = new ArrayList<>(Arrays.asList(deepURLs)); + List<URL> urlToSeek = new ClassGraph().getClasspathURLs(); // on va maintenant supprimer toutes les urls qui ne respectent pas // le pattern i18n : il faut que la resource contienne un repertoire i18n diff --git a/nuiton-i18n/src/test/java/org/nuiton/i18n/I18nTest.java b/nuiton-i18n/src/test/java/org/nuiton/i18n/I18nTest.java index 724a926..7a08d8f 100644 --- a/nuiton-i18n/src/test/java/org/nuiton/i18n/I18nTest.java +++ b/nuiton-i18n/src/test/java/org/nuiton/i18n/I18nTest.java @@ -58,16 +58,13 @@ public class I18nTest { } @After - public void after() throws Exception { + public void after() { I18n.close(); } @Test public void testWithNoInit() { - // Ce test ne peut pas fonctionner avec un ClassPathI18nInitializer si on a pas d'URLClassLoader - Assume.assumeTrue(getClass().getClassLoader() instanceof URLClassLoader); - String expected; String actual; @@ -82,9 +79,6 @@ public class I18nTest { @Test public void testWithNoInit2() { - // Ce test ne peut pas fonctionner avec un ClassPathI18nInitializer si on a pas d'URLClassLoader - Assume.assumeTrue(getClass().getClassLoader() instanceof URLClassLoader); - String expected; String actual; @@ -103,12 +97,9 @@ public class I18nTest { @Test public void testDefaultInit() { - // Ce test ne peut pas fonctionner avec un ClassPathI18nInitializer si on a pas d'URLClassLoader - Assume.assumeTrue(getClass().getClassLoader() instanceof URLClassLoader); - Assert.assertNull(I18n.store); - I18n.init(null, (Locale) null); + I18n.init(null, null); Assert.assertNotNull(I18n.store); Assert.assertNotNull(I18n.getDefaultLocale()); @@ -136,7 +127,6 @@ public class I18nTest { // passage en français I18n.init(initializer, Locale.FRANCE); -// I18n.getStore().setLanguage(Locale.FRANCE); expected = "Clé avec %s"; actual = I18n.t("key.with.param"); @@ -149,7 +139,6 @@ public class I18nTest { // passage en anglais I18n.setDefaultLocale(Locale.UK); -// I18n.getStore().setLanguage(Locale.UK); expected = "Key with %s"; actual = I18n.t("key.with.param"); @@ -162,7 +151,6 @@ public class I18nTest { // passage langue inconnue I18n.setDefaultLocale(Locale.CHINA); -// I18n.getStore().setLanguage(Locale.CHINA); expected = "key.with.param"; actual = I18n.t("key.with.param"); @@ -193,8 +181,6 @@ public class I18nTest { // en anglais -// I18n.getStore().setLanguage(Locale.UK); - expected = "Key with %s"; actual = I18n.l(Locale.UK, "key.with.param"); Assert.assertEquals(expected, actual); diff --git a/pom.xml b/pom.xml index 761e846..7c8baa1 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ <parent> <groupId>org.nuiton</groupId> <artifactId>nuitonpom</artifactId> - <version>11.9</version> + <version>11.11</version> </parent> <artifactId>i18n</artifactId> @@ -78,6 +78,12 @@ <artifactId>guava</artifactId> <version>31.1-jre</version> </dependency> + + <dependency> + <groupId>io.github.classgraph</groupId> + <artifactId>classgraph</artifactId> + <version>4.8.147</version> + </dependency> <dependency> <groupId>org.apache.commons</groupId> -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
participants (1)
-
nuiton.org scm