cal10n-dev
Threads by month
- ----- 2025 -----
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
August 2009
- 6 participants
- 27 discussions

[cai18n-dev] [GIT] Compiler assisted internalization library branch, master, updated. v0.1-4-g7c173a4
by git-noreply@pixie.qos.ch 28 Aug '09
by git-noreply@pixie.qos.ch 28 Aug '09
28 Aug '09
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Compiler assisted internalization library".
The branch, master has been updated
via 7c173a44f1aa6fd04b31afa895a616c6cf34745e (commit)
from 2ce155fac9190d5e05ca17063c78683985ffcdb6 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.qos.ch/gitweb/?p=cai18n.git;a=commit;h=7c173a44f1aa6fd04b31afa89…
http://github.com/ceki/cai18n/commit/7c173a44f1aa6fd04b31afa895a616c6cf3474…
commit 7c173a44f1aa6fd04b31afa895a616c6cf34745e
Author: Ceki Gulcu <ceki(a)qos.ch>
Date: Fri Aug 28 18:04:31 2009 +0200
- entry relating to release 0.3
diff --git a/cai18n-site/src/site/pages/news.html b/cai18n-site/src/site/pages/news.html
index 7c2af99..7f2ecd7 100644
--- a/cai18n-site/src/site/pages/news.html
+++ b/cai18n-site/src/site/pages/news.html
@@ -29,6 +29,10 @@
<hr width="80%" align="center" />
+ <h3>28th of August 2009 - Release of CAI18N version 0.3</h3>
+
+ <p>Same code, improved documentation.</p>
+
<h3>28th of August 2009 - Release of CAI18N version 0.2</h3>
<p>Editing changes attributing original idea for CAI18N to Takeshi
-----------------------------------------------------------------------
Summary of changes:
cai18n-site/src/site/pages/news.html | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
hooks/post-receive
--
Compiler assisted internalization library
1
0

