I18n-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- 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
- 802 discussions
Author: tchemit
Date: 2010-03-09 19:46:58 +0100 (Tue, 09 Mar 2010)
New Revision: 1712
Log:
Evolution #364: Use nuiton-processor 1.0.3
Modified:
trunk/ant-i18n-task/pom.xml
trunk/pom.xml
Modified: trunk/ant-i18n-task/pom.xml
===================================================================
--- trunk/ant-i18n-task/pom.xml 2010-03-09 18:18:28 UTC (rev 1711)
+++ trunk/ant-i18n-task/pom.xml 2010-03-09 18:46:58 UTC (rev 1712)
@@ -47,7 +47,7 @@
<!-- ************************************************************* -->
<!-- *** Project Information ************************************* -->
<!-- ************************************************************* -->
- <name>Nuiton I18n :: Ant task</name>
+ <name>I18n :: Ant task</name>
<inceptionYear>2010</inceptionYear>
<!-- ************************************************************* -->
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-03-09 18:18:28 UTC (rev 1711)
+++ trunk/pom.xml 2010-03-09 18:46:58 UTC (rev 1712)
@@ -223,7 +223,7 @@
<!-- pour un muli module on doit fixer le projectId -->
<projectId>i18n</projectId>
- <processor.version>1.0.3-SNAPSHOT</processor.version>
+ <processor.version>1.0.3</processor.version>
</properties>
1
0
Author: tchemit
Date: 2010-03-09 19:18:28 +0100 (Tue, 09 Mar 2010)
New Revision: 1711
Log:
update java license header before release
Modified:
trunk/ant-i18n-task/src/main/java/org/nuiton/i18n/ant/I18nExtractorTask.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GenerateMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GetterMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/AbstractI18nBundleMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/BundleMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/CollectI18nArtifactsMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/I18nArtifact.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParserMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/I18nLogger.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/I18nSourceEntry.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/KeysModifier.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/Parser.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/ParserEvent.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/ParserException.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/SourceEntry.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaActionConfigMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaTabConfigMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserValidationMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXmlMojo.java
trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/I18n.java
trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/I18nBundleBridge.java
trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/I18nDefaultTooltipFilter.java
trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/I18nFileReader.java
trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/I18nFilter.java
trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/I18nLanguage.java
trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/I18nStore.java
trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/bundle/I18nBundle.java
trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/bundle/I18nBundleScope.java
trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/bundle/I18nBundleUtil.java
trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/init/ClassPathI18nInitializer.java
trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/init/DefaultI18nInitializer.java
trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/init/I18nInitializer.java
trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/init/UserI18nInitializer.java
trunk/nuiton-i18n/src/main/java/org/nuiton/util/LocaleConverter.java
trunk/nuiton-i18n/src/test/java/org/nuiton/i18n/I18nStoreTest.java
trunk/nuiton-i18n/src/test/java/org/nuiton/i18n/bundle/I18nBundleScopeTest.java
trunk/nuiton-i18n/src/test/java/org/nuiton/util/LocaleConverterTest.java
Modified: trunk/ant-i18n-task/src/main/java/org/nuiton/i18n/ant/I18nExtractorTask.java
===================================================================
--- trunk/ant-i18n-task/src/main/java/org/nuiton/i18n/ant/I18nExtractorTask.java 2010-03-09 18:13:36 UTC (rev 1710)
+++ trunk/ant-i18n-task/src/main/java/org/nuiton/i18n/ant/I18nExtractorTask.java 2010-03-09 18:18:28 UTC (rev 1711)
@@ -1,7 +1,7 @@
/*
* *##%
- * Nuiton processor ant task
- * Copyright (C) 2009 CodeLutin
+ * Nuiton I18n :: Ant task
+ * Copyright (C) 2010 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java 2010-03-09 18:13:36 UTC (rev 1710)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java 2010-03-09 18:18:28 UTC (rev 1711)
@@ -1,7 +1,7 @@
/*
* *##%
* I18n :: Maven Plugin
- * Copyright (C) 2007 - 2009 CodeLutin
+ * Copyright (C) 2007 - 2010 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GenerateMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GenerateMojo.java 2010-03-09 18:13:36 UTC (rev 1710)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GenerateMojo.java 2010-03-09 18:18:28 UTC (rev 1711)
@@ -1,7 +1,7 @@
/*
* *##%
* I18n :: Maven Plugin
- * Copyright (C) 2007 - 2009 CodeLutin
+ * Copyright (C) 2007 - 2010 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GetterMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GetterMojo.java 2010-03-09 18:13:36 UTC (rev 1710)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GetterMojo.java 2010-03-09 18:18:28 UTC (rev 1711)
@@ -1,7 +1,7 @@
/*
* *##%
* I18n :: Maven Plugin
- * Copyright (C) 2007 - 2009 CodeLutin
+ * Copyright (C) 2007 - 2010 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/AbstractI18nBundleMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/AbstractI18nBundleMojo.java 2010-03-09 18:13:36 UTC (rev 1710)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/AbstractI18nBundleMojo.java 2010-03-09 18:18:28 UTC (rev 1711)
@@ -1,7 +1,7 @@
/*
* *##%
* I18n :: Maven Plugin
- * Copyright (C) 2007 - 2009 CodeLutin
+ * Copyright (C) 2007 - 2010 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/BundleMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/BundleMojo.java 2010-03-09 18:13:36 UTC (rev 1710)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/BundleMojo.java 2010-03-09 18:18:28 UTC (rev 1711)
@@ -1,7 +1,7 @@
/*
* *##%
* I18n :: Maven Plugin
- * Copyright (C) 2007 - 2009 CodeLutin
+ * Copyright (C) 2007 - 2010 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/CollectI18nArtifactsMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/CollectI18nArtifactsMojo.java 2010-03-09 18:13:36 UTC (rev 1710)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/CollectI18nArtifactsMojo.java 2010-03-09 18:18:28 UTC (rev 1711)
@@ -1,7 +1,7 @@
/*
* *##%
* I18n :: Maven Plugin
- * Copyright (C) 2007 - 2009 CodeLutin
+ * Copyright (C) 2007 - 2010 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/I18nArtifact.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/I18nArtifact.java 2010-03-09 18:13:36 UTC (rev 1710)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/I18nArtifact.java 2010-03-09 18:18:28 UTC (rev 1711)
@@ -1,7 +1,7 @@
/*
* *##%
* I18n :: Maven Plugin
- * Copyright (C) 2007 - 2009 CodeLutin
+ * Copyright (C) 2007 - 2010 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParserMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParserMojo.java 2010-03-09 18:13:36 UTC (rev 1710)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParserMojo.java 2010-03-09 18:18:28 UTC (rev 1711)
@@ -1,7 +1,7 @@
/*
* *##%
* I18n :: Maven Plugin
- * Copyright (C) 2007 - 2009 CodeLutin
+ * Copyright (C) 2007 - 2010 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/I18nLogger.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/I18nLogger.java 2010-03-09 18:13:36 UTC (rev 1710)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/I18nLogger.java 2010-03-09 18:18:28 UTC (rev 1711)
@@ -1,7 +1,7 @@
/**
* *##%
* I18n :: Maven Plugin
- * Copyright (C) 2007 - 2009 CodeLutin
+ * Copyright (C) 2007 - 2010 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/I18nSourceEntry.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/I18nSourceEntry.java 2010-03-09 18:13:36 UTC (rev 1710)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/I18nSourceEntry.java 2010-03-09 18:18:28 UTC (rev 1711)
@@ -1,7 +1,7 @@
/*
* *##%
* I18n :: Maven Plugin
- * Copyright (C) 2007 - 2009 CodeLutin
+ * Copyright (C) 2007 - 2010 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/KeysModifier.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/KeysModifier.java 2010-03-09 18:13:36 UTC (rev 1710)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/KeysModifier.java 2010-03-09 18:18:28 UTC (rev 1711)
@@ -1,7 +1,7 @@
/*
* *##%
* I18n :: Maven Plugin
- * Copyright (C) 2007 - 2009 CodeLutin
+ * Copyright (C) 2007 - 2010 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/Parser.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/Parser.java 2010-03-09 18:13:36 UTC (rev 1710)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/Parser.java 2010-03-09 18:18:28 UTC (rev 1711)
@@ -1,7 +1,7 @@
/*
* *##%
* I18n :: Maven Plugin
- * Copyright (C) 2007 - 2009 CodeLutin
+ * Copyright (C) 2007 - 2010 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/ParserEvent.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/ParserEvent.java 2010-03-09 18:13:36 UTC (rev 1710)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/ParserEvent.java 2010-03-09 18:18:28 UTC (rev 1711)
@@ -1,7 +1,7 @@
/*
* *##%
* I18n :: Maven Plugin
- * Copyright (C) 2007 - 2009 CodeLutin
+ * Copyright (C) 2007 - 2010 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/ParserException.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/ParserException.java 2010-03-09 18:13:36 UTC (rev 1710)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/ParserException.java 2010-03-09 18:18:28 UTC (rev 1711)
@@ -1,7 +1,7 @@
/*
* *##%
* I18n :: Maven Plugin
- * Copyright (C) 2007 - 2009 CodeLutin
+ * Copyright (C) 2007 - 2010 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/SourceEntry.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/SourceEntry.java 2010-03-09 18:13:36 UTC (rev 1710)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/SourceEntry.java 2010-03-09 18:18:28 UTC (rev 1711)
@@ -1,7 +1,7 @@
/*
* *##%
* I18n :: Maven Plugin
- * Copyright (C) 2007 - 2009 CodeLutin
+ * Copyright (C) 2007 - 2010 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaActionConfigMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaActionConfigMojo.java 2010-03-09 18:13:36 UTC (rev 1710)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaActionConfigMojo.java 2010-03-09 18:18:28 UTC (rev 1711)
@@ -1,7 +1,7 @@
/*
* *##%
* I18n :: Maven Plugin
- * Copyright (C) 2007 - 2009 CodeLutin
+ * Copyright (C) 2007 - 2010 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaMojo.java 2010-03-09 18:13:36 UTC (rev 1710)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaMojo.java 2010-03-09 18:18:28 UTC (rev 1711)
@@ -1,7 +1,7 @@
/*
* *##%
* I18n :: Maven Plugin
- * Copyright (C) 2007 - 2009 CodeLutin
+ * Copyright (C) 2007 - 2010 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaTabConfigMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaTabConfigMojo.java 2010-03-09 18:13:36 UTC (rev 1710)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaTabConfigMojo.java 2010-03-09 18:18:28 UTC (rev 1711)
@@ -1,7 +1,7 @@
/**
* *##%
* I18n :: Maven Plugin
- * Copyright (C) 2007 - 2009 CodeLutin
+ * Copyright (C) 2007 - 2010 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserValidationMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserValidationMojo.java 2010-03-09 18:13:36 UTC (rev 1710)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserValidationMojo.java 2010-03-09 18:18:28 UTC (rev 1711)
@@ -1,7 +1,7 @@
/*
* *##%
* I18n :: Maven Plugin
- * Copyright (C) 2007 - 2009 CodeLutin
+ * Copyright (C) 2007 - 2010 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXmlMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXmlMojo.java 2010-03-09 18:13:36 UTC (rev 1710)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXmlMojo.java 2010-03-09 18:18:28 UTC (rev 1711)
@@ -1,7 +1,7 @@
/*
* *##%
* I18n :: Maven Plugin
- * Copyright (C) 2007 - 2009 CodeLutin
+ * Copyright (C) 2007 - 2010 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/I18n.java
===================================================================
--- trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/I18n.java 2010-03-09 18:13:36 UTC (rev 1710)
+++ trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/I18n.java 2010-03-09 18:18:28 UTC (rev 1711)
@@ -1,5 +1,5 @@
/*
- * *##%
+ * *##%
* I18n :: Api
* Copyright (C) 2004 - 2010 CodeLutin
*
Modified: trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/I18nBundleBridge.java
===================================================================
--- trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/I18nBundleBridge.java 2010-03-09 18:13:36 UTC (rev 1710)
+++ trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/I18nBundleBridge.java 2010-03-09 18:18:28 UTC (rev 1711)
@@ -1,5 +1,5 @@
/*
- * *##%
+ * *##%
* I18n :: Api
* Copyright (C) 2004 - 2010 CodeLutin
*
Modified: trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/I18nDefaultTooltipFilter.java
===================================================================
--- trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/I18nDefaultTooltipFilter.java 2010-03-09 18:13:36 UTC (rev 1710)
+++ trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/I18nDefaultTooltipFilter.java 2010-03-09 18:18:28 UTC (rev 1711)
@@ -1,6 +1,6 @@
/* *##%
* I18n :: Api
- * Copyright (C) 2004 - 2009 CodeLutin
+ * Copyright (C) 2004 - 2010 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/I18nFileReader.java
===================================================================
--- trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/I18nFileReader.java 2010-03-09 18:13:36 UTC (rev 1710)
+++ trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/I18nFileReader.java 2010-03-09 18:18:28 UTC (rev 1711)
@@ -1,6 +1,6 @@
/* *##%
* I18n :: Api
- * Copyright (C) 2004 - 2009 CodeLutin
+ * Copyright (C) 2004 - 2010 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/I18nFilter.java
===================================================================
--- trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/I18nFilter.java 2010-03-09 18:13:36 UTC (rev 1710)
+++ trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/I18nFilter.java 2010-03-09 18:18:28 UTC (rev 1711)
@@ -1,6 +1,6 @@
/* *##%
* I18n :: Api
- * Copyright (C) 2004 - 2009 CodeLutin
+ * Copyright (C) 2004 - 2010 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/I18nLanguage.java
===================================================================
--- trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/I18nLanguage.java 2010-03-09 18:13:36 UTC (rev 1710)
+++ trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/I18nLanguage.java 2010-03-09 18:18:28 UTC (rev 1711)
@@ -1,5 +1,5 @@
/*
- * *##%
+ * *##%
* I18n :: Api
* Copyright (C) 2004 - 2010 CodeLutin
*
Modified: trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/I18nStore.java
===================================================================
--- trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/I18nStore.java 2010-03-09 18:13:36 UTC (rev 1710)
+++ trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/I18nStore.java 2010-03-09 18:18:28 UTC (rev 1711)
@@ -1,5 +1,5 @@
/*
- * *##%
+ * *##%
* I18n :: Api
* Copyright (C) 2004 - 2010 CodeLutin
*
Modified: trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/bundle/I18nBundle.java
===================================================================
--- trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/bundle/I18nBundle.java 2010-03-09 18:13:36 UTC (rev 1710)
+++ trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/bundle/I18nBundle.java 2010-03-09 18:18:28 UTC (rev 1711)
@@ -1,5 +1,5 @@
/*
- * *##%
+ * *##%
* I18n :: Api
* Copyright (C) 2004 - 2010 CodeLutin
*
Modified: trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/bundle/I18nBundleScope.java
===================================================================
--- trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/bundle/I18nBundleScope.java 2010-03-09 18:13:36 UTC (rev 1710)
+++ trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/bundle/I18nBundleScope.java 2010-03-09 18:18:28 UTC (rev 1711)
@@ -1,7 +1,7 @@
/*
* *##%
* I18n :: Api
- * Copyright (C) 2004 - 2009 CodeLutin
+ * Copyright (C) 2004 - 2010 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/bundle/I18nBundleUtil.java
===================================================================
--- trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/bundle/I18nBundleUtil.java 2010-03-09 18:13:36 UTC (rev 1710)
+++ trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/bundle/I18nBundleUtil.java 2010-03-09 18:18:28 UTC (rev 1711)
@@ -1,5 +1,5 @@
/*
- * *##%
+ * *##%
* I18n :: Api
* Copyright (C) 2004 - 2010 CodeLutin
*
Modified: trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/init/ClassPathI18nInitializer.java
===================================================================
--- trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/init/ClassPathI18nInitializer.java 2010-03-09 18:13:36 UTC (rev 1710)
+++ trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/init/ClassPathI18nInitializer.java 2010-03-09 18:18:28 UTC (rev 1711)
@@ -1,5 +1,5 @@
/*
- * *##%
+ * *##%
* I18n :: Api
* Copyright (C) 2004 - 2010 CodeLutin
*
Modified: trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/init/DefaultI18nInitializer.java
===================================================================
--- trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/init/DefaultI18nInitializer.java 2010-03-09 18:13:36 UTC (rev 1710)
+++ trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/init/DefaultI18nInitializer.java 2010-03-09 18:18:28 UTC (rev 1711)
@@ -1,5 +1,5 @@
/*
- * *##%
+ * *##%
* I18n :: Api
* Copyright (C) 2004 - 2010 CodeLutin
*
Modified: trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/init/I18nInitializer.java
===================================================================
--- trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/init/I18nInitializer.java 2010-03-09 18:13:36 UTC (rev 1710)
+++ trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/init/I18nInitializer.java 2010-03-09 18:18:28 UTC (rev 1711)
@@ -1,5 +1,5 @@
/*
- * *##%
+ * *##%
* I18n :: Api
* Copyright (C) 2004 - 2010 CodeLutin
*
Modified: trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/init/UserI18nInitializer.java
===================================================================
--- trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/init/UserI18nInitializer.java 2010-03-09 18:13:36 UTC (rev 1710)
+++ trunk/nuiton-i18n/src/main/java/org/nuiton/i18n/init/UserI18nInitializer.java 2010-03-09 18:18:28 UTC (rev 1711)
@@ -1,5 +1,5 @@
/*
- * *##%
+ * *##%
* I18n :: Api
* Copyright (C) 2004 - 2010 CodeLutin
*
Modified: trunk/nuiton-i18n/src/main/java/org/nuiton/util/LocaleConverter.java
===================================================================
--- trunk/nuiton-i18n/src/main/java/org/nuiton/util/LocaleConverter.java 2010-03-09 18:13:36 UTC (rev 1710)
+++ trunk/nuiton-i18n/src/main/java/org/nuiton/util/LocaleConverter.java 2010-03-09 18:18:28 UTC (rev 1711)
@@ -1,7 +1,7 @@
/*
* *##%
* I18n :: Api
- * Copyright (C) 2004 - 2009 CodeLutin
+ * Copyright (C) 2004 - 2010 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/nuiton-i18n/src/test/java/org/nuiton/i18n/I18nStoreTest.java
===================================================================
--- trunk/nuiton-i18n/src/test/java/org/nuiton/i18n/I18nStoreTest.java 2010-03-09 18:13:36 UTC (rev 1710)
+++ trunk/nuiton-i18n/src/test/java/org/nuiton/i18n/I18nStoreTest.java 2010-03-09 18:18:28 UTC (rev 1711)
@@ -1,5 +1,5 @@
/*
- * *##%
+ * *##%
* I18n :: Api
* Copyright (C) 2004 - 2010 CodeLutin
*
Modified: trunk/nuiton-i18n/src/test/java/org/nuiton/i18n/bundle/I18nBundleScopeTest.java
===================================================================
--- trunk/nuiton-i18n/src/test/java/org/nuiton/i18n/bundle/I18nBundleScopeTest.java 2010-03-09 18:13:36 UTC (rev 1710)
+++ trunk/nuiton-i18n/src/test/java/org/nuiton/i18n/bundle/I18nBundleScopeTest.java 2010-03-09 18:18:28 UTC (rev 1711)
@@ -1,5 +1,5 @@
/*
- * *##%
+ * *##%
* I18n :: Api
* Copyright (C) 2004 - 2010 CodeLutin
*
Modified: trunk/nuiton-i18n/src/test/java/org/nuiton/util/LocaleConverterTest.java
===================================================================
--- trunk/nuiton-i18n/src/test/java/org/nuiton/util/LocaleConverterTest.java 2010-03-09 18:13:36 UTC (rev 1710)
+++ trunk/nuiton-i18n/src/test/java/org/nuiton/util/LocaleConverterTest.java 2010-03-09 18:18:28 UTC (rev 1711)
@@ -1,5 +1,5 @@
/*
- * *##%
+ * *##%
* I18n :: Api
* Copyright (C) 2004 - 2010 CodeLutin
*
1
0
r1710 - in trunk: . ant-i18n-task ant-i18n-task/src ant-i18n-task/src/main ant-i18n-task/src/main/java ant-i18n-task/src/main/java/org ant-i18n-task/src/main/java/org/nuiton ant-i18n-task/src/main/java/org/nuiton/i18n ant-i18n-task/src/main/java/org/nuiton/i18n/ant ant-i18n-task/src/site ant-i18n-task/src/site/apt
by tchemit@users.nuiton.org 09 Mar '10
by tchemit@users.nuiton.org 09 Mar '10
09 Mar '10
Author: tchemit
Date: 2010-03-09 19:13:36 +0100 (Tue, 09 Mar 2010)
New Revision: 1710
Log:
- Evolution #365: Creates ant-i18n-task module
- Evolution #364: Use nuiton-processor 1.0.3
Added:
trunk/ant-i18n-task/
trunk/ant-i18n-task/LICENSE.txt
trunk/ant-i18n-task/README.txt
trunk/ant-i18n-task/changelog.txt
trunk/ant-i18n-task/pom.xml
trunk/ant-i18n-task/src/
trunk/ant-i18n-task/src/main/
trunk/ant-i18n-task/src/main/java/
trunk/ant-i18n-task/src/main/java/org/
trunk/ant-i18n-task/src/main/java/org/nuiton/
trunk/ant-i18n-task/src/main/java/org/nuiton/i18n/
trunk/ant-i18n-task/src/main/java/org/nuiton/i18n/ant/
trunk/ant-i18n-task/src/main/java/org/nuiton/i18n/ant/I18nExtractorTask.java
trunk/ant-i18n-task/src/main/resources/
trunk/ant-i18n-task/src/site/
trunk/ant-i18n-task/src/site/apt/
trunk/ant-i18n-task/src/site/apt/index.apt
trunk/ant-i18n-task/src/site/site_fr.xml
Modified:
trunk/pom.xml
Property changes on: trunk/ant-i18n-task
___________________________________________________________________
Added: svn:ignore
+ target
*.iml
*.ipr
*.iws
Added: trunk/ant-i18n-task/LICENSE.txt
===================================================================
--- trunk/ant-i18n-task/LICENSE.txt (rev 0)
+++ trunk/ant-i18n-task/LICENSE.txt 2010-03-09 18:13:36 UTC (rev 1710)
@@ -0,0 +1,166 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+
+ This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+ 0. Additional Definitions.
+
+ As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+ "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+ An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+ A "Combined Work" is a work produced by combining or linking an
+Application with the Library. The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+ The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+ The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+ 1. Exception to Section 3 of the GNU GPL.
+
+ You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+ 2. Conveying Modified Versions.
+
+ If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+ a) under this License, provided that you make a good faith effort to
+ ensure that, in the event an Application does not supply the
+ function or data, the facility still operates, and performs
+ whatever part of its purpose remains meaningful, or
+
+ b) under the GNU GPL, with none of the additional permissions of
+ this License applicable to that copy.
+
+ 3. Object Code Incorporating Material from Library Header Files.
+
+ The object code form of an Application may incorporate material from
+a header file that is part of the Library. You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+ a) Give prominent notice with each copy of the object code that the
+ Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the object code with a copy of the GNU GPL and this license
+ document.
+
+ 4. Combined Works.
+
+ You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+ a) Give prominent notice with each copy of the Combined Work that
+ the Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
+ document.
+
+ c) For a Combined Work that displays copyright notices during
+ execution, include the copyright notice for the Library among
+ these notices, as well as a reference directing the user to the
+ copies of the GNU GPL and this license document.
+
+ d) Do one of the following:
+
+ 0) Convey the Minimal Corresponding Source under the terms of this
+ License, and the Corresponding Application Code in a form
+ suitable for, and under terms that permit, the user to
+ recombine or relink the Application with a modified version of
+ the Linked Version to produce a modified Combined Work, in the
+ manner specified by section 6 of the GNU GPL for conveying
+ Corresponding Source.
+
+ 1) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (a) uses at run time
+ a copy of the Library already present on the user's computer
+ system, and (b) will operate properly with a modified version
+ of the Library that is interface-compatible with the Linked
+ Version.
+
+ e) Provide Installation Information, but only if you would otherwise
+ be required to provide such information under section 6 of the
+ GNU GPL, and only to the extent that such information is
+ necessary to install and execute a modified version of the
+ Combined Work produced by recombining or relinking the
+ Application with a modified version of the Linked Version. (If
+ you use option 4d0, the Installation Information must accompany
+ the Minimal Corresponding Source and Corresponding Application
+ Code. If you use option 4d1, you must provide the Installation
+ Information in the manner specified by section 6 of the GNU GPL
+ for conveying Corresponding Source.)
+
+ 5. Combined Libraries.
+
+ You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+ a) Accompany the combined library with a copy of the same work based
+ on the Library, uncombined with any other library facilities,
+ conveyed under the terms of this License.
+
+ b) Give prominent notice with the combined library that part of it
+ is a work based on the Library, and explaining where to find the
+ accompanying uncombined form of the same work.
+
+ 6. Revised Versions of the GNU Lesser General Public License.
+
+ The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+ If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.
+
Added: trunk/ant-i18n-task/README.txt
===================================================================
--- trunk/ant-i18n-task/README.txt (rev 0)
+++ trunk/ant-i18n-task/README.txt 2010-03-09 18:13:36 UTC (rev 1710)
@@ -0,0 +1,2 @@
+To deploy new version of pom: mvn deploy
+To install localy: mvn install
Added: trunk/ant-i18n-task/changelog.txt
===================================================================
--- trunk/ant-i18n-task/changelog.txt (rev 0)
+++ trunk/ant-i18n-task/changelog.txt 2010-03-09 18:13:36 UTC (rev 1710)
@@ -0,0 +1 @@
+No more used, we will soon make optional multi-module childs changelog.txt (mavenpom>1.0.0)
\ No newline at end of file
Added: trunk/ant-i18n-task/pom.xml
===================================================================
--- trunk/ant-i18n-task/pom.xml (rev 0)
+++ trunk/ant-i18n-task/pom.xml 2010-03-09 18:13:36 UTC (rev 1710)
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- ************************************************************* -->
+ <!-- *** POM Relationships *************************************** -->
+ <!-- ************************************************************* -->
+
+ <parent>
+ <groupId>org.nuiton</groupId>
+ <artifactId>i18n</artifactId>
+ <version>1.1-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.nuiton.i18n</groupId>
+ <artifactId>ant-i18n-task</artifactId>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>nuiton-i18n</artifactId>
+ <version>${project.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.nuiton.processor</groupId>
+ <artifactId>nuiton-processor</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant</artifactId>
+ </dependency>
+
+ <!-- tests dependencies -->
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+
+ </dependencies>
+
+ <!-- ************************************************************* -->
+ <!-- *** Project Information ************************************* -->
+ <!-- ************************************************************* -->
+ <name>Nuiton I18n :: Ant task</name>
+ <inceptionYear>2010</inceptionYear>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Settings ****************************************** -->
+ <!-- ************************************************************* -->
+
+ <packaging>jar</packaging>
+
+</project>
Added: trunk/ant-i18n-task/src/main/java/org/nuiton/i18n/ant/I18nExtractorTask.java
===================================================================
--- trunk/ant-i18n-task/src/main/java/org/nuiton/i18n/ant/I18nExtractorTask.java (rev 0)
+++ trunk/ant-i18n-task/src/main/java/org/nuiton/i18n/ant/I18nExtractorTask.java 2010-03-09 18:13:36 UTC (rev 1710)
@@ -0,0 +1,167 @@
+/*
+ * *##%
+ * Nuiton processor ant task
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
+
+package org.nuiton.i18n.ant;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.DirectoryScanner;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.taskdefs.MatchingTask;
+import org.nuiton.processor.I18nExtractor;
+
+/**
+ * I18nExtractorTask.
+ *
+ * Created: Aug 16, 2004
+ *
+ * @author Cédric Pineau <pineau(a)codelutin.com>
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * by : $Author: tchemit $
+ */
+public class I18nExtractorTask extends MatchingTask {
+
+ public static final int MSG_VERBOSE = Project.MSG_VERBOSE;
+
+ protected File srcDir;
+
+ protected File destFile;
+
+ protected String[] includes = EMPTY_STRING_ARRAY;
+
+ protected String[] excludes = EMPTY_STRING_ARRAY;
+
+ protected String[] srcFileNames;
+
+ private static final String[] EMPTY_STRING_ARRAY = new String[] {};
+
+ public I18nExtractorTask() {
+
+ }
+
+ protected void doExecute() throws BuildException {
+ // creation du repertoire pour le fichier destination
+ File parentFile = destFile.getParentFile();
+ if (!parentFile.exists()) {
+ boolean b = parentFile.mkdirs();
+ if (!b) {
+ throw new BuildException(
+ "could not create directory " + parentFile);
+ }
+ }
+ List<File> fileList = new ArrayList<File>();
+ for (String srcFileName : srcFileNames) {
+ fileList.add(new File(srcFileName));
+ }
+ try {
+ new I18nExtractor().extract(
+ fileList.toArray(new File[fileList.size()]), destFile);
+ } catch (IOException eee) {
+ throw new BuildException(eee);
+ }
+ }
+
+ public void setSrcdir(File srcDir) {
+ this.srcDir = srcDir;
+ }
+
+ public void setDestFile(File destFile) {
+ this.destFile = destFile;
+ }
+
+ @Override
+ public void execute() throws BuildException {
+ // first of all, make sure that we've got a srcdir
+ if (srcDir == null) {
+ throw new BuildException("srcdir attribute must be set!",
+ getLocation());
+ }
+ if (!srcDir.exists()) {
+ throw new BuildException("srcdir \"" + srcDir.getPath()
+ + "\" does not exist!", getLocation());
+ }
+
+ if (destFile == null) {
+ throw new BuildException("destFile attribute must be set!",
+ getLocation());
+ }
+
+ // Build the list of files to compute
+ buildFileList();
+
+ // generate the source files
+ doExecute();
+ }
+
+ protected void buildFileList() {
+
+ // Obtain this list of files within the source directory
+ DirectoryScanner ds = getDirectoryScanner(srcDir);
+
+ String[] ins = getIncludes();
+ if (ins.length > 0) {
+ ds.setIncludes(ins);
+ }
+ String[] exs = getExcludes();
+ if (exs.length > 0) {
+ ds.setExcludes(exs);
+ }
+
+ ds.scan();
+
+ // on met le resultat dans files
+ srcFileNames = ds.getIncludedFiles();
+ }
+
+ protected boolean isNewer(String filein, String fileout) {
+ boolean result = new File(filein).lastModified() > new File(fileout)
+ .lastModified();
+ if (result) {
+ log(filein + " is newer than " + fileout, MSG_VERBOSE);
+ }
+ return result;
+ }
+
+ protected String[] getExcludes() {
+ return excludes;
+ }
+
+ protected String[] getIncludes() {
+ return includes;
+ }
+
+ @Override
+ public void setIncludes(String includes) {
+ this.includes = includes.split(",");
+ }
+
+ @Override
+ public void setExcludes(String excludes) {
+ this.excludes = excludes.split(",");
+ }
+
+}
Property changes on: trunk/ant-i18n-task/src/main/java/org/nuiton/i18n/ant/I18nExtractorTask.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: trunk/ant-i18n-task/src/site/apt/index.apt
===================================================================
--- trunk/ant-i18n-task/src/site/apt/index.apt (rev 0)
+++ trunk/ant-i18n-task/src/site/apt/index.apt 2010-03-09 18:13:36 UTC (rev 1710)
@@ -0,0 +1,12 @@
+----
+Ant-i18n-task
+----
+----
+2010-03-09
+----
+
+
+Présentation
+
+ Le module <ant-i18n-task> permet l'utilisation depuis ant de
+ l'extracteur de clef i18n. Pour plus de détails sur Nuiton I18nExtractor.
Added: trunk/ant-i18n-task/src/site/site_fr.xml
===================================================================
--- trunk/ant-i18n-task/src/site/site_fr.xml (rev 0)
+++ trunk/ant-i18n-task/src/site/site_fr.xml 2010-03-09 18:13:36 UTC (rev 1710)
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="${project.name}">
+
+ <bannerLeft>
+ <name>${project.name}</name>
+ <href>index.html</href>
+ </bannerLeft>
+
+ <body>
+ <links>
+ <item name="Nuiton I18n" href="../nuiton-processor"/>
+ </links>
+
+ <breadcrumbs>
+ <item name="${project.name}" href="index.html" />
+ </breadcrumbs>
+
+ <menu ref="parent"/>
+
+ <menu name="Utilisateur">
+ <item href="index.html" name="Accueil"/>
+ </menu>
+
+ <menu name="Téléchargement">
+ <item href="${repository.home.url}/org/nuiton/i18n/${project.artifactId}/${project.version}/${project.build.finalName}.jar"
+ name="Librairie (jar)"/>
+ <item href="${repository.home.url}/org/nuiton/i18n/${project.artifactId}/${project.version}/${project.build.finalName}-javadoc.jar"
+ name="Javadoc (jar)"/>
+ <item href="${repository.home.url}/org/nuiton/i18n/${project.artifactId}/${project.version}/${project.build.finalName}-sources.jar"
+ name="Sources (jar)"/>
+ </menu>
+
+ <menu ref="reports"/>
+
+ </body>
+</project>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-03-09 16:32:25 UTC (rev 1709)
+++ trunk/pom.xml 2010-03-09 18:13:36 UTC (rev 1710)
@@ -18,6 +18,7 @@
<modules>
<module>nuiton-i18n</module>
<module>maven-i18n-plugin</module>
+ <module>ant-i18n-task</module>
<!--module>nuiton-i18n-editor</module-->
</modules>
@@ -194,6 +195,13 @@
<version>1.2.14</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant</artifactId>
+ <version>1.7.1</version>
+ <scope>compile</scope>
+ </dependency>
+
</dependencies>
</dependencyManagement>
@@ -215,18 +223,10 @@
<!-- pour un muli module on doit fixer le projectId -->
<projectId>i18n</projectId>
- <processor.version>1.0.1</processor.version>
+ <processor.version>1.0.3-SNAPSHOT</processor.version>
- <maven.compile.source>1.5</maven.compile.source>
- <maven.compile.target>1.5</maven.compile.target>
</properties>
- <build>
-
- <defaultGoal>install</defaultGoal>
-
- </build>
-
<!-- ************************************************************* -->
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
1
0
r1709 - in trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin: . parser parser/impl
by tchemit@users.nuiton.org 09 Mar '10
by tchemit@users.nuiton.org 09 Mar '10
09 Mar '10
Author: tchemit
Date: 2010-03-09 17:32:25 +0100 (Tue, 09 Mar 2010)
New Revision: 1709
Log:
- clean code
- do little improvment on code
Modified:
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GenerateMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GetterMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParserMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/I18nLogger.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/Parser.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/SourceEntry.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaMojo.java
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java 2010-03-08 18:35:57 UTC (rev 1708)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java 2010-03-09 16:32:25 UTC (rev 1709)
@@ -142,6 +142,8 @@
public void init() throws Exception {
if (verbose) {
+ // in verbose mode, no silent
+ silent = false;
getLog().info("config - verbose mode is on");
}
locales = I18nUtil.parseLocales(bundles);
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GenerateMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GenerateMojo.java 2010-03-08 18:35:57 UTC (rev 1708)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GenerateMojo.java 2010-03-09 16:32:25 UTC (rev 1709)
@@ -66,6 +66,14 @@
*/
protected boolean keepBackup;
+ /**
+ * Conserve les fichiers de getters.
+ *
+ * @parameter expression="${i18n.keepGetters}" default-value="false"
+ */
+ protected boolean keepGetters;
+
+
@Override
protected boolean checkSkip() {
if (!needGeneration()) {
@@ -89,6 +97,8 @@
// Merge
File bundleSrc = getI18nFile(src, artifactId, locale, false);
File bundleOut = getI18nFile(out, artifactId, locale, false);
+ File bundleGetterOut = getI18nFile(
+ out, artifactId + GetterMojo.FROM_GETTERS, locale, false);
SortedProperties propertiesSrc = new SortedProperties(encoding);
@@ -103,7 +113,8 @@
// bundle out, all the bundle src keys
propertiesOut.putAll(propertiesSrc);
}
- propertiesOut.load(bundleOut);
+ propertiesOut.load(bundleGetterOut);
+// propertiesOut.load(bundleOut);
// Parcours des clés
for (Object key : propertiesOut.keySet()) {
@@ -150,6 +161,10 @@
getLog().info("copy bundle " + locale + " to src");
}
}
+
+ if (!keepGetters) {
+ deleteFile(bundleGetterOut);
+ }
}
}
}
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GetterMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GetterMojo.java 2010-03-08 18:35:57 UTC (rev 1708)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GetterMojo.java 2010-03-09 16:32:25 UTC (rev 1709)
@@ -38,6 +38,15 @@
*/
public class GetterMojo extends AbstractI18nMojo {
+ /**
+ * Conserve les fichiers de getters.
+ *
+ * @parameter expression="${i18n.keepGetters}" default-value="false"
+ */
+ protected boolean keepGetters;
+
+ protected static final String FROM_GETTERS = "-fromGetters";
+
@Override
protected boolean checkSkip() {
@@ -58,10 +67,14 @@
getLog().info("config - locales : " + Arrays.toString(locales));
}
- File bundleGetters = new File(out.getAbsolutePath() +
- File.separatorChar + artifactId +
- ".properties");
- createNewFile(bundleGetters);
+ File bundleGetters = new File(out.getAbsoluteFile(),
+ artifactId + ".properties");
+
+ createDirectoryIfNecessary(bundleGetters.getParentFile());
+// createNewFile(bundleGetters);
+
+ SortedProperties propertiesOut = new SortedProperties(getEncoding());
+
DirectoryScanner ds = new DirectoryScanner();
ds.setBasedir(out);
ds.setIncludes(new String[]{"*.getter"});
@@ -72,8 +85,17 @@
for (String file : files) {
long t0 = System.nanoTime();
File bundleGetter = getGetterFile(out, file, false);
- concactProperties(bundleGetter, bundleGetters);
- if (genSrc) {
+
+ // chargement du getter
+ SortedProperties propertiesIn =
+ new SortedProperties(getEncoding()).load(bundleGetter);
+
+ // ajout des entrées dans le bundle
+ propertiesOut.putAll(propertiesIn);
+// concactProperties(bundleGetter, bundleGetters);
+
+ if (!keepGetters) {
+// if (genSrc) {
deleteFile(bundleGetter);
}
if (!silent) {
@@ -83,18 +105,24 @@
}
}
+ // sauvegarde du fichier des getters
+ propertiesOut.store(bundleGetters);
+
// Création des bundles
for (Locale locale : locales) {
if (getLog().isDebugEnabled()) {
getLog().debug("generate bundle for locale " + locale);
}
- File bundleOut = getI18nFile(out, artifactId, locale, false);
+ File bundleOut = getI18nFile(out, artifactId + FROM_GETTERS, locale, false);
+// File bundleOut = getI18nFile(out, artifactId, locale, false);
copyFile(bundleGetters, bundleOut);
if (!silent && verbose) {
getLog().info("generate bundle " + locale);
}
}
- deleteFile(bundleGetters);
+ if (!keepGetters) {
+ deleteFile(bundleGetters);
+ }
}
/**
@@ -104,7 +132,9 @@
* @param out le fichier sortant
* @throws IOException si problème pendant la sauvegarde ou fichier non
* trouvé.
+ * @deprecated since 1.1, this is no more used
*/
+ @Deprecated
protected void concactProperties(File in, File out) throws IOException {
SortedProperties propertiesIn = new SortedProperties(encoding).load(in);
SortedProperties propertiesOut =
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParserMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParserMojo.java 2010-03-08 18:35:57 UTC (rev 1708)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParserMojo.java 2010-03-09 16:32:25 UTC (rev 1709)
@@ -127,7 +127,7 @@
protected List<File> treadedFiles;
/** logger verbeux */
- protected I18nLogger verboseLog = new I18nLogger(this);
+ protected I18nLogger verboseLog;
public boolean isStrictMode() {
return strictMode;
@@ -139,6 +139,7 @@
@Override
public void init() throws Exception {
+ verboseLog = new I18nLogger(this);
super.init();
t0 = System.nanoTime();
result = new SortedProperties(encoding);
@@ -171,9 +172,9 @@
}
treadedFiles = new ArrayList<File>();
- if (!silent && verbose) {
- showTouchedFiles = true;
- }
+// if (!silent && verbose) {
+// showTouchedFiles = true;
+// }
}
@Override
@@ -229,9 +230,6 @@
@Override
public void parse() throws IOException {
if (treateDefaultEntry) {
- if (verbose && getLog().isInfoEnabled()) {
- getLog().info("add default entry");
- }
addDefaultEntry();
}
long t00 = System.nanoTime();
@@ -251,11 +249,13 @@
long t000 = System.nanoTime();
int nbFiles = entry.getFiles().length;
- if (!silent && verbose) {
+ if (!silent) {
+// if (!silent && verbose) {
vLog.infoEntry("start", vLog.getLogEntry(
"[incoming file(s) : " + entry.getFoudFiles() + "]",
0, 0, 0));
}
+ int nbTreatedFilesBefore = treadedFiles.size();
// launch parser for found files
parseEntry(entry);
@@ -268,10 +268,16 @@
}
}
fileTreated += nbFiles;
- if (!silent && verbose) {
- vLog.infoEntry("end", vLog.getLogEntry(
- "[treated file(s) : " + nbFiles + "]", nbFiles, t000,
- t00));
+ if (!silent) {
+// if (!silent && verbose) {
+ int nbTreatedFilesAfter = treadedFiles.size() -
+ nbTreatedFilesBefore;
+ vLog.infoEntry(
+ "end",
+ vLog.getLogEntry(
+ "[treated file(s) : " + nbTreatedFilesAfter +
+ "/" + nbFiles + "]", nbFiles, t000,
+ t00));
}
t00 = System.nanoTime();
}
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/I18nLogger.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/I18nLogger.java 2010-03-08 18:35:57 UTC (rev 1708)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/I18nLogger.java 2010-03-09 16:32:25 UTC (rev 1709)
@@ -104,10 +104,10 @@
* @return la chaine de log formatée
*/
public String getLogEntry(String msg, int nbFiles, long time, long all) {
- long now = System.nanoTime();
+ long now = System.nanoTime() ;
long delta = now - time;
String s = msg;
- if (time > 0) {
+ if (time > 0 && all == 0) {
s += " (" + PluginHelper.convertTime(delta) + ")";
}
if (all > 0) {
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/Parser.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/Parser.java 2010-03-08 18:35:57 UTC (rev 1708)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/Parser.java 2010-03-09 16:32:25 UTC (rev 1709)
@@ -44,15 +44,17 @@
* Parse sur un fichier
*
* @param file le fichier à parser
+ * @throws IOException if any pb
*/
- void parseFile(File file);
+ void parseFile(File file)throws IOException;
/**
* Parse une partie du fichier
*
* @param file le fichier à parser
* @param line la ligne à parser
+ * @throws IOException if any pb
*/
- void parseLine(File file, String line);
+ void parseLine(File file, String line)throws IOException;
}
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/SourceEntry.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/SourceEntry.java 2010-03-08 18:35:57 UTC (rev 1708)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/SourceEntry.java 2010-03-09 16:32:25 UTC (rev 1709)
@@ -166,7 +166,7 @@
if (includes != null) {
sb.append(", includes:").append(Arrays.toString(includes));
}
- if (excludes != null) {
+ if (excludes != null && excludes.length>0) {
sb.append(", excludes:").append(Arrays.toString(excludes));
}
return sb.toString();
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaMojo.java 2010-03-08 18:35:57 UTC (rev 1708)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaMojo.java 2010-03-09 16:32:25 UTC (rev 1709)
@@ -25,10 +25,7 @@
import org.nuiton.io.FileUpdaterHelper;
import org.nuiton.processor.filters.I18nFilter;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStreamReader;
-import java.io.LineNumberReader;
+import java.io.*;
/**
* Récupération des chaine a traduire depuis les fichiers java.
@@ -105,23 +102,28 @@
}
@Override
- public void parseFile(File srcFile) {
- LineNumberReader lnr;
+ public void parseFile(File srcFile) throws IOException {
String line = null;
+ LineNumberReader lnr = new LineNumberReader(new InputStreamReader(
+ new FileInputStream(srcFile)));
try {
- lnr = new LineNumberReader(new InputStreamReader(
- new FileInputStream(srcFile)));
-
- while (lnr.ready()) {
- line = lnr.readLine();
+ while ((line = lnr.readLine())!=null) {
parseLine(srcFile, line);
}
+// while (lnr.ready()) {
+// line = lnr.readLine();
+// parseLine(srcFile, line);
+// }
} catch (Exception e) {
if (line != null) {
- getLog().error("could not parse line " + line);
+ getLog().error(
+ "could not parse line (" + lnr.getLineNumber() + ") '"
+ + line + "' of file " + srcFile);
}
throw new ParserException(e);
+ } finally {
+ lnr.close();
}
}
@@ -130,6 +132,7 @@
String keysSet = filter.parse(line);
if (!keysSet.equals(I18nFilter.EMPTY_STRING)) {
+ // au moins une clef i18n a ete detectee dans le fichier
touchFile = true;
// Found a set of i18n Strings, split it.
String[] keys = keysSet.split("=");
@@ -139,11 +142,17 @@
event.eventChangeKey(key, !oldLanguage.containsKey(key));
keyModified = event.eventGetRealKey();
}
- if (oldParser.containsKey(key)) {
- result.put(keyModified, oldParser.get(key));
- } else {
- result.put(keyModified, key);
+ Object value = oldParser.get(key);
+ if (value == null) {
+ // nouvelle clef du parser, on utilise la clef comme valeur
+ value = key;
}
+ result.put(keyModified,value);
+// if (oldParser.containsKey(key)) {
+// result.put(keyModified, oldParser.get(key));
+// } else {
+// result.put(keyModified, key);
+// }
}
}
}
1
0
r1708 - in trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin: . bundle parser parser/impl
by tchemit@users.nuiton.org 08 Mar '10
by tchemit@users.nuiton.org 08 Mar '10
08 Mar '10
Author: tchemit
Date: 2010-03-08 19:35:57 +0100 (Mon, 08 Mar 2010)
New Revision: 1708
Log:
introduce bundle package to put all the bundle-mojo + move all specific to parser stuff to parser package
Added:
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/AbstractI18nBundleMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/BundleMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/CollectI18nArtifactsMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/I18nArtifact.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/I18nLogger.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/SourceEntry.java
Removed:
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nBundleMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/BundleMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/CollectI18nArtifactsMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/I18nArtifact.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/I18nLogger.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/SourceEntry.java
Modified:
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GenerateMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParserMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/I18nSourceEntry.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/KeysModifier.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserValidationMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXmlMojo.java
Deleted: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nBundleMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nBundleMojo.java 2010-03-08 11:04:08 UTC (rev 1707)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nBundleMojo.java 2010-03-08 18:35:57 UTC (rev 1708)
@@ -1,88 +0,0 @@
-/*
- * *##%
- * I18n :: Maven Plugin
- * Copyright (C) 2007 - 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * ##%*
- */
-package org.nuiton.i18n.plugin;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-import java.util.Locale;
-
-/**
- * Created: 26 déc. 2009
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @version $Revision$
- * <p/>
- * Mise a jour: $Date$ par :
- * $Author: tchemit $
- */
-public abstract class AbstractI18nBundleMojo extends AbstractI18nMojo {
-
- /**
- * Repertoire ou generer les bundles.
- *
- * @parameter expression="${i18n.collectOutputDir}" default-value="${basedir}/target/i18n"
- * @required
- * @since 1.0.2
- */
- protected File collectOutputDir;
-
- /**
- * Nom de base des fichiers qui contient les localisations des bundles.
- *
- * @parameter expression="${i18n.collectOutputName}" default-value="collect-${project.artifactId}-i18n"
- * @required
- * @since 1.0.2
- */
- protected String collectOutputName;
-
- /**
- * Pour obtenir les urls des fichiers i18n d'un projet (avec recherche
- * dans ses dépendances).
- * <p/>
- * <b>Note:</b> L'ordre des urls reflète l'ordre des dépendances.
- *
- * @param locale la locale a traiter
- * @return les urls des bundles i18n detectees pour le projet.
- * @throws Exception pour tout problème
- */
- protected abstract URL[] getCollectI18nResources(Locale locale)
- throws Exception;
-
- /**
- * Pour obtenir le fichier contenant les localisation des bundles i18n du
- * projet pour une {@code locale} donnée.
- *
- * @param locale la locale
- * @param create un drapeau pour forcer la création du fichier
- * s'il n'existe pas
- * @return le fichier qui contient les urls des bundles i18n pour la
- * locale donnée.
- * @throws IOException pour tout pb
- */
- protected File getCollectOutputFile(Locale locale, boolean create)
- throws IOException {
- File bundleOut = getI18nFile(collectOutputDir, collectOutputName,
- locale, create);
- return bundleOut;
- }
-
-}
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java 2010-03-08 11:04:08 UTC (rev 1707)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java 2010-03-08 18:35:57 UTC (rev 1708)
@@ -32,16 +32,14 @@
import java.util.SortedSet;
/**
- * Classe permettant d'obenir les parametres pendant les différentes phases
- * du plugin.
+ * Classe permettant d'obenir les parametres pendant les différentes phases du
+ * plugin.
*
* @author julien
*/
public abstract class AbstractI18nMojo extends AbstractPlugin {
- /**
- * Le nombre de getters détectés pendant le cycle de vie du build.
- */
+ /** Le nombre de getters détectés pendant le cycle de vie du build. */
private static int NB_GETTER_FILES;
/**
@@ -97,7 +95,8 @@
/**
* Met les fichiers generes dans le repertoire des sources i18n.
* <p/>
- * Note: Par défaut active, pour pouvoir paquager avec les bundles mis a jour.
+ * Note: Par défaut active, pour pouvoir paquager avec les bundles mis a
+ * jour.
*
* @parameter expression="${i18n.genSrc}" default-value="true"
*/
@@ -124,22 +123,15 @@
* ne conserve que les clef scannees (et donc traite tous les fichiers)
* <p/>
* <p/>
- * Note : par default, on ne l'active car rescanne tous les fichiers.
- * s
+ * Note : par default, on ne l'active car rescanne tous les fichiers. s
*
* @parameter expression="${i18n.strictMode}" default-value="false"
*/
protected boolean strictMode;
- /**
- * les locales a traiter
- */
+ /** les locales a traiter */
protected Locale[] locales;
- /**
- * logger verbeux
- */
- protected I18nLogger verboseLog;
@Override
protected boolean checkPackaging() {
@@ -149,8 +141,6 @@
public void init() throws Exception {
- verboseLog = new I18nLogger(this);
-
if (verbose) {
getLog().info("config - verbose mode is on");
}
@@ -167,8 +157,8 @@
}
/**
- * @return <code>true</code> si des getters ont etes enregistres pendant
- * le cycle de vie, <code>false</code> sinon.
+ * @return <code>true</code> si des getters ont etes enregistres pendant le
+ * cycle de vie, <code>false</code> sinon.
*/
protected boolean needGeneration() {
boolean needGeneration = NB_GETTER_FILES > 0;
@@ -178,17 +168,13 @@
/**
* Prend en compte qu'un getter a été détecté.
* <p/>
- * Cela veut dire qu'un goal de parser a détecté des clefs. Il
- * faudra donc activer les goal get et gen.
+ * Cela veut dire qu'un goal de parser a détecté des clefs. Il faudra donc
+ * activer les goal get et gen.
*/
protected void addGetter() {
NB_GETTER_FILES++;
}
- protected I18nLogger getVerboseLog() {
- return verboseLog;
- }
-
/**
* @param root le repertoire ou sont stockes les fichiers i18n
* @param artifactId le nom de l'artifact
Deleted: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/BundleMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/BundleMojo.java 2010-03-08 11:04:08 UTC (rev 1707)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/BundleMojo.java 2010-03-08 18:35:57 UTC (rev 1708)
@@ -1,246 +0,0 @@
-/*
- * *##%
- * I18n :: Maven Plugin
- * Copyright (C) 2007 - 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * ##%*
- */
-package org.nuiton.i18n.plugin;
-
-import org.nuiton.i18n.bundle.I18nBundleEntry;
-import org.nuiton.i18n.bundle.I18nBundleUtil;
-import org.nuiton.i18n.init.DefaultI18nInitializer;
-import org.nuiton.io.SortedProperties;
-import org.nuiton.plugin.PluginHelper;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.net.URL;
-import java.util.*;
-import java.util.Map.Entry;
-
-/**
- * Créer un bundle pour une application finale.
- * <p/>
- * Cela génère un merge de tous les fichiers i18n utilisés en un seul.
- * <p/>
- * On utilise la dépendance sur les artifacts pour connaitre l'ordre le
- * chargement des bundles.
- * <p/>
- * Si dans un bundle childs, la valeur de la clef est vide, on conserve alors
- * celui du parent,
- * <p/>
- * Ainsi on obtient un bundle dont toutes les clefs sont traduites.
- * <p/>
- * Le but aussi d'utiliser un unique bundle est de gagner du temps au runtime
- * car la recherche des bundles devient trop couteuse en temps lorsque l'on a de
- * nombreuses dépendances (au dessus de 100 deps cela peut prendre plusieurs
- * secondes, ce qui 'est pas acceptable).
- * <p/>
- * On a ajoute un second mode d'initialisation dans la clesse I18n pour
- * n'utiliser qu'un seul bundle et courcircuiter le chargement couteux...
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @goal bundle
- * @phase generate-resources
- * @execute goal=collect-i18n-artifacts
- * @requiresProject true
- * @requiresDependencyResolution runtime
- * @since 0.12
- */
-public class BundleMojo extends AbstractI18nBundleMojo {
-
- /**
- * Repertoire ou generer les bundles.
- *
- * @parameter expression="${i18n.bundleOutputDir}" default-value="${basedir}/target/generated-sources/resources/META-INF"
- * @required
- * @since 1.0.0
- */
- protected File bundleOutputDir;
-
- /**
- * Nom du bundle a generer.
- *
- * @parameter expression="${i18n.bundleOutputName}" default-value="${project.artifactId}-i18n"
- * @required
- * @since 1.0.2
- */
- protected String bundleOutputName;
-
- /**
- * Un drapeau pour vérifier que les bundles ne contiennent pas d'entrées
- * vides.
- *
- * @parameter expression="${i18n.checkBundle}" default-value="true"
- * @required
- * @since 1.0.0
- */
- protected boolean checkBundle;
-
- /**
- * Un drapeau pour afficher les entrées vides. (nécessite {@link
- * #checkBundle} activé).
- *
- * @parameter expression="${i18n.showEmpty}" default-value="false"
- * @required
- * @since 1.0.0
- */
- protected boolean showEmpty;
-
- @Override
- public void init() throws Exception {
- super.init();
-
- createDirectoryIfNecessary(bundleOutputDir);
-
- // ajout de repertoire de generation (le parent en fait)
- // dans les resources du projet
-
- addResourceDir(bundleOutputDir.getParentFile(), "**/*.properties");
- }
-
- @Override
- protected void doAction() throws Exception {
- long t00 = System.nanoTime();
-
- String version = getProject().getVersion();
- version = PluginHelper.removeSnapshotSuffix(version);
-
- if (!silent) {
- getLog().info("config - bundle name : " + bundleOutputName);
- getLog().info("config - basedir : " + bundleOutputDir);
- getLog().info("config - locales : " + Arrays.toString(locales));
- getLog().info("config - version : " + version);
- }
-
- Map<Locale, String> bundleDico =
- new LinkedHashMap<Locale, String>(locales.length);
-
- for (Locale locale : locales) {
-
- long t0 = System.nanoTime();
-
- File bundleOut = getI18nFile(bundleOutputDir, bundleOutputName,
- locale, false);
-
- if (!silent) {
- getLog().info("generate bundle for locale " + locale);
- }
-
- SortedProperties propertiesOut =
- new SortedProperties(encoding, false);
- StringBuilder buffer = new StringBuilder();
-
- URL[] urls = getCollectI18nResources(locale);
- if (urls.length == 0) {
- getLog().warn("no bundle for locale " + locale);
- continue;
- }
-
- for (URL url : urls) {
- long t000 = System.nanoTime();
- I18nBundleEntry bundleEntry =
- new I18nBundleEntry(url, locale, null);
- bundleEntry.load(propertiesOut);
- String strPath = bundleEntry.getPath().toString();
- int index = strPath.indexOf("i18n/");
-
- buffer.append(',').append(strPath.substring(index));
- if (verbose) {
- getLog().info(
- "loaded " + bundleEntry.getPath() + " in " +
- PluginHelper.convertTime(t000, System.nanoTime()));
- }
- }
-
- if (buffer.length() > 0) {
- bundleDico.put(locale, buffer.substring(1));
- if (!silent) {
- getLog().info(
- "bundles for locale : " + bundleDico.get(locale));
- }
- }
- propertiesOut.store(bundleOut);
- if (!silent && verbose) {
- getLog().info(
- "bundle created in " +
- PluginHelper.convertTime(t0, System.nanoTime()) +
- " (detected sentences : " + propertiesOut.size() + ")");
- }
- if (checkBundle) {
- checkBundle(locale, propertiesOut, showEmpty);
- }
- }
-
- // ecriture du ficher des definitions i18n (permet de faire une
- // recherche extact sur un fichier puis d'en deduire les bundles a
- // charger
- String f = String.format(DefaultI18nInitializer.UNIQUE_BUNDLE_DEF,
- bundleOutputName);
- File defOut = new File(bundleOutputDir, f);
- if (!silent) {
- getLog().info("prepare i18n definition " +
- defOut.getAbsolutePath());
- }
- SortedProperties p = new SortedProperties(encoding, false);
- p.setProperty(DefaultI18nInitializer.BUNDLE_DEF_LOCALES, bundles);
- p.setProperty(DefaultI18nInitializer.BUNDLE_DEF_VERSION, version);
- for (Entry<Locale, String> e : bundleDico.entrySet()) {
- p.setProperty(DefaultI18nInitializer.BUNDLES_FOR_LOCALE +
- e.getKey().toString(), e.getValue());
- }
- FileOutputStream out = new FileOutputStream(defOut);
- try {
- p.store(out, null);
- } finally {
- out.close();
- }
-
- if (!silent && verbose) {
- getLog().info("done in " +
- PluginHelper.convertTime(t00, System.nanoTime()));
- }
- }
-
- @Override
- protected URL[] getCollectI18nResources(Locale locale) throws IOException {
- File file = getCollectOutputFile(locale, false);
- if (!file.exists()) {
- return I18nBundleUtil.EMPTY_URL_ARRAY;
- }
- URL[] urls = getLinesAsURL(file);
- return urls;
- }
-
- /**
- * TODO Move this in PluginHelper.
- *
- * @param src the source file to read
- * @return the url instanciated from lines of the source file.
- * @throws IOException if any pb while reading file
- */
- public static URL[] getLinesAsURL(File src) throws IOException {
- List<URL> result = new ArrayList<URL>();
- for (String line : PluginHelper.getLines(src)) {
- if (!line.isEmpty()) {
- result.add(new URL(line));
- }
- }
- return result.toArray(new URL[result.size()]);
- }
-}
Deleted: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/CollectI18nArtifactsMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/CollectI18nArtifactsMojo.java 2010-03-08 11:04:08 UTC (rev 1707)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/CollectI18nArtifactsMojo.java 2010-03-08 18:35:57 UTC (rev 1708)
@@ -1,256 +0,0 @@
-/*
- * *##%
- * I18n :: Maven Plugin
- * Copyright (C) 2007 - 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * ##%*
- */
-package org.nuiton.i18n.plugin;
-
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.factory.ArtifactFactory;
-import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.resolver.ArtifactCollector;
-import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
-import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
-import org.apache.maven.shared.dependency.tree.DependencyNode;
-import org.apache.maven.shared.dependency.tree.DependencyTreeBuilder;
-import org.apache.maven.shared.dependency.tree.DependencyTreeBuilderException;
-import org.nuiton.i18n.bundle.I18nBundleEntry;
-import org.nuiton.plugin.DependencyUtil;
-import org.nuiton.plugin.PluginHelper;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-
-/**
- * Detects any i18n artifacts and store the result as a file.
- * <p/>
- * Created: 24 déc. 2009
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @version $Revision$
- * <p/>
- * Mise a jour: $Date$ par :
- * $Author: tchemit $
- * @goal collect-i18n-artifacts
- * @phase generate-resources
- * @requiresProject true
- * @requiresDependencyResolution runtime
- * @since 1.0.2
- */
-public class CollectI18nArtifactsMojo extends AbstractI18nBundleMojo {
-
- /**
- * Local Repository.
- *
- * @parameter expression="${localRepository}"
- * @required
- * @readonly
- * @since 1.0.2
- */
- protected ArtifactRepository localRepository;
-
- /**
- * Dependency tree builder component.
- *
- * @component
- * @since 1.0.2
- */
- protected DependencyTreeBuilder dependencyTreeBuilder;
-
- /**
- * Artifact Factory component.
- *
- * @component
- * @since 1.0.2
- */
- protected ArtifactFactory factory;
-
- /**
- * Artifact metadata source component.
- *
- * @component
- * @since 1.0.2
- */
- protected ArtifactMetadataSource artifactMetadataSource;
-
- /**
- * Artifact collector component.
- *
- * @component
- * @since 1.0.2
- */
- protected ArtifactCollector collector;
-
- I18nArtifact[] i18nArtifacts;
-
- @Override
- public void init() throws Exception {
- super.init();
-
- PluginHelper.createDirectoryIfNecessary(collectOutputDir);
- }
-
- @Override
- protected void doAction() throws Exception {
-
- // detects the i18n artifacts (only once since it cost some times)...
- i18nArtifacts = detectI18nArtifacts();
-
- if (i18nArtifacts.length == 0) {
- getLog().warn("no i18n artifact detected.");
- return;
- }
-
- for (Locale locale : locales) {
-
- if (!silent) {
- getLog().info("generate collected i18n artifacts for locale " +
- locale);
- }
- URL[] urls = getCollectI18nResources(locale);
-
- if (urls.length == 0) {
- getLog().warn("no i18n bundles for locale " + locale);
- return;
- }
-
- File bundleOut = getCollectOutputFile(locale, true);
-
- storeCollectI18nResources(bundleOut, urls);
-
- getLog().info("collected " + urls.length +
- " i18n artifacts for locale " + locale +
- " stored in " + bundleOut);
- }
- }
-
- @Override
- protected URL[] getCollectI18nResources(Locale locale)
- throws IOException, DependencyTreeBuilderException {
-
- // la locale par defaut est la première
- Locale defaultLocale = locales[0];
-
- List<URL> urls = new ArrayList<URL>();
- for (I18nArtifact artifact : i18nArtifacts) {
- I18nBundleEntry[] bundleEntries =
- artifact.getBundleEntries(locale, defaultLocale);
- for (I18nBundleEntry bundleEntry : bundleEntries) {
-
- URL path = bundleEntry.getPath();
- urls.add(path);
- if (verbose) {
- getLog().info("add " + path);
- }
- }
- }
- return urls.toArray(new URL[urls.size()]);
- }
-
- protected void storeCollectI18nResources(File bundleOut, URL[] urls)
- throws IOException {
- StringBuilder buffer = new StringBuilder();
-
- for (URL path : urls) {
-
- buffer.append(path).append("\n");
-
- if (verbose) {
- getLog().info("add " + path);
- }
- }
- writeFile(bundleOut, buffer.toString(), encoding);
- }
-
- /**
- * Detecte les {@link I18nArtifact} et les retourne dans l'ordre de
- * chargement dans le système i18n, i.e l'ordre des dependances entre
- * artifacts.
- *
- * @return les artifacts i18nables triés par leur ordre de chargement dans
- * le système i18n.
- * @throws IOException while detecting bundles from artifacts
- * @throws DependencyTreeBuilderException if any error while building the
- * depencendy tree
- */
- protected I18nArtifact[] detectI18nArtifacts()
- throws IOException, DependencyTreeBuilderException {
-
- Map<Artifact, I18nArtifact> dico =
- new HashMap<Artifact, I18nArtifact>();
-
- I18nArtifact i18nArtifact;
- for (Object o : project.getArtifacts()) {
- i18nArtifact = new I18nArtifact((Artifact) o);
- if (i18nArtifact.detectBundles()) {
- if (!silent) {
- getLog().info("detected i18n artifact " + i18nArtifact);
- }
- dico.put(i18nArtifact.getArtifact(), i18nArtifact);
- } else {
- if (getLog().isDebugEnabled()) {
- getLog().debug("reject artifact " + i18nArtifact);
- }
- }
- }
-
- ArtifactFilter artifactFilter
- = new ScopeArtifactFilter(Artifact.SCOPE_RUNTIME);
-
- DependencyNode rootNode = dependencyTreeBuilder.buildDependencyTree(
- project, localRepository, factory,
- artifactMetadataSource, artifactFilter, collector);
-
- List<Artifact> artifacts = new ArrayList<Artifact>(dico.keySet());
-
- DependencyUtil.sortArtifacts(rootNode, artifacts,
- getLog().isDebugEnabled());
-
- // l'artifact du projet est traite en dernier car s'il possède des
- // bundles alors ils doivent etre charge en dernier
-
- Artifact projectArtifact = project.getArtifact();
- i18nArtifact = new I18nArtifact(projectArtifact, src.getParentFile());
-
- if (i18nArtifact.detectBundles()) {
- if (!silent) {
- getLog().info("detected i18n artifact " + i18nArtifact);
- }
- artifacts.add(i18nArtifact.getArtifact());
- dico.put(i18nArtifact.getArtifact(), i18nArtifact);
- } else {
- if (getLog().isDebugEnabled()) {
- getLog().debug("reject artifact " + i18nArtifact);
- }
- }
-
- I18nArtifact[] result = new I18nArtifact[artifacts.size()];
- int i = 0;
- for (Artifact artifact : artifacts) {
- result[i++] = dico.get(artifact);
- }
- return result;
- }
-}
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GenerateMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GenerateMojo.java 2010-03-08 11:04:08 UTC (rev 1707)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GenerateMojo.java 2010-03-08 18:35:57 UTC (rev 1708)
@@ -48,8 +48,8 @@
protected boolean checkBundle;
/**
- * Un drapeau pour afficher les entrées vides. (nécessite
- * {@link #checkBundle} activé).
+ * Un drapeau pour afficher les entrées vides. (nécessite {@link
+ * #checkBundle} activé).
*
* @parameter expression="${i18n.showEmpty}" default-value="false"
* @required
Deleted: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/I18nArtifact.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/I18nArtifact.java 2010-03-08 11:04:08 UTC (rev 1707)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/I18nArtifact.java 2010-03-08 18:35:57 UTC (rev 1708)
@@ -1,109 +0,0 @@
-/*
- * *##%
- * I18n :: Maven Plugin
- * Copyright (C) 2007 - 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * ##%*
- */
-package org.nuiton.i18n.plugin;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.maven.artifact.Artifact;
-import org.nuiton.i18n.bundle.I18nBundle;
-import org.nuiton.i18n.bundle.I18nBundleEntry;
-import org.nuiton.i18n.bundle.I18nBundleUtil;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.List;
-import java.util.Locale;
-
-/**
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.12
- */
-public class I18nArtifact {
-
- static final Log log = LogFactory.getLog(I18nArtifact.class);
-
- protected final Artifact artifact;
-
- protected final URL url;
-
- protected I18nBundle[] bundles;
-
- public I18nArtifact(Artifact artifact) throws MalformedURLException {
- this.artifact = artifact;
- url = artifact.getFile().toURI().toURL();
- }
-
- public I18nArtifact(Artifact artifact,
- File file) throws MalformedURLException {
- this.artifact = artifact;
- url = file.toURI().toURL();
- }
-
- public Artifact getArtifact() {
- return artifact;
- }
-
- public URL getUrl() {
- return url;
- }
-
- public I18nBundleEntry[] getBundleEntries(Locale l, Locale defaultLocale) {
- if (bundles == null) {
- throw new NullPointerException(
- "le bundleManager n'a pas ete initialise!");
- }
- return I18nBundleUtil.getBundleEntries(l, defaultLocale, bundles);
- }
-
- public boolean detectBundles() throws IOException {
-
- URL[] i18nUrls = I18nBundleUtil.getURLs(url);
-
- if (i18nUrls == null || i18nUrls.length == 0) {
- // aucune url sur un fichier de traduction trouve
- // l'artifact n'est pas i18n.
- if (log.isDebugEnabled()) {
- log.debug("no i18n url for artifact " + artifact);
- }
- return false;
- }
-
- List<I18nBundle> listBundles =
- I18nBundleUtil.detectBundles(i18nUrls);
-
- if (listBundles.isEmpty()) {
- // pas de bundle instancie (cela ne devrait jamais arrive...)
- return false;
- }
-
- bundles = listBundles.toArray(new I18nBundle[listBundles.size()]);
-
- return true;
- }
-
- @Override
- public String toString() {
- return artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" +
- artifact.getVersion();
- }
-}
Deleted: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/I18nLogger.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/I18nLogger.java 2010-03-08 11:04:08 UTC (rev 1707)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/I18nLogger.java 2010-03-08 18:35:57 UTC (rev 1708)
@@ -1,132 +0,0 @@
-/**
- * *##%
- * I18n :: Maven Plugin
- * Copyright (C) 2007 - 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * ##%*
- */
-package org.nuiton.i18n.plugin;
-
-import org.apache.maven.plugin.logging.SystemStreamLog;
-import org.nuiton.plugin.PluginHelper;
-
-import java.beans.Introspector;
-import java.io.File;
-
-/**
- * Le logger utilisé par les mojo.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.9
- */
-public class I18nLogger extends SystemStreamLog {
-
- /**
- * l'entrée en cours de traitement (pour les parseurs)
- */
- private SourceEntry entry;
-
- /**
- * le fichier en cours de traitement (pour les parseurs)
- */
- protected File file;
-
- /**
- * le prefix du mojo courant a ajouter dans les logs.
- */
- protected String parser;
-
- public I18nLogger(AbstractI18nMojo parser) {
- this.parser = "i18n:" + Introspector.decapitalize(
- parser.getClass().getSimpleName()) + " on " +
- parser.getArtifactId();
- }
-
- @Override
- public void info(CharSequence content) {
- print(0, "INFO", null, content.toString());
- }
-
- @Override
- public void debug(CharSequence content) {
- print(0, "DEBUG", null, content.toString());
- }
-
- public void infoEntry(String action, CharSequence content) {
- print(0, "INFO", action,
- entry.toString() +
- (content == null ? "" : " - " + content.toString()));
- }
-
- public void infoFile(String action, String content) {
- print(2, "INFO", action, file.toString() +
- (content == null ? "" : " - " + content));
- }
-
- public void infoAction(String action, String content) {
- print(2, "INFO", action, content == null ? "" : " - " + content);
- }
-
- private void print(int start, String prefix, String context,
- String content) {
- StringBuilder sb = new StringBuilder();
- sb.append("[").append(prefix).append("] [").append(parser).append("] ");
-
- for (int i = 0; i < start; i++) {
- sb.append(' ');
- }
- if (context != null) {
- sb.append("<").append(context).append("> ");
- }
- sb.append(content);
- System.out.println(sb.toString());
- }
-
- public void setEntry(SourceEntry entry) {
- this.entry = entry;
- }
-
- /**
- * Construit une chaine de log formatée.
- *
- * @param msg le prefix du message
- * @param nbFiles le nombre de fichiers actuellement traités
- * @param time le time de traitement de ce fichier
- * @param all le temps de traitement de tous les fichiers
- * @return la chaine de log formatée
- */
- public String getLogEntry(String msg, int nbFiles, long time, long all) {
- long now = System.nanoTime();
- long delta = now - time;
- String s = msg;
- if (time > 0) {
- s += " (" + PluginHelper.convertTime(delta) + ")";
- }
- if (all > 0) {
- s += "(total time:" + PluginHelper.convertTime(now - all) + ")";
- }
- if (nbFiles > 0) {
- s += " ( ~ " +
- PluginHelper.convertTime((now - all) / nbFiles) + " / file)";
- }
- return s;
- }
-
- public void setFile(File file) {
- this.file = file;
- }
-
-}
Deleted: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/SourceEntry.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/SourceEntry.java 2010-03-08 11:04:08 UTC (rev 1707)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/SourceEntry.java 2010-03-08 18:35:57 UTC (rev 1708)
@@ -1,292 +0,0 @@
-/*
- * *##%
- * I18n :: Maven Plugin
- * Copyright (C) 2007 - 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * ##%*
- */
-package org.nuiton.i18n.plugin;
-
-import org.apache.maven.plugin.logging.Log;
-import org.codehaus.plexus.util.DirectoryScanner;
-import org.nuiton.io.FileUpdater;
-
-import java.io.File;
-import java.lang.annotation.Annotation;
-import java.net.URLClassLoader;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * A simple model for a sourceEntry represents by a basedir and includes
- * and/or exlucdes pattern.
- * <p/>
- * The class offers the usefull method :
- * {@link #getIncludedFiles(File, String[], String[])}
- * <p/>
- * to obtain the list of files from
- * the {@link #basedir} directory which respects the {@link #includes} and/or
- * {@link #excludes} patterns using an internal {@link DirectoryScanner}
- * object.
- * <p/>
- * Note : <b>The class does not extends <code>DirectoryScanner</code> since
- * we DO not want to expose his methods.</b>
- *
- * @author tchemit <chemit(a)codelutin.com>
- */
-public class SourceEntry {
-
- /**
- * If you want to restrict use of the entry, set the class name goal to
- * this property via {@link #setSpecificGoal(String)}.
- * <p/>
- * If let to <code>null</code>, all goals can use this entry.
- */
- protected String specificGoal;
-
- protected File basedir;
-
- protected String[] includes;
-
- protected String[] excludes;
-
- /**
- * Files to be find
- */
- protected String[] files;
-
- protected String[] skipFiles;
-
- protected String skipMessage;
-
- protected FileUpdater updater;
-
- public String[] getExcludes() {
- return excludes;
- }
-
- public void setExcludes(String[] excludes) {
- this.excludes = excludes;
- }
-
- public String[] getIncludes() {
- return includes;
- }
-
- public void setIncludes(String[] includes) {
- this.includes = includes;
- }
-
- public File getBasedir() {
- return basedir;
- }
-
- public void setBasedir(File basedir) {
- this.basedir = basedir;
- }
-
- public String getSpecificGoal() {
- return specificGoal;
- }
-
- public void setSpecificGoal(String specificGoal) {
- this.specificGoal = specificGoal;
- }
-
- public boolean useForGoal(String goal) {
- return specificGoal == null || specificGoal.equalsIgnoreCase(goal);
- }
-
- public boolean hasSrc() {
- return basedir != null;
- }
-
- public boolean hasIncludes() {
- return includes != null && includes.length > 0;
- }
-
- public boolean hasExcludes() {
- return excludes != null && excludes.length > 0;
- }
-
- /**
- * Test if a file is up to date and not to be treated.
- * <p/>
- *
- * @param file the file path to test
- * @return {@code true} if file is up to date and do not need to be parsed
- * @see FileUpdater
- */
- public final boolean isFileUptodate(File file) {
- return updater != null && updater.isFileUpToDate(file);
- }
-
- public String[] getIncludedFiles(File defaultBasedir,
- String[] defaultIncludes,
- String[] defaultExcludes) {
- // normalized entry
- if (!hasSrc()) {
- setBasedir(defaultBasedir);
- }
- if (!hasIncludes()) {
- setIncludes(defaultIncludes);
- }
- if (!hasExcludes()) {
- setExcludes(defaultExcludes);
- }
- // init directory scanner
- DirectoryScanner ds = new DirectoryScanner();
- ds.setBasedir(getBasedir());
- ds.setIncludes(getIncludes());
- if (hasExcludes()) {
- ds.setExcludes(getExcludes());
- }
- // scan
- ds.scan();
- // get found files
- String[] foundFiles;
- foundFiles = ds.getIncludedFiles();
- return foundFiles;
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder("basedir:").append(basedir);
- if (includes != null) {
- sb.append(", includes:").append(Arrays.toString(includes));
- }
- if (excludes != null) {
- sb.append(", excludes:").append(Arrays.toString(excludes));
- }
- return sb.toString();
- }
-
- public String[] getIncludedFiles(File basedir,
- String[] defaultIncludes,
- String[] defaultExcludes,
- URLClassLoader loader,
- List<String> annotationClass,
- Log log) {
- List<String> result = new ArrayList<String>();
-
- for (String s :
- getIncludedFiles(basedir, defaultIncludes, defaultExcludes)) {
- if (filterByAnnotation(s, loader, annotationClass, log)) {
- result.add(s);
- }
- }
- return result.toArray(new String[result.size()]);
- }
-
- protected boolean filterByAnnotation(String file,
- URLClassLoader loader,
- List<String> annotationClass,
- Log log) {
-
-
- Annotation annotation = getAnnotation(file, loader, annotationClass,
- log);
-
- boolean result = annotation != null;
-
- if (result && log.isDebugEnabled()) {
- log.debug("find i18n annotated file : " + file);
- }
- return result;
- }
-
- protected String getFQN(String file) {
- String filePath = file;
- filePath = filePath.substring(0, filePath.length() - ".java".length());
- String replaceEx = File.separator.equals("\\") ? "\\\\" : File.separator;
- return filePath.replaceAll(replaceEx, ".");
- }
-
- public Class<?> getClass(String file, URLClassLoader loader, Log log) {
- String fqn = getFQN(file);
- try {
- return loader.loadClass(fqn);
-
- } catch (Throwable e) {
- log.warn("could not find class " + fqn + " " + e);
- return null;
- }
- }
-
- public Annotation getAnnotation(String file,
- URLClassLoader loader,
- List<String> annotationClass,
- Log log) {
-
- Class<?> currentClass = getClass(file, loader, log);
-
- try {
- Annotation[] annos = currentClass.getAnnotations();
- if (annos != null && annos.length > 0) {
- for (Annotation anno : annos) {
- if (annotationClass.contains(
- anno.annotationType().getName())) {
- return anno;
- }
- }
- }
- } catch (Throwable e) {
- log.warn("could not find annotation for " + file + " " + e);
- }
- return null;
-
- }
-
- public Class<?> getClass(File file, URLClassLoader loader, Log log) {
- String f = file.getAbsolutePath().substring(
- basedir.getAbsolutePath().length() + 1);
- return getClass(f, loader, log);
- }
-
- public Annotation getAnnotation(File file,
- URLClassLoader loader,
- List<String> annotationClass,
- Log log) {
- String f = file.getAbsolutePath().substring(
- basedir.getAbsolutePath().length() + 1);
- return getAnnotation(f, loader, annotationClass, log);
- }
-
- public String getSkipMessage() {
- return skipMessage;
- }
-
- public String[] getFiles() {
- return files;
- }
-
- public String[] getSkipFiles() {
- return skipFiles;
- }
-
- public int getFoudFiles() {
- return skipFiles.length + files.length;
- }
-
- public FileUpdater getUpdater() {
- return updater;
- }
-
- public void setUpdater(FileUpdater updater) {
- this.updater = updater;
- }
-}
Copied: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/AbstractI18nBundleMojo.java (from rev 1707, trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nBundleMojo.java)
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/AbstractI18nBundleMojo.java (rev 0)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/AbstractI18nBundleMojo.java 2010-03-08 18:35:57 UTC (rev 1708)
@@ -0,0 +1,91 @@
+/*
+ * *##%
+ * I18n :: Maven Plugin
+ * Copyright (C) 2007 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
+package org.nuiton.i18n.plugin.bundle;
+
+import org.nuiton.i18n.plugin.AbstractI18nMojo;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.Locale;
+
+/**
+ * Created: 26 déc. 2009
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @version $Revision$
+ * <p/>
+ * Mise a jour: $Date$
+ * par : $Author: tchemit $
+ */
+public abstract class AbstractI18nBundleMojo extends AbstractI18nMojo {
+
+ /**
+ * Repertoire ou generer les bundles.
+ *
+ * @parameter expression="${i18n.collectOutputDir}" default-value="${basedir}/target/i18n"
+ * @required
+ * @since 1.0.2
+ */
+ protected File collectOutputDir;
+
+ /**
+ * Nom de base des fichiers qui contient les localisations des bundles.
+ *
+ * @parameter expression="${i18n.collectOutputName}"
+ * default-value="collect-${project.artifactId}-i18n"
+ * @required
+ * @since 1.0.2
+ */
+ protected String collectOutputName;
+
+ /**
+ * Pour obtenir les urls des fichiers i18n d'un projet (avec recherche dans
+ * ses dépendances).
+ * <p/>
+ * <b>Note:</b> L'ordre des urls reflète l'ordre des dépendances.
+ *
+ * @param locale la locale a traiter
+ * @return les urls des bundles i18n detectees pour le projet.
+ * @throws Exception pour tout problème
+ */
+ protected abstract URL[] getCollectI18nResources(Locale locale)
+ throws Exception;
+
+ /**
+ * Pour obtenir le fichier contenant les localisation des bundles i18n du
+ * projet pour une {@code locale} donnée.
+ *
+ * @param locale la locale
+ * @param create un drapeau pour forcer la création du fichier s'il n'existe
+ * pas
+ * @return le fichier qui contient les urls des bundles i18n pour la locale
+ * donnée.
+ * @throws IOException pour tout pb
+ */
+ protected File getCollectOutputFile(Locale locale, boolean create)
+ throws IOException {
+ File bundleOut = getI18nFile(collectOutputDir, collectOutputName,
+ locale, create);
+ return bundleOut;
+ }
+
+}
Property changes on: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/AbstractI18nBundleMojo.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Copied: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/BundleMojo.java (from rev 1707, trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/BundleMojo.java)
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/BundleMojo.java (rev 0)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/BundleMojo.java 2010-03-08 18:35:57 UTC (rev 1708)
@@ -0,0 +1,246 @@
+/*
+ * *##%
+ * I18n :: Maven Plugin
+ * Copyright (C) 2007 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
+package org.nuiton.i18n.plugin.bundle;
+
+import org.nuiton.i18n.bundle.I18nBundleEntry;
+import org.nuiton.i18n.bundle.I18nBundleUtil;
+import org.nuiton.i18n.init.DefaultI18nInitializer;
+import org.nuiton.io.SortedProperties;
+import org.nuiton.plugin.PluginHelper;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.URL;
+import java.util.*;
+import java.util.Map.Entry;
+
+/**
+ * Créer un bundle pour une application finale.
+ * <p/>
+ * Cela génère un merge de tous les fichiers i18n utilisés en un seul.
+ * <p/>
+ * On utilise la dépendance sur les artifacts pour connaitre l'ordre le
+ * chargement des bundles.
+ * <p/>
+ * Si dans un bundle childs, la valeur de la clef est vide, on conserve alors
+ * celui du parent,
+ * <p/>
+ * Ainsi on obtient un bundle dont toutes les clefs sont traduites.
+ * <p/>
+ * Le but aussi d'utiliser un unique bundle est de gagner du temps au runtime
+ * car la recherche des bundles devient trop couteuse en temps lorsque l'on a de
+ * nombreuses dépendances (au dessus de 100 deps cela peut prendre plusieurs
+ * secondes, ce qui 'est pas acceptable).
+ * <p/>
+ * On a ajoute un second mode d'initialisation dans la clesse I18n pour
+ * n'utiliser qu'un seul bundle et courcircuiter le chargement couteux...
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @goal bundle
+ * @phase generate-resources
+ * @execute goal=collect-i18n-artifacts
+ * @requiresProject true
+ * @requiresDependencyResolution runtime
+ * @since 0.12
+ */
+public class BundleMojo extends AbstractI18nBundleMojo {
+
+ /**
+ * Repertoire ou generer les bundles.
+ *
+ * @parameter expression="${i18n.bundleOutputDir}" default-value="${basedir}/target/generated-sources/resources/META-INF"
+ * @required
+ * @since 1.0.0
+ */
+ protected File bundleOutputDir;
+
+ /**
+ * Nom du bundle a generer.
+ *
+ * @parameter expression="${i18n.bundleOutputName}" default-value="${project.artifactId}-i18n"
+ * @required
+ * @since 1.0.2
+ */
+ protected String bundleOutputName;
+
+ /**
+ * Un drapeau pour vérifier que les bundles ne contiennent pas d'entrées
+ * vides.
+ *
+ * @parameter expression="${i18n.checkBundle}" default-value="true"
+ * @required
+ * @since 1.0.0
+ */
+ protected boolean checkBundle;
+
+ /**
+ * Un drapeau pour afficher les entrées vides. (nécessite {@link
+ * #checkBundle} activé).
+ *
+ * @parameter expression="${i18n.showEmpty}" default-value="false"
+ * @required
+ * @since 1.0.0
+ */
+ protected boolean showEmpty;
+
+ @Override
+ public void init() throws Exception {
+ super.init();
+
+ createDirectoryIfNecessary(bundleOutputDir);
+
+ // ajout de repertoire de generation (le parent en fait)
+ // dans les resources du projet
+
+ addResourceDir(bundleOutputDir.getParentFile(), "**/*.properties");
+ }
+
+ @Override
+ protected void doAction() throws Exception {
+ long t00 = System.nanoTime();
+
+ String version = getProject().getVersion();
+ version = PluginHelper.removeSnapshotSuffix(version);
+
+ if (!silent) {
+ getLog().info("config - bundle name : " + bundleOutputName);
+ getLog().info("config - basedir : " + bundleOutputDir);
+ getLog().info("config - locales : " + Arrays.toString(locales));
+ getLog().info("config - version : " + version);
+ }
+
+ Map<Locale, String> bundleDico =
+ new LinkedHashMap<Locale, String>(locales.length);
+
+ for (Locale locale : locales) {
+
+ long t0 = System.nanoTime();
+
+ File bundleOut = getI18nFile(bundleOutputDir, bundleOutputName,
+ locale, false);
+
+ if (!silent) {
+ getLog().info("generate bundle for locale " + locale);
+ }
+
+ SortedProperties propertiesOut =
+ new SortedProperties(encoding, false);
+ StringBuilder buffer = new StringBuilder();
+
+ URL[] urls = getCollectI18nResources(locale);
+ if (urls.length == 0) {
+ getLog().warn("no bundle for locale " + locale);
+ continue;
+ }
+
+ for (URL url : urls) {
+ long t000 = System.nanoTime();
+ I18nBundleEntry bundleEntry =
+ new I18nBundleEntry(url, locale, null);
+ bundleEntry.load(propertiesOut);
+ String strPath = bundleEntry.getPath().toString();
+ int index = strPath.indexOf("i18n/");
+
+ buffer.append(',').append(strPath.substring(index));
+ if (verbose) {
+ getLog().info(
+ "loaded " + bundleEntry.getPath() + " in " +
+ PluginHelper.convertTime(t000, System.nanoTime()));
+ }
+ }
+
+ if (buffer.length() > 0) {
+ bundleDico.put(locale, buffer.substring(1));
+ if (!silent) {
+ getLog().info(
+ "bundles for locale : " + bundleDico.get(locale));
+ }
+ }
+ propertiesOut.store(bundleOut);
+ if (!silent && verbose) {
+ getLog().info(
+ "bundle created in " +
+ PluginHelper.convertTime(t0, System.nanoTime()) +
+ " (detected sentences : " + propertiesOut.size() + ")");
+ }
+ if (checkBundle) {
+ checkBundle(locale, propertiesOut, showEmpty);
+ }
+ }
+
+ // ecriture du ficher des definitions i18n (permet de faire une
+ // recherche extact sur un fichier puis d'en deduire les bundles a
+ // charger
+ String f = String.format(DefaultI18nInitializer.UNIQUE_BUNDLE_DEF,
+ bundleOutputName);
+ File defOut = new File(bundleOutputDir, f);
+ if (!silent) {
+ getLog().info("prepare i18n definition " +
+ defOut.getAbsolutePath());
+ }
+ SortedProperties p = new SortedProperties(encoding, false);
+ p.setProperty(DefaultI18nInitializer.BUNDLE_DEF_LOCALES, bundles);
+ p.setProperty(DefaultI18nInitializer.BUNDLE_DEF_VERSION, version);
+ for (Entry<Locale, String> e : bundleDico.entrySet()) {
+ p.setProperty(DefaultI18nInitializer.BUNDLES_FOR_LOCALE +
+ e.getKey().toString(), e.getValue());
+ }
+ FileOutputStream out = new FileOutputStream(defOut);
+ try {
+ p.store(out, null);
+ } finally {
+ out.close();
+ }
+
+ if (!silent && verbose) {
+ getLog().info("done in " +
+ PluginHelper.convertTime(t00, System.nanoTime()));
+ }
+ }
+
+ @Override
+ protected URL[] getCollectI18nResources(Locale locale) throws IOException {
+ File file = getCollectOutputFile(locale, false);
+ if (!file.exists()) {
+ return I18nBundleUtil.EMPTY_URL_ARRAY;
+ }
+ URL[] urls = getLinesAsURL(file);
+ return urls;
+ }
+
+ /**
+ * TODO Move this in PluginHelper.
+ *
+ * @param src the source file to read
+ * @return the url instanciated from lines of the source file.
+ * @throws IOException if any pb while reading file
+ */
+ public static URL[] getLinesAsURL(File src) throws IOException {
+ List<URL> result = new ArrayList<URL>();
+ for (String line : PluginHelper.getLines(src)) {
+ if (!line.isEmpty()) {
+ result.add(new URL(line));
+ }
+ }
+ return result.toArray(new URL[result.size()]);
+ }
+}
Property changes on: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/BundleMojo.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/CollectI18nArtifactsMojo.java (from rev 1707, trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/CollectI18nArtifactsMojo.java)
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/CollectI18nArtifactsMojo.java (rev 0)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/CollectI18nArtifactsMojo.java 2010-03-08 18:35:57 UTC (rev 1708)
@@ -0,0 +1,253 @@
+/*
+ * *##%
+ * I18n :: Maven Plugin
+ * Copyright (C) 2007 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
+package org.nuiton.i18n.plugin.bundle;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.factory.ArtifactFactory;
+import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.resolver.ArtifactCollector;
+import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
+import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
+import org.apache.maven.shared.dependency.tree.DependencyNode;
+import org.apache.maven.shared.dependency.tree.DependencyTreeBuilder;
+import org.apache.maven.shared.dependency.tree.DependencyTreeBuilderException;
+import org.nuiton.i18n.bundle.I18nBundleEntry;
+import org.nuiton.plugin.DependencyUtil;
+import org.nuiton.plugin.PluginHelper;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.*;
+
+/**
+ * Detects any i18n artifacts and store the result as a file.
+ * <p/>
+ * Created: 24 déc. 2009
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @version $Revision$
+ * <p/>
+ * Mise a jour: $Date$
+ * par : $Author: tchemit $
+ * @goal collect-i18n-artifacts
+ * @phase generate-resources
+ * @requiresProject true
+ * @requiresDependencyResolution runtime
+ * @since 1.0.2
+ */
+public class CollectI18nArtifactsMojo extends AbstractI18nBundleMojo {
+
+ /**
+ * Local Repository.
+ *
+ * @parameter expression="${localRepository}"
+ * @required
+ * @readonly
+ * @since 1.0.2
+ */
+ protected ArtifactRepository localRepository;
+
+ /**
+ * Dependency tree builder component.
+ *
+ * @component
+ * @since 1.0.2
+ */
+ protected DependencyTreeBuilder dependencyTreeBuilder;
+
+ /**
+ * Artifact Factory component.
+ *
+ * @component
+ * @since 1.0.2
+ */
+ protected ArtifactFactory factory;
+
+ /**
+ * Artifact metadata source component.
+ *
+ * @component
+ * @since 1.0.2
+ */
+ protected ArtifactMetadataSource artifactMetadataSource;
+
+ /**
+ * Artifact collector component.
+ *
+ * @component
+ * @since 1.0.2
+ */
+ protected ArtifactCollector collector;
+
+ I18nArtifact[] i18nArtifacts;
+
+ @Override
+ public void init() throws Exception {
+ super.init();
+
+ PluginHelper.createDirectoryIfNecessary(collectOutputDir);
+ }
+
+ @Override
+ protected void doAction() throws Exception {
+
+ // detects the i18n artifacts (only once since it cost some times)...
+ i18nArtifacts = detectI18nArtifacts();
+
+ if (i18nArtifacts.length == 0) {
+ getLog().warn("no i18n artifact detected.");
+ return;
+ }
+
+ for (Locale locale : locales) {
+
+ if (!silent) {
+ getLog().info("generate collected i18n artifacts for locale " +
+ locale);
+ }
+ URL[] urls = getCollectI18nResources(locale);
+
+ if (urls.length == 0) {
+ getLog().warn("no i18n bundles for locale " + locale);
+ return;
+ }
+
+ File bundleOut = getCollectOutputFile(locale, true);
+
+ storeCollectI18nResources(bundleOut, urls);
+
+ getLog().info("collected " + urls.length +
+ " i18n artifacts for locale " + locale +
+ " stored in " + bundleOut);
+ }
+ }
+
+ @Override
+ protected URL[] getCollectI18nResources(Locale locale)
+ throws IOException, DependencyTreeBuilderException {
+
+ // la locale par defaut est la première
+ Locale defaultLocale = locales[0];
+
+ List<URL> urls = new ArrayList<URL>();
+ for (I18nArtifact artifact : i18nArtifacts) {
+ I18nBundleEntry[] bundleEntries =
+ artifact.getBundleEntries(locale, defaultLocale);
+ for (I18nBundleEntry bundleEntry : bundleEntries) {
+
+ URL path = bundleEntry.getPath();
+ urls.add(path);
+ if (verbose) {
+ getLog().info("add " + path);
+ }
+ }
+ }
+ return urls.toArray(new URL[urls.size()]);
+ }
+
+ protected void storeCollectI18nResources(File bundleOut, URL[] urls)
+ throws IOException {
+ StringBuilder buffer = new StringBuilder();
+
+ for (URL path : urls) {
+
+ buffer.append(path).append("\n");
+
+ if (verbose) {
+ getLog().info("add " + path);
+ }
+ }
+ writeFile(bundleOut, buffer.toString(), encoding);
+ }
+
+ /**
+ * Detecte les {@link I18nArtifact} et les retourne dans l'ordre de
+ * chargement dans le système i18n, i.e l'ordre des dependances entre
+ * artifacts.
+ *
+ * @return les artifacts i18nables triés par leur ordre de chargement dans
+ * le système i18n.
+ * @throws IOException while detecting bundles from
+ * artifacts
+ * @throws DependencyTreeBuilderException if any error while building the
+ * depencendy tree
+ */
+ protected I18nArtifact[] detectI18nArtifacts()
+ throws IOException, DependencyTreeBuilderException {
+
+ Map<Artifact, I18nArtifact> dico =
+ new HashMap<Artifact, I18nArtifact>();
+
+ I18nArtifact i18nArtifact;
+ for (Object o : project.getArtifacts()) {
+ i18nArtifact = new I18nArtifact((Artifact) o);
+ if (i18nArtifact.detectBundles()) {
+ if (!silent) {
+ getLog().info("detected i18n artifact " + i18nArtifact);
+ }
+ dico.put(i18nArtifact.getArtifact(), i18nArtifact);
+ } else {
+ if (getLog().isDebugEnabled()) {
+ getLog().debug("reject artifact " + i18nArtifact);
+ }
+ }
+ }
+
+ ArtifactFilter artifactFilter
+ = new ScopeArtifactFilter(Artifact.SCOPE_RUNTIME);
+
+ DependencyNode rootNode = dependencyTreeBuilder.buildDependencyTree(
+ project, localRepository, factory,
+ artifactMetadataSource, artifactFilter, collector);
+
+ List<Artifact> artifacts = new ArrayList<Artifact>(dico.keySet());
+
+ DependencyUtil.sortArtifacts(rootNode, artifacts,
+ getLog().isDebugEnabled());
+
+ // l'artifact du projet est traite en dernier car s'il possède des
+ // bundles alors ils doivent etre charge en dernier
+
+ Artifact projectArtifact = project.getArtifact();
+ i18nArtifact = new I18nArtifact(projectArtifact, src.getParentFile());
+
+ if (i18nArtifact.detectBundles()) {
+ if (!silent) {
+ getLog().info("detected i18n artifact " + i18nArtifact);
+ }
+ artifacts.add(i18nArtifact.getArtifact());
+ dico.put(i18nArtifact.getArtifact(), i18nArtifact);
+ } else {
+ if (getLog().isDebugEnabled()) {
+ getLog().debug("reject artifact " + i18nArtifact);
+ }
+ }
+
+ I18nArtifact[] result = new I18nArtifact[artifacts.size()];
+ int i = 0;
+ for (Artifact artifact : artifacts) {
+ result[i++] = dico.get(artifact);
+ }
+ return result;
+ }
+}
Property changes on: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/CollectI18nArtifactsMojo.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Copied: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/I18nArtifact.java (from rev 1707, trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/I18nArtifact.java)
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/I18nArtifact.java (rev 0)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/I18nArtifact.java 2010-03-08 18:35:57 UTC (rev 1708)
@@ -0,0 +1,109 @@
+/*
+ * *##%
+ * I18n :: Maven Plugin
+ * Copyright (C) 2007 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
+package org.nuiton.i18n.plugin.bundle;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.maven.artifact.Artifact;
+import org.nuiton.i18n.bundle.I18nBundle;
+import org.nuiton.i18n.bundle.I18nBundleEntry;
+import org.nuiton.i18n.bundle.I18nBundleUtil;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.List;
+import java.util.Locale;
+
+/**
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.12
+ */
+public class I18nArtifact {
+
+ static final Log log = LogFactory.getLog(I18nArtifact.class);
+
+ protected final Artifact artifact;
+
+ protected final URL url;
+
+ protected I18nBundle[] bundles;
+
+ public I18nArtifact(Artifact artifact) throws MalformedURLException {
+ this.artifact = artifact;
+ url = artifact.getFile().toURI().toURL();
+ }
+
+ public I18nArtifact(Artifact artifact,
+ File file) throws MalformedURLException {
+ this.artifact = artifact;
+ url = file.toURI().toURL();
+ }
+
+ public Artifact getArtifact() {
+ return artifact;
+ }
+
+ public URL getUrl() {
+ return url;
+ }
+
+ public I18nBundleEntry[] getBundleEntries(Locale l, Locale defaultLocale) {
+ if (bundles == null) {
+ throw new NullPointerException(
+ "le bundleManager n'a pas ete initialise!");
+ }
+ return I18nBundleUtil.getBundleEntries(l, defaultLocale, bundles);
+ }
+
+ public boolean detectBundles() throws IOException {
+
+ URL[] i18nUrls = I18nBundleUtil.getURLs(url);
+
+ if (i18nUrls == null || i18nUrls.length == 0) {
+ // aucune url sur un fichier de traduction trouve
+ // l'artifact n'est pas i18n.
+ if (log.isDebugEnabled()) {
+ log.debug("no i18n url for artifact " + artifact);
+ }
+ return false;
+ }
+
+ List<I18nBundle> listBundles =
+ I18nBundleUtil.detectBundles(i18nUrls);
+
+ if (listBundles.isEmpty()) {
+ // pas de bundle instancie (cela ne devrait jamais arrive...)
+ return false;
+ }
+
+ bundles = listBundles.toArray(new I18nBundle[listBundles.size()]);
+
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" +
+ artifact.getVersion();
+ }
+}
Property changes on: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/I18nArtifact.java
___________________________________________________________________
Added: svn:mergeinfo
+
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParserMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParserMojo.java 2010-03-08 11:04:08 UTC (rev 1707)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParserMojo.java 2010-03-08 18:35:57 UTC (rev 1708)
@@ -21,8 +21,6 @@
package org.nuiton.i18n.plugin.parser;
import org.nuiton.i18n.plugin.AbstractI18nMojo;
-import org.nuiton.i18n.plugin.I18nLogger;
-import org.nuiton.i18n.plugin.SourceEntry;
import org.nuiton.io.FileUpdater;
import org.nuiton.io.SortedProperties;
@@ -103,16 +101,15 @@
/**
* flag to save previous getter in a backup before doing parsing.
* <p/>
- * Note: by default, do not perform backup (but it was here originaly so let it possible...)
+ * Note: by default, do not perform backup (but it was here originaly so let
+ * it possible...)
*
* @parameter expression="${i18n.backupGetter}" default-value="false"
* @since 1.0.2
*/
protected boolean backupGetter;
- /**
- * Liste des évènements
- */
+ /** Liste des évènements */
protected List<ParserEvent> events = new ArrayList<ParserEvent>();
protected SortedProperties result;
@@ -129,10 +126,17 @@
protected List<File> treadedFiles;
+ /** logger verbeux */
+ protected I18nLogger verboseLog = new I18nLogger(this);
+
public boolean isStrictMode() {
return strictMode;
}
+ protected I18nLogger getVerboseLog() {
+ return verboseLog;
+ }
+
@Override
public void init() throws Exception {
super.init();
@@ -141,7 +145,6 @@
oldParser = new SortedProperties(encoding);
oldLanguage = new SortedProperties(encoding);
createDirectoryIfNecessary(out);
-// out.mkdirs();
// evenements
if (keysModifier) {
addParserEvent(KeysModifier.getInstance(
@@ -161,7 +164,7 @@
getLog().info("detected entries : " + entries.length);
for (SourceEntry e : entries) {
- getLog().info(e.toString()+", specific goal ? " +
+ getLog().info(e.toString() + ", specific goal ? " +
e.getSpecificGoal());
}
}
@@ -186,12 +189,10 @@
// Reprise sur un ancien parsing
File oldParserFile = getGetterFile(out, getOutGetter(), true);
File saveFile = getBackupFile(oldParserFile);
-// File saveFile = getGetterFileBackup(out, getOutGetter());
oldParser.load(oldParserFile);
if (backupGetter) {
backupFile(oldParserFile);
-// copyFile(oldParserFile, saveFile);
}
// Anciennes cles disponnibles
Copied: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/I18nLogger.java (from rev 1707, trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/I18nLogger.java)
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/I18nLogger.java (rev 0)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/I18nLogger.java 2010-03-08 18:35:57 UTC (rev 1708)
@@ -0,0 +1,127 @@
+/**
+ * *##%
+ * I18n :: Maven Plugin
+ * Copyright (C) 2007 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
+package org.nuiton.i18n.plugin.parser;
+
+import org.apache.maven.plugin.logging.SystemStreamLog;
+import org.nuiton.i18n.plugin.AbstractI18nMojo;
+import org.nuiton.plugin.PluginHelper;
+
+import java.beans.Introspector;
+import java.io.File;
+
+/**
+ * Le logger utilisé par les mojo de parsing.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.9
+ */
+public class I18nLogger extends SystemStreamLog {
+
+ /** l'entrée en cours de traitement (pour les parseurs) */
+ private SourceEntry entry;
+
+ /** le fichier en cours de traitement (pour les parseurs) */
+ protected File file;
+
+ /** le prefix du mojo courant a ajouter dans les logs. */
+ protected String parser;
+
+ public I18nLogger(AbstractI18nMojo parser) {
+ this.parser = "i18n:" + Introspector.decapitalize(
+ parser.getClass().getSimpleName()) + " on " +
+ parser.getArtifactId();
+ }
+
+ @Override
+ public void info(CharSequence content) {
+ print(0, "INFO", null, content.toString());
+ }
+
+ @Override
+ public void debug(CharSequence content) {
+ print(0, "DEBUG", null, content.toString());
+ }
+
+ public void infoEntry(String action, CharSequence content) {
+ print(0, "INFO", action,
+ entry.toString() +
+ (content == null ? "" : " - " + content.toString()));
+ }
+
+ public void infoFile(String action, String content) {
+ print(2, "INFO", action, file.toString() +
+ (content == null ? "" : " - " + content));
+ }
+
+ public void infoAction(String action, String content) {
+ print(2, "INFO", action, content == null ? "" : " - " + content);
+ }
+
+ private void print(int start, String prefix, String context,
+ String content) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("[").append(prefix).append("] [").append(parser).append("] ");
+
+ for (int i = 0; i < start; i++) {
+ sb.append(' ');
+ }
+ if (context != null) {
+ sb.append("<").append(context).append("> ");
+ }
+ sb.append(content);
+ System.out.println(sb.toString());
+ }
+
+ public void setEntry(SourceEntry entry) {
+ this.entry = entry;
+ }
+
+ /**
+ * Construit une chaine de log formatée.
+ *
+ * @param msg le prefix du message
+ * @param nbFiles le nombre de fichiers actuellement traités
+ * @param time le time de traitement de ce fichier
+ * @param all le temps de traitement de tous les fichiers
+ * @return la chaine de log formatée
+ */
+ public String getLogEntry(String msg, int nbFiles, long time, long all) {
+ long now = System.nanoTime();
+ long delta = now - time;
+ String s = msg;
+ if (time > 0) {
+ s += " (" + PluginHelper.convertTime(delta) + ")";
+ }
+ if (all > 0) {
+ s += "(total time:" + PluginHelper.convertTime(now - all) + ")";
+ }
+ if (nbFiles > 0) {
+ s += " ( ~ " +
+ PluginHelper.convertTime((now - all) / nbFiles) + " / file)";
+ }
+ return s;
+ }
+
+ public void setFile(File file) {
+ this.file = file;
+ }
+
+}
Property changes on: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/I18nLogger.java
___________________________________________________________________
Added: svn:mergeinfo
+
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/I18nSourceEntry.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/I18nSourceEntry.java 2010-03-08 11:04:08 UTC (rev 1707)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/I18nSourceEntry.java 2010-03-08 18:35:57 UTC (rev 1708)
@@ -20,8 +20,6 @@
*/
package org.nuiton.i18n.plugin.parser;
-import org.nuiton.i18n.plugin.SourceEntry;
-
import java.io.File;
import java.util.ArrayList;
import java.util.List;
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/KeysModifier.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/KeysModifier.java 2010-03-08 11:04:08 UTC (rev 1707)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/KeysModifier.java 2010-03-08 18:35:57 UTC (rev 1708)
@@ -47,6 +47,7 @@
private static final long serialVersionUID = 1L;
// Modification des clés dans le fichier
+
protected List<String> newKeys;
protected boolean needModifiedFile;
@@ -58,6 +59,7 @@
protected String encoding;
// Interface
+
protected JLabel name = new JLabel();
protected JLabel path = new JLabel();
@@ -205,7 +207,7 @@
return key.getText();
}
- /** Action sur le boutton pour passer � la cl� suivante */
+ /** Action sur le boutton pour passer a la cle suivante */
class EventNextKey implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
Copied: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/SourceEntry.java (from rev 1707, trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/SourceEntry.java)
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/SourceEntry.java (rev 0)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/SourceEntry.java 2010-03-08 18:35:57 UTC (rev 1708)
@@ -0,0 +1,289 @@
+/*
+ * *##%
+ * I18n :: Maven Plugin
+ * Copyright (C) 2007 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
+package org.nuiton.i18n.plugin.parser;
+
+import org.apache.maven.plugin.logging.Log;
+import org.codehaus.plexus.util.DirectoryScanner;
+import org.nuiton.io.FileUpdater;
+
+import java.io.File;
+import java.lang.annotation.Annotation;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * A simple model for a sourceEntry represents by a basedir and includes and/or
+ * exlucdes pattern.
+ * <p/>
+ * The class offers the usefull method : {@link #getIncludedFiles(File,
+ * String[], String[])}
+ * <p/>
+ * to obtain the list of files from the {@link #basedir} directory which
+ * respects the {@link #includes} and/or {@link #excludes} patterns using an
+ * internal {@link DirectoryScanner} object.
+ * <p/>
+ * Note : <b>The class does not extends <code>DirectoryScanner</code> since we
+ * DO not want to expose his methods.</b>
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ */
+public class SourceEntry {
+
+ /**
+ * If you want to restrict use of the entry, set the class name goal to this
+ * property via {@link #setSpecificGoal(String)}.
+ * <p/>
+ * If let to <code>null</code>, all goals can use this entry.
+ */
+ protected String specificGoal;
+
+ protected File basedir;
+
+ protected String[] includes;
+
+ protected String[] excludes;
+
+ /** Files to be find */
+ protected String[] files;
+
+ protected String[] skipFiles;
+
+ protected String skipMessage;
+
+ protected FileUpdater updater;
+
+ public String[] getExcludes() {
+ return excludes;
+ }
+
+ public void setExcludes(String[] excludes) {
+ this.excludes = excludes;
+ }
+
+ public String[] getIncludes() {
+ return includes;
+ }
+
+ public void setIncludes(String[] includes) {
+ this.includes = includes;
+ }
+
+ public File getBasedir() {
+ return basedir;
+ }
+
+ public void setBasedir(File basedir) {
+ this.basedir = basedir;
+ }
+
+ public String getSpecificGoal() {
+ return specificGoal;
+ }
+
+ public void setSpecificGoal(String specificGoal) {
+ this.specificGoal = specificGoal;
+ }
+
+ public boolean useForGoal(String goal) {
+ return specificGoal == null || specificGoal.equalsIgnoreCase(goal);
+ }
+
+ public boolean hasSrc() {
+ return basedir != null;
+ }
+
+ public boolean hasIncludes() {
+ return includes != null && includes.length > 0;
+ }
+
+ public boolean hasExcludes() {
+ return excludes != null && excludes.length > 0;
+ }
+
+ /**
+ * Test if a file is up to date and not to be treated.
+ * <p/>
+ *
+ * @param file the file path to test
+ * @return {@code true} if file is up to date and do not need to be parsed
+ * @see FileUpdater
+ */
+ public final boolean isFileUptodate(File file) {
+ return updater != null && updater.isFileUpToDate(file);
+ }
+
+ public String[] getIncludedFiles(File defaultBasedir,
+ String[] defaultIncludes,
+ String[] defaultExcludes) {
+ // normalized entry
+ if (!hasSrc()) {
+ setBasedir(defaultBasedir);
+ }
+ if (!hasIncludes()) {
+ setIncludes(defaultIncludes);
+ }
+ if (!hasExcludes()) {
+ setExcludes(defaultExcludes);
+ }
+ // init directory scanner
+ DirectoryScanner ds = new DirectoryScanner();
+ ds.setBasedir(getBasedir());
+ ds.setIncludes(getIncludes());
+ if (hasExcludes()) {
+ ds.setExcludes(getExcludes());
+ }
+ // scan
+ ds.scan();
+ // get found files
+ String[] foundFiles;
+ foundFiles = ds.getIncludedFiles();
+ return foundFiles;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("basedir:").append(basedir);
+ if (includes != null) {
+ sb.append(", includes:").append(Arrays.toString(includes));
+ }
+ if (excludes != null) {
+ sb.append(", excludes:").append(Arrays.toString(excludes));
+ }
+ return sb.toString();
+ }
+
+ public String[] getIncludedFiles(File basedir,
+ String[] defaultIncludes,
+ String[] defaultExcludes,
+ URLClassLoader loader,
+ List<String> annotationClass,
+ Log log) {
+ List<String> result = new ArrayList<String>();
+
+ for (String s :
+ getIncludedFiles(basedir, defaultIncludes, defaultExcludes)) {
+ if (filterByAnnotation(s, loader, annotationClass, log)) {
+ result.add(s);
+ }
+ }
+ return result.toArray(new String[result.size()]);
+ }
+
+ protected boolean filterByAnnotation(String file,
+ URLClassLoader loader,
+ List<String> annotationClass,
+ Log log) {
+
+
+ Annotation annotation = getAnnotation(file, loader, annotationClass,
+ log);
+
+ boolean result = annotation != null;
+
+ if (result && log.isDebugEnabled()) {
+ log.debug("find i18n annotated file : " + file);
+ }
+ return result;
+ }
+
+ protected String getFQN(String file) {
+ String filePath = file;
+ filePath = filePath.substring(0, filePath.length() - ".java".length());
+ String replaceEx = File.separator.equals("\\") ? "\\\\" : File.separator;
+ return filePath.replaceAll(replaceEx, ".");
+ }
+
+ public Class<?> getClass(String file, URLClassLoader loader, Log log) {
+ String fqn = getFQN(file);
+ try {
+ return loader.loadClass(fqn);
+
+ } catch (Throwable e) {
+ log.warn("could not find class " + fqn + " " + e);
+ return null;
+ }
+ }
+
+ public Annotation getAnnotation(String file,
+ URLClassLoader loader,
+ List<String> annotationClass,
+ Log log) {
+
+ Class<?> currentClass = getClass(file, loader, log);
+
+ try {
+ Annotation[] annos = currentClass.getAnnotations();
+ if (annos != null && annos.length > 0) {
+ for (Annotation anno : annos) {
+ if (annotationClass.contains(
+ anno.annotationType().getName())) {
+ return anno;
+ }
+ }
+ }
+ } catch (Throwable e) {
+ log.warn("could not find annotation for " + file + " " + e);
+ }
+ return null;
+
+ }
+
+ public Class<?> getClass(File file, URLClassLoader loader, Log log) {
+ String f = file.getAbsolutePath().substring(
+ basedir.getAbsolutePath().length() + 1);
+ return getClass(f, loader, log);
+ }
+
+ public Annotation getAnnotation(File file,
+ URLClassLoader loader,
+ List<String> annotationClass,
+ Log log) {
+ String f = file.getAbsolutePath().substring(
+ basedir.getAbsolutePath().length() + 1);
+ return getAnnotation(f, loader, annotationClass, log);
+ }
+
+ public String getSkipMessage() {
+ return skipMessage;
+ }
+
+ public String[] getFiles() {
+ return files;
+ }
+
+ public String[] getSkipFiles() {
+ return skipFiles;
+ }
+
+ public int getFoudFiles() {
+ return skipFiles.length + files.length;
+ }
+
+ public FileUpdater getUpdater() {
+ return updater;
+ }
+
+ public void setUpdater(FileUpdater updater) {
+ this.updater = updater;
+ }
+}
Property changes on: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/SourceEntry.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaMojo.java 2010-03-08 11:04:08 UTC (rev 1707)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaMojo.java 2010-03-08 18:35:57 UTC (rev 1708)
@@ -20,11 +20,7 @@
package org.nuiton.i18n.plugin.parser.impl;
-import org.nuiton.i18n.plugin.SourceEntry;
-import org.nuiton.i18n.plugin.parser.AbstractI18nParserMojo;
-import org.nuiton.i18n.plugin.parser.I18nSourceEntry;
-import org.nuiton.i18n.plugin.parser.ParserEvent;
-import org.nuiton.i18n.plugin.parser.ParserException;
+import org.nuiton.i18n.plugin.parser.*;
import org.nuiton.io.FileUpdater;
import org.nuiton.io.FileUpdaterHelper;
import org.nuiton.processor.filters.I18nFilter;
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserValidationMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserValidationMojo.java 2010-03-08 11:04:08 UTC (rev 1707)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserValidationMojo.java 2010-03-08 18:35:57 UTC (rev 1708)
@@ -19,8 +19,8 @@
* ##%* */
package org.nuiton.i18n.plugin.parser.impl;
-import org.nuiton.i18n.plugin.SourceEntry;
import org.nuiton.i18n.plugin.parser.I18nSourceEntry;
+import org.nuiton.i18n.plugin.parser.SourceEntry;
import org.nuiton.io.FileUpdater;
import org.nuiton.io.MirroredFileUpdater;
import org.xml.sax.EntityResolver;
@@ -36,8 +36,9 @@
/**
* Récupération des chaine à traduire depuis les fichiers xml de validation.
* <p/>
- * Le goal doit etre execute avant que les resources soient copiees dans target/classes
- * pour rendre operatne le file updater (sinon lesfichiers sont toujours a jour...)
+ * Le goal doit etre execute avant que les resources soient copiees dans
+ * target/classes pour rendre operatne le file updater (sinon lesfichiers sont
+ * toujours a jour...)
*
* @author chemit
* @goal parserValidation
@@ -161,6 +162,7 @@
public static final String XWORK_PUBLIC_ID =
"-//OpenSymphony Group//XWork Validator 1.0.2//EN";
+
boolean useLocal = useLocalResolver;
@Override
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXmlMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXmlMojo.java 2010-03-08 11:04:08 UTC (rev 1707)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXmlMojo.java 2010-03-08 18:35:57 UTC (rev 1708)
@@ -44,10 +44,9 @@
*/
public abstract class ParserXmlMojo extends AbstractI18nParserMojo {
- /**
- * Taille du buffer pour les lectures/écritures
- */
+ /** Taille du buffer pour les lectures/écritures */
protected static final int BUFFER_SIZE = 8 * 1024;
+
/**
* default src for an entry.
*
@@ -72,14 +71,10 @@
*/
public abstract String extract(String i18nString);
- /**
- * @return le fichier des rules
- */
+ /** @return le fichier des rules */
protected abstract String getFileRules();
- /**
- * @return le fichier des rules de base à toujours charger
- */
+ /** @return le fichier des rules de base à toujours charger */
protected abstract String getCoreFileRules();
@Override
1
0
r1707 - in trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin: . parser
by tchemit@users.nuiton.org 08 Mar '10
by tchemit@users.nuiton.org 08 Mar '10
08 Mar '10
Author: tchemit
Date: 2010-03-08 12:04:08 +0100 (Mon, 08 Mar 2010)
New Revision: 1707
Log:
- reformat code (80 car max per line)
- fix bug on specificGoal
Modified:
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/BundleMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/CollectI18nArtifactsMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GenerateMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GetterMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/SourceEntry.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParserMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/I18nSourceEntry.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/KeysModifier.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/Parser.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/ParserEvent.java
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java 2010-03-07 16:58:44 UTC (rev 1706)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java 2010-03-08 11:04:08 UTC (rev 1707)
@@ -16,7 +16,8 @@
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * ##%* */
+ * ##%*
+ */
package org.nuiton.i18n.plugin;
import org.apache.maven.project.MavenProject;
@@ -41,7 +42,7 @@
/**
* Le nombre de getters détectés pendant le cycle de vie du build.
*/
- private static int NB_GETTER_FILES = 0;
+ private static int NB_GETTER_FILES;
/**
* Dependance du projet.
@@ -147,7 +148,6 @@
}
public void init() throws Exception {
-// public boolean init() throws Exception {
verboseLog = new I18nLogger(this);
@@ -160,7 +160,6 @@
"Il faut au moins une locale declaree (utiliser " +
"la propriete 'bundles')");
}
-// return true;
}
public String getArtifactId() {
@@ -226,26 +225,6 @@
return file;
}
-
-// /**
-// * @param root le repertoire ou sont stockes les fichiers getter
-// * @param getter le nom du getter
-// * @return le fichier i18n
-// */
-// public File getGetterFileBackup(File root, String getter) {
-// return new File(root.getAbsolutePath() + File.separatorChar + getter + '~');
-// }
-
-// /**
-// * @param root le reertoire ou sont stockes les fichiers i18n
-// * @param artifactId le nom de l'artifact
-// * @param bundle le nom du bundle
-// * @return le fichier i18n de backup
-// */
-// public File getI18nFileBackup(File root, String artifactId, Locale bundle) {
-// return new File(root.getAbsolutePath() + File.separatorChar + artifactId + "-" + bundle.toString() + ".properties~");
-// }
-
protected void checkBundle(Locale locale, Properties propertiesOut,
boolean showEmpty) {
// on verifie qu'il n'y a pas de traduction vide
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/BundleMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/BundleMojo.java 2010-03-07 16:58:44 UTC (rev 1706)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/BundleMojo.java 2010-03-08 11:04:08 UTC (rev 1707)
@@ -16,7 +16,8 @@
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * ##%* */
+ * ##%*
+ */
package org.nuiton.i18n.plugin;
import org.nuiton.i18n.bundle.I18nBundleEntry;
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/CollectI18nArtifactsMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/CollectI18nArtifactsMojo.java 2010-03-07 16:58:44 UTC (rev 1706)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/CollectI18nArtifactsMojo.java 2010-03-08 11:04:08 UTC (rev 1707)
@@ -146,55 +146,6 @@
}
}
-// @Override
-// public void execute() throws MojoExecutionException, MojoFailureException {
-//
-// if ("pom".equals(project.getPackaging()) || "site".equals(project.getPackaging())) {
-// getLog().info("skip goal for none java-based packaging.");
-// return;
-// }
-//
-// try {
-// init();
-// } catch (Exception e) {
-// throw new MojoExecutionException("could not init goal for reason " + e.getMessage(), e);
-// }
-//
-// try {
-//
-// // detects the i18n artifacts (only once since it cost some times)...
-// i18nArtifacts = detectI18nArtifacts();
-//
-// if (i18nArtifacts.length == 0) {
-// getLog().warn("no i18n artifact detected.");
-// return;
-// }
-//
-// for (Locale locale : locales) {
-//
-// if (!silent) {
-// getLog().info("generate collected i18n artifacts for locale " + locale);
-// }
-// URL[] urls = getCollectI18nResources(locale);
-//
-// if (urls.length == 0) {
-// getLog().warn("no i18n bundles for locale " + locale);
-// return;
-// }
-//
-// File bundleOut = getCollectOutputFile(locale, true);
-//
-// storeCollectI18nResources(bundleOut, urls);
-//
-// getLog().info("collected " + urls.length + " i18n artifacts for locale " + locale + " stored in " + bundleOut);
-// }
-// } catch (IOException e) {
-// throw new MojoExecutionException("could not treate i18n artifacts", e);
-// } catch (DependencyTreeBuilderException e) {
-// throw new MojoExecutionException("could not obtain i18n artifacts", e);
-// }
-// }
-
@Override
protected URL[] getCollectI18nResources(Locale locale)
throws IOException, DependencyTreeBuilderException {
@@ -247,7 +198,8 @@
protected I18nArtifact[] detectI18nArtifacts()
throws IOException, DependencyTreeBuilderException {
- Map<Artifact, I18nArtifact> dico = new HashMap<Artifact, I18nArtifact>();
+ Map<Artifact, I18nArtifact> dico =
+ new HashMap<Artifact, I18nArtifact>();
I18nArtifact i18nArtifact;
for (Object o : project.getArtifacts()) {
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GenerateMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GenerateMojo.java 2010-03-07 16:58:44 UTC (rev 1706)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GenerateMojo.java 2010-03-08 11:04:08 UTC (rev 1707)
@@ -16,7 +16,8 @@
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * ##%* */
+ * ##%*
+ */
package org.nuiton.i18n.plugin;
import org.nuiton.io.SortedProperties;
@@ -35,22 +36,27 @@
* @execute goal=get
*/
public class GenerateMojo extends AbstractI18nMojo {
+
/**
- * Un drapeau pour vérifier que les bundles ne contiennent pas d'entrées vides.
+ * Un drapeau pour vérifier que les bundles ne contiennent pas d'entrées
+ * vides.
*
* @parameter expression="${i18n.checkBundle}" default-value="true"
* @required
* @since 1.0.0
*/
protected boolean checkBundle;
+
/**
- * Un drapeau pour afficher les entrées vides. (nécessite {@link #checkBundle} activé).
+ * Un drapeau pour afficher les entrées vides. (nécessite
+ * {@link #checkBundle} activé).
*
* @parameter expression="${i18n.showEmpty}" default-value="false"
* @required
* @since 1.0.0
*/
protected boolean showEmpty;
+
/**
* conserve les anciens fichiers de traduction avec un suffix ~
* <p/>
@@ -118,7 +124,12 @@
//fixme : on devrait laisser le fichier en utf8 ?
//propertiesOut.store(bundleOut);
- propertiesOut.store(new FileOutputStream(bundleOut));
+ FileOutputStream outStream = new FileOutputStream(bundleOut);
+ try {
+ propertiesOut.store(outStream);
+ } finally {
+ outStream.close();
+ }
// Sauvegarde avant copie
if (genSrc && keepBackup) {
@@ -141,96 +152,4 @@
}
}
}
-
-// @Override
-// public void execute() throws MojoExecutionException, MojoFailureException {
-//
-// try {
-// init();
-// } catch (Exception e) {
-// throw new MojoExecutionException("could not init goal for reason " + e.getMessage(), e);
-// }
-//
-// if (!needGeneration()) {
-// getLog().info("Nothing to generate - all files are up to date.");
-// return;
-// }
-//
-// if (!silent) {
-// getLog().info("config - src basedir : " + src.getAbsolutePath());
-// getLog().info("config - out basedir : " + out.getAbsolutePath());
-// getLog().info("config - locales : " + Arrays.toString(locales));
-// }
-// for (Locale locale : locales) {
-// if (!silent) {
-// getLog().info("prepare bundle for locale " + locale);
-// }
-// try {
-// // Merge
-// File bundleSrc = getI18nFile(src, artifactId, locale, false);
-// File bundleOut = getI18nFile(out, artifactId, locale, false);
-//
-// SortedProperties propertiesSrc = new SortedProperties(encoding);
-//
-// if (bundleSrc.exists()) {
-// propertiesSrc.load(bundleSrc);
-// }
-//
-// SortedProperties propertiesOut = new SortedProperties(encoding);
-//
-// if (!strictMode) {
-// // si on n'est pas en mode strict, on doit push back in bundle out, all the bundle src keys
-// propertiesOut.putAll(propertiesSrc);
-// }
-// propertiesOut.load(bundleOut);
-//
-// // Parcours des clés
-// for (Object key : propertiesOut.keySet()) {
-// Object oldKey = propertiesOut.get(key);
-// Object value = propertiesSrc.get(oldKey);
-//
-// // Récupération de la clé si elle a été renommée
-// if (!key.equals(oldKey) && value == null) {
-// value = propertiesSrc.get(key);
-// }
-//
-// if (value != null) {
-// propertiesOut.put(key, value);
-// } else {
-// propertiesOut.put(key, "");
-// }
-// }
-//
-// //fixme : on devrait laisser le fichier en utf8 ?
-// //propertiesOut.store(bundleOut);
-// propertiesOut.store(new FileOutputStream(bundleOut));
-//
-// // Sauvegarde avant copie
-// if (genSrc && keepBackup) {
-// backupFile(bundleSrc);
-// }
-// if (!silent) {
-// getLog().info("merge bundle " + locale + " to out");
-// }
-//
-// if (checkBundle) {
-// checkBundle(locale, propertiesOut, showEmpty);
-// }
-//
-// if (genSrc) {
-// // Copie des fichiers dans les sources
-// copyFile(bundleOut, bundleSrc);
-// //if (verbose) {
-// if (!silent) {
-// getLog().info("copy bundle " + locale + " to src");
-// }
-// //}
-// }
-//
-// } catch (IOException e) {
-// getLog().error("File Error I/O ", e);
-// throw new MojoFailureException("File Error I/O ");
-// }
-// }
-// }
}
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GetterMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GetterMojo.java 2010-03-07 16:58:44 UTC (rev 1706)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GetterMojo.java 2010-03-08 11:04:08 UTC (rev 1707)
@@ -16,7 +16,8 @@
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * ##%* */
+ * ##%*
+ */
package org.nuiton.i18n.plugin;
import org.codehaus.plexus.util.DirectoryScanner;
@@ -96,70 +97,6 @@
deleteFile(bundleGetters);
}
-// @Override
-// public void execute() throws MojoExecutionException, MojoFailureException {
-//
-// try {
-// init();
-// } catch (Exception e) {
-// throw new MojoExecutionException("could not init goal for reason " + e.getMessage(), e);
-// }
-//
-// if (!needGeneration()) {
-// if (verbose) {
-// getLog().info("Nothing to generate - all files are up to date.");
-// }
-// return;
-// }
-// if (!silent) {
-// getLog().info("config - basedir : " + out.getAbsolutePath());
-// getLog().info("config - locales : " + Arrays.toString(locales));
-// }
-//
-// try {
-// File bundleGetters = new File(out.getAbsolutePath() + File.separatorChar + artifactId + ".properties");
-// boolean b = bundleGetters.createNewFile();
-// if (!b) {
-// throw new IOException("could not create file " + bundleGetters);
-// }
-// DirectoryScanner ds = new DirectoryScanner();
-// ds.setBasedir(out);
-// ds.setIncludes(new String[]{"*.getter"});
-// ds.scan();
-// String[] files = ds.getIncludedFiles();
-//
-// // Fusion des fichiers propriétés des différents parsers
-// for (String file : files) {
-// long t0 = System.nanoTime();
-// File bundleGetter = getGetterFile(out, file, false);
-// concactProperties(bundleGetter, bundleGetters);
-// if (genSrc) {
-// PluginHelper.deleteFile(bundleGetter);
-// }
-// if (!silent) {
-// getLog().info("import getter " + bundleGetter.getName() + " in " + PluginHelper.convertTime(System.nanoTime() - t0));
-// }
-// }
-//
-// // Création des bundles
-// for (Locale locale : locales) {
-// if (getLog().isDebugEnabled()) {
-// getLog().debug("generate bundle for locale " + locale);
-// }
-// File bundleOut = getI18nFile(out, artifactId, locale, false);
-// copyFile(bundleGetters, bundleOut);
-// if (!silent && verbose) {
-// getLog().info("generate bundle " + locale);
-// }
-// }
-// PluginHelper.deleteFile(bundleGetters);
-// } catch (IOException e) {
-// getLog().error("File Error I/O ", e);
-// throw new MojoFailureException("File Error I/O");
-// }
-// }
-
-
/**
* Concatene deux fichiers de proprietes
*
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/SourceEntry.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/SourceEntry.java 2010-03-07 16:58:44 UTC (rev 1706)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/SourceEntry.java 2010-03-08 11:04:08 UTC (rev 1707)
@@ -56,7 +56,7 @@
* <p/>
* If let to <code>null</code>, all goals can use this entry.
*/
- protected String specificGoal = null;
+ protected String specificGoal;
protected File basedir;
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParserMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParserMojo.java 2010-03-07 16:58:44 UTC (rev 1706)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParserMojo.java 2010-03-08 11:04:08 UTC (rev 1707)
@@ -16,7 +16,8 @@
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * ##%* */
+ * ##%*
+ */
package org.nuiton.i18n.plugin.parser;
import org.nuiton.i18n.plugin.AbstractI18nMojo;
@@ -37,34 +38,22 @@
*/
public abstract class AbstractI18nParserMojo extends AbstractI18nMojo implements Parser {
- /**
- * @return the outGetter to use for the instance (java.getter,...)
- */
+ /** @return the outGetter to use for the instance (java.getter,...) */
protected abstract String getOutGetter();
- /**
- * @return the starting regex expression to catch keys in key modifier
- */
+ /** @return the starting regex expression to catch keys in key modifier */
protected abstract String getKeyModifierStart();
- /**
- * @return the ending regex expression to catch keys in key modifier
- */
+ /** @return the ending regex expression to catch keys in key modifier */
protected abstract String getKeyModifierEnd();
- /**
- * @return the default includes to add to directory scanner
- */
+ /** @return the default includes to add to directory scanner */
protected abstract String[] getDefaultIncludes();
- /**
- * @return the default excludes to add to directory scanner
- */
+ /** @return the default excludes to add to directory scanner */
protected abstract String[] getDefaultExcludes();
- /**
- * @return the default src directory to use in directory scanner
- */
+ /** @return the default src directory to use in directory scanner */
protected abstract File getDefaultBasedir();
public abstract FileUpdater newFileUpdater(SourceEntry entry);
@@ -95,8 +84,8 @@
/**
* flag to display touched files while parsing.
* <p/>
- * Note: the value will be always <code>true</code> if {@link #verbose} is set
- * at <code>true</code>.
+ * Note: the value will be always <code>true</code> if {@link #verbose} is
+ * set at <code>true</code>.
*
* @parameter expression="${i18n.showTouchedFiles}" default-value="${maven.verbose}"
* @since 0.9
@@ -132,7 +121,7 @@
protected SortedProperties oldLanguage;
- protected int fileTreated = 0;
+ protected int fileTreated;
protected long t0;
@@ -160,13 +149,24 @@
}
// check there is something to treate
- if (entries == null || entries.length == 0 && !treateDefaultEntry) {
+ if ((entries == null || entries.length == 0) && !treateDefaultEntry) {
// nothing to do
throw new IllegalStateException(
"No entry defined and treateDefaultEntry is false, " +
"will skip the goal.");
}
+ if (verbose && entries != null && entries.length > 0) {
+ if (getLog().isInfoEnabled()) {
+
+ getLog().info("detected entries : " + entries.length);
+ for (SourceEntry e : entries) {
+ getLog().info(e.toString()+", specific goal ? " +
+ e.getSpecificGoal());
+ }
+ }
+ }
+
treadedFiles = new ArrayList<File>();
if (!silent && verbose) {
showTouchedFiles = true;
@@ -225,76 +225,16 @@
}
}
-// @Override
-// public void execute() throws MojoExecutionException, MojoFailureException {
-//
-// try {
-// init();
-// } catch (Exception e) {
-// throw new MojoExecutionException("could not init goal for reason " + e.getMessage(), e);
-// }
-//
-// if (entries == null || entries.length == 0 && !treateDefaultEntry) {
-// // nothing to do
-// return;
-// }
-//
-// if (!silent && safeMode) {
-// getLog().info("config - safeMode is on (could be slower).");
-// }
-// if (!silent && strictMode) {
-// getLog().info("config - strictMode is on (all files will be parsed).");
-// }
-//
-// try {
-// // Reprise sur un ancien parsing
-// File oldParserFile = getGetterFile(out, getOutGetter(), true);
-// File saveFile = getGetterFileBackup(out, getOutGetter());
-//
-// oldParser.load(oldParserFile);
-// copyFile(oldParserFile, saveFile);
-//
-// // Anciennes cles disponnibles
-// //fixme : pourquoi on utilise un bundle precis ? le premier ici, je ne comprends pas
-// File oldLanguageFile = getI18nFile(src, artifactId, locales[0], true);
-//
-// oldLanguage.load(oldLanguageFile);
-//
-// // Parsing
-// parse();
-//
-// // Suppression du fichier sauvegarder
-// boolean b = saveFile.delete();
-// if (!b) {
-// throw new IOException("could not delete file " + saveFile);
-// }
-//
-// int i = treadedFiles.size();
-// if (fileTreated == 0) {
-// if (!silent) {
-// getLog().info("Nothing to generate - all files are up to date.");
-// }
-// } else {
-// if (!silent) {
-// getLog().info(getVerboseLog().getLogEntry("parsing is done. [treated file(s) : " + i + '/' + fileTreated + "]", fileTreated, 0, t0));
-// }
-// addGetter();
-// }
-//
-// } catch (Exception e) {
-// getLog().error("Error code parsing ", e);
-// throw new MojoFailureException("Error code parsing");
-// }
-//
-// }
-
@Override
public void parse() throws IOException {
if (treateDefaultEntry) {
+ if (verbose && getLog().isInfoEnabled()) {
+ getLog().info("add default entry");
+ }
addDefaultEntry();
}
long t00 = System.nanoTime();
- for (I18nSourceEntry entry : this.entries) {
+ for (I18nSourceEntry entry : entries) {
I18nLogger vLog = getVerboseLog();
vLog.setEntry(entry);
@@ -342,7 +282,6 @@
* This is a convinient method to simplify the configuration of the plugin.
*/
protected void addDefaultEntry() {
-// List<MySourceEntry> list;
if (verbose) {
getLog().info("add default entry");
}
@@ -431,7 +370,7 @@
* @param parserEvent l'évènement d'ajout
*/
protected void addParserEvent(ParserEvent parserEvent) {
- this.events.add(parserEvent);
+ events.add(parserEvent);
}
/**
@@ -440,7 +379,7 @@
* @param parserEvent l'évènement de suppression
*/
protected void removeParserEvent(ParserEvent parserEvent) {
- this.events.remove(parserEvent);
+ events.remove(parserEvent);
}
}
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/I18nSourceEntry.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/I18nSourceEntry.java 2010-03-07 16:58:44 UTC (rev 1706)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/I18nSourceEntry.java 2010-03-08 11:04:08 UTC (rev 1707)
@@ -36,7 +36,11 @@
public static final String[] EMPTY_STRING_ARRAY = new String[0];
public boolean init(AbstractI18nParserMojo mojo) {
- if (!useForGoal(mojo.getClass().getSimpleName())) {
+ String mojoName = mojo.getClass().getSimpleName();
+ if (mojoName.endsWith("Mojo")) {
+ mojoName = mojoName.substring(0, mojoName.length() - 4);
+ }
+ if (!useForGoal(mojoName)) {
// skip not for this goal
skipMessage = "exclude for this goal.";
return true;
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/KeysModifier.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/KeysModifier.java 2010-03-07 16:58:44 UTC (rev 1706)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/KeysModifier.java 2010-03-08 11:04:08 UTC (rev 1707)
@@ -163,9 +163,9 @@
iterator.hasNext();) {
String oldKey = iterator.next();
String realKey = iterator.next();
- Pattern p = Pattern.compile("(" + patternLeft +
+ Pattern p = Pattern.compile('(' + patternLeft +
")(" + Pattern.quote(oldKey) +
- ")(" + patternRight + ")");
+ ")(" + patternRight + ')');
Matcher matcher = p.matcher(content);
matcher.region(region, content.length());
matcher.find();
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/Parser.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/Parser.java 2010-03-07 16:58:44 UTC (rev 1706)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/Parser.java 2010-03-08 11:04:08 UTC (rev 1707)
@@ -16,7 +16,8 @@
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * ##%* */
+ * ##%*
+ */
package org.nuiton.i18n.plugin.parser;
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/ParserEvent.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/ParserEvent.java 2010-03-07 16:58:44 UTC (rev 1706)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/ParserEvent.java 2010-03-08 11:04:08 UTC (rev 1707)
@@ -16,7 +16,8 @@
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * ##%* */
+ * ##%*
+ */
package org.nuiton.i18n.plugin.parser;
1
0
r1706 - in trunk/nuiton-i18n-editor: . src/main/java/org/nuiton/i18n/editor src/main/java/org/nuiton/i18n/editor/project src/main/java/org/nuiton/i18n/editor/project/impl src/main/java/org/nuiton/i18n/editor/ui src/main/java/org/nuiton/i18n/editor/ui/project src/main/java/org/nuiton/i18n/editor/ui/project/tabs
by tchemit@users.nuiton.org 07 Mar '10
by tchemit@users.nuiton.org 07 Mar '10
07 Mar '10
Author: tchemit
Date: 2010-03-07 17:58:44 +0100 (Sun, 07 Mar 2010)
New Revision: 1706
Log:
use las version of i18n, jaxx and nuiton-utils + make it works (new api of i18n and jaxx)
Modified:
trunk/nuiton-i18n-editor/pom.xml
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/I18nEditor.java
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/I18nEditorConfig.java
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/I18nEditorContext.java
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/AbstractI18nProject.java
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/AbstractI18nProjectProvider.java
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProjectFactory.java
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/DirectoryI18nProject.java
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/DirectoryI18nProjectProvider.java
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/JarI18nProject.java
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/JarI18nProjectProvider.java
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUI.jaxx
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUIHandler.java
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/PropertiesTreeModel.java
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectStep.java
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectUI.jaxx
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectUIModel.java
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/SelectBundlesTableModel.java
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/AbstractProjectTabPanelUI.css
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/ChooseProjectTypePanelUI.jaxx
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/PersistPanelUI.jaxx
Modified: trunk/nuiton-i18n-editor/pom.xml
===================================================================
--- trunk/nuiton-i18n-editor/pom.xml 2010-03-07 16:16:45 UTC (rev 1705)
+++ trunk/nuiton-i18n-editor/pom.xml 2010-03-07 16:58:44 UTC (rev 1706)
@@ -11,7 +11,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>i18n</artifactId>
- <version>1.0.2-SNAPSHOT</version>
+ <version>1.1-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.i18n</groupId>
@@ -73,8 +73,8 @@
<!-- main class in jar -->
<maven.jar.main.class>org.nuiton.i18n.editor.I18nEditor</maven.jar.main.class>
- <jaxx.version>2.0.0-SNAPSHOT</jaxx.version>
- <lutinutil.version>1.1.2-SNAPSHOT</lutinutil.version>
+ <jaxx.version>2.0.0-beta-6</jaxx.version>
+ <lutinutil.version>1.2-SNAPSHOT</lutinutil.version>
<!-- default license to use -->
<license.licenseName>gpl_v3</license.licenseName>
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/I18nEditor.java
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/I18nEditor.java 2010-03-07 16:16:45 UTC (rev 1705)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/I18nEditor.java 2010-03-07 16:58:44 UTC (rev 1706)
@@ -18,13 +18,15 @@
*/
package org.nuiton.i18n.editor;
+import jaxx.runtime.JAXXUtil;
import org.nuiton.i18n.editor.ui.I18nEditorUIHandler;
import org.nuiton.i18n.I18n;
import java.io.IOException;
+import java.util.Arrays;
+import java.util.Date;
import javax.swing.SwingUtilities;
import jaxx.runtime.SwingUtil;
-import jaxx.runtime.Util;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.i18n.editor.ui.I18nEditorUI;
@@ -47,12 +49,12 @@
* Lancement de l'interface
*
* @param args path to manage
- * @throws java.io.IOException if any IO exception
+ * @throws IOException if any IO exception
*/
public static void main(String[] args) throws IOException {
startingTime = System.nanoTime();
- log.info("I18nEditor start at " + new java.util.Date() + " args: " + java.util.Arrays.toString(args));
+ log.info("I18nEditor start at " + new Date() + " args: " + Arrays.toString(args));
try {
@@ -60,7 +62,7 @@
log.info(_("i18neditor.init.context.done", StringUtil.convertTime(startingTime, System.nanoTime())));
- Util.checkJAXXContextEntry(context, Util.newContextEntryDef(I18nEditorConfig.class));
+ JAXXUtil.checkJAXXContextEntry(context, JAXXUtil.newContextEntryDef(I18nEditorConfig.class));
I18nEditorConfig config = context.getContextValue(I18nEditorConfig.class);
@@ -115,7 +117,7 @@
// force to kill main thread
- log.info(_("i18neditor.init.closed", new java.util.Date()));
+ log.info(_("i18neditor.init.closed", new Date()));
Runtime.getRuntime().halt(0);
} catch (Exception ex) {
log.error("error while closing " + ex.getMessage(), ex);
@@ -154,7 +156,7 @@
}
if (log.isDebugEnabled()) {
- log.debug("init done in " + (StringUtil.convertTime(t0, System.nanoTime())));
+ log.debug("init done in " + StringUtil.convertTime(t0, System.nanoTime()));
}
return context;
}
@@ -170,7 +172,7 @@
System.out.println("Actions:");
for (I18nEditorConfig.Action a : I18nEditorConfig.Action.values()) {
- System.out.println("\t" + java.util.Arrays.toString(a.aliases) + "(" + a.action + "):" + a.description);
+ System.out.println("\t" + Arrays.toString(a.aliases) + "(" + a.action + "):" + a.description);
}
disableMainUI();
}
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/I18nEditorConfig.java
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/I18nEditorConfig.java 2010-03-07 16:16:45 UTC (rev 1705)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/I18nEditorConfig.java 2010-03-07 16:58:44 UTC (rev 1706)
@@ -20,9 +20,14 @@
import java.io.IOException;
import java.io.InputStream;
+
+import jaxx.runtime.JAXXUtil;
+import jaxx.runtime.context.DefaultApplicationContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import static org.nuiton.i18n.I18n._;
+
+import org.nuiton.util.ApplicationConfig;
import org.nuiton.util.FileUtil;
import org.nuiton.util.Version;
@@ -44,10 +49,10 @@
* et quel est son type (local ou pas).
*
* @author chemit
- * @see jaxx.runtime.context.DefaultApplicationContext.AutoLoad
+ * @see DefaultApplicationContext.AutoLoad
*/
-(a)jaxx.runtime.context.DefaultApplicationContext.AutoLoad
-public class I18nEditorConfig extends org.nuiton.util.ApplicationConfig {
+(a)DefaultApplicationContext.AutoLoad
+public class I18nEditorConfig extends ApplicationConfig {
/** to use log facility, just put in your code: log.info(\"...\"); */
static private Log log = LogFactory.getLog(I18nEditorConfig.class);
@@ -238,7 +243,7 @@
};
public void removeJaxxPropertyChangeListener() {
- PropertyChangeListener[] toRemove = jaxx.runtime.Util.findJaxxPropertyChangeListener(DEFAULT_JAXX_PCS, getPropertyChangeListeners());
+ PropertyChangeListener[] toRemove = JAXXUtil.findJaxxPropertyChangeListener(DEFAULT_JAXX_PCS, getPropertyChangeListeners());
if (toRemove == null || toRemove.length == 0) {
return;
}
@@ -261,7 +266,7 @@
//////////////////////////////////////////////////
// Toutes les options disponibles
//////////////////////////////////////////////////
- public static enum Option implements OptionDef {
+ public enum Option implements OptionDef {
CONFIG_FILE(CONFIG_FILE_NAME, _("i18neditor.config.configFileName.description"), "nuitoni18neditor-config", String.class, true, true),
// directories
@@ -277,7 +282,7 @@
public final boolean _transient;
public final boolean _final;
- private Option(String key, String description, String defaultValue, Class<?> type, boolean _transient, boolean _final) {
+ Option(String key, String description, String defaultValue, Class<?> type, boolean _transient, boolean _final) {
this.key = key;
this.description = description;
this.defaultValue = defaultValue;
@@ -317,12 +322,12 @@
}
}
- public static enum Step {
+ public enum Step {
AfterInit, BeforeExit
}
- public static enum Action {
+ public enum Action {
HELP(_("i18neditor.action.commandline.help"), I18nEditor.class.getName() + "#help", "-h", "--help"),
CONFIGURE(_("i18neditor.action.commandline.configure"), I18nEditor.class.getName() + "#configure", "-c", "--configure"),
@@ -331,7 +336,7 @@
public String action;
public String[] aliases;
- private Action(String description, String action, String... aliases) {
+ Action(String description, String action, String... aliases) {
this.description = description;
this.action = action;
this.aliases = aliases;
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/I18nEditorContext.java
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/I18nEditorContext.java 2010-03-07 16:16:45 UTC (rev 1705)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/I18nEditorContext.java 2010-03-07 16:58:44 UTC (rev 1706)
@@ -21,7 +21,9 @@
import java.beans.PropertyChangeListener;
import java.util.List;
import java.util.Locale;
-import jaxx.runtime.Util;
+
+import jaxx.runtime.JAXXUtil;
+import jaxx.runtime.context.DefaultApplicationContext;
import jaxx.runtime.context.JAXXContextEntryDef;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -38,18 +40,18 @@
*
* @author chemit
*/
-public class I18nEditorContext extends jaxx.runtime.context.DefaultApplicationContext {
+public class I18nEditorContext extends DefaultApplicationContext {
/** to use log facility, just put in your code: log.info(\"...\"); */
static private final Log log = LogFactory.getLog(I18nEditorContext.class);
//-------------------------------------------
// UI instances
//-------------------------------------------
- public static final JAXXContextEntryDef<I18nEditorUI> MAIN_UI_ENTRY_DEF = Util.newContextEntryDef("mainui", I18nEditorUI.class);
- public static final JAXXContextEntryDef<I18nProject> PROJECT_DEF = Util.newContextEntryDef(I18nProject.class);
- private static final JAXXContextEntryDef<String> SELECTED_KEY_DEF = Util.newContextEntryDef("selectedKey", String.class);
- private static final JAXXContextEntryDef<String> RE_SELECTED_KEY_DEF = Util.newContextEntryDef("reSelectedKey", String.class);
- private static final JAXXContextEntryDef<TreeModelMode> TREE_MODEL_MODE_DEF = Util.newContextEntryDef(TreeModelMode.class);
+ public static final JAXXContextEntryDef<I18nEditorUI> MAIN_UI_ENTRY_DEF = JAXXUtil.newContextEntryDef("mainui", I18nEditorUI.class);
+ public static final JAXXContextEntryDef<I18nProject> PROJECT_DEF = JAXXUtil.newContextEntryDef(I18nProject.class);
+ private static final JAXXContextEntryDef<String> SELECTED_KEY_DEF = JAXXUtil.newContextEntryDef("selectedKey", String.class);
+ private static final JAXXContextEntryDef<String> RE_SELECTED_KEY_DEF = JAXXUtil.newContextEntryDef("reSelectedKey", String.class);
+ private static final JAXXContextEntryDef<TreeModelMode> TREE_MODEL_MODE_DEF = JAXXUtil.newContextEntryDef(TreeModelMode.class);
public static final String PROJECT_PROPERTY = "project";
public static final String SELECTED_PACKAGES_PROPERTY = "selectedPackages";
public static final String SELECTED_BUNDLES_PROPERTY = "selectedBundles";
@@ -58,8 +60,7 @@
/** Séparateur des propriétés */
public static final String SEPARATOR = ".";
/**
- * l'intance partagée accessible après un appel à la méthode
- * {@link #init()}
+ * l'intance partagée accessible
*/
protected static I18nEditorContext instance;
@@ -67,10 +68,8 @@
* Récupération du contexte applicatif.
*
* @return l'instance partagé du contexte.
- * @throws IllegalStateException si le contexte n'a pas été initialisé via
- * la méthode {@link #init()}
*/
- public static synchronized I18nEditorContext get() throws IllegalStateException {
+ public static synchronized I18nEditorContext get() {
if (instance == null) {
instance = new I18nEditorContext();
}
@@ -82,7 +81,6 @@
protected final Object lock = new Object();
protected I18nEditorContext() {
- super();
TREE_MODEL_MODE_DEF.setContextValue(this, TreeModelMode.TREE);
}
@@ -205,7 +203,7 @@
/**
* close the application's context.
*
- * @throws java.lang.Exception if any pb while closing
+ * @throws Exception if any pb while closing
*/
public void close() throws Exception {
if (log.isDebugEnabled()) {
@@ -326,7 +324,9 @@
};
public void removeJaxxPropertyChangeListener() {
- PropertyChangeListener[] toRemove = jaxx.runtime.Util.findJaxxPropertyChangeListener(DEFAULT_JAXX_PCS, getPropertyChangeListeners());
+ PropertyChangeListener[] toRemove =
+ JAXXUtil.findJaxxPropertyChangeListener(
+ DEFAULT_JAXX_PCS, getPropertyChangeListeners());
if (toRemove == null || toRemove.length == 0) {
return;
}
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/AbstractI18nProject.java
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/AbstractI18nProject.java 2010-03-07 16:16:45 UTC (rev 1705)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/AbstractI18nProject.java 2010-03-07 16:58:44 UTC (rev 1706)
@@ -37,7 +37,7 @@
import org.apache.commons.logging.LogFactory;
import org.nuiton.i18n.bundle.I18nBundle;
import org.nuiton.i18n.bundle.I18nBundleEntry;
-import org.nuiton.i18n.bundle.I18nBundleFactory;
+import org.nuiton.i18n.bundle.I18nBundleUtil;
/**
*
@@ -75,10 +75,10 @@
protected PropertyChangeSupport pcs;
protected AbstractI18nProject() {
- this.resources = new LinkedHashMap<String, Properties>();
- this.selectedBundles = new ArrayList<Locale>();
- this.selectedPackages = new ArrayList<String>();
- this.pcs = new PropertyChangeSupport(this);
+ resources = new LinkedHashMap<String, Properties>();
+ selectedBundles = new ArrayList<Locale>();
+ selectedPackages = new ArrayList<String>();
+ pcs = new PropertyChangeSupport(this);
}
@Override
@@ -129,12 +129,12 @@
@Override
public String[] getPackages() {
- return I18nBundleFactory.getBundleNames(i18nBundles);
+ return I18nBundleUtil.getBundleNames(i18nBundles);
}
@Override
public Locale[] getBundles() {
- return I18nBundleFactory.getLocales(i18nBundles);
+ return I18nBundleUtil.getLocales(i18nBundles);
}
@Override
@@ -249,7 +249,7 @@
@Override
public void copyDefinitionTo(I18nProject project) {
// check we are on the same type of project
- if (project.getClass() != getClass()) {
+ if (!getClass().equals(project.getClass())) {
throw new IllegalArgumentException("copyDefinitionTo method must use same project type, but was not! (required : " + getClass() + ", but find " + project.getClass() + 3);
}
project.setName(name);
@@ -268,7 +268,7 @@
selectedPackages.clear();
// detections des bundles i18n a partir des urls donnees
- List<I18nBundle> tmp = I18nBundleFactory.detectBundles(urls.toArray(new URL[urls.size()]));
+ List<I18nBundle> tmp = I18nBundleUtil.detectBundles(urls.toArray(new URL[urls.size()]));
i18nBundles = tmp.toArray(new I18nBundle[tmp.size()]);
selectedBundles.addAll(Arrays.asList(getBundles()));
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/AbstractI18nProjectProvider.java
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/AbstractI18nProjectProvider.java 2010-03-07 16:16:45 UTC (rev 1705)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/AbstractI18nProjectProvider.java 2010-03-07 16:58:44 UTC (rev 1706)
@@ -26,7 +26,6 @@
import java.util.Map;
import java.util.Map.Entry;
import org.nuiton.i18n.I18n;
-import org.nuiton.i18n.editor.project.impl.DirectoryI18nProject;
import org.nuiton.i18n.editor.ui.project.ProjectUIModel;
/**
@@ -82,7 +81,7 @@
return p;
}
- public <T extends Object> T getParameter(Class<T> returnType, String propertyName, Map<String, Object> parameters, boolean mustExist) {
+ public <T> T getParameter(Class<T> returnType, String propertyName, Map<String, Object> parameters, boolean mustExist) {
Map<String, Class<?>> map = getAuthorizedParameters();
// check name
if (!map.containsKey(propertyName)) {
@@ -90,7 +89,7 @@
}
// check type
Class<?> requiredType = map.get(propertyName);
- if (returnType != requiredType && !returnType.isAssignableFrom(requiredType)) {
+ if (!returnType.equals(requiredType) && !returnType.isAssignableFrom(requiredType)) {
throw new IllegalArgumentException("the property " + propertyName + " must be of the type " + requiredType + ", but was : " + requiredType);
}
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProjectFactory.java
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProjectFactory.java 2010-03-07 16:16:45 UTC (rev 1705)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProjectFactory.java 2010-03-07 16:58:44 UTC (rev 1706)
@@ -92,7 +92,11 @@
try {
Properties p = new Properties();
stream = new FileInputStream(projectFile);
- p.load(stream);
+ try {
+ p.load(stream);
+ } finally {
+ stream.close();
+ }
String tmp = p.getProperty(AbstractI18nProjectProvider.CLASS_PARAMETER);
Class<? extends I18nProject> projectClass = (Class<? extends I18nProject>) Class.forName(tmp);
@@ -152,7 +156,7 @@
public static <P extends I18nProject> I18nProjectProvider<P> getProvider(Class<P> projectClass) {
for (I18nProjectProvider<?> p : getProviders()) {
- if (p.getType() == projectClass) {
+ if (projectClass.equals(p.getType())) {
return (I18nProjectProvider<P>) p;
}
}
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/DirectoryI18nProject.java
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/DirectoryI18nProject.java 2010-03-07 16:16:45 UTC (rev 1705)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/DirectoryI18nProject.java 2010-03-07 16:58:44 UTC (rev 1706)
@@ -34,7 +34,6 @@
protected File directorySource = new File("");
public DirectoryI18nProject() {
- super();
}
public File getDirectorySource() {
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/DirectoryI18nProjectProvider.java
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/DirectoryI18nProjectProvider.java 2010-03-07 16:16:45 UTC (rev 1705)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/DirectoryI18nProjectProvider.java 2010-03-07 16:58:44 UTC (rev 1706)
@@ -27,11 +27,12 @@
import java.util.Map;
import java.util.Properties;
import java.util.TreeMap;
-import org.nuiton.i18n.I18n;
import org.nuiton.i18n.editor.project.I18nProjectConfigurePanelUI;
import org.nuiton.i18n.editor.ui.project.ProjectUIModel;
import org.nuiton.util.ConverterUtil;
+import static org.nuiton.i18n.I18n.*;
+
/**
*
* @author chemit
@@ -39,7 +40,10 @@
public class DirectoryI18nProjectProvider extends AbstractI18nProjectProvider<DirectoryI18nProject> {
public DirectoryI18nProjectProvider() {
- super(DirectoryI18nProject.class, I18n.n_("i18neditor.project.type.directory"), I18n.n_("i18neditor.project.type.directory.description"));
+ super(DirectoryI18nProject.class,
+ n_("i18neditor.project.type.directory"),
+ n_("i18neditor.project.type.directory.description")
+ );
}
@Override
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/JarI18nProject.java
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/JarI18nProject.java 2010-03-07 16:16:45 UTC (rev 1705)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/JarI18nProject.java 2010-03-07 16:58:44 UTC (rev 1706)
@@ -40,7 +40,6 @@
protected boolean uniqueJarDefinition;
public JarI18nProject() {
- super();
}
public File getJarSource() {
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/JarI18nProjectProvider.java
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/JarI18nProjectProvider.java 2010-03-07 16:16:45 UTC (rev 1705)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/JarI18nProjectProvider.java 2010-03-07 16:58:44 UTC (rev 1706)
@@ -20,6 +20,8 @@
import java.io.File;
import java.io.IOException;
+
+import org.nuiton.i18n.bundle.I18nBundleUtil;
import org.nuiton.i18n.editor.project.AbstractI18nProjectProvider;
import java.net.URL;
import java.net.URLClassLoader;
@@ -31,7 +33,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.i18n.I18n;
-import org.nuiton.i18n.bundle.I18nBundleFactory;
import org.nuiton.i18n.editor.project.I18nProjectConfigurePanelUI;
import org.nuiton.i18n.editor.ui.project.ProjectUIModel;
import org.nuiton.util.ConverterUtil;
@@ -141,7 +142,7 @@
urls.remove(u);
}
} else {
- urls = Resource.getURLs(I18nBundleFactory.SEARCH_BUNDLE_PATTERN, loader);
+ urls = Resource.getURLs(I18nBundleUtil.SEARCH_BUNDLE_PATTERN, loader);
log.info("detected bundles : " + urls);
}
return urls;
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUI.jaxx
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUI.jaxx 2010-03-07 16:16:45 UTC (rev 1705)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUI.jaxx 2010-03-07 16:58:44 UTC (rev 1706)
@@ -30,6 +30,9 @@
<style source='I18nEditorUI.css'/>
<script><![CDATA[
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
import jaxx.runtime.SwingUtil;
import javax.swing.tree.*;
import java.util.Locale;
@@ -266,7 +269,7 @@
<jaxx.runtime.swing.editor.I18nEditor id='changeI18n'
opaque='false'
showText='false'
- locales='{java.util.Arrays.asList(org.nuiton.i18n.I18n.getLoader().getLocales())}'
+ locales='{java.util.Arrays.asList(org.nuiton.i18n.I18n.getStore().getLocales())}'
selectedLocale='{config.getLocale()}'/>
</JToolBar>
</JMenuBar>
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUIHandler.java
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUIHandler.java 2010-03-07 16:16:45 UTC (rev 1705)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUIHandler.java 2010-03-07 16:58:44 UTC (rev 1706)
@@ -25,6 +25,8 @@
import java.util.Map;
import java.util.Set;
import javax.swing.JMenu;
+
+import jaxx.runtime.swing.editor.config.model.ConfigUIModelBuilder;
import org.nuiton.i18n.editor.*;
import java.awt.Desktop;
import java.io.File;
@@ -61,6 +63,7 @@
import org.nuiton.i18n.editor.ui.project.ProjectUIModel;
import static org.nuiton.i18n.I18n._;
import static org.nuiton.i18n.I18n.n_;
+import static org.nuiton.i18n.editor.I18nEditorConfig.Option;
/**
*
@@ -83,7 +86,7 @@
*/
public I18nEditorUI initUI(I18nEditorContext context, boolean fullscreen) {
- final I18nEditorUI ui = new I18nEditorUI(context);
+ I18nEditorUI ui = new I18nEditorUI(context);
I18nEditorContext.MAIN_UI_ENTRY_DEF.setContextValue(context, ui);
@@ -399,7 +402,7 @@
project.deleteKey(packageName, locale, key);
}
- final BundleValuesUI ui = sourceUI.getParentContainer(BundleValuesUI.class);
+ BundleValuesUI ui = sourceUI.getParentContainer(BundleValuesUI.class);
ui.getBundlesContent().remove(sourceUI);
if (ui.getBundlesContent().getComponentCount() == 0) {
Container parent = ui.getParent();
@@ -484,22 +487,49 @@
public void showConfig(I18nEditorContext context) {
I18nEditorUI ui = getUI(context);
- ConfigUIModel model = new ConfigUIModel(context.getConfig());
- model.addCategory(
- n_("i18neditor.config.category.directories"),
- n_("i18neditor.config.category.directories.description"),
- I18nEditorConfig.Option.CONFIG_FILE,
- I18nEditorConfig.Option.PROJECTS_DIRECTORY,
- I18nEditorConfig.Option.TMP_DIRECTORY);
+ ConfigUIModelBuilder builder = new ConfigUIModelBuilder();
- model.addCategory(
- n_("i18neditor.config.category.ui"),
- n_("i18neditor.config.category.ui.description"),
- I18nEditorConfig.Option.FULL_SCREEN,
- I18nEditorConfig.Option.LOCALE);
+ builder.createModel(ui.getContext().getConfig());
- ConfigUI configUI = ConfigUIBuilder.newConfigUI(context, model, "i18neditor.config.category.ui");
+ //TODO Add callbacks
+// builder.registerCallBack(
+// "application",
+// n_("i18neditor.action.reload.application"),
+// UIHelper.createActionIcon("reload-application"),
+// reloadApplicationCallback
+// );
+
+ builder.addOption(Option.CONFIG_FILE);
+ builder.addOption(Option.PROJECTS_DIRECTORY);
+ builder.addOption(Option.TMP_DIRECTORY);
+//
+// model.addCategory(
+// n_("i18neditor.config.category.directories"),
+// n_("i18neditor.config.category.directories.description"),
+// Option.CONFIG_FILE,
+// Option.PROJECTS_DIRECTORY,
+// Option.TMP_DIRECTORY);
+
+ builder.addCategory(
+ n_("i18neditor.config.category.ui"),
+ n_("i18neditor.config.category.ui.description")
+ );
+
+ builder.addOption(Option.FULL_SCREEN);
+ builder.addOption(Option.LOCALE);
+//
+// model.addCategory(
+// n_("i18neditor.config.category.ui"),
+// n_("i18neditor.config.category.ui.description"),
+// Option.FULL_SCREEN,
+// Option.LOCALE);
+
+ ConfigUIModel model = builder.flushModel();
+
+ ConfigUI configUI = ConfigUIBuilder.newConfigUI(
+ context, model, "i18neditor.config.category.ui");
+
ConfigUIBuilder.showConfigUI(configUI, ui, false);
// configUI.showInDialog(ui, ui != null);
}
@@ -769,7 +799,7 @@
reloadKeys(ui);
}
- protected void closeProjectUI(final I18nEditorUI ui, I18nProject project) {
+ protected void closeProjectUI(I18nEditorUI ui, I18nProject project) {
if (ui == null) {
return;
@@ -883,7 +913,7 @@
log.debug("adding package " + p);
}
bundleValuesUI.setBundles(new ArrayList<Locale>(values.keySet()));
- for (java.util.Map.Entry<Locale, String> e : values.entrySet()) {
+ for (Map.Entry<Locale, String> e : values.entrySet()) {
BundleValueUI v = new BundleValueUI(bundleValuesUI);
v.setBundle(e.getKey());
if (log.isDebugEnabled()) {
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/PropertiesTreeModel.java
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/PropertiesTreeModel.java 2010-03-07 16:16:45 UTC (rev 1705)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/PropertiesTreeModel.java 2010-03-07 16:58:44 UTC (rev 1706)
@@ -56,7 +56,7 @@
*/
public PropertiesTreeModel(TreeModelMode mode, String... list) {
super(null);
- this.keys = list;
+ keys = list;
// Création de la racine (qui n'est jamais affichee)
PropertieNode r = new PropertieNode("");
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectStep.java
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectStep.java 2010-03-07 16:16:45 UTC (rev 1705)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectStep.java 2010-03-07 16:58:44 UTC (rev 1706)
@@ -18,6 +18,8 @@
*/
package org.nuiton.i18n.editor.ui.project;
+import jaxx.runtime.swing.wizard.WizardStep;
+
import static org.nuiton.i18n.I18n.n_;
/**
@@ -25,32 +27,32 @@
*
* @author tchemit
*/
-public enum ProjectStep implements jaxx.runtime.swing.wizard.WizardStep {
+public enum ProjectStep implements WizardStep {
- /**
- * pour choisir le type de projet a creer (@see ProjectType)
- */
- CHOOSE_PROJECT_TYPE(n_("i18neditor.project.step.chooseProjectType"), n_("i18neditor.project.step.chooseProjectType.description")),
- /**
- * pour configurer un projet
- */
- CONFIGURE_PROJECT(n_("i18neditor.project.step.configureProject"), n_("i18neditor.project.step.configureProject.description")),
- /**
- * pour choisir les bundles parmis ceux trouvés
- */
- SELECT_BUNDLES(n_("i18neditor.project.step.selecteBundles"), n_("i18neditor.project.step.selecteBundles.description")),
- /**
- * pour renseigner si on persiste le projet
- */
- PERSIST(n_("i18neditor.project.step.persist"), n_("i18neditor.project.step.persist.description")),
- /**
- * pour confirmer et charger le projet
- */
- RESUME(n_("i18neditor.project.step.resume"), n_("i18neditor.project.step.resume.description"));
+ /** pour choisir le type de projet a creer (@see ProjectType) */
+ CHOOSE_PROJECT_TYPE(
+ n_("i18neditor.project.step.chooseProjectType"),
+ n_("i18neditor.project.step.chooseProjectType.description")),
+ /** pour configurer un projet */
+ CONFIGURE_PROJECT(
+ n_("i18neditor.project.step.configureProject"),
+ n_("i18neditor.project.step.configureProject.description")),
+ /** pour choisir les bundles parmis ceux trouvés */
+ SELECT_BUNDLES(
+ n_("i18neditor.project.step.selecteBundles"),
+ n_("i18neditor.project.step.selecteBundles.description")),
+ /** pour renseigner si on persiste le projet */
+ PERSIST(n_("i18neditor.project.step.persist"),
+ n_("i18neditor.project.step.persist.description")),
+ /** pour confirmer et charger le projet */
+ RESUME(n_("i18neditor.project.step.resume"),
+ n_("i18neditor.project.step.resume.description"));
+
private final String label;
+
private final String description;
- private ProjectStep(String label, String description) {
+ ProjectStep(String label, String description) {
this.label = label;
this.description = description;
}
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectUI.jaxx
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectUI.jaxx 2010-03-07 16:16:45 UTC (rev 1705)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectUI.jaxx 2010-03-07 16:58:44 UTC (rev 1706)
@@ -35,8 +35,8 @@
import jaxx.runtime.swing.editor.MyDefaultCellEditor;
import jaxx.runtime.swing.wizard.WizardOperationState;
import jaxx.runtime.swing.wizard.WizardUtil;
-import static jaxx.runtime.Util.newContextEntryDef;
-import static jaxx.runtime.Util.checkJAXXContextEntry;
+import static jaxx.runtime.JAXXUtil.newContextEntryDef;
+import static jaxx.runtime.JAXXUtil.checkJAXXContextEntry;
import org.nuiton.i18n.editor.I18nEditorContext;
import org.nuiton.i18n.editor.I18nEditorConfig;
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectUIModel.java
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectUIModel.java 2010-03-07 16:16:45 UTC (rev 1705)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectUIModel.java 2010-03-07 16:58:44 UTC (rev 1706)
@@ -70,12 +70,12 @@
ProjectStep.SELECT_BUNDLES,
ProjectStep.PERSIST,
ProjectStep.RESUME);
- this.projects = new HashMap<I18nProjectProvider<?>, I18nProject>();
+ projects = new HashMap<I18nProjectProvider<?>, I18nProject>();
// init map of different types of projects
Set<I18nProjectProvider<?>> providers = I18nProjectFactory.getProviders();
for (I18nProjectProvider<?> p : providers) {
I18nProject newProject = p.newProject();
- this.projects.put(p, newProject);
+ projects.put(p, newProject);
// the model listens every modification of each project
// and at each time revalidate the model
newProject.addPropertyChangeListener(new PropertyChangeListener() {
@@ -96,7 +96,7 @@
*
* @param ui l'ui de l'assistant
*/
- public void finalizeUIInit(final ProjectUI ui) {
+ public void finalizeUIInit(ProjectUI ui) {
config = ui.getContextValue(I18nEditorConfig.class);
@@ -211,9 +211,9 @@
I18nProjectProvider<?> oldType = this.type;
this.type = type;
firePropertyChange(TYPE_PROPERTY_NAME, oldType, type);
- I18nProject oldProject = this.project;
+ I18nProject oldProject = project;
I18nProject newProject = projects.get(type);
- this.project = newProject;
+ project = newProject;
firePropertyChange(PROJECT_PROPERTY_NAME, oldProject, newProject);
validate();
}
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/SelectBundlesTableModel.java
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/SelectBundlesTableModel.java 2010-03-07 16:16:45 UTC (rev 1705)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/SelectBundlesTableModel.java 2010-03-07 16:58:44 UTC (rev 1706)
@@ -20,6 +20,7 @@
import java.net.URL;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.swing.table.AbstractTableModel;
@@ -46,8 +47,7 @@
protected boolean selectAll;
public SelectBundlesTableModel() {
- super();
- selected = new java.util.HashSet<Integer>();
+ selected = new HashSet<Integer>();
}
@Override
@@ -62,7 +62,7 @@
public void setUrls(List<URL> entries) {
// on nettoye toujours le model lors de l'init d'une entité
- this.entries = new java.util.ArrayList<URL>(entries);
+ this.entries = new ArrayList<URL>(entries);
// selected.clear();
// par defaut, on selectionne toutes les references
setSelectAll(true);
@@ -173,7 +173,6 @@
}
}
fireTableCellUpdated(rowIndex, columnIndex);
- return;
}
// no edit for others columns
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/AbstractProjectTabPanelUI.css
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/AbstractProjectTabPanelUI.css 2010-03-07 16:16:45 UTC (rev 1705)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/AbstractProjectTabPanelUI.css 2010-03-07 16:58:44 UTC (rev 1706)
@@ -31,7 +31,7 @@
}
#descriptionPane {
- columnHeaderView:{new JLabel(_("i18neditor.common.descrition"), jaxx.runtime.Util.getUIManagerActionIcon("information"), 10)};
+ columnHeaderView:{new JLabel(_("i18neditor.common.descrition"), SwingUtil.getUIManagerActionIcon("information"), 10)};
}
#description {
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/ChooseProjectTypePanelUI.jaxx
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/ChooseProjectTypePanelUI.jaxx 2010-03-07 16:16:45 UTC (rev 1705)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/ChooseProjectTypePanelUI.jaxx 2010-03-07 16:58:44 UTC (rev 1706)
@@ -26,6 +26,9 @@
<AbstractProjectTabPanelUI _step='{ProjectStep.CHOOSE_PROJECT_TYPE}'>
<script><![CDATA[
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
import org.nuiton.i18n.editor.*;
import org.nuiton.i18n.editor.project.*;
import org.nuiton.i18n.editor.ui.project.*;
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/PersistPanelUI.jaxx
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/PersistPanelUI.jaxx 2010-03-07 16:16:45 UTC (rev 1705)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/PersistPanelUI.jaxx 2010-03-07 16:58:44 UTC (rev 1706)
@@ -26,6 +26,9 @@
<script><![CDATA[
import jaxx.runtime.SwingUtil;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
import org.nuiton.i18n.editor.*;
import org.nuiton.i18n.editor.project.I18nProject;
import org.nuiton.i18n.editor.project.AbstractI18nProject;
1
0
Author: tchemit
Date: 2010-03-07 17:16:45 +0100 (Sun, 07 Mar 2010)
New Revision: 1705
Log:
Evolution #345: Rename module nuiton-i18n-api to nuiton-i18n
Modified:
trunk/maven-i18n-plugin/pom.xml
trunk/nuiton-i18n/pom.xml
trunk/pom.xml
Modified: trunk/maven-i18n-plugin/pom.xml
===================================================================
--- trunk/maven-i18n-plugin/pom.xml 2010-03-07 16:13:22 UTC (rev 1704)
+++ trunk/maven-i18n-plugin/pom.xml 2010-03-07 16:16:45 UTC (rev 1705)
@@ -19,7 +19,7 @@
<dependency>
<groupId>${project.groupId}</groupId>
- <artifactId>nuiton-i18n-api</artifactId>
+ <artifactId>nuiton-i18n</artifactId>
<version>${project.version}</version>
</dependency>
Modified: trunk/nuiton-i18n/pom.xml
===================================================================
--- trunk/nuiton-i18n/pom.xml 2010-03-07 16:13:22 UTC (rev 1704)
+++ trunk/nuiton-i18n/pom.xml 2010-03-07 16:16:45 UTC (rev 1705)
@@ -14,7 +14,7 @@
</parent>
<groupId>org.nuiton.i18n</groupId>
- <artifactId>nuiton-i18n-api</artifactId>
+ <artifactId>nuiton-i18n</artifactId>
<dependencies>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-03-07 16:13:22 UTC (rev 1704)
+++ trunk/pom.xml 2010-03-07 16:16:45 UTC (rev 1705)
@@ -16,7 +16,7 @@
<version>1.1-SNAPSHOT</version>
<modules>
- <module>nuiton-i18n-api</module>
+ <module>nuiton-i18n</module>
<module>maven-i18n-plugin</module>
<!--module>nuiton-i18n-editor</module-->
</modules>
1
0
Author: tchemit
Date: 2010-03-07 17:13:22 +0100 (Sun, 07 Mar 2010)
New Revision: 1704
Log:
Evolution #345: Rename module nuiton-i18n-api to nuiton-i18n
Added:
trunk/nuiton-i18n/
Removed:
trunk/nuiton-i18n-api/
Property changes on: trunk/nuiton-i18n
___________________________________________________________________
Added: svn:ignore
+ target
velocity.log
maven.log
.eclipse
.classpath
*.iml
*.ipr
*.iws
.settings
.project
Added: svn:mergeinfo
+
1
0
r1703 - in trunk/maven-i18n-plugin: . src/main/java/org/nuiton/i18n/plugin src/main/java/org/nuiton/i18n/plugin/parser src/main/java/org/nuiton/i18n/plugin/parser/impl
by tchemit@users.nuiton.org 07 Mar '10
by tchemit@users.nuiton.org 07 Mar '10
07 Mar '10
Author: tchemit
Date: 2010-03-07 17:03:59 +0100 (Sun, 07 Mar 2010)
New Revision: 1703
Log:
- reformat code (80 car per line max)
- fix javadoc
- remove comment old code
- use new api from nuiton-i18n-api
Modified:
trunk/maven-i18n-plugin/pom.xml
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nBundleMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/BundleMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/CollectI18nArtifactsMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GenerateMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GetterMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/I18nArtifact.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/I18nLogger.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/SourceEntry.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParserMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/I18nSourceEntry.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/KeysModifier.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/Parser.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/ParserEvent.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/ParserException.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserValidationMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXmlMojo.java
Modified: trunk/maven-i18n-plugin/pom.xml
===================================================================
--- trunk/maven-i18n-plugin/pom.xml 2010-03-07 16:02:33 UTC (rev 1702)
+++ trunk/maven-i18n-plugin/pom.xml 2010-03-07 16:03:59 UTC (rev 1703)
@@ -9,7 +9,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>i18n</artifactId>
- <version>1.0.2-SNAPSHOT</version>
+ <version>1.1-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.i18n</groupId>
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nBundleMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nBundleMojo.java 2010-03-07 16:02:33 UTC (rev 1702)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nBundleMojo.java 2010-03-07 16:03:59 UTC (rev 1703)
@@ -28,7 +28,7 @@
/**
* Created: 26 déc. 2009
*
- * @author Tony Chemit <chemit(a)codelutin.com> Copyright Code Lutin
+ * @author tchemit <chemit(a)codelutin.com>
* @version $Revision$
* <p/>
* Mise a jour: $Date$ par :
@@ -44,6 +44,7 @@
* @since 1.0.2
*/
protected File collectOutputDir;
+
/**
* Nom de base des fichiers qui contient les localisations des bundles.
*
@@ -63,19 +64,24 @@
* @return les urls des bundles i18n detectees pour le projet.
* @throws Exception pour tout problème
*/
- protected abstract URL[] getCollectI18nResources(Locale locale) throws Exception;
+ protected abstract URL[] getCollectI18nResources(Locale locale)
+ throws Exception;
/**
- * Pour obtenir le fichier contenant les localisation des bundles i18n du projet
- * pour une {@code locale} donnée.
+ * Pour obtenir le fichier contenant les localisation des bundles i18n du
+ * projet pour une {@code locale} donnée.
*
* @param locale la locale
- * @param create un drapeau pour forcer la création du fichier s'il n'existe pas
- * @return le fichier qui contient les urls des bundles i18n pour la locale donnée.
+ * @param create un drapeau pour forcer la création du fichier
+ * s'il n'existe pas
+ * @return le fichier qui contient les urls des bundles i18n pour la
+ * locale donnée.
* @throws IOException pour tout pb
*/
- protected File getCollectOutputFile(Locale locale, boolean create) throws IOException {
- File bundleOut = getI18nFile(collectOutputDir, collectOutputName, locale, create);
+ protected File getCollectOutputFile(Locale locale, boolean create)
+ throws IOException {
+ File bundleOut = getI18nFile(collectOutputDir, collectOutputName,
+ locale, create);
return bundleOut;
}
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java 2010-03-07 16:02:33 UTC (rev 1702)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java 2010-03-07 16:03:59 UTC (rev 1703)
@@ -42,6 +42,7 @@
* Le nombre de getters détectés pendant le cycle de vie du build.
*/
private static int NB_GETTER_FILES = 0;
+
/**
* Dependance du projet.
*
@@ -50,6 +51,7 @@
* @since 1.0.2
*/
protected MavenProject project;
+
/**
* Nom du projet.
*
@@ -57,6 +59,7 @@
* @readonly
*/
protected String artifactId;
+
/**
* Langues des bundles generes.
* <p/>
@@ -65,6 +68,7 @@
* @required
*/
protected String bundles;
+
/**
* Repertoire sources des fichiers i18n.
*
@@ -72,6 +76,7 @@
* @required
*/
protected File src;
+
/**
* Repertoire des fichiers generes i18n.
*
@@ -79,6 +84,7 @@
* @required
*/
protected File out;
+
/**
* encoding a utiliser pour charger et sauver les bundles
*
@@ -86,6 +92,7 @@
* @required
*/
protected String encoding;
+
/**
* Met les fichiers generes dans le repertoire des sources i18n.
* <p/>
@@ -94,6 +101,7 @@
* @parameter expression="${i18n.genSrc}" default-value="true"
*/
protected boolean genSrc;
+
/**
* verbose flag
* <p/>
@@ -102,6 +110,7 @@
* @parameter expression="${i18n.verbose}" default-value="${maven.verbose}"
*/
protected boolean verbose;
+
/**
* silent flag
*
@@ -109,6 +118,7 @@
* @since 1.0.0-rc-5
*/
protected boolean silent;
+
/**
* ne conserve que les clef scannees (et donc traite tous les fichiers)
* <p/>
@@ -119,10 +129,12 @@
* @parameter expression="${i18n.strictMode}" default-value="false"
*/
protected boolean strictMode;
+
/**
* les locales a traiter
*/
protected Locale[] locales;
+
/**
* logger verbeux
*/
@@ -144,7 +156,9 @@
}
locales = I18nUtil.parseLocales(bundles);
if (locales == null || locales.length == 0) {
- throw new IllegalStateException("Il faut au moins une locale declaree (utiliser la propriete 'bundles')");
+ throw new IllegalStateException(
+ "Il faut au moins une locale declaree (utiliser " +
+ "la propriete 'bundles')");
}
// return true;
}
@@ -182,10 +196,13 @@
* @param locale le nom du bundle
* @param create <code>true</code> pour creer le fichier si non present
* @return le fichier i18n
- * @throws java.io.IOException si probleme lors de la creation du fichier
+ * @throws IOException si probleme lors de la creation du fichier
*/
- public File getI18nFile(File root, String artifactId, Locale locale, boolean create) throws IOException {
- File file = new File(root.getAbsolutePath() + File.separatorChar + artifactId + "-" + locale.toString() + ".properties");
+ public File getI18nFile(File root, String artifactId,
+ Locale locale, boolean create) throws IOException {
+ File file = new File(
+ root.getAbsolutePath() + File.separatorChar + artifactId +
+ "-" + locale.toString() + ".properties");
if (create && !file.exists()) {
createNewFile(file);
}
@@ -197,10 +214,12 @@
* @param getter le nom du getter
* @param create <code>true</code> pour creer le fichier si non present
* @return le fichier i18n
- * @throws java.io.IOException si probleme lors de la creation du fichier
+ * @throws IOException si probleme lors de la creation du fichier
*/
- public File getGetterFile(File root, String getter, boolean create) throws IOException {
- File file = new File(root.getAbsolutePath() + File.separatorChar + getter);
+ public File getGetterFile(File root, String getter, boolean create)
+ throws IOException {
+ File file = new File(
+ root.getAbsolutePath() + File.separatorChar + getter);
if (create && !file.exists()) {
createNewFile(file);
}
@@ -227,7 +246,8 @@
// return new File(root.getAbsolutePath() + File.separatorChar + artifactId + "-" + bundle.toString() + ".properties~");
// }
- protected void checkBundle(Locale locale, Properties propertiesOut, boolean showEmpty) {
+ protected void checkBundle(Locale locale, Properties propertiesOut,
+ boolean showEmpty) {
// on verifie qu'il n'y a pas de traduction vide
SortedSet<String> emptyEntries = PluginHelper.getEmptyKeys(propertiesOut);
if (!emptyEntries.isEmpty()) {
@@ -243,15 +263,22 @@
if (showEmpty) {
int index = 0;
for (String key : emptyEntries) {
- buffer.append("\n - ").append(index++).append("/").append(size).append(" : ").append(key);
+ buffer.append("\n - ");
+ buffer.append(index++);
+ buffer.append("/");
+ buffer.append(size);
+ buffer.append(" : ");
+ buffer.append(key);
}
} else {
- buffer.append(" (use -Di18n.showEmpty to see these entries)");
+ buffer.append(" (use -Di18n.showEmpty to see these" +
+ " entries)");
}
getLog().warn(buffer.toString());
} else {
if (!silent && verbose) {
- getLog().info("bundle " + locale + " is valid (no empty entries).");
+ getLog().info("bundle " + locale + " is valid (no empty" +
+ " entries).");
}
}
}
@@ -266,11 +293,6 @@
copyFile(f, dst);
}
-// protected void copyFile(File src, File dst) throws IOException {
-// PluginHelper.copy(src, dst);
-// }
-
-
public String getEncoding() {
return encoding;
}
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/BundleMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/BundleMojo.java 2010-03-07 16:02:33 UTC (rev 1702)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/BundleMojo.java 2010-03-07 16:03:59 UTC (rev 1703)
@@ -20,11 +20,14 @@
package org.nuiton.i18n.plugin;
import org.nuiton.i18n.bundle.I18nBundleEntry;
-import org.nuiton.i18n.bundle.I18nBundleFactory;
+import org.nuiton.i18n.bundle.I18nBundleUtil;
+import org.nuiton.i18n.init.DefaultI18nInitializer;
import org.nuiton.io.SortedProperties;
import org.nuiton.plugin.PluginHelper;
-import java.io.*;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
import java.net.URL;
import java.util.*;
import java.util.Map.Entry;
@@ -34,11 +37,11 @@
* <p/>
* Cela génère un merge de tous les fichiers i18n utilisés en un seul.
* <p/>
- * On utilise la dépendance sur les artifacts pour connaitre l'ordre le chargement
- * des bundles.
+ * On utilise la dépendance sur les artifacts pour connaitre l'ordre le
+ * chargement des bundles.
* <p/>
- * Si dans un bundle childs, la valeur de la clef est vide, on conserve alors celui
- * du parent,
+ * Si dans un bundle childs, la valeur de la clef est vide, on conserve alors
+ * celui du parent,
* <p/>
* Ainsi on obtient un bundle dont toutes les clefs sont traduites.
* <p/>
@@ -47,11 +50,10 @@
* nombreuses dépendances (au dessus de 100 deps cela peut prendre plusieurs
* secondes, ce qui 'est pas acceptable).
* <p/>
- * On a ajoute un second mode d'initialisation dans la clesse I18n pour n'utiliser
- * qu'un seul bundle et courcircuiter le chargement couteux...
- * *
+ * On a ajoute un second mode d'initialisation dans la clesse I18n pour
+ * n'utiliser qu'un seul bundle et courcircuiter le chargement couteux...
*
- * @author chemit
+ * @author tchemit <chemit(a)codelutin.com>
* @goal bundle
* @phase generate-resources
* @execute goal=collect-i18n-artifacts
@@ -60,6 +62,7 @@
* @since 0.12
*/
public class BundleMojo extends AbstractI18nBundleMojo {
+
/**
* Repertoire ou generer les bundles.
*
@@ -68,6 +71,7 @@
* @since 1.0.0
*/
protected File bundleOutputDir;
+
/**
* Nom du bundle a generer.
*
@@ -76,16 +80,20 @@
* @since 1.0.2
*/
protected String bundleOutputName;
+
/**
- * Un drapeau pour vérifier que les bundles ne contiennent pas d'entrées vides.
+ * Un drapeau pour vérifier que les bundles ne contiennent pas d'entrées
+ * vides.
*
* @parameter expression="${i18n.checkBundle}" default-value="true"
* @required
* @since 1.0.0
*/
protected boolean checkBundle;
+
/**
- * Un drapeau pour afficher les entrées vides. (nécessite {@link #checkBundle} activé).
+ * Un drapeau pour afficher les entrées vides. (nécessite {@link
+ * #checkBundle} activé).
*
* @parameter expression="${i18n.showEmpty}" default-value="false"
* @required
@@ -109,25 +117,32 @@
protected void doAction() throws Exception {
long t00 = System.nanoTime();
+ String version = getProject().getVersion();
+ version = PluginHelper.removeSnapshotSuffix(version);
+
if (!silent) {
getLog().info("config - bundle name : " + bundleOutputName);
getLog().info("config - basedir : " + bundleOutputDir);
getLog().info("config - locales : " + Arrays.toString(locales));
+ getLog().info("config - version : " + version);
}
- Map<Locale, String> bundleDico = new LinkedHashMap<Locale, String>(locales.length);
+ Map<Locale, String> bundleDico =
+ new LinkedHashMap<Locale, String>(locales.length);
for (Locale locale : locales) {
long t0 = System.nanoTime();
- File bundleOut = getI18nFile(bundleOutputDir, bundleOutputName, locale, false);
+ File bundleOut = getI18nFile(bundleOutputDir, bundleOutputName,
+ locale, false);
if (!silent) {
getLog().info("generate bundle for locale " + locale);
}
- SortedProperties propertiesOut = new SortedProperties(encoding, false);
+ SortedProperties propertiesOut =
+ new SortedProperties(encoding, false);
StringBuilder buffer = new StringBuilder();
URL[] urls = getCollectI18nResources(locale);
@@ -138,26 +153,33 @@
for (URL url : urls) {
long t000 = System.nanoTime();
- I18nBundleEntry bundleEntry = new I18nBundleEntry(url, locale, null);
+ I18nBundleEntry bundleEntry =
+ new I18nBundleEntry(url, locale, null);
bundleEntry.load(propertiesOut);
String strPath = bundleEntry.getPath().toString();
int index = strPath.indexOf("i18n/");
buffer.append(',').append(strPath.substring(index));
if (verbose) {
- getLog().info("loaded " + bundleEntry.getPath() + " in " + PluginHelper.convertTime(t000, System.nanoTime()));
+ getLog().info(
+ "loaded " + bundleEntry.getPath() + " in " +
+ PluginHelper.convertTime(t000, System.nanoTime()));
}
}
if (buffer.length() > 0) {
bundleDico.put(locale, buffer.substring(1));
if (!silent) {
- getLog().info("bundles for locale : " + bundleDico.get(locale));
+ getLog().info(
+ "bundles for locale : " + bundleDico.get(locale));
}
}
propertiesOut.store(bundleOut);
if (!silent && verbose) {
- getLog().info("bundle created in " + PluginHelper.convertTime(t0, System.nanoTime()) + " (detected sentences : " + propertiesOut.size() + ")");
+ getLog().info(
+ "bundle created in " +
+ PluginHelper.convertTime(t0, System.nanoTime()) +
+ " (detected sentences : " + propertiesOut.size() + ")");
}
if (checkBundle) {
checkBundle(locale, propertiesOut, showEmpty);
@@ -167,136 +189,57 @@
// ecriture du ficher des definitions i18n (permet de faire une
// recherche extact sur un fichier puis d'en deduire les bundles a
// charger
- String f = String.format(I18nBundleFactory.UNIQUE_BUNDLE_DEF, bundleOutputName);
+ String f = String.format(DefaultI18nInitializer.UNIQUE_BUNDLE_DEF,
+ bundleOutputName);
File defOut = new File(bundleOutputDir, f);
if (!silent) {
- getLog().info("prepare i18n definition " + defOut.getAbsolutePath());
+ getLog().info("prepare i18n definition " +
+ defOut.getAbsolutePath());
}
SortedProperties p = new SortedProperties(encoding, false);
- p.setProperty(I18nBundleFactory.BUNDLE_DEF_LOCALES, bundles);
+ p.setProperty(DefaultI18nInitializer.BUNDLE_DEF_LOCALES, bundles);
+ p.setProperty(DefaultI18nInitializer.BUNDLE_DEF_VERSION, version);
for (Entry<Locale, String> e : bundleDico.entrySet()) {
- p.setProperty(I18nBundleFactory.BUNDLES_FOR_LOCALE + e.getKey().toString(), e.getValue());
+ p.setProperty(DefaultI18nInitializer.BUNDLES_FOR_LOCALE +
+ e.getKey().toString(), e.getValue());
}
- p.store(new FileOutputStream(defOut), null);
+ FileOutputStream out = new FileOutputStream(defOut);
+ try {
+ p.store(out, null);
+ } finally {
+ out.close();
+ }
if (!silent && verbose) {
- getLog().info("done in " + PluginHelper.convertTime(t00, System.nanoTime()));
+ getLog().info("done in " +
+ PluginHelper.convertTime(t00, System.nanoTime()));
}
}
-// @Override
-// public void execute() throws MojoExecutionException, MojoFailureException {
-//
-// if ("pom".equals(project.getPackaging()) || "site".equals(project.getPackaging())) {
-// return;
-// }
-//
-// long t00 = System.nanoTime();
-//
-// try {
-// init();
-// } catch (Exception e) {
-// throw new MojoExecutionException("could not init gaol for reason " + e.getMessage(), e);
-// }
-//
-// if (!silent) {
-// getLog().info("config - bundle name : " + bundleOutputName);
-// getLog().info("config - basedir : " + bundleOutputDir);
-// getLog().info("config - locales : " + Arrays.toString(locales));
-// }
-//
-// Map<Locale, String> bundleDico = new LinkedHashMap<Locale, String>(locales.length);
-//
-// try {
-//
-// for (Locale locale : locales) {
-//
-// long t0 = System.nanoTime();
-//
-// File bundleOut = getI18nFile(bundleOutputDir, bundleOutputName, locale, false);
-//
-// if (!silent) {
-// getLog().info("generate bundle for locale " + locale);
-// }
-//
-// SortedProperties propertiesOut = new SortedProperties(encoding, false);
-// StringBuilder buffer = new StringBuilder();
-//
-// URL[] urls = getCollectI18nResources(locale);
-// if (urls.length == 0) {
-// getLog().warn("no bundle for locale " + locale);
-// continue;
-// }
-//
-// for (URL url : urls) {
-// long t000 = System.nanoTime();
-// I18nBundleEntry bundleEntry = new I18nBundleEntry(url, locale, null);
-// bundleEntry.load(propertiesOut);
-// String strPath = bundleEntry.getPath().toString();
-// int index = strPath.indexOf("i18n/");
-//
-// buffer.append(',').append(strPath.substring(index));
-// if (verbose) {
-// getLog().info("loaded " + bundleEntry.getPath() + " in " + PluginHelper.convertTime(t000, System.nanoTime()));
-// }
-// }
-//
-// if (buffer.length() > 0) {
-// bundleDico.put(locale, buffer.substring(1));
-// if (!silent) {
-// getLog().info("bundles for locale : " + bundleDico.get(locale));
-// }
-// }
-// propertiesOut.store(bundleOut);
-// if (!silent && verbose) {
-// getLog().info("bundle created in " + PluginHelper.convertTime(t0, System.nanoTime()) + " (detected sentences : " + propertiesOut.size() + ")");
-// }
-// if (checkBundle) {
-// checkBundle(locale, propertiesOut, showEmpty);
-// }
-// }
-//
-// // ecriture du ficher des definitions i18n (permet de faire une
-// // recherche extact sur un fichier puis d'en deduire les bundles a
-// // charger
-// String f = String.format(I18nBundleFactory.UNIQUE_BUNDLE_DEF, bundleOutputName);
-// File defOut = new File(bundleOutputDir, f);
-// if (!silent) {
-// getLog().info("prepare i18n definition " + defOut.getAbsolutePath());
-// }
-// SortedProperties p = new SortedProperties(encoding, false);
-// p.setProperty(I18nBundleFactory.BUNDLE_DEF_LOCALES, bundles);
-// for (Entry<Locale, String> e : bundleDico.entrySet()) {
-// p.setProperty(I18nBundleFactory.BUNDLES_FOR_LOCALE + e.getKey().toString(), e.getValue());
-// }
-// p.store(new FileOutputStream(defOut), null);
-//
-// if (!silent && verbose) {
-// getLog().info("done in " + PluginHelper.convertTime(t00, System.nanoTime()));
-// }
-// } catch (IOException e) {
-// getLog().error("File Error I/O ", e);
-// throw new MojoFailureException("File Error I/O ");
-// }
-// }
-
-
@Override
protected URL[] getCollectI18nResources(Locale locale) throws IOException {
File file = getCollectOutputFile(locale, false);
if (!file.exists()) {
- return new URL[0];
+ return I18nBundleUtil.EMPTY_URL_ARRAY;
}
+ URL[] urls = getLinesAsURL(file);
+ return urls;
+ }
- List<URL> urls = new ArrayList<URL>();
- BufferedReader stream = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
- while (stream.ready()) {
- String line = stream.readLine().trim();
+ /**
+ * TODO Move this in PluginHelper.
+ *
+ * @param src the source file to read
+ * @return the url instanciated from lines of the source file.
+ * @throws IOException if any pb while reading file
+ */
+ public static URL[] getLinesAsURL(File src) throws IOException {
+ List<URL> result = new ArrayList<URL>();
+ for (String line : PluginHelper.getLines(src)) {
if (!line.isEmpty()) {
- URL f = new URL(line);
- urls.add(f);
+ result.add(new URL(line));
}
}
- return urls.toArray(new URL[urls.size()]);
+ return result.toArray(new URL[result.size()]);
}
}
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/CollectI18nArtifactsMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/CollectI18nArtifactsMojo.java 2010-03-07 16:02:33 UTC (rev 1702)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/CollectI18nArtifactsMojo.java 2010-03-07 16:03:59 UTC (rev 1703)
@@ -38,6 +38,7 @@
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -47,7 +48,7 @@
* <p/>
* Created: 24 déc. 2009
*
- * @author Tony Chemit <chemit(a)codelutin.com> Copyright Code Lutin
+ * @author tchemit <chemit(a)codelutin.com>
* @version $Revision$
* <p/>
* Mise a jour: $Date$ par :
@@ -59,6 +60,7 @@
* @since 1.0.2
*/
public class CollectI18nArtifactsMojo extends AbstractI18nBundleMojo {
+
/**
* Local Repository.
*
@@ -68,6 +70,7 @@
* @since 1.0.2
*/
protected ArtifactRepository localRepository;
+
/**
* Dependency tree builder component.
*
@@ -75,6 +78,7 @@
* @since 1.0.2
*/
protected DependencyTreeBuilder dependencyTreeBuilder;
+
/**
* Artifact Factory component.
*
@@ -82,6 +86,7 @@
* @since 1.0.2
*/
protected ArtifactFactory factory;
+
/**
* Artifact metadata source component.
*
@@ -89,6 +94,7 @@
* @since 1.0.2
*/
protected ArtifactMetadataSource artifactMetadataSource;
+
/**
* Artifact collector component.
*
@@ -120,7 +126,8 @@
for (Locale locale : locales) {
if (!silent) {
- getLog().info("generate collected i18n artifacts for locale " + locale);
+ getLog().info("generate collected i18n artifacts for locale " +
+ locale);
}
URL[] urls = getCollectI18nResources(locale);
@@ -133,7 +140,9 @@
storeCollectI18nResources(bundleOut, urls);
- getLog().info("collected " + urls.length + " i18n artifacts for locale " + locale + " stored in " + bundleOut);
+ getLog().info("collected " + urls.length +
+ " i18n artifacts for locale " + locale +
+ " stored in " + bundleOut);
}
}
@@ -187,14 +196,16 @@
// }
@Override
- protected URL[] getCollectI18nResources(Locale locale) throws IOException, DependencyTreeBuilderException {
+ protected URL[] getCollectI18nResources(Locale locale)
+ throws IOException, DependencyTreeBuilderException {
// la locale par defaut est la première
Locale defaultLocale = locales[0];
List<URL> urls = new ArrayList<URL>();
for (I18nArtifact artifact : i18nArtifacts) {
- I18nBundleEntry[] bundleEntries = artifact.getBundleEntries(locale, defaultLocale);
+ I18nBundleEntry[] bundleEntries =
+ artifact.getBundleEntries(locale, defaultLocale);
for (I18nBundleEntry bundleEntry : bundleEntries) {
URL path = bundleEntry.getPath();
@@ -207,7 +218,8 @@
return urls.toArray(new URL[urls.size()]);
}
- protected void storeCollectI18nResources(File bundleOut, URL[] urls) throws IOException {
+ protected void storeCollectI18nResources(File bundleOut, URL[] urls)
+ throws IOException {
StringBuilder buffer = new StringBuilder();
for (URL path : urls) {
@@ -222,17 +234,20 @@
}
/**
- * Detecte les {@link I18nArtifact} et les retourne dans l'ordre de chargement
- * dans le système i18n, i.e l'ordre des dependances entre artifacts.
+ * Detecte les {@link I18nArtifact} et les retourne dans l'ordre de
+ * chargement dans le système i18n, i.e l'ordre des dependances entre
+ * artifacts.
*
- * @return les artifacts i18nables triés par leur ordre de chargement dans le système i18n.
- * @throws java.io.IOException while detecting bundles from artifacts
- * @throws org.apache.maven.shared.dependency.tree.DependencyTreeBuilderException
- * if any error while building the depencendy tree
+ * @return les artifacts i18nables triés par leur ordre de chargement dans
+ * le système i18n.
+ * @throws IOException while detecting bundles from artifacts
+ * @throws DependencyTreeBuilderException if any error while building the
+ * depencendy tree
*/
- protected I18nArtifact[] detectI18nArtifacts() throws IOException, DependencyTreeBuilderException {
+ protected I18nArtifact[] detectI18nArtifacts()
+ throws IOException, DependencyTreeBuilderException {
- Map<Artifact, I18nArtifact> dico = new java.util.HashMap<Artifact, I18nArtifact>();
+ Map<Artifact, I18nArtifact> dico = new HashMap<Artifact, I18nArtifact>();
I18nArtifact i18nArtifact;
for (Object o : project.getArtifacts()) {
@@ -249,14 +264,17 @@
}
}
- ArtifactFilter artifactFilter = new ScopeArtifactFilter(Artifact.SCOPE_RUNTIME);
+ ArtifactFilter artifactFilter
+ = new ScopeArtifactFilter(Artifact.SCOPE_RUNTIME);
- DependencyNode rootNode = dependencyTreeBuilder.buildDependencyTree(project, localRepository, factory,
+ DependencyNode rootNode = dependencyTreeBuilder.buildDependencyTree(
+ project, localRepository, factory,
artifactMetadataSource, artifactFilter, collector);
- List<Artifact> artifacts = new java.util.ArrayList<Artifact>(dico.keySet());
+ List<Artifact> artifacts = new ArrayList<Artifact>(dico.keySet());
- DependencyUtil.sortArtifacts(rootNode, artifacts, getLog().isDebugEnabled());
+ DependencyUtil.sortArtifacts(rootNode, artifacts,
+ getLog().isDebugEnabled());
// l'artifact du projet est traite en dernier car s'il possède des
// bundles alors ils doivent etre charge en dernier
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GenerateMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GenerateMojo.java 2010-03-07 16:02:33 UTC (rev 1702)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GenerateMojo.java 2010-03-07 16:03:59 UTC (rev 1703)
@@ -93,7 +93,8 @@
SortedProperties propertiesOut = new SortedProperties(encoding);
if (!strictMode) {
- // si on n'est pas en mode strict, on doit push back in bundle out, all the bundle src keys
+ // si on n'est pas en mode strict, on doit push back in
+ // bundle out, all the bundle src keys
propertiesOut.putAll(propertiesSrc);
}
propertiesOut.load(bundleOut);
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GetterMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GetterMojo.java 2010-03-07 16:02:33 UTC (rev 1702)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GetterMojo.java 2010-03-07 16:03:59 UTC (rev 1703)
@@ -57,7 +57,9 @@
getLog().info("config - locales : " + Arrays.toString(locales));
}
- File bundleGetters = new File(out.getAbsolutePath() + File.separatorChar + artifactId + ".properties");
+ File bundleGetters = new File(out.getAbsolutePath() +
+ File.separatorChar + artifactId +
+ ".properties");
createNewFile(bundleGetters);
DirectoryScanner ds = new DirectoryScanner();
ds.setBasedir(out);
@@ -74,7 +76,9 @@
deleteFile(bundleGetter);
}
if (!silent) {
- getLog().info("import getter " + bundleGetter.getName() + " in " + PluginHelper.convertTime(System.nanoTime() - t0));
+ String time = PluginHelper.convertTime(System.nanoTime() - t0);
+ getLog().info("import getter " + bundleGetter.getName() +
+ " in " + time);
}
}
@@ -161,11 +165,13 @@
*
* @param in le fichier entrant
* @param out le fichier sortant
- * @throws IOException si problème pendant la sauvegarde ou fichier non trouvé.
+ * @throws IOException si problème pendant la sauvegarde ou fichier non
+ * trouvé.
*/
protected void concactProperties(File in, File out) throws IOException {
SortedProperties propertiesIn = new SortedProperties(encoding).load(in);
- SortedProperties propertiesOut = new SortedProperties(encoding).load(out);
+ SortedProperties propertiesOut =
+ new SortedProperties(encoding).load(out);
propertiesOut.putAll(propertiesIn);
propertiesOut.store(out);
}
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/I18nArtifact.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/I18nArtifact.java 2010-03-07 16:02:33 UTC (rev 1702)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/I18nArtifact.java 2010-03-07 16:03:59 UTC (rev 1703)
@@ -1,4 +1,4 @@
-/**
+/*
* *##%
* I18n :: Maven Plugin
* Copyright (C) 2007 - 2009 CodeLutin
@@ -25,7 +25,7 @@
import org.apache.maven.artifact.Artifact;
import org.nuiton.i18n.bundle.I18nBundle;
import org.nuiton.i18n.bundle.I18nBundleEntry;
-import org.nuiton.i18n.bundle.I18nBundleFactory;
+import org.nuiton.i18n.bundle.I18nBundleUtil;
import java.io.File;
import java.io.IOException;
@@ -35,24 +35,28 @@
import java.util.Locale;
/**
- * @author chemit
+ * @author tchemit <chemit(a)codelutin.com>
* @since 0.12
*/
public class I18nArtifact {
static final Log log = LogFactory.getLog(I18nArtifact.class);
+
protected final Artifact artifact;
+
protected final URL url;
+
protected I18nBundle[] bundles;
public I18nArtifact(Artifact artifact) throws MalformedURLException {
this.artifact = artifact;
- this.url = artifact.getFile().toURI().toURL();
+ url = artifact.getFile().toURI().toURL();
}
- public I18nArtifact(Artifact artifact, File file) throws MalformedURLException {
+ public I18nArtifact(Artifact artifact,
+ File file) throws MalformedURLException {
this.artifact = artifact;
- this.url = file.toURI().toURL();
+ url = file.toURI().toURL();
}
public Artifact getArtifact() {
@@ -65,14 +69,15 @@
public I18nBundleEntry[] getBundleEntries(Locale l, Locale defaultLocale) {
if (bundles == null) {
- throw new NullPointerException("le bundleManager n'a pas ete initialise!");
+ throw new NullPointerException(
+ "le bundleManager n'a pas ete initialise!");
}
- return I18nBundleFactory.getBundleEntries(l, defaultLocale, bundles);
+ return I18nBundleUtil.getBundleEntries(l, defaultLocale, bundles);
}
public boolean detectBundles() throws IOException {
- URL[] i18nUrls = I18nBundleFactory.getURLs(url);
+ URL[] i18nUrls = I18nBundleUtil.getURLs(url);
if (i18nUrls == null || i18nUrls.length == 0) {
// aucune url sur un fichier de traduction trouve
@@ -83,20 +88,22 @@
return false;
}
- List<I18nBundle> listBundles = I18nBundleFactory.detectBundles(i18nUrls);
+ List<I18nBundle> listBundles =
+ I18nBundleUtil.detectBundles(i18nUrls);
if (listBundles.isEmpty()) {
// pas de bundle instancie (cela ne devrait jamais arrive...)
return false;
}
- this.bundles = listBundles.toArray(new I18nBundle[listBundles.size()]);
+ bundles = listBundles.toArray(new I18nBundle[listBundles.size()]);
return true;
}
@Override
public String toString() {
- return artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getVersion();
+ return artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" +
+ artifact.getVersion();
}
}
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/I18nLogger.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/I18nLogger.java 2010-03-07 16:02:33 UTC (rev 1702)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/I18nLogger.java 2010-03-07 16:03:59 UTC (rev 1703)
@@ -29,7 +29,7 @@
/**
* Le logger utilisé par les mojo.
*
- * @author chemit
+ * @author tchemit <chemit(a)codelutin.com>
* @since 0.9
*/
public class I18nLogger extends SystemStreamLog {
@@ -50,7 +50,9 @@
protected String parser;
public I18nLogger(AbstractI18nMojo parser) {
- this.parser = "i18n:" + Introspector.decapitalize(parser.getClass().getSimpleName()) + " on " + parser.getArtifactId();
+ this.parser = "i18n:" + Introspector.decapitalize(
+ parser.getClass().getSimpleName()) + " on " +
+ parser.getArtifactId();
}
@Override
@@ -64,18 +66,22 @@
}
public void infoEntry(String action, CharSequence content) {
- print(0, "INFO", action, entry.toString() + (content == null ? "" : " - " + content.toString()));
+ print(0, "INFO", action,
+ entry.toString() +
+ (content == null ? "" : " - " + content.toString()));
}
public void infoFile(String action, String content) {
- print(2, "INFO", action, file.toString() + (content == null ? "" : " - " + content));
+ print(2, "INFO", action, file.toString() +
+ (content == null ? "" : " - " + content));
}
public void infoAction(String action, String content) {
- print(2, "INFO", action, (content == null ? "" : " - " + content));
+ print(2, "INFO", action, content == null ? "" : " - " + content);
}
- private void print(int start, String prefix, String context, String content) {
+ private void print(int start, String prefix, String context,
+ String content) {
StringBuilder sb = new StringBuilder();
sb.append("[").append(prefix).append("] [").append(parser).append("] ");
@@ -113,7 +119,8 @@
s += "(total time:" + PluginHelper.convertTime(now - all) + ")";
}
if (nbFiles > 0) {
- s += " ( ~ " + PluginHelper.convertTime(((now - all) / (nbFiles))) + " / file)";
+ s += " ( ~ " +
+ PluginHelper.convertTime((now - all) / nbFiles) + " / file)";
}
return s;
}
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/SourceEntry.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/SourceEntry.java 2010-03-07 16:02:33 UTC (rev 1702)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/SourceEntry.java 2010-03-07 16:03:59 UTC (rev 1703)
@@ -32,21 +32,24 @@
import java.util.List;
/**
- * A simple model for a sourceEntry represents by a basedir and includes and/or exlucdes pattern.
+ * A simple model for a sourceEntry represents by a basedir and includes
+ * and/or exlucdes pattern.
* <p/>
* The class offers the usefull method :
* {@link #getIncludedFiles(File, String[], String[])}
* <p/>
* to obtain the list of files from
* the {@link #basedir} directory which respects the {@link #includes} and/or
- * {@link #excludes} patterns using an internal {@link DirectoryScanner} object.
+ * {@link #excludes} patterns using an internal {@link DirectoryScanner}
+ * object.
* <p/>
- * Note : <b>The class does not extends <code>DirectoryScanner</code> since we DO not want
- * to expose his methods.</b>
+ * Note : <b>The class does not extends <code>DirectoryScanner</code> since
+ * we DO not want to expose his methods.</b>
*
- * @author tony
+ * @author tchemit <chemit(a)codelutin.com>
*/
public class SourceEntry {
+
/**
* If you want to restrict use of the entry, set the class name goal to
* this property via {@link #setSpecificGoal(String)}.
@@ -58,7 +61,9 @@
protected File basedir;
protected String[] includes;
+
protected String[] excludes;
+
/**
* Files to be find
*/
@@ -123,14 +128,16 @@
* <p/>
*
* @param file the file path to test
- * @return <code>true</code> if file is up to date and do not need to be parsed
+ * @return {@code true} if file is up to date and do not need to be parsed
* @see FileUpdater
*/
public final boolean isFileUptodate(File file) {
return updater != null && updater.isFileUpToDate(file);
}
- public String[] getIncludedFiles(File defaultBasedir, String[] defaultIncludes, String[] defaultExcludes) {
+ public String[] getIncludedFiles(File defaultBasedir,
+ String[] defaultIncludes,
+ String[] defaultExcludes) {
// normalized entry
if (!hasSrc()) {
setBasedir(defaultBasedir);
@@ -168,10 +175,16 @@
return sb.toString();
}
- public String[] getIncludedFiles(File basedir, String[] defaultIncludes, String[] defaultExcludes, URLClassLoader loader, List<String> annotationClass, Log log) {
+ public String[] getIncludedFiles(File basedir,
+ String[] defaultIncludes,
+ String[] defaultExcludes,
+ URLClassLoader loader,
+ List<String> annotationClass,
+ Log log) {
List<String> result = new ArrayList<String>();
- for (String s : getIncludedFiles(basedir, defaultIncludes, defaultExcludes)) {
+ for (String s :
+ getIncludedFiles(basedir, defaultIncludes, defaultExcludes)) {
if (filterByAnnotation(s, loader, annotationClass, log)) {
result.add(s);
}
@@ -179,10 +192,14 @@
return result.toArray(new String[result.size()]);
}
- protected boolean filterByAnnotation(String file, URLClassLoader loader, List<String> annotationClass, Log log) {
+ protected boolean filterByAnnotation(String file,
+ URLClassLoader loader,
+ List<String> annotationClass,
+ Log log) {
- Annotation annotation = getAnnotation(file, loader, annotationClass, log);
+ Annotation annotation = getAnnotation(file, loader, annotationClass,
+ log);
boolean result = annotation != null;
@@ -210,7 +227,10 @@
}
}
- public Annotation getAnnotation(String file, URLClassLoader loader, List<String> annotationClass, Log log) {
+ public Annotation getAnnotation(String file,
+ URLClassLoader loader,
+ List<String> annotationClass,
+ Log log) {
Class<?> currentClass = getClass(file, loader, log);
@@ -218,7 +238,8 @@
Annotation[] annos = currentClass.getAnnotations();
if (annos != null && annos.length > 0) {
for (Annotation anno : annos) {
- if (annotationClass.contains(anno.annotationType().getName())) {
+ if (annotationClass.contains(
+ anno.annotationType().getName())) {
return anno;
}
}
@@ -231,12 +252,17 @@
}
public Class<?> getClass(File file, URLClassLoader loader, Log log) {
- String f = file.getAbsolutePath().substring(basedir.getAbsolutePath().length() + 1);
+ String f = file.getAbsolutePath().substring(
+ basedir.getAbsolutePath().length() + 1);
return getClass(f, loader, log);
}
- public Annotation getAnnotation(File file, URLClassLoader loader, List<String> annotationClass, Log log) {
- String f = file.getAbsolutePath().substring(basedir.getAbsolutePath().length() + 1);
+ public Annotation getAnnotation(File file,
+ URLClassLoader loader,
+ List<String> annotationClass,
+ Log log) {
+ String f = file.getAbsolutePath().substring(
+ basedir.getAbsolutePath().length() + 1);
return getAnnotation(f, loader, annotationClass, log);
}
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParserMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParserMojo.java 2010-03-07 16:02:33 UTC (rev 1702)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParserMojo.java 2010-03-07 16:03:59 UTC (rev 1703)
@@ -77,18 +77,21 @@
* @parameter expression="${i18n.keysModifier}" default-value="false"
*/
protected boolean keysModifier;
+
/**
* treate default entry
*
* @parameter expression="${i18n.treateDefaultEntry}" default-value="true"
*/
protected boolean treateDefaultEntry;
+
/**
* Source entries (src+includes+excludes) .
*
* @parameter expression="${i18n.entries}"
*/
protected I18nSourceEntry[] entries;
+
/**
* flag to display touched files while parsing.
* <p/>
@@ -99,6 +102,7 @@
* @since 0.9
*/
protected boolean showTouchedFiles;
+
/**
* flag to save at eachfile treated the getter file
*
@@ -106,6 +110,7 @@
* @since 0.9
*/
protected boolean safeMode;
+
/**
* flag to save previous getter in a backup before doing parsing.
* <p/>
@@ -115,16 +120,24 @@
* @since 1.0.2
*/
protected boolean backupGetter;
+
/**
* Liste des évènements
*/
protected List<ParserEvent> events = new ArrayList<ParserEvent>();
+
protected SortedProperties result;
+
protected SortedProperties oldParser;
+
protected SortedProperties oldLanguage;
+
protected int fileTreated = 0;
+
protected long t0;
+
protected boolean touchFile;
+
protected List<File> treadedFiles;
public boolean isStrictMode() {
@@ -142,13 +155,16 @@
// out.mkdirs();
// evenements
if (keysModifier) {
- addParserEvent(KeysModifier.getInstance(getKeyModifierStart(), getKeyModifierEnd(), encoding));
+ addParserEvent(KeysModifier.getInstance(
+ getKeyModifierStart(), getKeyModifierEnd(), encoding));
}
// check there is something to treate
if (entries == null || entries.length == 0 && !treateDefaultEntry) {
// nothing to do
- throw new IllegalStateException("No entry defined and treateDefaultEntry is false, will skip the goal.");
+ throw new IllegalStateException(
+ "No entry defined and treateDefaultEntry is false, " +
+ "will skip the goal.");
}
treadedFiles = new ArrayList<File>();
@@ -163,7 +179,8 @@
getLog().info("config - safeMode is on (could be slower).");
}
if (!silent && strictMode) {
- getLog().info("config - strictMode is on (all files will be parsed).");
+ getLog().info("config - strictMode is on (all files will be" +
+ " parsed).");
}
// Reprise sur un ancien parsing
@@ -178,7 +195,8 @@
}
// Anciennes cles disponnibles
- //fixme : pourquoi on utilise un bundle precis ? le premier ici, je ne comprends pas
+ //fixme : pourquoi on utilise un bundle precis ? le premier ici,
+ // je ne comprends pas
File oldLanguageFile = getI18nFile(src, artifactId, locales[0], true);
oldLanguage.load(oldLanguageFile);
@@ -199,7 +217,9 @@
}
} else {
if (!silent) {
- getLog().info(getVerboseLog().getLogEntry("Parsing is done. [treated file(s) : " + i + '/' + fileTreated + "]", fileTreated, 0, t0));
+ getLog().info(getVerboseLog().getLogEntry(
+ "Parsing is done. [treated file(s) : " + i + '/' +
+ fileTreated + "]", fileTreated, 0, t0));
}
addGetter();
}
@@ -291,7 +311,9 @@
long t000 = System.nanoTime();
int nbFiles = entry.getFiles().length;
if (!silent && verbose) {
- vLog.infoEntry("start", vLog.getLogEntry("[incoming file(s) : " + entry.getFoudFiles() + "]", 0, 0, 0));
+ vLog.infoEntry("start", vLog.getLogEntry(
+ "[incoming file(s) : " + entry.getFoudFiles() + "]",
+ 0, 0, 0));
}
// launch parser for found files
@@ -306,7 +328,9 @@
}
fileTreated += nbFiles;
if (!silent && verbose) {
- vLog.infoEntry("end", vLog.getLogEntry("[treated file(s) : " + nbFiles + "]", nbFiles, t000, t00));
+ vLog.infoEntry("end", vLog.getLogEntry(
+ "[treated file(s) : " + nbFiles + "]", nbFiles, t000,
+ t00));
}
t00 = System.nanoTime();
}
@@ -323,7 +347,8 @@
getLog().info("add default entry");
}
boolean hasEntries = entries != null && entries.length > 0;
- I18nSourceEntry[] tmp = new I18nSourceEntry[hasEntries ? entries.length + 1 : 1];
+ I18nSourceEntry[] tmp =
+ new I18nSourceEntry[hasEntries ? entries.length + 1 : 1];
if (hasEntries) {
System.arraycopy(entries, 0, tmp, 0, entries.length);
}
@@ -344,7 +369,8 @@
for (int i = 0, max = files.length; i < max; i++) {
String file1 = files[i];
long t000 = System.nanoTime();
- String fileName = entry.getBasedir().getAbsolutePath() + File.separator + file1;
+ String fileName = entry.getBasedir().getAbsolutePath() +
+ File.separator + file1;
File file = new File(fileName);
for (ParserEvent event : events) {
event.eventChangeFile(file);
@@ -359,10 +385,11 @@
}
parseFile(file);
- //TC-20090214 pour des questions de performance, on ne sauvegarde pas
- // a chaque traitement de fichier, les clefs mais une fois pour chaque
- // source entry
- // Detection de nouvelles cles, sauvegarde du fichier pour pouvoir le restaurer en cas de plantage
+ //TC-20090214 pour des questions de performance, on ne sauvegarde
+ // pas a chaque traitement de fichier, les clefs mais une fois pour
+ // chaque source entry
+ // Detection de nouvelles cles, sauvegarde du fichier pour pouvoir
+ // le restaurer en cas de plantage
if (safeMode) {
if (size != result.size()) {
saveGetterFile();
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/I18nSourceEntry.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/I18nSourceEntry.java 2010-03-07 16:02:33 UTC (rev 1702)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/I18nSourceEntry.java 2010-03-07 16:03:59 UTC (rev 1703)
@@ -33,6 +33,8 @@
*/
public class I18nSourceEntry extends SourceEntry {
+ public static final String[] EMPTY_STRING_ARRAY = new String[0];
+
public boolean init(AbstractI18nParserMojo mojo) {
if (!useForGoal(mojo.getClass().getSimpleName())) {
// skip not for this goal
@@ -51,8 +53,8 @@
if (mojo.isStrictMode() || updater == null) {
// mojo strict mode or not updater, so force all files
- skipFiles = new String[0];
- this.files = filesForEntry;
+ skipFiles = EMPTY_STRING_ARRAY;
+ files = filesForEntry;
return false;
}
@@ -72,12 +74,13 @@
if (!todo) {
// skip, no file out-of -date
skipMessage = "all files are up to date.";
- this.skipFiles = listSkipFiles.toArray(new String[listSkipFiles.size()]);
- this.files = new String[0];
+ skipFiles = listSkipFiles.toArray(
+ new String[listSkipFiles.size()]);
+ files = EMPTY_STRING_ARRAY;
return true;
}
- this.skipFiles = listSkipFiles.toArray(new String[listSkipFiles.size()]);
- this.files = listFiles.toArray(new String[listFiles.size()]);
+ skipFiles = listSkipFiles.toArray(new String[listSkipFiles.size()]);
+ files = listFiles.toArray(new String[listFiles.size()]);
return false;
}
@@ -88,6 +91,8 @@
* @return the list of relative path of files for the given entry
*/
protected String[] getFilesForEntry(AbstractI18nParserMojo mojo) {
- return getIncludedFiles(mojo.getDefaultBasedir(), mojo.getDefaultIncludes(), mojo.getDefaultExcludes());
+ return getIncludedFiles(mojo.getDefaultBasedir(),
+ mojo.getDefaultIncludes(),
+ mojo.getDefaultExcludes());
}
}
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/KeysModifier.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/KeysModifier.java 2010-03-07 16:02:33 UTC (rev 1702)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/KeysModifier.java 2010-03-07 16:03:59 UTC (rev 1703)
@@ -48,20 +48,28 @@
// Modification des clés dans le fichier
protected List<String> newKeys;
+
protected boolean needModifiedFile;
+
protected String patternLeft;
+
protected String patternRight;
+
protected String encoding;
// Interface
protected JLabel name = new JLabel();
+
protected JLabel path = new JLabel();
+
protected JTextField key = new JTextField();
+
protected JTextField pattern = new JTextField(".*");
+
protected JCheckBox onlyNewKey = new JCheckBox();
+ protected JButton next = new JButton("Next >>");
- protected JButton next = new JButton("Next >>");
private static KeysModifier keysModifier;
/**
@@ -72,7 +80,9 @@
* @param encoding encoding
* @return the shared instance with new config
*/
- public static KeysModifier getInstance(String patternLeft, String patternRight, String encoding) {
+ public static KeysModifier getInstance(String patternLeft,
+ String patternRight,
+ String encoding) {
if (keysModifier == null) {
keysModifier = new KeysModifier();
}
@@ -149,10 +159,13 @@
throw new ParserException(e);
}
- for (Iterator<String> iterator = newKeys.iterator(); iterator.hasNext();) {
+ for (Iterator<String> iterator = newKeys.iterator();
+ iterator.hasNext();) {
String oldKey = iterator.next();
String realKey = iterator.next();
- Pattern p = Pattern.compile("(" + patternLeft + ")(" + Pattern.quote(oldKey) + ")(" + patternRight + ")");
+ Pattern p = Pattern.compile("(" + patternLeft +
+ ")(" + Pattern.quote(oldKey) +
+ ")(" + patternRight + ")");
Matcher matcher = p.matcher(content);
matcher.region(region, content.length());
matcher.find();
@@ -173,7 +186,9 @@
key.setText(keyI18n);
newKeys.add(key.getText());
repaint();
- if (isVisible() && keyI18n.matches(pattern.getText()) && (!onlyNewKey.isSelected() || newKey)) {
+ if (isVisible() &&
+ keyI18n.matches(pattern.getText()) &&
+ (!onlyNewKey.isSelected() || newKey)) {
try {
wait();
} catch (InterruptedException e) {
@@ -185,7 +200,8 @@
@Override
public String eventGetRealKey() {
newKeys.add(key.getText());
- needModifiedFile |= !newKeys.get(newKeys.size() - 1).equals(newKeys.get(newKeys.size() - 2));
+ needModifiedFile |= !newKeys.get(newKeys.size() - 1).equals(
+ newKeys.get(newKeys.size() - 2));
return key.getText();
}
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/Parser.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/Parser.java 2010-03-07 16:02:33 UTC (rev 1702)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/Parser.java 2010-03-07 16:03:59 UTC (rev 1703)
@@ -35,7 +35,7 @@
/**
* Lancement du parser
*
- * @throws java.io.IOException if any io pb
+ * @throws IOException if any io pb
*/
void parse() throws IOException;
@@ -50,8 +50,8 @@
* Parse une partie du fichier
*
* @param file le fichier à parser
- * @param args ? TODO
+ * @param line la ligne à parser
*/
- void parseLine(File file, String args);
+ void parseLine(File file, String line);
}
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/ParserEvent.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/ParserEvent.java 2010-03-07 16:02:33 UTC (rev 1702)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/ParserEvent.java 2010-03-07 16:03:59 UTC (rev 1703)
@@ -32,22 +32,22 @@
/**
* Méthode appelée quand on change de fichier parsé
*
- * @param file
+ * @param file le nouveau fichier a parser
*/
void eventChangeFile(File file);
/**
* Méthode appelée après le parsing du fichier
*
- * @param file
+ * @param file le prochain fichier a parser
*/
void eventNextFile(File file);
/**
* Méthode appelée quand on change de clé
*
- * @param keyI18n
- * @param newKey
+ * @param keyI18n la clef i18n
+ * @param newKey la nouvelle clef i18n
*/
void eventChangeKey(String keyI18n, boolean newKey);
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/ParserException.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/ParserException.java 2010-03-07 16:02:33 UTC (rev 1702)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/ParserException.java 2010-03-07 16:03:59 UTC (rev 1703)
@@ -30,7 +30,6 @@
private static final long serialVersionUID = 1L;
public ParserException() {
- super();
}
public ParserException(String message, Throwable cause) {
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaMojo.java 2010-03-07 16:02:33 UTC (rev 1702)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaMojo.java 2010-03-07 16:03:59 UTC (rev 1703)
@@ -22,6 +22,7 @@
import org.nuiton.i18n.plugin.SourceEntry;
import org.nuiton.i18n.plugin.parser.AbstractI18nParserMojo;
+import org.nuiton.i18n.plugin.parser.I18nSourceEntry;
import org.nuiton.i18n.plugin.parser.ParserEvent;
import org.nuiton.i18n.plugin.parser.ParserException;
import org.nuiton.io.FileUpdater;
@@ -71,7 +72,7 @@
@Override
public String[] getDefaultExcludes() {
- return new String[]{};
+ return I18nSourceEntry.EMPTY_STRING_ARRAY;
}
@Override
@@ -112,7 +113,8 @@
LineNumberReader lnr;
String line = null;
try {
- lnr = new LineNumberReader(new InputStreamReader(new FileInputStream(srcFile)));
+ lnr = new LineNumberReader(new InputStreamReader(
+ new FileInputStream(srcFile)));
while (lnr.ready()) {
line = lnr.readLine();
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserValidationMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserValidationMojo.java 2010-03-07 16:02:33 UTC (rev 1702)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserValidationMojo.java 2010-03-07 16:03:59 UTC (rev 1703)
@@ -20,6 +20,7 @@
package org.nuiton.i18n.plugin.parser.impl;
import org.nuiton.i18n.plugin.SourceEntry;
+import org.nuiton.i18n.plugin.parser.I18nSourceEntry;
import org.nuiton.io.FileUpdater;
import org.nuiton.io.MirroredFileUpdater;
import org.xml.sax.EntityResolver;
@@ -45,24 +46,28 @@
public class ParserValidationMojo extends ParserXmlMojo {
final URL xworksResource = getClass().getResource("/xwork-validator-1.0.2.dtd");
+
/**
* Source entries (src+includes+excludes) .
*
* @parameter expression="${i18n.defaultIncludes}" default-value="**\/**-validation.xml"
*/
protected String defaultIncludes;
+
/**
* Where jaxx files should have been generated.
*
* @parameter expression="${i18n.cp}" default-value="${basedir}/target/classes"
*/
protected File cp;
+
/**
* Regles xml.
*
* @parameter expression="${i18n.rulesValidation}" default-value="validation.rules"
*/
protected String rulesValidation;
+
/**
* default src for an entry.
*
@@ -70,6 +75,7 @@
* @required
*/
protected File defaultBasedir;
+
/**
* Always use the local xowrks dtd to increase performance.
*
@@ -85,7 +91,7 @@
@Override
public String[] getDefaultExcludes() {
- return new String[]{};
+ return I18nSourceEntry.EMPTY_STRING_ARRAY;
}
@Override
@@ -95,12 +101,13 @@
@Override
public FileUpdater newFileUpdater(SourceEntry entry) {
- return new MirroredFileUpdater("", "", entry.getBasedir(), this.cp) {
+ return new MirroredFileUpdater("", "", entry.getBasedir(), cp) {
@Override
public File getMirrorFile(File f) {
- String file = f.getAbsolutePath().substring(this.prefixSourceDirecotory);
- return new File(this.destinationDirectory + File.separator + file);
+ String file =
+ f.getAbsolutePath().substring(prefixSourceDirecotory);
+ return new File(destinationDirectory + File.separator + file);
}
};
}
@@ -152,13 +159,16 @@
return new EntityResolver() {
- public static final String XWORK_PUBLIC_ID = "-//OpenSymphony Group//XWork Validator 1.0.2//EN";
+ public static final String XWORK_PUBLIC_ID =
+ "-//OpenSymphony Group//XWork Validator 1.0.2//EN";
boolean useLocal = useLocalResolver;
@Override
- public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
+ public InputSource resolveEntity(String publicId, String systemId)
+ throws SAXException, IOException {
if (getLog().isDebugEnabled()) {
- getLog().debug("publicID:" + publicId + ", systemId:" + systemId);
+ getLog().debug("publicID:" + publicId + ", systemId:" +
+ systemId);
}
if (XWORK_PUBLIC_ID.equals(publicId)) {
if (!useLocal) {
@@ -171,7 +181,8 @@
openConnection.setConnectTimeout(1000);
try {
openConnection.connect();
- return new InputSource(openConnection.getInputStream());
+ return new InputSource(
+ openConnection.getInputStream());
} catch (SocketTimeoutException e) {
useLocal = true;
} catch (IOException e) {
@@ -180,7 +191,8 @@
}
// use directly local resource
- InputSource inputSource = new InputSource(xworksResource.openStream());
+ InputSource inputSource =
+ new InputSource(xworksResource.openStream());
return inputSource;
}
// use the default behaviour
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXmlMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXmlMojo.java 2010-03-07 16:02:33 UTC (rev 1702)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXmlMojo.java 2010-03-07 16:03:59 UTC (rev 1703)
@@ -55,9 +55,13 @@
* @required
*/
protected File defaultBasedir;
+
protected String rules;
+
protected XPathFactory factory;
+
protected XPath xpath;
+
protected DocumentBuilder builder;
/**
@@ -81,10 +85,11 @@
@Override
public void init() throws Exception {
super.init();
- this.factory = XPathFactory.newInstance();
- this.rules = getRules(getFileRules());
- this.xpath = factory.newXPath();
- DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
+ factory = XPathFactory.newInstance();
+ rules = getRules(getFileRules());
+ xpath = factory.newXPath();
+ DocumentBuilderFactory documentBuilderFactory =
+ DocumentBuilderFactory.newInstance();
documentBuilderFactory.setNamespaceAware(true); // never forget this!
try {
@@ -98,7 +103,9 @@
}
} catch (ParserConfigurationException ex) {
- throw new IllegalStateException("could not load DocumentBuilder for reason " + ex.getMessage(), ex);
+ throw new IllegalStateException(
+ "could not load DocumentBuilder for reason " +
+ ex.getMessage(), ex);
}
}
@@ -128,7 +135,8 @@
parseLine(file, node.getTextContent());
}
if (safeMode) {
- // Détection de nouvelles clés, sauvegarde du fichier pour pouvoir le restaurer en cas de plantage
+ // Détection de nouvelles clés, sauvegarde du fichier pour
+ // pouvoir le restaurer en cas de plantage
if (size != result.size()) {
saveGetterFile();
}
@@ -213,7 +221,8 @@
inputStream = classLoader.getResourceAsStream(fileRules);
}
if (inputStream == null) {
- throw new ParserException("could not found file of rules : " + fileRules);
+ throw new ParserException(
+ "could not found file of rules : " + fileRules);
}
inputStream = new BufferedInputStream(inputStream);
@@ -247,9 +256,12 @@
in.close();
// Suppression
String txt = sb.toString().trim();
- txt = txt.replaceAll("#.*\n", ""); // suppression des commentaires
- txt = txt.replaceAll("\\s+", " | "); // contruction du xpath avec des ou
- txt = txt.replaceAll("(^ \\| )|( \\| $)", ""); // suppression des ou de début ee fin
+ // suppression des commentaires
+ txt = txt.replaceAll("#.*\n", "");
+ // contruction du xpath avec des ou
+ txt = txt.replaceAll("\\s+", " | ");
+ // suppression des ou de début ee fin
+ txt = txt.replaceAll("(^ \\| )|( \\| $)", "");
return txt;
}
}
1
0