[cai18n-dev] [GIT] Compiler assisted internalization library branch, master, updated. v0.1-3-g2ce155f
by git-noreply@pixie.qos.ch 28 Aug '09
by git-noreply@pixie.qos.ch 28 Aug '09
28 Aug '09
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Compiler assisted internalization library".
The branch, master has been updated
via 2ce155fac9190d5e05ca17063c78683985ffcdb6 (commit)
from 1fec687141367be578aea7dfbdedae5fad92f8cb (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.qos.ch/gitweb/?p=cai18n.git;a=commit;h=2ce155fac9190d5e05ca17063…
http://github.com/ceki/cai18n/commit/2ce155fac9190d5e05ca17063c78683985ffcd…
commit 2ce155fac9190d5e05ca17063c78683985ffcdb6
Author: Ceki Gulcu <ceki(a)qos.ch>
Date: Fri Aug 28 18:02:35 2009 +0200
- same code better docs
- preparing release 0.3
diff --git a/cai18n-api/pom.xml b/cai18n-api/pom.xml
index cfa7ce2..2b491f6 100644
--- a/cai18n-api/pom.xml
+++ b/cai18n-api/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>ch.qos.cai18n</groupId>
<artifactId>cai18n-parent</artifactId>
- <version>0.2</version>
+ <version>0.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/cai18n-api/src/main/java/ch/qos/cai18n/verifier/Cai18nError.java b/cai18n-api/src/main/java/ch/qos/cai18n/verifier/Cai18nError.java
index f75420b..a1b3b2a 100644
--- a/cai18n-api/src/main/java/ch/qos/cai18n/verifier/Cai18nError.java
+++ b/cai18n-api/src/main/java/ch/qos/cai18n/verifier/Cai18nError.java
@@ -75,7 +75,7 @@ public class Cai18nError {
public String toString() {
switch (errorType) {
case MISSING_RBN_ANNOTATION:
- return "Missing @ResourceBundleName annotation in enum class ["
+ return "Missing @ResourceBundleName annotation in enum type ["
+ enumClassName + "]";
// case MISSING_LOCALE_NAMES_ANNOTATION:
// return "Missing @LocaleNames annotation in enum class [" +
@@ -83,19 +83,19 @@ public class Cai18nError {
// + "]";
case FAILED_TO_FIND_RB:
return "Failed to locate resource bundle [" + resouceBundleName
- + "]for locale [" + locale + "] for enum class [" + enumClassName
+ + "]for locale [" + locale + "] for enum type [" + enumClassName
+ "]";
case EMPTY_RB:
return "Empty resource bundle named [" + resouceBundleName
+ "] for locale [" + locale + "]";
case EMPTY_ENUM:
- return "Empty enum class [" + enumClassName + "]";
+ return "Empty enum type [" + enumClassName + "]";
case ABSENT_IN_ENUM:
return "Code [" + code + "] present in resource bundle named ["
+ resouceBundleName + "] for locale [" + locale
- + "] but absent in enum class [" + enumClassName + "]";
+ + "] but absent in enum type [" + enumClassName + "]";
case ABSENT_IN_RB:
- return "Code [" + code + "] present in enum class [" + enumClassName
+ return "Code [" + code + "] present in enum type [" + enumClassName
+ "] but absent in resource bundle named [" + resouceBundleName
+ "] for locale [" + locale + "]";
default:
diff --git a/cai18n-api/src/test/java/ch/qos/cai18n/sample/MyColorVerificationTest.java b/cai18n-api/src/test/java/ch/qos/cai18n/sample/MyColorVerificationTest.java
index 7a3d5aa..12f94c2 100644
--- a/cai18n-api/src/test/java/ch/qos/cai18n/sample/MyColorVerificationTest.java
+++ b/cai18n-api/src/test/java/ch/qos/cai18n/sample/MyColorVerificationTest.java
@@ -39,6 +39,9 @@ public class MyColorVerificationTest {
public void en_UK() {
IMessageCodeVerifier mcv = new MessageCodeVerifier(Colors.class);
List<Cai18nError> errorList = mcv.verify(Locale.UK);
+ for(Cai18nError error: errorList) {
+ System.out.println(error);
+ }
assertEquals(0, errorList.size());
}
@@ -46,6 +49,9 @@ public class MyColorVerificationTest {
public void fr() {
IMessageCodeVerifier mcv = new MessageCodeVerifier(Colors.class);
List<Cai18nError> errorList = mcv.verify(Locale.FRANCE);
+ for(Cai18nError error: errorList) {
+ System.out.println(error);
+ }
assertEquals(0, errorList.size());
}
}
diff --git a/cai18n-api/src/test/resources/colors_fr.properties b/cai18n-api/src/test/resources/colors_fr.properties
index 0ea9e8c..93c28bb 100644
--- a/cai18n-api/src/test/resources/colors_fr.properties
+++ b/cai18n-api/src/test/resources/colors_fr.properties
@@ -1,3 +1,3 @@
-BLUE=les violettes sont bleues
+BLEU=les violettes sont bleues
RED=les roses sont rouges
GREEN=les {0} sont verts
\ No newline at end of file
diff --git a/cai18n-site/pom.xml b/cai18n-site/pom.xml
index d664cfa..b9f03d3 100644
--- a/cai18n-site/pom.xml
+++ b/cai18n-site/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>ch.qos.cai18n</groupId>
<artifactId>cai18n-parent</artifactId>
- <version>0.2</version>
+ <version>0.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/cai18n-site/src/site/pages/manual.html b/cai18n-site/src/site/pages/manual.html
index a274a08..e882817 100644
--- a/cai18n-site/src/site/pages/manual.html
+++ b/cai18n-site/src/site/pages/manual.html
@@ -33,7 +33,7 @@
ResourceBundles</a>.
</p>
- <h3>Acknowledgement</h3>
+ <h3>Acknowledgment</h3>
<p>The original idea behind CAI18N is attributed to Takeshi Kondo. It
consolidated into what it is today subsequent to a <a
@@ -56,7 +56,7 @@
import ch.qos.cai18n.LocaleNames;
import ch.qos.cai18n.ResourceBundleName;
-@ResourceBundleName("colors") // mandatory annonation
+@ResourceBundleName("colors") // mandatory annotation
@LocaleNames({"en_UK", "fr"}) // list of locale names used by
// verification tools
public enum Colors {
@@ -91,7 +91,7 @@ GREEN=les {0} sont verts</pre>
<h2>Retrieving internationalized messages</h2>
- <p>In your application, you would retreive the localized message as
+ <p>In your application, you would retrieve the localized message as
follows: </p>
<pre class="prettyprint source">// obtain a message conveyor for France
@@ -140,6 +140,9 @@ public class MyColorVerificationTest {
public void en_UK() {
IMessageCodeVerifier mcv = new MessageCodeVerifier(Colors.class);
List<Cai18nError> errorList = mcv.verify(Locale.UK);
+ for(Cai18nError error: errorList) {
+ System.out.println(error);
+ }
assertEquals(0, errorList.size());
}
@@ -147,13 +150,42 @@ public class MyColorVerificationTest {
public void fr() {
IMessageCodeVerifier mcv = new MessageCodeVerifier(Colors.class);
List<Cai18nError> errorList = mcv.verify(Locale.FRANCE);
+ for(Cai18nError error: errorList) {
+ System.out.println(error);
+ }
assertEquals(0, errorList.size());
}
} </pre>
- <p>Instead of a unit test case for each locale, assuming you
- declared the locales in the enum type via the @LocaleNames
- annotation, you can verify all locales in one sweeping step.</p>
+ <p>The above unit tests start by creating a
+ <code>MessageCodeVerifier</code> instance associated with an enum
+ type, <code>Colors</code> in this case. The test proceeds to invoke
+ the <code>verify()</code> method passing a locale as an
+ argument. The <code>verify()</code> method returns the list of
+ errors, that is the list of discrepancies between the codes listed
+ in the enum type and the correspondign resource bundle. An empty
+ list will be returned if there are no errors.
+ </p>
+
+ <p>The unit test verifies that no errors have occured by asserting
+ that the size of the error list is zero.</p>
+
+ <p>Suppose the code "BLUE" was misspelled as "BLEU" in the
+ <em>colors_fr.properties</em> resource bundle. The unit test would
+ print the following list of errors and throw an
+ <code>AssertionError</code>.
+
+ </p>
+ <pre class="source">Code [BLUE] present in enum type [ch.qos.cai18n.sample.Colors] but absent in resource bundle \
+ named [colors] for locale [fr_FR]
+Code [BLEU] present in resource bundle named [colors] for locale [fr_FR] but absent \
+ in enum type [ch.qos.cai18n.sample.Colors]</pre>
+
+ <h3>One test to rule them all</h3>
+
+ <p>Instead of a separate unit test case for each locale, assuming
+ you declared the locales in the enum type via the @LocaleNames
+ annotation, you can verify all locales in one fell swoop.</p>
<pre class="prettyprint source">
package foo.aPackage;
@@ -176,6 +208,9 @@ public class MyAllInOneColorVerificationTest {
public void all() {
IMessageCodeVerifier mcv = new MessageCodeVerifier(Colors.class);
List<Cai18nError> errorList = mcv.verifyAllLocales();
+ for(Cai18nError error: errorList) {
+ System.out.println(error);
+ }
assertEquals(0, errorList.size());
}
} </pre>
@@ -186,12 +221,13 @@ public class MyAllInOneColorVerificationTest {
<p>The CAI18N project ships with a maven plugin designed to verify
that the keys specified in a given enum type match those found in
the corresponding resource bundles and for each locale. Our plugin
- is unsuprisingly called <em>mvn-cai18n-plugin</em>.
+ is unsurprisingly called <em>mvn-cai18n-plugin</em>.
</p>
- <p><b>At this very early stage of the CAI18N project, you need to
- install the <em>maven-cai18n-plugin</em> by running "maven install"
- from the folder where you unpacked the CAI18N distribution.</b>
+ <p><b>Until the relevant artifacts are uploaded to the central maven
+ repository, you unfortunately need to install the
+ <em>maven-cai18n-plugin</em> manually by running "mvn install" from
+ the folder where you unpacked the CAI18N distribution.</b>
</p>
<p>Using <em>maven-cai18n-plugin</em> is pretty easy. To verify
@@ -230,7 +266,7 @@ public class MyAllInOneColorVerificationTest {
<p>After you add the above snippet to the pom.xml file of your
project, <em>maven-cai18n-plugin</em> will make sure that
- your resource bundles and your enum type are in synhronized.
+ your resource bundles and your enum type are in synchronized.
</p>
<p>The plugin will iterate through every resource bundle for every
@@ -238,12 +274,50 @@ public class MyAllInOneColorVerificationTest {
annotation.
</p>
+ <h2>Eclipse plug-in</h2>
+
+ <p>We are looking for volunteers willing to implement IDE support
+ for CAI18N. Below is a litst of possible features of this IDE which
+ we think could have added value.
+ </p>
+
+ <ul>
+ <li><b>mismatch highlighting</b>
+ <p>While editing a property file,
+ highlight any keys, a.k.a. message codes, that do not match the
+ keys defined in the corresponding enum type.</p>
+ </li>
+
+
+ <li><b>auto-correction</b>
+ <p>The mismatch highlighting feature could be enhanced by making
+ correction suggestions. For example, if in the property file the
+ user misspells the key "red_elephant" as "red_elefant", by
+ measuring the <a
+ href="http://en.wikipedia.org/wiki/Levenshtein_distance">Levenshtein
+ distance</a> the plug-in could propose the nearest neighhbor of
+ "red_elefant" in the enum type, which should be "red_elephant"
+ with high probability.
+ </p>
+ </li>
+
+ <li>
+ <b>Skeleton generation</b>
+ <p>Given an enum type, generate the skeleton of the
+ corresponding resource bundle</p>
+ </li>
+ </ul>
+
+
+ <p>If interested please contact the cai18n-dev mailing list.</p>
<h2>Ant task</h2>
<p>We are looking for volunteers to implement an Ant task to verify
- resource bundles. If interested please contact the cai18n-dev
- mailing list.</p>
+ resource bundles. The Ant task could be modeled after the
+ <em>maven-cai18n-plugin</em> altough the Ant plugin is likely to be
+ simpler. If interested please contact the cai18n-dev mailing
+ list.</p>
<script src="templates/footer.js" type="text/javascript"></script>
</div>
diff --git a/maven-cai18n-plugin-smoke/pom.xml b/maven-cai18n-plugin-smoke/pom.xml
index 0a3b491..3d6cfac 100644
--- a/maven-cai18n-plugin-smoke/pom.xml
+++ b/maven-cai18n-plugin-smoke/pom.xml
@@ -4,7 +4,7 @@
<parent>
<groupId>ch.qos.cai18n</groupId>
<artifactId>cai18n-parent</artifactId>
- <version>0.2</version>
+ <version>0.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/maven-cai18n-plugin/pom.xml b/maven-cai18n-plugin/pom.xml
index 9bfcff9..7bfbd12 100644
--- a/maven-cai18n-plugin/pom.xml
+++ b/maven-cai18n-plugin/pom.xml
@@ -8,7 +8,7 @@
<parent>
<artifactId>cai18n-parent</artifactId>
<groupId>ch.qos.cai18n</groupId>
- <version>0.2</version>
+ <version>0.3</version>
</parent>
<groupId>ch.qos.cai18n.plugins</groupId>
diff --git a/pom.xml b/pom.xml
index 9b5103b..6068ef0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
<groupId>ch.qos.cai18n</groupId>
<artifactId>cai18n-parent</artifactId>
<packaging>pom</packaging>
- <version>0.2</version>
+ <version>0.3</version>
<name>Compiler assisted internationalization library (CAI18N) - Parent</name>
<url>http://cai18n.qos.ch</url>
-----------------------------------------------------------------------
Summary of changes:
cai18n-api/pom.xml | 2 +-
.../java/ch/qos/cai18n/verifier/Cai18nError.java | 10 +-
.../qos/cai18n/sample/MyColorVerificationTest.java | 6 +
cai18n-api/src/test/resources/colors_fr.properties | 2 +-
cai18n-site/pom.xml | 2 +-
cai18n-site/src/site/pages/manual.html | 100 +++++++++++++++++---
maven-cai18n-plugin-smoke/pom.xml | 2 +-
maven-cai18n-plugin/pom.xml | 2 +-
pom.xml | 2 +-
9 files changed, 104 insertions(+), 24 deletions(-)
hooks/post-receive
--
Compiler assisted internalization library
1
0

[cai18n-dev] [GIT] Compiler assisted internalization library branch, master, updated. v0.1-2-g1fec687
by git-noreply@pixie.qos.ch 28 Aug '09
by git-noreply@pixie.qos.ch 28 Aug '09
28 Aug '09
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Compiler assisted internalization library".
The branch, master has been updated
via 1fec687141367be578aea7dfbdedae5fad92f8cb (commit)
via 29c2fe5918033438a9fe7f5d71f0e1a4c0fa2953 (commit)
from 398d827991fe13d96c27ee5ee8f539e79af5894a (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.qos.ch/gitweb/?p=cai18n.git;a=commit;h=1fec687141367be578aea7dfb…
http://github.com/ceki/cai18n/commit/1fec687141367be578aea7dfbdedae5fad92f8…
commit 1fec687141367be578aea7dfbdedae5fad92f8cb
Author: Ceki Gulcu <ceki(a)qos.ch>
Date: Fri Aug 28 12:02:05 2009 +0200
minor doc improvements
diff --git a/cai18n-site/src/site/pages/manual.html b/cai18n-site/src/site/pages/manual.html
index 622947a..a274a08 100644
--- a/cai18n-site/src/site/pages/manual.html
+++ b/cai18n-site/src/site/pages/manual.html
@@ -113,10 +113,12 @@ String blue = mc.getMessage(Colors.BLUE); </pre>
<h2>Verification as a test case</h2>
- <p>You can quickly and easily check for mismatches between a given
- enum type and the corresponding resource bundles.</p>
+ <p>A convenient and low hassle method for checking for mismatches
+ between a given enum type and the corresponding resource bundles is
+ through Junit test cases.</p>
- <p>Here is the unit test</p>
+ <p>Here is a sample Junit test for the Colors enum discussed
+ above.</p>
<pre class="prettyprint source">
package foo.aPackage;
@@ -187,9 +189,9 @@ public class MyAllInOneColorVerificationTest {
is unsuprisingly called <em>mvn-cai18n-plugin</em>.
</p>
- <p><b>At this very early stage, you need to install the
- <em>maven-cai18n-plugin</em> by running "maven install" from the
- folder where you unpacked the CAI18N distribution.</b>
+ <p><b>At this very early stage of the CAI18N project, you need to
+ install the <em>maven-cai18n-plugin</em> by running "maven install"
+ from the folder where you unpacked the CAI18N distribution.</b>
</p>
<p>Using <em>maven-cai18n-plugin</em> is pretty easy. To verify
diff --git a/cai18n-site/src/site/pages/news.html b/cai18n-site/src/site/pages/news.html
index 193b861..7c2af99 100644
--- a/cai18n-site/src/site/pages/news.html
+++ b/cai18n-site/src/site/pages/news.html
@@ -33,9 +33,13 @@
<p>Editing changes attributing original idea for CAI18N to Takeshi
Kondo, also mentioning the discussion involving Ralph Goers, Ceki
- Gülcü, Takeshi Kondo and Pete Muir on the slf4j-dev mailing list.
- usable. </p>
+ Gülcü, Takeshi Kondo and Pete Muir on the slf4j-dev
+ mailing list. usable. </p>
+
+ <p>Added a new section in the manual about verification using
+ Junit test cases.</p>
+ <p>Improved javadoc documentaion.</p>
<hr width="80%" align="center" />
http://git.qos.ch/gitweb/?p=cai18n.git;a=commit;h=29c2fe5918033438a9fe7f5d7…
http://github.com/ceki/cai18n/commit/29c2fe5918033438a9fe7f5d71f0e1a4c0fa29…
commit 29c2fe5918033438a9fe7f5d71f0e1a4c0fa2953
Author: Ceki Gulcu <ceki(a)qos.ch>
Date: Fri Aug 28 11:54:52 2009 +0200
- attribute original idea to Takeshi Kondo
- added doc on doing verificaion via unit testing
- preparing release 0.2
diff --git a/cai18n-api/pom.xml b/cai18n-api/pom.xml
index a6d5447..cfa7ce2 100644
--- a/cai18n-api/pom.xml
+++ b/cai18n-api/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>ch.qos.cai18n</groupId>
<artifactId>cai18n-parent</artifactId>
- <version>0.1</version>
+ <version>0.2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/cai18n-api/src/main/java/ch/qos/cai18n/Cai18nConstants.java b/cai18n-api/src/main/java/ch/qos/cai18n/Cai18nConstants.java
index 7568ff0..794bc49 100644
--- a/cai18n-api/src/main/java/ch/qos/cai18n/Cai18nConstants.java
+++ b/cai18n-api/src/main/java/ch/qos/cai18n/Cai18nConstants.java
@@ -1,5 +1,12 @@
package ch.qos.cai18n;
+/**
+ *
+ * This class defines the shared constants in CAI18N.
+ *
+ * @author Ceki Gülcü
+ *
+ */
public class Cai18nConstants {
final public static String CODE_URL_PREFIX = "http://cai18n.qos.ch/codes.html";
diff --git a/cai18n-api/src/main/java/ch/qos/cai18n/LocaleNames.java b/cai18n-api/src/main/java/ch/qos/cai18n/LocaleNames.java
index 776bf19..1ee5d1f 100644
--- a/cai18n-api/src/main/java/ch/qos/cai18n/LocaleNames.java
+++ b/cai18n-api/src/main/java/ch/qos/cai18n/LocaleNames.java
@@ -25,7 +25,38 @@ import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-
+
+import ch.qos.cai18n.verifier.MessageCodeVerifier;
+
+/**
+ * This annotation serves to designate a list of locale names for which resource
+ * bundles exist.
+ *
+ * <p>
+ * Typical usage is:
+ *
+ * <pre>
+ * @LocaleNames({"en", "jp"})
+ * @ResourceBundleName("colors");
+ * public class enum Colors {
+ * RED, WHITE, BLUE;
+ * }
+ * </pre>
+ *
+ * <p>
+ * In the above example, @LocaleNames({"en", "jp"}) means that there are English
+ * (en) and Japanese translations for the message codes found the Colors enum.
+ * The name of the corresponding resource bundle named "colors".
+ *
+ * <p>
+ * Verification tools such {@link MessageCodeVerifier} can thus conclude that
+ * the resource bundle files <em>colors_en.properties</em> and
+ * <em>colors_jp.properties</em> exist and should be checked against the codes
+ * defined in the Colors enum.
+ *
+ * @author Ceki Gülcü
+ *
+ */
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface LocaleNames {
diff --git a/cai18n-api/src/main/java/ch/qos/cai18n/MessageConveyor.java b/cai18n-api/src/main/java/ch/qos/cai18n/MessageConveyor.java
index d471b5a..8233741 100644
--- a/cai18n-api/src/main/java/ch/qos/cai18n/MessageConveyor.java
+++ b/cai18n-api/src/main/java/ch/qos/cai18n/MessageConveyor.java
@@ -28,14 +28,40 @@ import java.util.ResourceBundle;
import ch.qos.cai18n.util.AnnotationExtractor;
+/**
+ * The default implementation for {@link IMessageConveyor} based on resource
+ * bundles.
+ *
+ * <p>
+ * See also {@link #getMessage(Enum, Object...)} for details.
+ *
+ * @author Ceki Gülcü
+ */
public class MessageConveyor implements IMessageConveyor {
Locale locale;
+ /**
+ * The {@link Locale} associated with this instance.
+ *
+ * @param locale
+ */
public MessageConveyor(Locale locale) {
this.locale = locale;
}
+ /**
+ * Given an enum e, find the corresponding resource bundle and return the
+ * internationalized message defined by the message code 'e'.
+ *
+ * <p>
+ * The name of the resource bundle is defined via the
+ * {@link ResourceBundleName} annotation whereas the locale was specified in
+ * this MessageConveyor instance's constructor.
+ *
+ * @param e an enum instance used as message code
+ *
+ */
public <E extends Enum<?>> String getMessage(E e, Object... args) {
String code = e.toString();
diff --git a/cai18n-api/src/main/java/ch/qos/cai18n/ResourceBundleName.java b/cai18n-api/src/main/java/ch/qos/cai18n/ResourceBundleName.java
index e1e8b3c..788567a 100644
--- a/cai18n-api/src/main/java/ch/qos/cai18n/ResourceBundleName.java
+++ b/cai18n-api/src/main/java/ch/qos/cai18n/ResourceBundleName.java
@@ -22,12 +22,43 @@
package ch.qos.cai18n;
import java.lang.annotation.ElementType;
+
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
+import ch.qos.cai18n.verifier.MessageCodeVerifier;
+
+/**
+ * This annotation serves to designate the name of the resource bundle
+ * corresponding to an enum type.
+ *
+ * <p>
+ * Typical usage is:
+ *
+ * <pre>
+ * @LocaleNames({"en", "jp"})
+ * @ResourceBundleName("colors");
+ * public class enum Colors {
+ * RED, WHITE, BLUE;
+ * }
+ * </pre>
+ *
+ * <p>
+ * In the above example, @ResourceBundleName("colors") means that there exists
+ * resource files with the root name "colors". In conjunction with the
+ * information provided in the @LocaleNames annotation, we can assume that the
+ * files <em>colors_en.properties</em> and <em>colors_jp.properties</em> exist.
+ *
+ * <p>
+ * Verification tools such as {@link MessageCodeVerifier} can then proceed to
+ * check that the codes defined in the enum type match those in the resource bundles.
+ *
+ * @author Ceki Gülcü
+ *
+ */
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface ResourceBundleName {
String value();
-}
+}
diff --git a/cai18n-api/src/main/java/ch/qos/cai18n/package.html b/cai18n-api/src/main/java/ch/qos/cai18n/package.html
new file mode 100644
index 0000000..a3a71a7
--- /dev/null
+++ b/cai18n-api/src/main/java/ch/qos/cai18n/package.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+
+<html>
+<head>
+<title></title>
+</head>
+
+<body>
+
+<p>The main package of the CAI18N project.</p>
+
+<p>It contains the {@link IMessageConveyor} interface and the default
+implementation {@link MessageConveyor}.
+
+
+</p>
+</body>
+</html>
diff --git a/cai18n-api/src/main/java/ch/qos/cai18n/util/package.html b/cai18n-api/src/main/java/ch/qos/cai18n/util/package.html
new file mode 100644
index 0000000..271f684
--- /dev/null
+++ b/cai18n-api/src/main/java/ch/qos/cai18n/util/package.html
@@ -0,0 +1,16 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+
+<html>
+<head>
+<title></title>
+</head>
+
+<body>
+
+<p>Package containing utility classes, used internally by the CAI18N
+project.</p>
+
+
+</p>
+</body>
+</html>
diff --git a/cai18n-api/src/main/java/ch/qos/cai18n/verifier/ErrorFactory.java b/cai18n-api/src/main/java/ch/qos/cai18n/verifier/ErrorFactory.java
index 2f74f53..ddc1a85 100644
--- a/cai18n-api/src/main/java/ch/qos/cai18n/verifier/ErrorFactory.java
+++ b/cai18n-api/src/main/java/ch/qos/cai18n/verifier/ErrorFactory.java
@@ -25,19 +25,27 @@ import java.util.Locale;
import ch.qos.cai18n.verifier.Cai18nError.ErrorType;
+/**
+ * Simplifies the creation of {@link Cai18nError} instances.
+ *
+ * @author Ceki Gülcü
+ *
+ */
public class ErrorFactory {
final Locale locale;
final Class<?> enumClass;
final String resourceBundleName;
-
- public ErrorFactory(Class<?> enumClass, Locale locale, String resourceBundleName) {
+
+ public ErrorFactory(Class<?> enumClass, Locale locale,
+ String resourceBundleName) {
this.locale = locale;
this.enumClass = enumClass;
this.resourceBundleName = resourceBundleName;
}
-
+
Cai18nError buildError(ErrorType errorType, String code) {
- return new Cai18nError(errorType, code, enumClass, locale, resourceBundleName);
+ return new Cai18nError(errorType, code, enumClass, locale,
+ resourceBundleName);
}
}
diff --git a/cai18n-api/src/main/java/ch/qos/cai18n/verifier/IMessageCodeVerifier.java b/cai18n-api/src/main/java/ch/qos/cai18n/verifier/IMessageCodeVerifier.java
index 7fa7309..19a65d4 100644
--- a/cai18n-api/src/main/java/ch/qos/cai18n/verifier/IMessageCodeVerifier.java
+++ b/cai18n-api/src/main/java/ch/qos/cai18n/verifier/IMessageCodeVerifier.java
@@ -4,6 +4,11 @@ import java.util.List;
import java.util.Locale;
/**
+ * An interface for verifying that given an enum type, the keys match those
+ * found in the corresponding resource bundles.
+ *
+ * <p>
+ * See also {@link MessageCodeVerifier} for a concrete implementation.
*
* @author Ceki Gülcü
*
@@ -38,6 +43,16 @@ public interface IMessageCodeVerifier {
public List<Cai18nError> verify(Locale locale);
/**
+ * Verify that the keys defined in the enumClass match those found in the
+ * corresponding resource bundle for all locales declared in the enum type
+ * via the {@link @LocaleNames} annotation.
+ *
+ * @param locale
+ * @return
+ */
+ public List<Cai18nError> verifyAllLocales();
+
+ /**
* Same as {@link #verify(Locale)} except that the return type is
* List<String>.
*
diff --git a/cai18n-api/src/main/java/ch/qos/cai18n/verifier/MessageCodeVerifier.java b/cai18n-api/src/main/java/ch/qos/cai18n/verifier/MessageCodeVerifier.java
index 3992b8f..35bd09f 100644
--- a/cai18n-api/src/main/java/ch/qos/cai18n/verifier/MessageCodeVerifier.java
+++ b/cai18n-api/src/main/java/ch/qos/cai18n/verifier/MessageCodeVerifier.java
@@ -141,6 +141,29 @@ public class MessageCodeVerifier implements IMessageCodeVerifier {
return strList;
}
+ /***
+ * Verify all declared locales in one step.
+ */
+ public List<Cai18nError> verifyAllLocales() {
+ List<Cai18nError> errorList = new ArrayList<Cai18nError>();
+
+ String[] localeNameArray = getLocaleNames();
+
+ if (localeNameArray == null || localeNameArray.length == 0) {
+ String errMsg = "Missing @LocaleNames annotation in enum type ["
+ + enumTypeAsStr + "]";
+ throw new IllegalStateException(errMsg);
+ }
+ for (String localeName : localeNameArray) {
+ Locale locale = new Locale(localeName);
+ List<Cai18nError> tmpList = verify(locale);
+ errorList.addAll(tmpList);
+ }
+
+ return errorList;
+ }
+
+
/* (non-Javadoc)
* @see ch.qos.cai18n.verifier.IIMessageCodeVerifier#getLocaleNames()
*/
@@ -154,4 +177,6 @@ public class MessageCodeVerifier implements IMessageCodeVerifier {
return rbName;
}
+
+
}
diff --git a/cai18n-api/src/main/java/ch/qos/cai18n/verifier/package.html b/cai18n-api/src/main/java/ch/qos/cai18n/verifier/package.html
new file mode 100644
index 0000000..493d9fc
--- /dev/null
+++ b/cai18n-api/src/main/java/ch/qos/cai18n/verifier/package.html
@@ -0,0 +1,12 @@
+<html>
+ <head>
+ <title></title>
+ </head>
+
+ <body>
+
+ <p>Support classes for verifying that there are no message code
+ mis-matches between resource bundles and the corresponding enum type.</p>
+
+ </body>
+</html>
diff --git a/cai18n-api/src/test/java/ch/qos/cai18n/sample/Colors.java b/cai18n-api/src/test/java/ch/qos/cai18n/sample/Colors.java
index 3dc468a..f4a59e3 100644
--- a/cai18n-api/src/test/java/ch/qos/cai18n/sample/Colors.java
+++ b/cai18n-api/src/test/java/ch/qos/cai18n/sample/Colors.java
@@ -22,9 +22,11 @@
package ch.qos.cai18n.sample;
+import ch.qos.cai18n.LocaleNames;
import ch.qos.cai18n.ResourceBundleName;
@ResourceBundleName("colors")
+@LocaleNames({"en_UK", "fr"})
public enum Colors {
RED, BLUE, GREEN;
}
diff --git a/cai18n-api/src/test/java/ch/qos/cai18n/sample/Colors.java b/cai18n-api/src/test/java/ch/qos/cai18n/sample/MyAllInOneColorVerificationTest.java
similarity index 66%
copy from cai18n-api/src/test/java/ch/qos/cai18n/sample/Colors.java
copy to cai18n-api/src/test/java/ch/qos/cai18n/sample/MyAllInOneColorVerificationTest.java
index 3dc468a..0b0b2ad 100644
--- a/cai18n-api/src/test/java/ch/qos/cai18n/sample/Colors.java
+++ b/cai18n-api/src/test/java/ch/qos/cai18n/sample/MyAllInOneColorVerificationTest.java
@@ -19,12 +19,32 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
-
package ch.qos.cai18n.sample;
-import ch.qos.cai18n.ResourceBundleName;
-@ResourceBundleName("colors")
-public enum Colors {
- RED, BLUE, GREEN;
+import static org.junit.Assert.assertEquals;
+
+import java.util.List;
+
+import org.junit.Test;
+
+import ch.qos.cai18n.verifier.Cai18nError;
+import ch.qos.cai18n.verifier.IMessageCodeVerifier;
+import ch.qos.cai18n.verifier.MessageCodeVerifier;
+
+/**
+ *
+ * @author Ceki Gülcü
+ *
+ */
+public class MyAllInOneColorVerificationTest {
+
+
+ @Test
+ public void all() {
+ IMessageCodeVerifier mcv = new MessageCodeVerifier(Colors.class);
+ List<Cai18nError> errorList = mcv.verifyAllLocales();
+ assertEquals(0, errorList.size());
+ }
+
}
diff --git a/cai18n-api/src/main/java/ch/qos/cai18n/verifier/ErrorFactory.java b/cai18n-api/src/test/java/ch/qos/cai18n/sample/MyColorVerificationTest.java
similarity index 60%
copy from cai18n-api/src/main/java/ch/qos/cai18n/verifier/ErrorFactory.java
copy to cai18n-api/src/test/java/ch/qos/cai18n/sample/MyColorVerificationTest.java
index 2f74f53..7a3d5aa 100644
--- a/cai18n-api/src/main/java/ch/qos/cai18n/verifier/ErrorFactory.java
+++ b/cai18n-api/src/test/java/ch/qos/cai18n/sample/MyColorVerificationTest.java
@@ -19,25 +19,33 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
-package ch.qos.cai18n.verifier;
+package ch.qos.cai18n.sample;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.List;
import java.util.Locale;
-import ch.qos.cai18n.verifier.Cai18nError.ErrorType;
+import org.junit.Test;
-public class ErrorFactory {
+import ch.qos.cai18n.verifier.Cai18nError;
+import ch.qos.cai18n.verifier.IMessageCodeVerifier;
+import ch.qos.cai18n.verifier.MessageCodeVerifier;
- final Locale locale;
- final Class<?> enumClass;
- final String resourceBundleName;
-
- public ErrorFactory(Class<?> enumClass, Locale locale, String resourceBundleName) {
- this.locale = locale;
- this.enumClass = enumClass;
- this.resourceBundleName = resourceBundleName;
+public class MyColorVerificationTest {
+
+ @Test
+ public void en_UK() {
+ IMessageCodeVerifier mcv = new MessageCodeVerifier(Colors.class);
+ List<Cai18nError> errorList = mcv.verify(Locale.UK);
+ assertEquals(0, errorList.size());
}
-
- Cai18nError buildError(ErrorType errorType, String code) {
- return new Cai18nError(errorType, code, enumClass, locale, resourceBundleName);
+
+ @Test
+ public void fr() {
+ IMessageCodeVerifier mcv = new MessageCodeVerifier(Colors.class);
+ List<Cai18nError> errorList = mcv.verify(Locale.FRANCE);
+ assertEquals(0, errorList.size());
}
}
diff --git a/cai18n-site/pom.xml b/cai18n-site/pom.xml
index d170ce6..d664cfa 100644
--- a/cai18n-site/pom.xml
+++ b/cai18n-site/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>ch.qos.cai18n</groupId>
<artifactId>cai18n-parent</artifactId>
- <version>0.1</version>
+ <version>0.2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/cai18n-site/src/site/pages/index.html b/cai18n-site/src/site/pages/index.html
index 5b427df..94318e8 100644
--- a/cai18n-site/src/site/pages/index.html
+++ b/cai18n-site/src/site/pages/index.html
@@ -25,7 +25,6 @@
<p>Compiler Assisted Internationalization, abbreviated as CAI18N,
is a java library for writing internationalized messages.
</p>
-
<p>Before you start using CAI18N, we highly recommend that you read
the two-page <a href="manual.html">CAI18N user manual</a>.
diff --git a/cai18n-site/src/site/pages/manual.html b/cai18n-site/src/site/pages/manual.html
index eec52a8..622947a 100644
--- a/cai18n-site/src/site/pages/manual.html
+++ b/cai18n-site/src/site/pages/manual.html
@@ -21,6 +21,7 @@
</div>
<div id="content">
+
<h1>CAI18N Manual</h1>
@@ -32,6 +33,16 @@
ResourceBundles</a>.
</p>
+ <h3>Acknowledgement</h3>
+
+ <p>The original idea behind CAI18N is attributed to Takeshi Kondo. It
+ consolidated into what it is today subsequent to a <a
+ href="http://markmail.org/thread/drcabfc6z42sijdo">discussion</a>
+ involving Ralph Goers, Ceki Gülcü, Takeshi Kondo and Pete
+ Muir on the slf4j-dev mailing list.
+ </p>
+
+
<h3>Core idea</h3>
<p>Instead of using values of type String as the key each message,
@@ -100,6 +111,73 @@ String blue = mc.getMessage(Colors.BLUE); </pre>
comes with additional tooling support.
</p>
+ <h2>Verification as a test case</h2>
+
+ <p>You can quickly and easily check for mismatches between a given
+ enum type and the corresponding resource bundles.</p>
+
+ <p>Here is the unit test</p>
+
+ <pre class="prettyprint source">
+package foo.aPackage;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.List;
+import java.util.Locale;
+
+import org.junit.Test;
+
+import ch.qos.cai18n.verifier.Cai18nError;
+import ch.qos.cai18n.verifier.IMessageCodeVerifier;
+import ch.qos.cai18n.verifier.MessageCodeVerifier;
+
+public class MyColorVerificationTest {
+
+ @Test
+ public void en_UK() {
+ IMessageCodeVerifier mcv = new MessageCodeVerifier(Colors.class);
+ List<Cai18nError> errorList = mcv.verify(Locale.UK);
+ assertEquals(0, errorList.size());
+ }
+
+ @Test
+ public void fr() {
+ IMessageCodeVerifier mcv = new MessageCodeVerifier(Colors.class);
+ List<Cai18nError> errorList = mcv.verify(Locale.FRANCE);
+ assertEquals(0, errorList.size());
+ }
+} </pre>
+
+ <p>Instead of a unit test case for each locale, assuming you
+ declared the locales in the enum type via the @LocaleNames
+ annotation, you can verify all locales in one sweeping step.</p>
+
+ <pre class="prettyprint source">
+package foo.aPackage;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.List;
+import java.util.Locale;
+
+import org.junit.Test;
+
+import ch.qos.cai18n.verifier.Cai18nError;
+import ch.qos.cai18n.verifier.IMessageCodeVerifier;
+import ch.qos.cai18n.verifier.MessageCodeVerifier;
+
+public class MyAllInOneColorVerificationTest {
+
+ // verify all locales in one step
+ @Test
+ public void all() {
+ IMessageCodeVerifier mcv = new MessageCodeVerifier(Colors.class);
+ List<Cai18nError> errorList = mcv.verifyAllLocales();
+ assertEquals(0, errorList.size());
+ }
+} </pre>
+
<h2>Maven Plugin</h2>
@@ -133,7 +211,7 @@ String blue = mc.getMessage(Colors.BLUE); </pre>
<id>aNameOfYourChoice</id>
<phase>verify</phase>
<goals>
- <goal>check</goal>
+ <goal>verify</goal>
</goals>
<configuration>
<b><enumTypes></b>
diff --git a/cai18n-site/src/site/pages/news.html b/cai18n-site/src/site/pages/news.html
index 8f14f60..193b861 100644
--- a/cai18n-site/src/site/pages/news.html
+++ b/cai18n-site/src/site/pages/news.html
@@ -27,6 +27,15 @@
href="http://www.qos.ch/mailman/listinfo/cai18n-announce">cai18n-announce</a>
mailing list.</p>
+ <hr width="80%" align="center" />
+
+ <h3>28th of August 2009 - Release of CAI18N version 0.2</h3>
+
+ <p>Editing changes attributing original idea for CAI18N to Takeshi
+ Kondo, also mentioning the discussion involving Ralph Goers, Ceki
+ Gülcü, Takeshi Kondo and Pete Muir on the slf4j-dev mailing list.
+ usable. </p>
+
<hr width="80%" align="center" />
diff --git a/maven-cai18n-plugin-smoke/pom.xml b/maven-cai18n-plugin-smoke/pom.xml
index 7d4977e..0a3b491 100644
--- a/maven-cai18n-plugin-smoke/pom.xml
+++ b/maven-cai18n-plugin-smoke/pom.xml
@@ -4,7 +4,7 @@
<parent>
<groupId>ch.qos.cai18n</groupId>
<artifactId>cai18n-parent</artifactId>
- <version>0.1</version>
+ <version>0.2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -32,7 +32,7 @@
<id>countries</id>
<phase>verify</phase>
<goals>
- <goal>check</goal>
+ <goal>verify</goal>
</goals>
<configuration>
<enumTypes>
diff --git a/maven-cai18n-plugin-smoke/src/main/java/ch/qos/cai18n/smoke/package.html b/maven-cai18n-plugin-smoke/src/main/java/ch/qos/cai18n/smoke/package.html
new file mode 100644
index 0000000..19504e7
--- /dev/null
+++ b/maven-cai18n-plugin-smoke/src/main/java/ch/qos/cai18n/smoke/package.html
@@ -0,0 +1,11 @@
+<html>
+ <head>
+ <title></title>
+ </head>
+
+ <body>
+
+ <p>Smoke testing the maven plugin.
+ </p>
+ </body>
+</html>
diff --git a/maven-cai18n-plugin/pom.xml b/maven-cai18n-plugin/pom.xml
index efa4b13..9bfcff9 100644
--- a/maven-cai18n-plugin/pom.xml
+++ b/maven-cai18n-plugin/pom.xml
@@ -8,7 +8,7 @@
<parent>
<artifactId>cai18n-parent</artifactId>
<groupId>ch.qos.cai18n</groupId>
- <version>0.1</version>
+ <version>0.2</version>
</parent>
<groupId>ch.qos.cai18n.plugins</groupId>
diff --git a/maven-cai18n-plugin/src/main/java/ch/qos/cai18n/ThisFirstClassLoader.java b/maven-cai18n-plugin/src/main/java/ch/qos/cai18n/ThisFirstClassLoader.java
deleted file mode 100644
index c7165c5..0000000
--- a/maven-cai18n-plugin/src/main/java/ch/qos/cai18n/ThisFirstClassLoader.java
+++ /dev/null
@@ -1,71 +0,0 @@
-package ch.qos.cai18n;
-
-import java.net.URL;
-import java.net.URLClassLoader;
-
-/**
- * An almost trivial no fuss implementation of a class loader following the
- * child-first delegation model.
- *
- * @author Ceki Gülcü
- */
-public class ThisFirstClassLoader extends URLClassLoader {
-
- public ThisFirstClassLoader(URL[] urls) {
- super(urls);
- }
-
- public ThisFirstClassLoader(URL[] urls, ClassLoader parent) {
- super(urls, parent);
- }
-
- public void addURL(URL url) {
- super.addURL(url);
- }
-
- @Override
- public Class<?> loadClass(String name) throws ClassNotFoundException {
- return loadClass(name, false);
- }
-
- /**
- * We override the parent-first behavior established by java.lang.Classloader.
- *
- * The implementation is surprisingly straightforward.
- */
- protected Class<?> loadClass(String name, boolean resolve)
- throws ClassNotFoundException {
-
- if(name.equals("ch.qos.cai18n.verifier.IMessageCodeVerifier")) {
- return super.loadClass(name, resolve);
- }
-
- // First, check if the class has already been loaded
- Class<?> c = findLoadedClass(name);
-
- // if not loaded, search the local (child) resources
- if (c == null) {
- try {
- c = findClass(name);
- } catch (ClassNotFoundException cnfe) {
- // ignore
- }
- }
-
- // if we could not find it, delegate to parent
- // Note that we don't attempt to catch any ClassNotFoundException
- if (c == null) {
- if (getParent() != null) {
- c = getParent().loadClass(name);
- } else {
- c = getSystemClassLoader().loadClass(name);
- }
- }
-
- if (resolve) {
- resolveClass(c);
- }
-
- return c;
- }
-}
diff --git a/maven-cai18n-plugin/src/main/java/ch/qos/cai18n/plugins/ThisFirstClassLoader.java b/maven-cai18n-plugin/src/main/java/ch/qos/cai18n/plugins/ThisFirstClassLoader.java
new file mode 100644
index 0000000..12cf782
--- /dev/null
+++ b/maven-cai18n-plugin/src/main/java/ch/qos/cai18n/plugins/ThisFirstClassLoader.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2009 QOS.ch All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package ch.qos.cai18n.plugins;
+
+import java.net.URL;
+import java.net.URLClassLoader;
+
+/**
+ * An almost trivial no fuss implementation of a class loader following the
+ * child-first delegation model.
+ *
+ * @author Ceki Gülcü
+ */
+public class ThisFirstClassLoader extends URLClassLoader {
+
+ public ThisFirstClassLoader(URL[] urls) {
+ super(urls);
+ }
+
+ public ThisFirstClassLoader(URL[] urls, ClassLoader parent) {
+ super(urls, parent);
+ }
+
+ public void addURL(URL url) {
+ super.addURL(url);
+ }
+
+ @Override
+ public Class<?> loadClass(String name) throws ClassNotFoundException {
+ return loadClass(name, false);
+ }
+
+ /**
+ * We override the parent-first behavior established by java.lang.Classloader.
+ *
+ * The implementation is surprisingly straightforward.
+ */
+ protected Class<?> loadClass(String name, boolean resolve)
+ throws ClassNotFoundException {
+
+ // Treating IMessageCodeVerifier as a special case is the whole point of the
+ // exercise.
+ if (name.equals("ch.qos.cai18n.verifier.IMessageCodeVerifier")) {
+ return super.loadClass(name, resolve);
+ }
+
+ // First, check if the class has already been loaded
+ Class<?> c = findLoadedClass(name);
+
+ // if not loaded, search the local (child) resources
+ if (c == null) {
+ try {
+ c = findClass(name);
+ } catch (ClassNotFoundException cnfe) {
+ // ignore
+ }
+ }
+
+ // if we could not find it, delegate to parent
+ // Note that we don't attempt to catch any ClassNotFoundException
+ if (c == null) {
+ if (getParent() != null) {
+ c = getParent().loadClass(name);
+ } else {
+ c = getSystemClassLoader().loadClass(name);
+ }
+ }
+
+ if (resolve) {
+ resolveClass(c);
+ }
+
+ return c;
+ }
+}
diff --git a/maven-cai18n-plugin/src/main/java/ch/qos/cai18n/VerifyMojo.java b/maven-cai18n-plugin/src/main/java/ch/qos/cai18n/plugins/VerifyMojo.java
similarity index 95%
rename from maven-cai18n-plugin/src/main/java/ch/qos/cai18n/VerifyMojo.java
rename to maven-cai18n-plugin/src/main/java/ch/qos/cai18n/plugins/VerifyMojo.java
index f913fd6..9a76142 100644
--- a/maven-cai18n-plugin/src/main/java/ch/qos/cai18n/VerifyMojo.java
+++ b/maven-cai18n-plugin/src/main/java/ch/qos/cai18n/plugins/VerifyMojo.java
@@ -19,7 +19,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
-package ch.qos.cai18n;
+package ch.qos.cai18n.plugins;
import java.io.File;
import java.lang.reflect.Constructor;
@@ -37,12 +37,13 @@ import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
+import ch.qos.cai18n.Cai18nConstants;
import ch.qos.cai18n.verifier.IMessageCodeVerifier;
/**
* Verifies resources bundles in various locales against an enumType
*
- * @goal check
+ * @goal verify
* @phase verify
* @requiresProject true
*/
diff --git a/maven-cai18n-plugin/src/main/java/ch/qos/cai18n/plugins/package.html b/maven-cai18n-plugin/src/main/java/ch/qos/cai18n/plugins/package.html
new file mode 100644
index 0000000..1a26308
--- /dev/null
+++ b/maven-cai18n-plugin/src/main/java/ch/qos/cai18n/plugins/package.html
@@ -0,0 +1,12 @@
+<html>
+ <head>
+ <title></title>
+ </head>
+
+ <body>
+
+ <p>Maven plugin verifying that the codes defined in an enum type
+ match those in the corresponding resource bundles.
+ </p>
+ </body>
+</html>
diff --git a/pom.xml b/pom.xml
index d222ee2..9b5103b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,11 +6,17 @@
<groupId>ch.qos.cai18n</groupId>
<artifactId>cai18n-parent</artifactId>
<packaging>pom</packaging>
- <version>0.1</version>
+ <version>0.2</version>
<name>Compiler assisted internationalization library (CAI18N) - Parent</name>
<url>http://cai18n.qos.ch</url>
-
+
+ <organization>
+ <name>QOS.ch</name>
+ <url>http://www.qos.ch</url>
+ </organization>
+ <inceptionYear>2009</inceptionYear>
+
<modules>
<module>cai18n-api</module>
<module>cai18n-site</module>
@@ -164,9 +170,15 @@
</links>
<groups>
<group>
- <title>SLF4J packages</title>
- <packages>ch.qos.cai18n:ch.qos.cai18n..*</packages>
+ <title>CAI18N API packages</title>
+ <packages>ch.qos.cai18n:ch.qos.cai18n.verifier:ch.qos.cai18n.util</packages>
</group>
+
+ <group>
+ <title>CAI18N Maven plugin</title>
+ <packages>ch.qos.cai18n.plugins</packages>
+ </group>
+
</groups>
</configuration>
</plugin>
-----------------------------------------------------------------------
Summary of changes:
cai18n-api/pom.xml | 2 +-
.../main/java/ch/qos/cai18n/Cai18nConstants.java | 7 ++
.../src/main/java/ch/qos/cai18n/LocaleNames.java | 33 +++++++-
.../main/java/ch/qos/cai18n/MessageConveyor.java | 26 ++++++
.../java/ch/qos/cai18n/ResourceBundleName.java | 33 +++++++-
.../src/main/java/ch/qos/cai18n/package.html | 18 ++++
.../src/main/java/ch/qos/cai18n/util/package.html | 16 ++++
.../java/ch/qos/cai18n/verifier/ErrorFactory.java | 16 +++-
.../qos/cai18n/verifier/IMessageCodeVerifier.java | 15 +++
.../qos/cai18n/verifier/MessageCodeVerifier.java | 25 +++++
.../main/java/ch/qos/cai18n/verifier/package.html | 12 +++
.../src/test/java/ch/qos/cai18n/sample/Colors.java | 2 +
.../MyAllInOneColorVerificationTest.java} | 33 ++++---
.../MyColorVerificationTest.java} | 30 ++++---
cai18n-site/pom.xml | 2 +-
cai18n-site/src/site/pages/index.html | 1 -
cai18n-site/src/site/pages/manual.html | 88 +++++++++++++++++-
cai18n-site/src/site/pages/news.html | 13 +++
maven-cai18n-plugin-smoke/pom.xml | 4 +-
.../src/main/java/ch/qos/cai18n/smoke/package.html | 11 +++
maven-cai18n-plugin/pom.xml | 2 +-
.../java/ch/qos/cai18n/ThisFirstClassLoader.java | 71 ---------------
.../qos/cai18n/plugins/ThisFirstClassLoader.java | 94 ++++++++++++++++++++
.../ch/qos/cai18n/{ => plugins}/VerifyMojo.java | 5 +-
.../main/java/ch/qos/cai18n/plugins/package.html | 12 +++
pom.xml | 20 ++++-
26 files changed, 470 insertions(+), 121 deletions(-)
create mode 100644 cai18n-api/src/main/java/ch/qos/cai18n/package.html
create mode 100644 cai18n-api/src/main/java/ch/qos/cai18n/util/package.html
create mode 100644 cai18n-api/src/main/java/ch/qos/cai18n/verifier/package.html
copy cai18n-api/src/test/java/ch/qos/cai18n/{util/AnnotationExtractorTest.java => sample/MyAllInOneColorVerificationTest.java} (69%)
copy cai18n-api/src/test/java/ch/qos/cai18n/{util/AnnotationExtractorTest.java => sample/MyColorVerificationTest.java} (63%)
create mode 100644 maven-cai18n-plugin-smoke/src/main/java/ch/qos/cai18n/smoke/package.html
delete mode 100644 maven-cai18n-plugin/src/main/java/ch/qos/cai18n/ThisFirstClassLoader.java
create mode 100644 maven-cai18n-plugin/src/main/java/ch/qos/cai18n/plugins/ThisFirstClassLoader.java
rename maven-cai18n-plugin/src/main/java/ch/qos/cai18n/{ => plugins}/VerifyMojo.java (95%)
create mode 100644 maven-cai18n-plugin/src/main/java/ch/qos/cai18n/plugins/package.html
hooks/post-receive
--
Compiler assisted internalization library
1
0
28th of August 2009 - Release of CAI18N version 0.2
I am happy to announce the immediate availability of CAI18N version
0.2.
Please refer to the the news page for precise details.
http://cai18n.qos.ch/news.html
You can download cai18n, including full source code, class files and
documentation on our download page, shown below.
http://cai18n.qos.ch/download.html
You can receive cai18n related announcements by subscribing to the
cai18n announce mailing list. To subscribe to cai18n-announce list,
please visit the following URL.
http://www.qos.ch/mailman/listinfo/cai18n-announce
Best regards,
--
Ceki Gülcü
Logback: The reliable, generic, fast and flexible logging framework for Java.
http://logback.qos.ch
1
0

[cai18n-dev] [GIT] Compiler assisted internalization library annotated tag, v0.1, created. v0.1
by git-noreply@pixie.qos.ch 27 Aug '09
by git-noreply@pixie.qos.ch 27 Aug '09
27 Aug '09
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Compiler assisted internalization library".
The annotated tag, v0.1 has been created
at 26264b209c3bdcdf20a0c3c1ee0e40529c3ab071 (tag)
tagging 398d827991fe13d96c27ee5ee8f539e79af5894a (commit)
tagged by Ceki Gulcu
on Thu Aug 27 22:56:51 2009 +0200
- Log -----------------------------------------------------------------
tagging as 0.1
Ceki Gulcu (28):
added empty pom.xml file
added first test case
Renamed the ch.qos.i18n package as ch.qos.cai18n
Renamed the ch.qos.i18n package as ch.qos.cai18n (can't amend because previous commit was already pushed)
minor
modularizing the project
adding site module, other corrections
ongoing work
ongoing work
Improving the docs
changed the color of the project logo from green to orange
added licensing information (MIT)
- added assembly instructions
working on maven plugin
ongoing work on the maven plugin
- MessageCodeVerifier moved to c.q.c.verifier package
- removed unused mohos
- interestingly enough when a @goal is declared in VerifyMojo, mvn
added author tag (testing email notifications)
- IMessageConveyor is the interface, MessageConveyor is the default impl.
- typo fix
x- Enum class can now be annotated which makes it much easier during verification
ongoing work
ongoing work on the mojo
annotation extraction does not quite work
A working version of the maven-plugin
preparing release 0.1
minor corrections
ceki (2):
ongoing work
Added verification tests
-----------------------------------------------------------------------
hooks/post-receive
--
Compiler assisted internalization library
1
0

[cai18n-dev] [GIT] Compiler assisted internalization library branch, master, updated. 398d827991fe13d96c27ee5ee8f539e79af5894a
by git-noreply@pixie.qos.ch 27 Aug '09
by git-noreply@pixie.qos.ch 27 Aug '09
27 Aug '09
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Compiler assisted internalization library".
The branch, master has been updated
via 398d827991fe13d96c27ee5ee8f539e79af5894a (commit)
from d0f5232e421db6bdb9400d299c05d6b4d22190f0 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.qos.ch/gitweb/?p=cai18n.git;a=commit;h=398d827991fe13d96c27ee5ee…
http://github.com/ceki/cai18n/commit/398d827991fe13d96c27ee5ee8f539e79af589…
commit 398d827991fe13d96c27ee5ee8f539e79af5894a
Author: Ceki Gulcu <ceki(a)qos.ch>
Date: Thu Aug 27 22:55:39 2009 +0200
minor corrections
diff --git a/cai18n-site/src/site/pages/download.html b/cai18n-site/src/site/pages/download.html
index 92ea3b9..35a5a7b 100644
--- a/cai18n-site/src/site/pages/download.html
+++ b/cai18n-site/src/site/pages/download.html
@@ -28,8 +28,8 @@
<ul>
<li><a
- href="dist/cai18n-${pom.version}.zip">cai18n-${pom.version}.zip</a></li>
- <li><a href="dist/cai118n-${project.version}.tar.gz">cai18n-${pom.version}.tar.gz</a></li>
+ href="dist/cai18n-${pom.version}.zip">cai18n-${pom.version}.zip</a></li>
+ <li><a href="dist/cai18n-${project.version}.tar.gz">cai18n-${pom.version}.tar.gz</a></li>
</ul>
diff --git a/cai18n-site/src/site/pages/news.html b/cai18n-site/src/site/pages/news.html
index effda81..8f14f60 100644
--- a/cai18n-site/src/site/pages/news.html
+++ b/cai18n-site/src/site/pages/news.html
@@ -22,10 +22,10 @@
<h2>CAI18N News</h2>
- <p>You can receive cai18n-related announcements by subscribing
- to the <a
- href="http://www.qos.ch/mailman/listinfo/cai18n-announce">logback
- announce</a> mailing list.</p>
+ <p>You can receive cai18n-related announcements by subscribing to
+ the <a
+ href="http://www.qos.ch/mailman/listinfo/cai18n-announce">cai18n-announce</a>
+ mailing list.</p>
<hr width="80%" align="center" />
diff --git a/pom.xml b/pom.xml
index 995fcfd..d222ee2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -112,7 +112,7 @@
</descriptor>
</descriptors>
<finalName>
- cai-${project.version}
+ cai18n-${project.version}
</finalName>
<appendAssemblyId>false</appendAssemblyId>
<outputDirectory>target/site/dist/</outputDirectory>
-----------------------------------------------------------------------
Summary of changes:
cai18n-site/src/site/pages/download.html | 4 ++--
cai18n-site/src/site/pages/news.html | 8 ++++----
pom.xml | 2 +-
3 files changed, 7 insertions(+), 7 deletions(-)
hooks/post-receive
--
Compiler assisted internalization library
1
0
27th of August 2009 - Release of CAI18N version 0.1
I am extremely happy to announce the immediate availability of CAI18N
version 0.1.
Please refer to the the news page for precise details.
http://cai18n.qos.ch/news.html
You can download cai18n, including full source code, class files and
documentation on our download page, shown below.
http://cai18n.qos.ch/download.html
You can receive cai18n related announcements by subscribing to the
cai18n announce mailing list. To subscribe to cai18n-announce list,
please visit the following URL.
http://www.qos.ch/mailman/listinfo/cai18n-announce
Best regards,
--
Ceki Gülcü
Logback: The reliable, generic, fast and flexible logging framework for Java.
http://logback.qos.ch
1
0

[cai18n-dev] [GIT] Compiler assisted internalization library branch, master, updated. d0f5232e421db6bdb9400d299c05d6b4d22190f0
by git-noreply@pixie.qos.ch 27 Aug '09
by git-noreply@pixie.qos.ch 27 Aug '09
27 Aug '09
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Compiler assisted internalization library".
The branch, master has been updated
via d0f5232e421db6bdb9400d299c05d6b4d22190f0 (commit)
from 57ed2b47cc45c6c50b3f20b6bc9f964a38776189 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.qos.ch/gitweb/?p=cai18n.git;a=commit;h=d0f5232e421db6bdb9400d299…
http://github.com/ceki/cai18n/commit/d0f5232e421db6bdb9400d299c05d6b4d22190…
commit d0f5232e421db6bdb9400d299c05d6b4d22190f0
Author: Ceki Gulcu <ceki(a)qos.ch>
Date: Thu Aug 27 22:35:26 2009 +0200
preparing release 0.1
diff --git a/cai18n-api/pom.xml b/cai18n-api/pom.xml
index ab988eb..a6d5447 100644
--- a/cai18n-api/pom.xml
+++ b/cai18n-api/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>ch.qos.cai18n</groupId>
<artifactId>cai18n-parent</artifactId>
- <version>0.0-SNAPSHOT</version>
+ <version>0.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/cai18n-site/pom.xml b/cai18n-site/pom.xml
index a8ef6a3..d170ce6 100644
--- a/cai18n-site/pom.xml
+++ b/cai18n-site/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>ch.qos.cai18n</groupId>
<artifactId>cai18n-parent</artifactId>
- <version>0.0-SNAPSHOT</version>
+ <version>0.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/cai18n-site/src/site/pages/download.html b/cai18n-site/src/site/pages/download.html
new file mode 100644
index 0000000..92ea3b9
--- /dev/null
+++ b/cai18n-site/src/site/pages/download.html
@@ -0,0 +1,64 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
+ <title>Download</title>
+ <link rel="stylesheet" type="text/css" href="css/common.css" />
+ <link rel="stylesheet" type="text/css" href="css/screen.css" media="screen" />
+ <link rel="stylesheet" type="text/css" href="css/_print.css" media="print" />
+ </head>
+ <body>
+ <script type="text/javascript">prefix='';</script>
+
+ <script src="templates/header.js" type="text/javascript"></script>
+ <div id="left">
+ <noscript>Please turn on Javascript to view this menu</noscript>
+ <script src="templates/left.js" type="text/javascript"></script>
+ </div>
+ <div id="content">
+
+ <h2>Download links</h2>
+
+
+ <p>CAI18N modules are available as downloads including full source
+ code, class files and documentation.
+ </p>
+
+ <ul>
+ <li><a
+ href="dist/cai18n-${pom.version}.zip">cai18n-${pom.version}.zip</a></li>
+ <li><a href="dist/cai118n-${project.version}.tar.gz">cai18n-${pom.version}.tar.gz</a></li>
+ </ul>
+
+
+ <p>If you wish to download an older version of cai18n, please
+ refer to the <a href="http://cai18n.qos.ch/dist/">distributions
+ directory</a>.</p>
+
+
+
+ <hr/>
+
+ <h2>Third-party tools</h2>
+
+ <dl>
+ <dt>
+ None
+ </dt>
+
+ <dd>
+ <p>None for the moment.</p>
+ </dd>
+
+ </dl>
+
+
+
+
+ <script src="templates/footer.js" type="text/javascript"></script>
+</div>
+</body>
+</html>
+
\ No newline at end of file
diff --git a/cai18n-site/src/site/pages/manual.html b/cai18n-site/src/site/pages/manual.html
index c1b515d..eec52a8 100644
--- a/cai18n-site/src/site/pages/manual.html
+++ b/cai18n-site/src/site/pages/manual.html
@@ -46,7 +46,8 @@ import ch.qos.cai18n.LocaleNames;
import ch.qos.cai18n.ResourceBundleName;
@ResourceBundleName("colors") // mandatory annonation
-@LocaleNames({"en_UK", "fr"}) // optional list of locale names
+@LocaleNames({"en_UK", "fr"}) // list of locale names used by
+ // verification tools
public enum Colors {
BLUE,
RED,
@@ -102,7 +103,61 @@ String blue = mc.getMessage(Colors.BLUE); </pre>
<h2>Maven Plugin</h2>
- <p>Already implemented. Needs to be documented.</p>
+ <p>The CAI18N project ships with a maven plugin designed to verify
+ that the keys specified in a given enum type match those found in
+ the corresponding resource bundles and for each locale. Our plugin
+ is unsuprisingly called <em>mvn-cai18n-plugin</em>.
+ </p>
+
+ <p><b>At this very early stage, you need to install the
+ <em>maven-cai18n-plugin</em> by running "maven install" from the
+ folder where you unpacked the CAI18N distribution.</b>
+ </p>
+
+ <p>Using <em>maven-cai18n-plugin</em> is pretty easy. To verify
+ enums in a given project, just declare the
+ <em>maven-cai18n-plugin</em> in the <code><build></code> section,
+ enumerating all the enum types you would like to see checked.</p>
+
+ <p>Here is a sample <em>pom.xml</em> snippet.</p>
+
+ <pre class="prettyprint source"><build>
+ <plugins>
+ ... other plugins
+ <plugin>
+ <groupId>ch.qos.cai18n.plugins</groupId>
+ <artifactId>maven-cai18n-plugin</artifactId>
+ <version>${project.version}</version>
+ <executions>
+ <execution>
+ <id>aNameOfYourChoice</id>
+ <phase>verify</phase>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ <configuration>
+ <b><enumTypes></b>
+ <b><!-- list every enum type you would like to see checked --></b>
+ <b><enumType>some.enumTpe.Colors</enumType></b>
+ <b><enumType>another.enumTpe.Countries</enumType></b>
+ <b></enumTypes></b>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+</build> </pre>
+
+ <p>After you add the above snippet to the pom.xml file of your
+ project, <em>maven-cai18n-plugin</em> will make sure that
+ your resource bundles and your enum type are in synhronized.
+ </p>
+
+ <p>The plugin will iterate through every resource bundle for every
+ locale listed in the enum type via the <code>@LocaleNames</code>
+ annotation.
+ </p>
+
<h2>Ant task</h2>
diff --git a/cai18n-site/src/site/pages/news.html b/cai18n-site/src/site/pages/news.html
index b4623f9..effda81 100644
--- a/cai18n-site/src/site/pages/news.html
+++ b/cai18n-site/src/site/pages/news.html
@@ -22,12 +22,19 @@
<h2>CAI18N News</h2>
- <!--
- <p>You can receive cai18n-related announcements by subscribing
- to the <a
- href="http://www.qos.ch/mailman/listinfo/cai18n-announce">logback
- announce</a> mailing list.</p>
- -->
+ <p>You can receive cai18n-related announcements by subscribing
+ to the <a
+ href="http://www.qos.ch/mailman/listinfo/cai18n-announce">logback
+ announce</a> mailing list.</p>
+
+
+ <hr width="80%" align="center" />
+
+ <h3>27th of August 2009 - Release of CAI18N version 0.1</h3>
+
+ <p>This is the first release of CAI18N. It should be quite
+ usable. </p>
+
<hr width="80%" align="center" />
diff --git a/maven-cai18n-plugin-smoke/pom.xml b/maven-cai18n-plugin-smoke/pom.xml
index 26f223f..7d4977e 100644
--- a/maven-cai18n-plugin-smoke/pom.xml
+++ b/maven-cai18n-plugin-smoke/pom.xml
@@ -4,7 +4,7 @@
<parent>
<groupId>ch.qos.cai18n</groupId>
<artifactId>cai18n-parent</artifactId>
- <version>0.0-SNAPSHOT</version>
+ <version>0.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/maven-cai18n-plugin/pom.xml b/maven-cai18n-plugin/pom.xml
index 87f3d10..efa4b13 100644
--- a/maven-cai18n-plugin/pom.xml
+++ b/maven-cai18n-plugin/pom.xml
@@ -8,14 +8,12 @@
<parent>
<artifactId>cai18n-parent</artifactId>
<groupId>ch.qos.cai18n</groupId>
- <version>0.0-SNAPSHOT</version>
+ <version>0.1</version>
</parent>
<groupId>ch.qos.cai18n.plugins</groupId>
<artifactId>maven-cai18n-plugin</artifactId>
-
- <version>0.0-SNAPSHOT</version>
-
+
<packaging>maven-plugin</packaging>
<name> Compiler assisted internationalization library (CAI18N) - Maven</name>
diff --git a/pom.xml b/pom.xml
index 4d7e888..995fcfd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
<groupId>ch.qos.cai18n</groupId>
<artifactId>cai18n-parent</artifactId>
<packaging>pom</packaging>
- <version>0.0-SNAPSHOT</version>
+ <version>0.1</version>
<name>Compiler assisted internationalization library (CAI18N) - Parent</name>
<url>http://cai18n.qos.ch</url>
@@ -153,6 +153,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.2</version>
<configuration>
<aggregate>true</aggregate>
<excludePackageNames>ch.qos.xyz:ch.qos.xyz.*</excludePackageNames>
diff --git a/src/main/assembly/dist.xml b/src/main/assembly/dist.xml
index 866392a..aaf0065 100644
--- a/src/main/assembly/dist.xml
+++ b/src/main/assembly/dist.xml
@@ -31,7 +31,34 @@
<exclude>*.bak</exclude>
</excludes>
</fileSet>
- <!-- Module Source directories -->
+
+ <fileSet>
+ <directory>maven-cai18n-plugin/</directory>
+ <outputDirectory>maven-cai18n-plugin</outputDirectory>
+ <includes>
+ <include>
+ pom.xml
+ </include>
+ </includes>
+ <excludes>
+ <exclude>*.bak</exclude>
+ </excludes>
+ </fileSet>
+
+ <fileSet>
+ <directory>maven-cai18n-plugin-smoke</directory>
+ <outputDirectory>maven-cai18n-plugin-smoke</outputDirectory>
+ <includes>
+ <include>
+ pom.xml
+ </include>
+ </includes>
+ <excludes>
+ <exclude>*.bak</exclude>
+ </excludes>
+ </fileSet>
+
+ <!-- Module Source directories -->
<fileSet>
<directory>cai18n-api/src/</directory>
<outputDirectory>cai18n-api/src/</outputDirectory>
@@ -47,6 +74,15 @@
<outputDirectory>cai18n-site/src/</outputDirectory>
</fileSet>
+ <fileSet>
+ <directory>maven-cai18n-plugin/src/</directory>
+ <outputDirectory>maven-cai18n-plugin/src/</outputDirectory>
+ </fileSet>
+
+ <fileSet>
+ <directory>maven-cai18n-plugin-smoke/src/</directory>
+ <outputDirectory>maven-cai18n-plugin-smoke/src/</outputDirectory>
+ </fileSet>
<!-- Module JARs -->
<fileSet>
@@ -65,6 +101,7 @@
</includes>
</fileSet>
+
<!-- Website -->
<fileSet>
<directory>target/site</directory>
-----------------------------------------------------------------------
Summary of changes:
cai18n-api/pom.xml | 2 +-
cai18n-site/pom.xml | 2 +-
.../src/site/pages/{index.html => download.html} | 51 +++++++++++++----
cai18n-site/src/site/pages/manual.html | 59 +++++++++++++++++++-
cai18n-site/src/site/pages/news.html | 19 ++++--
maven-cai18n-plugin-smoke/pom.xml | 2 +-
maven-cai18n-plugin/pom.xml | 6 +-
pom.xml | 3 +-
src/main/assembly/dist.xml | 39 +++++++++++++-
9 files changed, 154 insertions(+), 29 deletions(-)
copy cai18n-site/src/site/pages/{index.html => download.html} (51%)
hooks/post-receive
--
Compiler assisted internalization library
1
0

[cai18n-dev] [GIT] Compiler assisted internalization library branch, master, updated. 57ed2b47cc45c6c50b3f20b6bc9f964a38776189
by git-noreply@pixie.qos.ch 27 Aug '09
by git-noreply@pixie.qos.ch 27 Aug '09
27 Aug '09
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Compiler assisted internalization library".
The branch, master has been updated
via 57ed2b47cc45c6c50b3f20b6bc9f964a38776189 (commit)
from a0ec2890e80cdde734f81be242b5a23ff3cd147c (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.qos.ch/gitweb/?p=cai18n.git;a=commit;h=57ed2b47cc45c6c50b3f20b6b…
http://github.com/ceki/cai18n/commit/57ed2b47cc45c6c50b3f20b6bc9f964a387761…
commit 57ed2b47cc45c6c50b3f20b6bc9f964a38776189
Author: Ceki Gulcu <ceki(a)qos.ch>
Date: Thu Aug 27 21:18:29 2009 +0200
A working version of the maven-plugin
diff --git a/cai18n-api/src/main/java/ch/qos/cai18n/util/AnnotationExtractor.java b/cai18n-api/src/main/java/ch/qos/cai18n/util/AnnotationExtractor.java
index fc051dd..e8bff49 100644
--- a/cai18n-api/src/main/java/ch/qos/cai18n/util/AnnotationExtractor.java
+++ b/cai18n-api/src/main/java/ch/qos/cai18n/util/AnnotationExtractor.java
@@ -42,10 +42,8 @@ public class AnnotationExtractor {
}
static public <E extends Enum<?>> String[] getLocaleNames(Class<E> enumClass) {
- System.out.println("xx****enumClass="+enumClass.getName());
LocaleNames localeNamesAnnotation = (LocaleNames) enumClass
.getAnnotation(LocaleNames.class);
- System.out.println("localeNamesAnnotation="+localeNamesAnnotation);
if (localeNamesAnnotation == null) {
return null;
}
diff --git a/cai18n-api/src/main/java/ch/qos/cai18n/verifier/IMessageCodeVerifier.java b/cai18n-api/src/main/java/ch/qos/cai18n/verifier/IMessageCodeVerifier.java
new file mode 100644
index 0000000..7fa7309
--- /dev/null
+++ b/cai18n-api/src/main/java/ch/qos/cai18n/verifier/IMessageCodeVerifier.java
@@ -0,0 +1,63 @@
+package ch.qos.cai18n.verifier;
+
+import java.util.List;
+import java.util.Locale;
+
+/**
+ *
+ * @author Ceki Gülcü
+ *
+ */
+public interface IMessageCodeVerifier {
+
+ // WARNING: The name of this class is referenced in String form
+ // to do class loader tricks. Do not change the name of this class
+ // without looking at the maven-plugin.
+
+ /**
+ * Get the of enum type that this verifier is related to to.
+ *
+ * @return
+ */
+ public Class<? extends Enum<?>> getEnumType();
+
+ /**
+ * Get the name of enum type to this verifier is related to to.
+ *
+ * @return
+ */
+ public String getEnumTypeAsStr();
+
+ /**
+ * Verify that the keys defined in the enumClass match those found in the
+ * resource bundle corresponding to a certain locale
+ *
+ * @param locale
+ * @return
+ */
+ public List<Cai18nError> verify(Locale locale);
+
+ /**
+ * Same as {@link #verify(Locale)} except that the return type is
+ * List<String>.
+ *
+ * @param locale
+ * @return
+ */
+ public List<String> typeIsolatedVerify(Locale locale);
+
+ /**
+ * Get the locales specified in the enumType (via annotations)
+ *
+ * @return
+ */
+ public String[] getLocaleNames();
+
+ /**
+ * Get the name of the resource bundle specified in the enumType (via
+ * annotations)
+ *
+ * @return
+ */
+ public String getResourceBundleName();
+}
\ No newline at end of file
diff --git a/cai18n-api/src/main/java/ch/qos/cai18n/verifier/MessageCodeVerifier.java b/cai18n-api/src/main/java/ch/qos/cai18n/verifier/MessageCodeVerifier.java
index d7907ff..3992b8f 100644
--- a/cai18n-api/src/main/java/ch/qos/cai18n/verifier/MessageCodeVerifier.java
+++ b/cai18n-api/src/main/java/ch/qos/cai18n/verifier/MessageCodeVerifier.java
@@ -37,45 +37,63 @@ import ch.qos.cai18n.verifier.Cai18nError.ErrorType;
*
* @author Ceki Gulcu
*/
-public class MessageCodeVerifier {
-
- final Class<? extends Enum<?>> enumClass;
- final ClassLoader classLoader;
+public class MessageCodeVerifier implements IMessageCodeVerifier {
+ Class<? extends Enum<?>> enumType;
+ String enumTypeAsStr;
+
public MessageCodeVerifier(Class<? extends Enum<?>> enumClass) {
- this(enumClass, MessageCodeVerifier.class.getClassLoader());
+ this.enumType = enumClass;
+ this.enumTypeAsStr = enumClass.getName();
+ }
+
+ @SuppressWarnings("unchecked")
+ public MessageCodeVerifier(String enumTypeAsStr) {
+ this.enumTypeAsStr = enumTypeAsStr;
+ String errMsg = "Failed to find enum class [" + enumTypeAsStr + "]";
+ try {
+ this.enumType = (Class<? extends Enum<?>>) Class.forName(enumTypeAsStr);
+ } catch (ClassNotFoundException e) {
+ throw new IllegalStateException(errMsg, e);
+ } catch (NoClassDefFoundError e) {
+ throw new IllegalStateException(errMsg, e);
+ }
}
- public MessageCodeVerifier(Class<? extends Enum<?>> enumClass,
- ClassLoader classLoader) {
- this.enumClass = enumClass;
- this.classLoader = classLoader;
+
+ /* (non-Javadoc)
+ * @see ch.qos.cai18n.verifier.IIMessageCodeVerifier#getEnumType()
+ */
+ public Class<? extends Enum<?>> getEnumType() {
+ return enumType;
+ }
+
+ /* (non-Javadoc)
+ * @see ch.qos.cai18n.verifier.IIMessageCodeVerifier#getEnumTypeAsStr()
+ */
+ public String getEnumTypeAsStr() {
+ return enumTypeAsStr;
}
- /**
- * Verify that the keys defined in the enumClass match those found in the
- * resource bundle corresponding to a certain locale
- *
- * @param locale
- * @return
+ /* (non-Javadoc)
+ * @see ch.qos.cai18n.verifier.IIMessageCodeVerifier#verify(java.util.Locale)
*/
public List<Cai18nError> verify(Locale locale) {
List<Cai18nError> errorList = new ArrayList<Cai18nError>();
String resouceBundleName = AnnotationExtractor
- .getResourceBundleName(enumClass);
+ .getResourceBundleName(enumType);
if (resouceBundleName == null) {
errorList.add(new Cai18nError(ErrorType.MISSING_RBN_ANNOTATION, "",
- enumClass, locale, ""));
+ enumType, locale, ""));
// no point in continuing
return errorList;
}
- ResourceBundle rb = ResourceBundle.getBundle(resouceBundleName, locale,
- classLoader);
+ ResourceBundle rb = ResourceBundle.getBundle(resouceBundleName, locale);
- ErrorFactory errorFactory = new ErrorFactory(enumClass, locale,
+ ErrorFactory errorFactory = new ErrorFactory(enumType, locale,
resouceBundleName);
if (rb == null) {
@@ -87,7 +105,7 @@ public class MessageCodeVerifier {
errorList.add(errorFactory.buildError(ErrorType.EMPTY_RB, ""));
}
- Enum<?>[] enumArray = enumClass.getEnumConstants();
+ Enum<?>[] enumArray = enumType.getEnumConstants();
if (enumArray == null || enumArray.length == 0) {
errorList.add(errorFactory.buildError(ErrorType.EMPTY_ENUM, ""));
}
@@ -111,4 +129,29 @@ public class MessageCodeVerifier {
return errorList;
}
+ /* (non-Javadoc)
+ * @see ch.qos.cai18n.verifier.IIMessageCodeVerifier#typeIsolatedVerify(java.util.Locale)
+ */
+ public List<String> typeIsolatedVerify(Locale locale) {
+ List<Cai18nError> errorList = verify(locale);
+ List<String> strList = new ArrayList<String>();
+ for (Cai18nError error : errorList) {
+ strList.add(error.toString());
+ }
+ return strList;
+ }
+
+ /* (non-Javadoc)
+ * @see ch.qos.cai18n.verifier.IIMessageCodeVerifier#getLocaleNames()
+ */
+ public String[] getLocaleNames() {
+ String[] localeNameArray = AnnotationExtractor.getLocaleNames(enumType);
+ return localeNameArray;
+ }
+
+ public String getResourceBundleName() {
+ String rbName = AnnotationExtractor.getResourceBundleName(enumType);
+ return rbName;
+ }
+
}
diff --git a/cai18n-api/src/test/java/ch/qos/cai18n/sample/MessageCodeVerifierTest.java b/cai18n-api/src/test/java/ch/qos/cai18n/sample/MessageCodeVerifierTest.java
index 346f66a..d2e67ea 100644
--- a/cai18n-api/src/test/java/ch/qos/cai18n/sample/MessageCodeVerifierTest.java
+++ b/cai18n-api/src/test/java/ch/qos/cai18n/sample/MessageCodeVerifierTest.java
@@ -30,6 +30,7 @@ import java.util.Locale;
import org.junit.Test;
import ch.qos.cai18n.verifier.Cai18nError;
+import ch.qos.cai18n.verifier.IMessageCodeVerifier;
import ch.qos.cai18n.verifier.MessageCodeVerifier;
/**
@@ -41,14 +42,14 @@ public class MessageCodeVerifierTest {
@Test
public void smoke() {
- MessageCodeVerifier miv = new MessageCodeVerifier(Colors.class);
+ IMessageCodeVerifier miv = new MessageCodeVerifier(Colors.class);
List<Cai18nError> errorList = miv.verify(Locale.UK);
assertEquals(0, errorList.size());
}
@Test
public void withErrors_UK() {
- MessageCodeVerifier miv = new MessageCodeVerifier(Countries.class);
+ IMessageCodeVerifier miv = new MessageCodeVerifier(Countries.class);
List<Cai18nError> errorList = miv.verify(Locale.UK);
assertEquals(2, errorList.size());
assertEquals("CH", errorList.get(0).getCode());
@@ -58,7 +59,7 @@ public class MessageCodeVerifierTest {
@Test
public void withErrors_FR() {
- MessageCodeVerifier miv = new MessageCodeVerifier(Countries.class);
+ IMessageCodeVerifier miv = new MessageCodeVerifier(Countries.class);
List<Cai18nError> errorList = miv.verify(Locale.FRANCE);
assertEquals(3, errorList.size());
assertEquals("CH", errorList.get(0).getCode());
diff --git a/maven-cai18n-plugin-smoke/pom.xml b/maven-cai18n-plugin-smoke/pom.xml
index 45a1215..26f223f 100644
--- a/maven-cai18n-plugin-smoke/pom.xml
+++ b/maven-cai18n-plugin-smoke/pom.xml
@@ -18,7 +18,7 @@
<dependency>
<groupId>ch.qos.cai18n</groupId>
<artifactId>cai18n-api</artifactId>
- </dependency>
+ </dependency>
</dependencies>
<build>
@@ -32,7 +32,7 @@
<id>countries</id>
<phase>verify</phase>
<goals>
- <goal>vv</goal>
+ <goal>check</goal>
</goals>
<configuration>
<enumTypes>
diff --git a/maven-cai18n-plugin/pom.xml b/maven-cai18n-plugin/pom.xml
index bcafd58..87f3d10 100644
--- a/maven-cai18n-plugin/pom.xml
+++ b/maven-cai18n-plugin/pom.xml
@@ -29,11 +29,41 @@
</dependency>
<dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-artifact-manager</artifactId>
+ <version>2.0.4</version>
+ </dependency>
+
+ <dependency>
<groupId>ch.qos.cai18n</groupId>
<artifactId>cai18n-api</artifactId>
</dependency>
-
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <version>2.0.9</version>
+ <artifactId>maven-project</artifactId>
+ </dependency>
+
+
+ <dependency>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>1.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-descriptor</artifactId>
+ <version>2.0.4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-classworlds</artifactId>
+ <version>1.2-alpha-6</version>
+ </dependency>
+
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
diff --git a/maven-cai18n-plugin/src/main/java/ch/qos/cai18n/ThisFirstClassLoader.java b/maven-cai18n-plugin/src/main/java/ch/qos/cai18n/ThisFirstClassLoader.java
new file mode 100644
index 0000000..c7165c5
--- /dev/null
+++ b/maven-cai18n-plugin/src/main/java/ch/qos/cai18n/ThisFirstClassLoader.java
@@ -0,0 +1,71 @@
+package ch.qos.cai18n;
+
+import java.net.URL;
+import java.net.URLClassLoader;
+
+/**
+ * An almost trivial no fuss implementation of a class loader following the
+ * child-first delegation model.
+ *
+ * @author Ceki Gülcü
+ */
+public class ThisFirstClassLoader extends URLClassLoader {
+
+ public ThisFirstClassLoader(URL[] urls) {
+ super(urls);
+ }
+
+ public ThisFirstClassLoader(URL[] urls, ClassLoader parent) {
+ super(urls, parent);
+ }
+
+ public void addURL(URL url) {
+ super.addURL(url);
+ }
+
+ @Override
+ public Class<?> loadClass(String name) throws ClassNotFoundException {
+ return loadClass(name, false);
+ }
+
+ /**
+ * We override the parent-first behavior established by java.lang.Classloader.
+ *
+ * The implementation is surprisingly straightforward.
+ */
+ protected Class<?> loadClass(String name, boolean resolve)
+ throws ClassNotFoundException {
+
+ if(name.equals("ch.qos.cai18n.verifier.IMessageCodeVerifier")) {
+ return super.loadClass(name, resolve);
+ }
+
+ // First, check if the class has already been loaded
+ Class<?> c = findLoadedClass(name);
+
+ // if not loaded, search the local (child) resources
+ if (c == null) {
+ try {
+ c = findClass(name);
+ } catch (ClassNotFoundException cnfe) {
+ // ignore
+ }
+ }
+
+ // if we could not find it, delegate to parent
+ // Note that we don't attempt to catch any ClassNotFoundException
+ if (c == null) {
+ if (getParent() != null) {
+ c = getParent().loadClass(name);
+ } else {
+ c = getSystemClassLoader().loadClass(name);
+ }
+ }
+
+ if (resolve) {
+ resolveClass(c);
+ }
+
+ return c;
+ }
+}
diff --git a/maven-cai18n-plugin/src/main/java/ch/qos/cai18n/VerifyMojo.java b/maven-cai18n-plugin/src/main/java/ch/qos/cai18n/VerifyMojo.java
index 5839535..f913fd6 100644
--- a/maven-cai18n-plugin/src/main/java/ch/qos/cai18n/VerifyMojo.java
+++ b/maven-cai18n-plugin/src/main/java/ch/qos/cai18n/VerifyMojo.java
@@ -22,25 +22,27 @@
package ch.qos.cai18n;
import java.io.File;
+import java.lang.reflect.Constructor;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
+import java.util.Set;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
-import ch.qos.cai18n.util.AnnotationExtractor;
-import ch.qos.cai18n.verifier.Cai18nError;
-import ch.qos.cai18n.verifier.MessageCodeVerifier;
+import ch.qos.cai18n.verifier.IMessageCodeVerifier;
/**
- * Verifies resources bundles
+ * Verifies resources bundles in various locales against an enumType
*
- * @goal vv
+ * @goal check
* @phase verify
* @requiresProject true
*/
@@ -48,8 +50,8 @@ public class VerifyMojo extends AbstractMojo {
final static String MISSING_LOCALE = Cai18nConstants.CODE_URL_PREFIX
+ "#missingLocale";
- final static String MISSING_ENUM_CLASS = Cai18nConstants.CODE_URL_PREFIX
- + "#missingEnumClass";
+ final static String MISSING_ENUM_TYPES = Cai18nConstants.CODE_URL_PREFIX
+ + "#missingEnumType";
/**
* @parameter
@@ -66,28 +68,46 @@ public class VerifyMojo extends AbstractMojo {
*/
private File outputDirectory;
- ClassLoader classLoader;
+ // direct dependencies of this project
+ /**
+ *
+ * @parameter expression="${project.artifacts}"
+ * @required
+ * @readonly
+ */
+ private Set<Artifact> projectArtifacts;
+
+ /**
+ * @parameter expression="${localRepository}"
+ * @required
+ * @readonly
+ * @since 1.0
+ */
+ private ArtifactRepository localRepository;
+
public void execute() throws MojoExecutionException, MojoFailureException {
+
if (enumTypes == null) {
throw new MojoFailureException(
- "<enumClass> must be specified. Please see " + MISSING_ENUM_CLASS);
+ "Missing <enumTypes> element. Please see " + MISSING_ENUM_TYPES);
}
for (String enumTypeAsStr : enumTypes) {
- Class<? extends Enum<?>> enumClass = loadEnumClass(enumTypeAsStr);
- System.out.println("***enumClass=" + enumClass.getName());
- getLog().info("Checking codes for enum class [" + enumTypeAsStr + "]");
- checkAllLocales(enumClass);
+ IMessageCodeVerifier imcv = getMessageCodeVerifierInstance(enumTypeAsStr);
+ getLog().info("Checking all resource bundles for enum type [" + enumTypeAsStr + "]");
+ checkAllLocales(imcv);
}
}
- public void checkAllLocales(Class<? extends Enum<?>> enumClass)
- throws MojoFailureException {
- String enumClassAsStr = enumClass.getName();
+ public void checkAllLocales(IMessageCodeVerifier mcv)
+ throws MojoFailureException, MojoExecutionException {
+
+ String enumClassAsStr = mcv.getEnumTypeAsStr();
+
+ String[] localeNameArray = mcv.getLocaleNames();
- String[] localeNameArray = AnnotationExtractor.getLocaleNames(enumClass);
if (localeNameArray == null || localeNameArray.length == 0) {
- String errMsg = "Missing @LocaleNames annotation in enum ["
+ String errMsg = "Missing @LocaleNames annotation in enum type ["
+ enumClassAsStr + "]";
getLog().error(errMsg);
throw new MojoFailureException(errMsg);
@@ -96,10 +116,9 @@ public class VerifyMojo extends AbstractMojo {
boolean failure = false;
for (String localeName : localeNameArray) {
Locale locale = new Locale(localeName);
- List<Cai18nError> errorList = check(enumClass, locale);
+ List<String> errorList = mcv.typeIsolatedVerify(locale);
if (errorList.size() == 0) {
- String resouceBundleName = AnnotationExtractor
- .getResourceBundleName(enumClass);
+ String resouceBundleName = mcv.getResourceBundleName();
getLog().info(
"SUCCESSFUL verification for resource bundle [" + resouceBundleName
+ "] for locale [" + locale + "]");
@@ -108,8 +127,8 @@ public class VerifyMojo extends AbstractMojo {
getLog().error(
"FAILURE during verification of resource bundle for locale ["
+ locale + "] enum class [" + enumClassAsStr + "]");
- for (Cai18nError s : errorList) {
- getLog().error(s.toString());
+ for (String s : errorList) {
+ getLog().error(s);
}
}
}
@@ -119,40 +138,51 @@ public class VerifyMojo extends AbstractMojo {
}
}
- public List<Cai18nError> check(Class<? extends Enum<?>> enumClass,
- Locale locale) throws MojoFailureException {
-
- MessageCodeVerifier mcv = new MessageCodeVerifier(enumClass,
- getClassLoader());
- List<Cai18nError> errorList = mcv.verify(locale);
- return errorList;
- }
-
- @SuppressWarnings("unchecked")
- Class<? extends Enum<?>> loadEnumClass(String enumClassAsStr)
+ IMessageCodeVerifier getMessageCodeVerifierInstance(String enumClassAsStr)
throws MojoExecutionException {
- String errMsg = "Failed to find enum class [" + enumClassAsStr + "]";
+ String errMsg = "Failed to instantiate MessageCodeVerifier class";
try {
- return (Class<? extends Enum<?>>) Class.forName(enumClassAsStr, true,
- getClassLoader());
+
+ URLClassLoader cl = (URLClassLoader) buildClassLoader();
+ Class<?> cla = Class.forName(
+ "ch.qos.cai18n.verifier.MessageCodeVerifier", true, cl);
+
+
+ Constructor<?> cons = cla.getConstructor(String.class);
+ IMessageCodeVerifier imcv = (IMessageCodeVerifier) cons
+ .newInstance(enumClassAsStr);
+ return imcv;
} catch (ClassNotFoundException e) {
throw new MojoExecutionException(errMsg, e);
} catch (NoClassDefFoundError e) {
throw new MojoExecutionException(errMsg, e);
+ } catch (Exception e) {
+ throw new MojoExecutionException(errMsg, e);
}
}
- ClassLoader getClassLoader() {
- if (classLoader == null) {
- classLoader = buildClassLoader();
- }
- return classLoader;
- }
-
ClassLoader buildClassLoader() {
ArrayList<URL> classpathURLArray = new ArrayList<URL>();
classpathURLArray.add(toURL(outputDirectory));
- return new URLClassLoader(classpathURLArray.toArray(new URL[] {}));
+ classpathURLArray.addAll(getDirectDependencies());
+ ClassLoader parentCL = this.getClass().getClassLoader();
+ return new ThisFirstClassLoader(classpathURLArray.toArray(new URL[] {}), parentCL);
+ }
+
+ List<URL> getDirectDependencies() {
+ ArrayList<URL> urlList = new ArrayList<URL>();
+ for (Artifact a : projectArtifacts) {
+ // localRepository.getUrl() returns a bogus URL
+ String pathOfArtifact = localRepository.getBasedir() + "/"
+ + localRepository.pathOf(a);
+ try {
+ URL url = new URL("file:/" + pathOfArtifact);
+ urlList.add(url);
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ }
+ }
+ return urlList;
}
URL toURL(File file) {
-----------------------------------------------------------------------
Summary of changes:
.../ch/qos/cai18n/util/AnnotationExtractor.java | 2 -
.../qos/cai18n/verifier/IMessageCodeVerifier.java | 63 ++++++++++
.../qos/cai18n/verifier/MessageCodeVerifier.java | 85 +++++++++++----
.../qos/cai18n/sample/MessageCodeVerifierTest.java | 7 +-
maven-cai18n-plugin-smoke/pom.xml | 4 +-
maven-cai18n-plugin/pom.xml | 32 +++++-
.../java/ch/qos/cai18n/ThisFirstClassLoader.java | 71 ++++++++++++
.../src/main/java/ch/qos/cai18n/VerifyMojo.java | 120 ++++++++++++--------
8 files changed, 310 insertions(+), 74 deletions(-)
create mode 100644 cai18n-api/src/main/java/ch/qos/cai18n/verifier/IMessageCodeVerifier.java
create mode 100644 maven-cai18n-plugin/src/main/java/ch/qos/cai18n/ThisFirstClassLoader.java
hooks/post-receive
--
Compiler assisted internalization library
1
0

[cai18n-dev] [GIT] Compiler assisted internalization library branch, master, updated. a0ec2890e80cdde734f81be242b5a23ff3cd147c
by git-noreply@pixie.qos.ch 26 Aug '09
by git-noreply@pixie.qos.ch 26 Aug '09
26 Aug '09
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Compiler assisted internalization library".
The branch, master has been updated
via a0ec2890e80cdde734f81be242b5a23ff3cd147c (commit)
from b522d133160c1fa486bfc3021b856ec088e57a9f (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.qos.ch/gitweb/?p=cai18n.git;a=commit;h=a0ec2890e80cdde734f81be24…
http://github.com/ceki/cai18n/commit/a0ec2890e80cdde734f81be242b5a23ff3cd14…
commit a0ec2890e80cdde734f81be242b5a23ff3cd147c
Author: Ceki Gulcu <ceki(a)qos.ch>
Date: Wed Aug 26 23:31:51 2009 +0200
annotation extraction does not quite work
diff --git a/cai18n-api/src/main/java/ch/qos/cai18n/LocaleNames.java b/cai18n-api/src/main/java/ch/qos/cai18n/LocaleNames.java
index 73119e0..776bf19 100644
--- a/cai18n-api/src/main/java/ch/qos/cai18n/LocaleNames.java
+++ b/cai18n-api/src/main/java/ch/qos/cai18n/LocaleNames.java
@@ -25,7 +25,7 @@ import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-
+
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface LocaleNames {
diff --git a/cai18n-api/src/main/java/ch/qos/cai18n/ResourceBundleName.java b/cai18n-api/src/main/java/ch/qos/cai18n/ResourceBundleName.java
index 449aebd..e1e8b3c 100644
--- a/cai18n-api/src/main/java/ch/qos/cai18n/ResourceBundleName.java
+++ b/cai18n-api/src/main/java/ch/qos/cai18n/ResourceBundleName.java
@@ -30,4 +30,4 @@ import java.lang.annotation.Target;
@Target(ElementType.TYPE)
public @interface ResourceBundleName {
String value();
-}
+}
diff --git a/cai18n-api/src/main/java/ch/qos/cai18n/util/AnnotationExtractor.java b/cai18n-api/src/main/java/ch/qos/cai18n/util/AnnotationExtractor.java
index e8bff49..fc051dd 100644
--- a/cai18n-api/src/main/java/ch/qos/cai18n/util/AnnotationExtractor.java
+++ b/cai18n-api/src/main/java/ch/qos/cai18n/util/AnnotationExtractor.java
@@ -42,8 +42,10 @@ public class AnnotationExtractor {
}
static public <E extends Enum<?>> String[] getLocaleNames(Class<E> enumClass) {
+ System.out.println("xx****enumClass="+enumClass.getName());
LocaleNames localeNamesAnnotation = (LocaleNames) enumClass
.getAnnotation(LocaleNames.class);
+ System.out.println("localeNamesAnnotation="+localeNamesAnnotation);
if (localeNamesAnnotation == null) {
return null;
}
diff --git a/cai18n-api/src/main/java/ch/qos/cai18n/LocaleNames.java b/cai18n-api/src/test/java/ch/qos/cai18n/AllCai18nTest.java
similarity index 79%
copy from cai18n-api/src/main/java/ch/qos/cai18n/LocaleNames.java
copy to cai18n-api/src/test/java/ch/qos/cai18n/AllCai18nTest.java
index 73119e0..0047679 100644
--- a/cai18n-api/src/main/java/ch/qos/cai18n/LocaleNames.java
+++ b/cai18n-api/src/test/java/ch/qos/cai18n/AllCai18nTest.java
@@ -19,15 +19,16 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
+
package ch.qos.cai18n;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+(a)RunWith(Suite.class)
+(a)SuiteClasses({ch.qos.cai18n.util.PackageTest.class,
+ ch.qos.cai18n.sample.PackageTest.class})
+public class AllCai18nTest {
-(a)Retention(RetentionPolicy.RUNTIME)
-(a)Target(ElementType.TYPE)
-public @interface LocaleNames {
- String[] value();
}
diff --git a/cai18n-api/src/test/java/ch/qos/cai18n/util/AnnatationExtractorTest.java b/cai18n-api/src/test/java/ch/qos/cai18n/util/AnnotationExtractorTest.java
similarity index 95%
rename from cai18n-api/src/test/java/ch/qos/cai18n/util/AnnatationExtractorTest.java
rename to cai18n-api/src/test/java/ch/qos/cai18n/util/AnnotationExtractorTest.java
index 9766236..5d7efb2 100644
--- a/cai18n-api/src/test/java/ch/qos/cai18n/util/AnnatationExtractorTest.java
+++ b/cai18n-api/src/test/java/ch/qos/cai18n/util/AnnotationExtractorTest.java
@@ -29,7 +29,7 @@ import java.util.Arrays;
import org.junit.Test;
-public class AnnatationExtractorTest {
+public class AnnotationExtractorTest {
@Test
public void resourcceBundleName() {
diff --git a/cai18n-api/src/main/java/ch/qos/cai18n/LocaleNames.java b/cai18n-api/src/test/java/ch/qos/cai18n/util/PackageTest.java
similarity index 77%
copy from cai18n-api/src/main/java/ch/qos/cai18n/LocaleNames.java
copy to cai18n-api/src/test/java/ch/qos/cai18n/util/PackageTest.java
index 73119e0..128dfc0 100644
--- a/cai18n-api/src/main/java/ch/qos/cai18n/LocaleNames.java
+++ b/cai18n-api/src/test/java/ch/qos/cai18n/util/PackageTest.java
@@ -19,15 +19,14 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
-package ch.qos.cai18n;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
+package ch.qos.cai18n.util;
-(a)Retention(RetentionPolicy.RUNTIME)
-(a)Target(ElementType.TYPE)
-public @interface LocaleNames {
- String[] value();
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+(a)RunWith(Suite.class)
+@SuiteClasses( { AnnotationExtractorTest.class })
+public class PackageTest {
}
diff --git a/maven-cai18n-plugin-smoke/pom.xml b/maven-cai18n-plugin-smoke/pom.xml
index 3c7acf4..45a1215 100644
--- a/maven-cai18n-plugin-smoke/pom.xml
+++ b/maven-cai18n-plugin-smoke/pom.xml
@@ -29,15 +29,15 @@
<version>${project.version}</version>
<executions>
<execution>
- <id>colors</id>
+ <id>countries</id>
<phase>verify</phase>
<goals>
- <goal>verify</goal>
+ <goal>vv</goal>
</goals>
- <configuration>
- <enumClasses>
- <enumClass>ch.qos.cai18n.smoke.Countries</enumClass>
- </enumClasses>
+ <configuration>
+ <enumTypes>
+ <enumType>ch.qos.cai18n.smoke.Countries</enumType>
+ </enumTypes>
</configuration>
</execution>
</executions>
diff --git a/maven-cai18n-plugin-smoke/src/main/java/ch/qos/cai18n/smoke/Countries.java b/maven-cai18n-plugin-smoke/src/main/java/ch/qos/cai18n/smoke/Countries.java
index 01bd269..48f97a1 100644
--- a/maven-cai18n-plugin-smoke/src/main/java/ch/qos/cai18n/smoke/Countries.java
+++ b/maven-cai18n-plugin-smoke/src/main/java/ch/qos/cai18n/smoke/Countries.java
@@ -1,5 +1,10 @@
package ch.qos.cai18n.smoke;
+import ch.qos.cai18n.LocaleNames;
+import ch.qos.cai18n.ResourceBundleName;
+
+@ResourceBundleName("countries")
+@LocaleNames({"en", "fr"})
public enum Countries {
CH,
CN,
diff --git a/maven-cai18n-plugin-smoke/src/main/resources/ch/qos/cai18n/smoke/Countries_en.properties b/maven-cai18n-plugin-smoke/src/main/resources/countries_en.properties
similarity index 100%
rename from maven-cai18n-plugin-smoke/src/main/resources/ch/qos/cai18n/smoke/Countries_en.properties
rename to maven-cai18n-plugin-smoke/src/main/resources/countries_en.properties
diff --git a/maven-cai18n-plugin-smoke/src/main/resources/ch/qos/cai18n/smoke/Countries_fr.properties b/maven-cai18n-plugin-smoke/src/main/resources/countries_fr.properties
similarity index 100%
rename from maven-cai18n-plugin-smoke/src/main/resources/ch/qos/cai18n/smoke/Countries_fr.properties
rename to maven-cai18n-plugin-smoke/src/main/resources/countries_fr.properties
diff --git a/maven-cai18n-plugin/pom.xml b/maven-cai18n-plugin/pom.xml
index 3e937a6..bcafd58 100644
--- a/maven-cai18n-plugin/pom.xml
+++ b/maven-cai18n-plugin/pom.xml
@@ -14,7 +14,7 @@
<groupId>ch.qos.cai18n.plugins</groupId>
<artifactId>maven-cai18n-plugin</artifactId>
- <!--<version>0.0-SNAPSHOT</version>-->
+ <version>0.0-SNAPSHOT</version>
<packaging>maven-plugin</packaging>
@@ -33,18 +33,6 @@
<artifactId>cai18n-api</artifactId>
</dependency>
-
- <dependency>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>2.0.2</version>
- </dependency>
-
- <dependency>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>exec-maven-plugin</artifactId>
- <version>1.1</version>
- </dependency>
<dependency>
<groupId>junit</groupId>
diff --git a/maven-cai18n-plugin/src/main/java/ch/qos/cai18n/VerifyMojo.java b/maven-cai18n-plugin/src/main/java/ch/qos/cai18n/VerifyMojo.java
index a685f6f..5839535 100644
--- a/maven-cai18n-plugin/src/main/java/ch/qos/cai18n/VerifyMojo.java
+++ b/maven-cai18n-plugin/src/main/java/ch/qos/cai18n/VerifyMojo.java
@@ -40,7 +40,7 @@ import ch.qos.cai18n.verifier.MessageCodeVerifier;
/**
* Verifies resources bundles
*
- *
+ * @goal vv
* @phase verify
* @requiresProject true
*/
@@ -52,11 +52,10 @@ public class VerifyMojo extends AbstractMojo {
+ "#missingEnumClass";
/**
- * @parameter alias="enumClass"
+ * @parameter
* @required
*/
- private String[] enumClassStrArray;
-
+ private String[] enumTypes;
/**
* The directory for compiled classes.
@@ -70,15 +69,14 @@ public class VerifyMojo extends AbstractMojo {
ClassLoader classLoader;
public void execute() throws MojoExecutionException, MojoFailureException {
-
- System.out.println("outputDir=" + outputDirectory);
- if (enumClassStrArray == null) {
+ if (enumTypes == null) {
throw new MojoFailureException(
"<enumClass> must be specified. Please see " + MISSING_ENUM_CLASS);
}
- for(String enumClassAsStr: enumClassStrArray) {
- Class<? extends Enum<?>> enumClass = loadEnumClass(enumClassAsStr);
- getLog().info("Checking codes for enum class ["+enumClassAsStr+"]");
+ for (String enumTypeAsStr : enumTypes) {
+ Class<? extends Enum<?>> enumClass = loadEnumClass(enumTypeAsStr);
+ System.out.println("***enumClass=" + enumClass.getName());
+ getLog().info("Checking codes for enum class [" + enumTypeAsStr + "]");
checkAllLocales(enumClass);
}
}
@@ -86,11 +84,11 @@ public class VerifyMojo extends AbstractMojo {
public void checkAllLocales(Class<? extends Enum<?>> enumClass)
throws MojoFailureException {
String enumClassAsStr = enumClass.getName();
-
+
String[] localeNameArray = AnnotationExtractor.getLocaleNames(enumClass);
if (localeNameArray == null || localeNameArray.length == 0) {
String errMsg = "Missing @LocaleNames annotation in enum ["
- + enumClass.getClass().getName() + "]";
+ + enumClassAsStr + "]";
getLog().error(errMsg);
throw new MojoFailureException(errMsg);
}
@@ -107,14 +105,17 @@ public class VerifyMojo extends AbstractMojo {
+ "] for locale [" + locale + "]");
} else {
failure = true;
- getLog().error("FAILURE during verification of resource bundle for locale ["+locale+"] enum class ["+enumClassAsStr+"]");
+ getLog().error(
+ "FAILURE during verification of resource bundle for locale ["
+ + locale + "] enum class [" + enumClassAsStr + "]");
for (Cai18nError s : errorList) {
getLog().error(s.toString());
}
}
}
- if(failure) {
- throw new MojoFailureException("FAIL Verification of ["+enumClassAsStr+"] codes.");
+ if (failure) {
+ throw new MojoFailureException("FAIL Verification of [" + enumClassAsStr
+ + "] codes.");
}
}
-----------------------------------------------------------------------
Summary of changes:
.../src/main/java/ch/qos/cai18n/LocaleNames.java | 2 +-
.../java/ch/qos/cai18n/ResourceBundleName.java | 2 +-
.../ch/qos/cai18n/util/AnnotationExtractor.java | 2 +
.../PackageTest.java => AllCai18nTest.java} | 10 ++++--
...actorTest.java => AnnotationExtractorTest.java} | 2 +-
.../qos/cai18n/{sample => util}/PackageTest.java | 4 +-
maven-cai18n-plugin-smoke/pom.xml | 12 ++++----
.../main/java/ch/qos/cai18n/smoke/Countries.java | 5 +++
...tries_en.properties => countries_en.properties} | 0
...tries_fr.properties => countries_fr.properties} | 0
maven-cai18n-plugin/pom.xml | 14 +--------
.../src/main/java/ch/qos/cai18n/VerifyMojo.java | 31 ++++++++++---------
12 files changed, 41 insertions(+), 43 deletions(-)
copy cai18n-api/src/test/java/ch/qos/cai18n/{sample/PackageTest.java => AllCai18nTest.java} (87%)
rename cai18n-api/src/test/java/ch/qos/cai18n/util/{AnnatationExtractorTest.java => AnnotationExtractorTest.java} (95%)
copy cai18n-api/src/test/java/ch/qos/cai18n/{sample => util}/PackageTest.java (90%)
rename maven-cai18n-plugin-smoke/src/main/resources/{ch/qos/cai18n/smoke/Countries_en.properties => countries_en.properties} (100%)
rename maven-cai18n-plugin-smoke/src/main/resources/{ch/qos/cai18n/smoke/Countries_fr.properties => countries_fr.properties} (100%)
hooks/post-receive
--
Compiler assisted internalization library
1
0