r2521 - in trunk: nuiton-config/src/main/java/org/nuiton/util/config nuiton-utils/src/main/java/org/nuiton/util nuiton-utils/src/test/java/org/nuiton/util nuiton-utils-maven-report-plugin nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/config nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/plugin/report
Author: tchemit Date: 2013-03-03 16:20:18 +0100 (Sun, 03 Mar 2013) New Revision: 2521 Url: http://nuiton.org/projects/nuiton-utils/repository/revisions/2521 Log: fixes #2554: Deprecates old applicationConfig reports refs #2555: Write new report adapated to new config module refs #2506: Introduce nuiton-config module (move upper level ActionDef to ConfigActionDef and OptionDef to ConfigOptionDef) add missing stuff on some classes Added: trunk/nuiton-config/src/main/java/org/nuiton/util/config/ConfigActionDef.java trunk/nuiton-config/src/main/java/org/nuiton/util/config/ConfigOptionDef.java trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/config/ trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/config/AbstractApplicationConfigReport.java trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/config/AggregateApplicationConfigReport.java trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/config/ApplicationConfigReport.java trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/config/ApplicationConfigReportRenderer.java Modified: trunk/nuiton-config/src/main/java/org/nuiton/util/config/ApplicationConfig.java trunk/nuiton-config/src/main/java/org/nuiton/util/config/ApplicationConfigHelper.java trunk/nuiton-config/src/main/java/org/nuiton/util/config/ApplicationConfigProvider.java trunk/nuiton-utils-maven-report-plugin/pom.xml trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/plugin/report/AbstractApplicationConfigReport.java trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/plugin/report/AggregateApplicationConfigReport.java trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/plugin/report/ApplicationConfigReport.java trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/plugin/report/ApplicationConfigReportRenderer.java trunk/nuiton-utils/src/main/java/org/nuiton/util/AliasMap.java trunk/nuiton-utils/src/main/java/org/nuiton/util/SemVer.java trunk/nuiton-utils/src/test/java/org/nuiton/util/AliasMapTest.java trunk/nuiton-utils/src/test/java/org/nuiton/util/SemVerTest.java Modified: trunk/nuiton-config/src/main/java/org/nuiton/util/config/ApplicationConfig.java =================================================================== --- trunk/nuiton-config/src/main/java/org/nuiton/util/config/ApplicationConfig.java 2013-02-26 15:30:54 UTC (rev 2520) +++ trunk/nuiton-config/src/main/java/org/nuiton/util/config/ApplicationConfig.java 2013-03-03 15:20:18 UTC (rev 2521) @@ -51,7 +51,6 @@ import java.io.OutputStreamWriter; import java.io.PrintStream; import java.io.Reader; -import java.io.Serializable; import java.io.Writer; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; @@ -126,8 +125,8 @@ * </pre> * <p/> * <ul> - * <li>MyAppConfigOption doit étendre {@link OptionDef} et décrir la configuration de l'application. - * <li>MyAppConfigAction doit étendre {@link ActionDef} et décrir la liste des options + * <li>MyAppConfigOption doit étendre {@link ConfigOptionDef} et décrir la configuration de l'application. + * <li>MyAppConfigAction doit étendre {@link ConfigActionDef} et décrir la liste des options * et de leur alias disponible pour l'application. * </ul> * <p/> @@ -531,7 +530,7 @@ * @deprecated since 2.4.8, prefer use {@link #ApplicationConfig(Properties, String)} */ @Deprecated - public <O extends OptionDef, A extends ActionDef> ApplicationConfig( + public <O extends ConfigOptionDef, A extends ConfigActionDef> ApplicationConfig( Class<O> optionClass, Class<A> actionClass, Properties defaults, String configFilename) { this(defaults, configFilename); @@ -586,14 +585,14 @@ } /** - * Load default options of enum pass in param (enum must extend {@link OptionDef}) + * Load default options of enum pass in param (enum must extend {@link ConfigOptionDef}) * * @param optionClass to load - * @param <O> type of enum extend {@link OptionDef} - * @deprecated since 2.4.8, prefer use now {@link #loadDefaultOptions(OptionDef[])} + * @param <O> type of enum extend {@link ConfigOptionDef} + * @deprecated since 2.4.8, prefer use now {@link #loadDefaultOptions(ConfigOptionDef[])} */ @Deprecated - public <O extends OptionDef> void loadDefaultOptions(Class<O> optionClass) { + public <O extends ConfigOptionDef> void loadDefaultOptions(Class<O> optionClass) { loadDefaultOptions(optionClass.getEnumConstants()); } @@ -602,13 +601,13 @@ * Load default given options. * * @param options options to load - * @param <O> type of enum extend {@link OptionDef} + * @param <O> type of enum extend {@link ConfigOptionDef} * @since 2.4.8 */ - public <O extends OptionDef> void loadDefaultOptions(O[] options) { + public <O extends ConfigOptionDef> void loadDefaultOptions(O[] options) { // load default option (included configuration file name : important) - for (OptionDef o : options) { + for (ConfigOptionDef o : options) { if (o.getDefaultValue() != null) { setDefaultOption(o.getKey(), o.getDefaultValue()); } @@ -616,14 +615,14 @@ } /** - * Load actions of enum pass in param (enum must extend {@link ActionDef}) + * Load actions of enum pass in param (enum must extend {@link ConfigActionDef}) * * @param actionClass to load - * @param <A> type of enum extend {@link ActionDef} - * @deprecated since 2.4.8, prefer use now {@link #loadActions(ActionDef[])} + * @param <A> type of enum extend {@link ConfigActionDef} + * @deprecated since 2.4.8, prefer use now {@link #loadActions(ConfigActionDef[])} */ @Deprecated - public <A extends ActionDef> void loadActions(Class<A> actionClass) { + public <A extends ConfigActionDef> void loadActions(Class<A> actionClass) { loadActions(actionClass.getEnumConstants()); } @@ -632,10 +631,10 @@ * Load given actions. * * @param actions actions to load - * @param <A> type of enum extend {@link ActionDef} + * @param <A> type of enum extend {@link ConfigActionDef} * @since 2.4.8 */ - public <A extends ActionDef> void loadActions(A[] actions) { + public <A extends ConfigActionDef> void loadActions(A[] actions) { // load actions for (A a : actions) { @@ -1168,7 +1167,7 @@ * @param key la clef de l'option à tester * @return {@code true} si 'loption existe, {@code false} sinon. */ - public boolean hasOption(OptionDef key) { + public boolean hasOption(ConfigOptionDef key) { boolean result = hasOption(key.getKey()); return result; } @@ -1398,7 +1397,7 @@ * @param key the definition of the option * @return the value for the given option */ - public Object getOption(OptionDef key) { + public Object getOption(ConfigOptionDef key) { Object result = getOption(key.getType(), key.getKey()); return result; } @@ -2421,192 +2420,6 @@ } /** - * Le contrat de marquage des options, on utilise cette interface pour - * caracteriser une option de configuration. - * <p/> - * <pre> - * public enum MyConfigOption implements OptionDef { - * - * APP_CONFIG_FILE( - * ApplicationConfig.CONFIG_FILE_NAME, - * "Main configuration app file", - * "myApp-config.properties", - * String.class, true, true), - * - * APP_NAME( - * ApplicationConfig.CONFIG_FILE_NAME, - * Application name, - * "MyApp", - * String.class, true, true); - * - * public String key; - * public String description; - * public String defaultValue; - * public Class<?> type; - * public boolean isTransient; - * public boolean isFinal; - * - * private WikittyConfigOption(String key, String description, - * String defaultValue, Class<?> type, boolean isTransient, boolean isFinal) { - * this.key = key; - * this.description = description; - * this.defaultValue = defaultValue; - * this.type = type; - * this.isTransient = isTransient; - * this.isFinal = isFinal; - * } - * - * @Override - * public boolean isFinal() { - * return isFinal; - * } - * - * @Override - * public boolean isTransient() { - * return isTransient; - * } - * - * @Override - * public String getDefaultValue() { - * return defaultValue; - * } - * - * @Override - * public String getDescription() { - * return description; - * } - * - * @Override - * public String getKey() { - * return key; - * } - * - * @Override - * public Class<?> getType() { - * return type; - * } - * - * @Override - * public void setDefaultValue(String defaultValue) { - * this.defaultValue = defaultValue; - * } - * - * @Override - * public void setTransient(boolean isTransient) { - * this.isTransient = isTransient; - * } - * - * @Override - * public void setFinal(boolean isFinal) { - * this.isFinal = isFinal; - * } - * } - * </pre> - * - * @since 1.0.0-rc-9 - */ - public interface OptionDef extends Serializable { - - /** @return la clef identifiant l'option */ - String getKey(); - - /** @return le type de l'option */ - Class<?> getType(); - - /** @return la clef i18n de description de l'option */ - String getDescription(); - - /** - * @return la valeur par defaut de l'option sous forme de chaine de - * caracteres - */ - String getDefaultValue(); - - /** - * @return <code>true</code> si l'option ne peut etre sauvegardee sur - * disque (utile par exemple pour les mots de passe, ...) - */ - boolean isTransient(); - - /** - * @return <code>true</code> si l'option n'est pas modifiable (utilise - * par exemple pour la version de l'application, ...) - */ - boolean isFinal(); - - /** - * Changes the default value of the option. - * - * @param defaultValue the new default value of the option - */ - void setDefaultValue(String defaultValue); - - /** - * Changes the transient state of the option. - * - * @param isTransient the new value of the transient state - */ - void setTransient(boolean isTransient); - - /** - * Changes the final state of the option. - * - * @param isFinal the new transient state value - */ - void setFinal(boolean isFinal); - } - - /** - * Le contrat de marquage des action, on utilise cette interface pour - * caracteriser une action. - * <p/> - * Ex : - * <p/> - * <pre> - * public enum MyAppConfigAction implements ActionDef { - * HELP(MyAppHelpAction.class.getName() + "#show", "-h", "--help"); - * public String action; - * public String[] aliases; - * - * private WikittyConfigAction(String action, String... aliases) { - * this.action = action; - * this.aliases = aliases; - * } - * - * @Override - * public String getAction() { - * return action; - * } - * - * @Override - * public String[] getAliases() { - * return aliases; - * } - * - * } - * </pre> - * - * @author sletellier - * @since 1.5.2 - */ - public interface ActionDef extends Serializable { - - /** - * Must return fully qualified method path : package.Class#method - * - * @return action to run - */ - String getAction(); - - /** - * Return all alias used to execute action. - * - * @return aliases used to execute action - */ - String[] getAliases(); - } - - /** * Defines a runtime action to be launched via the {@link #doAction()} * method. * Modified: trunk/nuiton-config/src/main/java/org/nuiton/util/config/ApplicationConfigHelper.java =================================================================== --- trunk/nuiton-config/src/main/java/org/nuiton/util/config/ApplicationConfigHelper.java 2013-02-26 15:30:54 UTC (rev 2520) +++ trunk/nuiton-config/src/main/java/org/nuiton/util/config/ApplicationConfigHelper.java 2013-03-03 15:20:18 UTC (rev 2521) @@ -131,7 +131,7 @@ provider.getName()); } if (log.isInfoEnabled()) { - for (ApplicationConfig.OptionDef optionDef : provider.getOptions()) { + for (ConfigOptionDef optionDef : provider.getOptions()) { log.info(" " + optionDef.getKey() + " (" + optionDef.getDefaultValue() + ')'); } @@ -145,13 +145,13 @@ * * @param providers providers to inspect * @return the set of all options that are transient - * @see ApplicationConfig.OptionDef#isTransient() + * @see ConfigOptionDef#isTransient() * @since 2.6.7 */ - public static Set<ApplicationConfig.OptionDef> getTransientOptions(Set<ApplicationConfigProvider> providers) { - Set<ApplicationConfig.OptionDef> result = new HashSet<ApplicationConfig.OptionDef>(); + public static Set<ConfigOptionDef> getTransientOptions(Set<ApplicationConfigProvider> providers) { + Set<ConfigOptionDef> result = new HashSet<ConfigOptionDef>(); for (ApplicationConfigProvider provider : providers) { - for (ApplicationConfig.OptionDef def : provider.getOptions()) { + for (ConfigOptionDef def : provider.getOptions()) { if (def.isTransient()) { result.add(def); } @@ -166,13 +166,13 @@ * * @param providers providers to inspect * @return the set of all options that are final - * @see ApplicationConfig.OptionDef#isFinal() + * @see ConfigOptionDef#isFinal() * @since 2.6.7 */ - public static Set<ApplicationConfig.OptionDef> getFinalOptions(Set<ApplicationConfigProvider> providers) { - Set<ApplicationConfig.OptionDef> result = new HashSet<ApplicationConfig.OptionDef>(); + public static Set<ConfigOptionDef> getFinalOptions(Set<ApplicationConfigProvider> providers) { + Set<ConfigOptionDef> result = new HashSet<ConfigOptionDef>(); for (ApplicationConfigProvider provider : providers) { - for (ApplicationConfig.OptionDef def : provider.getOptions()) { + for (ConfigOptionDef def : provider.getOptions()) { if (def.isFinal()) { result.add(def); } @@ -189,16 +189,16 @@ * * @param providers providers to inspect * @return the set of options key not to store in the config file - * @see ApplicationConfig.OptionDef#isFinal() - * @see ApplicationConfig.OptionDef#isTransient() + * @see ConfigOptionDef#isFinal() + * @see ConfigOptionDef#isTransient() * @since 2.6.7 */ public static Set<String> getTransientOrFinalOptionKey(Set<ApplicationConfigProvider> providers) { Set<String> result = new HashSet<String>(); - for (ApplicationConfig.OptionDef def : getTransientOptions(providers)) { + for (ConfigOptionDef def : getTransientOptions(providers)) { result.add(def.getKey()); } - for (ApplicationConfig.OptionDef def : getFinalOptions(providers)) { + for (ConfigOptionDef def : getFinalOptions(providers)) { result.add(def.getKey()); } return result; Modified: trunk/nuiton-config/src/main/java/org/nuiton/util/config/ApplicationConfigProvider.java =================================================================== --- trunk/nuiton-config/src/main/java/org/nuiton/util/config/ApplicationConfigProvider.java 2013-02-26 15:30:54 UTC (rev 2520) +++ trunk/nuiton-config/src/main/java/org/nuiton/util/config/ApplicationConfigProvider.java 2013-03-03 15:20:18 UTC (rev 2521) @@ -65,15 +65,15 @@ * Returns all options offered by the configuration. * * @return all options offered by the configuration - * @see ApplicationConfig.OptionDef + * @see ConfigOptionDef */ - ApplicationConfig.OptionDef[] getOptions(); + ConfigOptionDef[] getOptions(); /** * Returns all actions offered by the configuration. * * @return all actions offered by the configuration. - * @see ApplicationConfig.ActionDef + * @see ConfigActionDef */ - ApplicationConfig.ActionDef[] getActions(); + ConfigActionDef[] getActions(); } Added: trunk/nuiton-config/src/main/java/org/nuiton/util/config/ConfigActionDef.java =================================================================== --- trunk/nuiton-config/src/main/java/org/nuiton/util/config/ConfigActionDef.java (rev 0) +++ trunk/nuiton-config/src/main/java/org/nuiton/util/config/ConfigActionDef.java 2013-03-03 15:20:18 UTC (rev 2521) @@ -0,0 +1,78 @@ +package org.nuiton.util.config; + +/* + * #%L + * Nuiton Utils :: Nuiton Config + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 - 2013 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>. + * #L% + */ + +import java.io.Serializable; + +/** + * Le contrat de marquage des actions, on utilise cette interface pour + * caracteriser une action. + * <p/> + * Ex : + * <p/> + * <pre> + * public enum MyAppConfigAction implements ConfigActionDef { + * HELP(MyAppHelpAction.class.getName() + "#show", "-h", "--help"); + * public String action; + * public String[] aliases; + * + * private WikittyConfigAction(String action, String... aliases) { + * this.action = action; + * this.aliases = aliases; + * } + * + * @Override + * public String getAction() { + * return action; + * } + * + * @Override + * public String[] getAliases() { + * return aliases; + * } + * + * } + * </pre> + * + * @author sletellier + * @author tchemit <chemit@codelutin.com> + * @since 2.6.10 + */ +public interface ConfigActionDef extends Serializable { + + /** + * Must return fully qualified method path : package.Class#method + * + * @return action to run + */ + String getAction(); + + /** + * Return all alias used to execute action. + * + * @return aliases used to execute action + */ + String[] getAliases(); +} Property changes on: trunk/nuiton-config/src/main/java/org/nuiton/util/config/ConfigActionDef.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/nuiton-config/src/main/java/org/nuiton/util/config/ConfigOptionDef.java =================================================================== --- trunk/nuiton-config/src/main/java/org/nuiton/util/config/ConfigOptionDef.java (rev 0) +++ trunk/nuiton-config/src/main/java/org/nuiton/util/config/ConfigOptionDef.java 2013-03-03 15:20:18 UTC (rev 2521) @@ -0,0 +1,163 @@ +package org.nuiton.util.config; + +/* + * #%L + * Nuiton Utils :: Nuiton Config + * $Id$ + * $HeadURL:$ + * %% + * Copyright (C) 2011 - 2013 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>. + * #L% + */ + +import java.io.Serializable; + +/** + * Le contrat de marquage des options, on utilise cette interface pour + * caracteriser une option de configuration. + * <p/> + * <pre> + * public enum MyConfigOption implements ConfigOptionDef { + * + * APP_CONFIG_FILE( + * ApplicationConfig.CONFIG_FILE_NAME, + * "Main configuration app file", + * "myApp-config.properties", + * String.class, true, true), + * + * APP_NAME( + * ApplicationConfig.CONFIG_FILE_NAME, + * Application name, + * "MyApp", + * String.class, true, true); + * + * public String key; + * public String description; + * public String defaultValue; + * public Class<?> type; + * public boolean isTransient; + * public boolean isFinal; + * + * private WikittyConfigOption(String key, String description, + * String defaultValue, Class<?> type, boolean isTransient, boolean isFinal) { + * this.key = key; + * this.description = description; + * this.defaultValue = defaultValue; + * this.type = type; + * this.isTransient = isTransient; + * this.isFinal = isFinal; + * } + * + * @Override + * public boolean isFinal() { + * return isFinal; + * } + * + * @Override + * public boolean isTransient() { + * return isTransient; + * } + * + * @Override + * public String getDefaultValue() { + * return defaultValue; + * } + * + * @Override + * public String getDescription() { + * return description; + * } + * + * @Override + * public String getKey() { + * return key; + * } + * + * @Override + * public Class<?> getType() { + * return type; + * } + * + * @Override + * public void setDefaultValue(String defaultValue) { + * this.defaultValue = defaultValue; + * } + * + * @Override + * public void setTransient(boolean isTransient) { + * this.isTransient = isTransient; + * } + * + * @Override + * public void setFinal(boolean isFinal) { + * this.isFinal = isFinal; + * } + * } + * </pre> + * + * @since 1.0.0-rc-9 + */ +public interface ConfigOptionDef extends Serializable { + + /** @return la clef identifiant l'option */ + String getKey(); + + /** @return le type de l'option */ + Class<?> getType(); + + /** @return la clef i18n de description de l'option */ + String getDescription(); + + /** + * @return la valeur par defaut de l'option sous forme de chaine de + * caracteres + */ + String getDefaultValue(); + + /** + * @return <code>true</code> si l'option ne peut etre sauvegardee sur + * disque (utile par exemple pour les mots de passe, ...) + */ + boolean isTransient(); + + /** + * @return <code>true</code> si l'option n'est pas modifiable (utilise + * par exemple pour la version de l'application, ...) + */ + boolean isFinal(); + + /** + * Changes the default value of the option. + * + * @param defaultValue the new default value of the option + */ + void setDefaultValue(String defaultValue); + + /** + * Changes the transient state of the option. + * + * @param isTransient the new value of the transient state + */ + void setTransient(boolean isTransient); + + /** + * Changes the final state of the option. + * + * @param isFinal the new transient state value + */ + void setFinal(boolean isFinal); +} Property changes on: trunk/nuiton-config/src/main/java/org/nuiton/util/config/ConfigOptionDef.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Property changes on: trunk/nuiton-utils/src/main/java/org/nuiton/util/AliasMap.java ___________________________________________________________________ Added: svn:eol-style + native Property changes on: trunk/nuiton-utils/src/main/java/org/nuiton/util/SemVer.java ___________________________________________________________________ Added: svn:eol-style + native Property changes on: trunk/nuiton-utils/src/test/java/org/nuiton/util/AliasMapTest.java ___________________________________________________________________ Added: svn:eol-style + native Property changes on: trunk/nuiton-utils/src/test/java/org/nuiton/util/SemVerTest.java ___________________________________________________________________ Added: svn:eol-style + native Modified: trunk/nuiton-utils-maven-report-plugin/pom.xml =================================================================== --- trunk/nuiton-utils-maven-report-plugin/pom.xml 2013-02-26 15:30:54 UTC (rev 2520) +++ trunk/nuiton-utils-maven-report-plugin/pom.xml 2013-03-03 15:20:18 UTC (rev 2521) @@ -46,6 +46,12 @@ </dependency> <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>nuiton-config</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> <groupId>org.apache.maven</groupId> <artifactId>maven-project</artifactId> </dependency> Copied: trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/config/AbstractApplicationConfigReport.java (from rev 2512, trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/plugin/report/AbstractApplicationConfigReport.java) =================================================================== --- trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/config/AbstractApplicationConfigReport.java (rev 0) +++ trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/config/AbstractApplicationConfigReport.java 2013-03-03 15:20:18 UTC (rev 2521) @@ -0,0 +1,314 @@ +package org.nuiton.util.config; + +/* + * #%L + * Nuiton Utils :: Maven Report Plugin + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 - 2013 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>. + * #L% + */ + +import org.apache.maven.doxia.siterenderer.Renderer; +import org.apache.maven.plugins.annotations.Component; +import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.project.MavenProject; +import org.apache.maven.reporting.AbstractMavenReport; +import org.apache.maven.reporting.MavenReportException; +import org.codehaus.plexus.i18n.I18N; +import org.codehaus.plexus.util.StringUtils; +import org.nuiton.i18n.I18n; +import org.nuiton.i18n.init.ClassPathI18nInitializer; +import org.nuiton.i18n.init.DefaultI18nInitializer; +import org.nuiton.i18n.init.I18nInitializer; + +import java.io.File; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Locale; +import java.util.Set; + +/** + * Abstract application config report used by normal and aggregate report. + * + * @author tchemit <chemit@codelutin.com> + * @since 2.6.10 + */ +public abstract class AbstractApplicationConfigReport extends AbstractMavenReport { + + /** + * Report output directory. Note that this parameter is only relevant if the goal is run from the command line or + * from the default build lifecycle. If the goal is run indirectly as part of a site generation, the output + * directory configured in the Maven Site Plugin is used instead. + * + * @since 2.6.10 + */ + @Parameter(property = "config.outputDirectory", + defaultValue = "${project.reporting.outputDirectory}", + required = true) + protected File outputDirectory; + + /** + * Report output encoding. Note that this parameter is only relevant if the goal is run from the command line or + * from the default build lifecycle. If the goal is run indirectly as part of a site generation, the output + * encoding configured in the Maven Site Plugin is used instead. + * + * @since 2.6.10 + */ + @Parameter(property = "config.outputEncoding", + defaultValue = "${project.reporting.outputEncoding}", + required = true) + protected String outputEncoding; + + /** + * Optional i18n bundle name as used by the nuiton I18n system to init his + * files. + * <p/> + * If not given, will look at all i18n files in all over class-path (which + * could be costy if many dependencies), otherwise will init I18n system + * usinga {@link DefaultI18nInitializer} with this bundle name. + * + * @since 2.6.10 + */ + @Parameter(property = "config.i18nBundleName") + protected String i18nBundleName; + + /** + * List of application config to include in report (separated by comma). + * <p/> + * <strong>Note:</strong> If not filled then will use all config + * found in class-path. + * + * @since 2.6.10 + */ + @Parameter(property = "config.include") + protected String include; + + /** + * List of application config to exclude from report (separated by comma). + * <p/> + * <strong>Note:</strong> If not filled no config will be exclude. + * + * @since 2.6.10 + */ + @Parameter(property = "config.exclude") + protected String exclude; + + /** + * Flag to activate verbose mode. + * <p/> + * <b>Note:</b> Verbose mode is always on if you starts a debug maven instance + * (says via {@code -X}). + * + * @since 2.6.10 + */ + @Parameter(property = "config.verbose", defaultValue = "${maven.verbose}") + protected boolean verbose; + + /** + * Flag to render option in detail (add a section for each option). + * + * @since 2.6.10 + */ + @Parameter(property = "config.showOptionDetail", defaultValue = "true") + protected boolean showOptionDetail; + + /** + * Skip to generate the report. + * + * @since 2.6.10 + */ + @Parameter(property = "config.skip") + protected boolean skip; + + /** + * The Maven Project. + * + * @since 2.6.10 + */ + @Component + protected MavenProject project; + + + /** + * Doxia Site Renderer component. + * + * @since 2.6.10 + */ + @Component + protected Renderer siteRenderer; + + /** + * Internationalization component. + * + * @since 2.6.10 + */ + @Component + protected I18N i18n; + + /** + * Class loader with all compile dependencies of the module in class-path + * (used to init i18n) and obtain config provider over compile class-path. + * + * @since 2.6.10 + */ + protected ClassLoader newClassLoader; + + /** + * Set of ApplicationconfigProvider detected from configuration. + * + * @since 2.6.10 + */ + protected Set<ApplicationConfigProvider> configProviders; + + @Override + public String getOutputName() { + return "application-config-report"; + } + + public String getDescription(Locale locale) { + return i18n.getString(getOutputName(), locale, "report.description"); + } + + public String getName(Locale locale) { + return i18n.getString(getOutputName(), locale, "report.title"); + } + + @Override + public String getCategoryName() { + return CATEGORY_PROJECT_REPORTS; + } + + @Override + public boolean canGenerateReport() { + return !skip; + } + + @Override + protected Renderer getSiteRenderer() { + return siteRenderer; + } + + @Override + protected String getOutputDirectory() { + return outputDirectory.getAbsolutePath(); + } + + @Override + protected MavenProject getProject() { + return project; + } + + protected abstract ClassLoader createClassLoader() throws MavenReportException; + + @Override + protected void executeReport(Locale locale) throws MavenReportException { + + if (newClassLoader == null) { + + // not init + init(locale); + } else { + + // just change init language + I18n.setDefaultLocale(locale); + } + ApplicationConfigReportRenderer renderer = + new ApplicationConfigReportRenderer(getSink(), + i18n, + locale, + getOutputName(), + configProviders, + showOptionDetail); + renderer.render(); + } + + protected void init(Locale locale) throws MavenReportException { + if (getLog().isDebugEnabled()) { + + // debug mode set verbose flag to true + verbose = true; + } + + if (newClassLoader == null) { + + newClassLoader = createClassLoader(); + } + + // get i18n initializer + I18nInitializer initializer; + if (StringUtils.isNotEmpty(i18nBundleName)) { + initializer = new DefaultI18nInitializer(i18nBundleName, + newClassLoader); + } else { + initializer = new ClassPathI18nInitializer(newClassLoader); + } + // init i18n + I18n.init(initializer, locale); + + if (configProviders == null) { + + Set<String> includes = null; + if (StringUtils.isNotEmpty(include)) { + includes = new HashSet<String>(Arrays.asList(include.split("\\s*,\\s*"))); + if (verbose) { + getLog().info("config - includes : " + includes); + } + } + + Set<String> excludes = null; + if (StringUtils.isNotEmpty(exclude)) { + excludes = new HashSet<String>(Arrays.asList(exclude.split("\\s*,\\s*"))); + if (verbose) { + getLog().info("config - excludes : " + excludes); + } + } + + configProviders = ApplicationConfigHelper.getProviders( + newClassLoader, + includes, + excludes, + verbose + ); + } + } + + protected ClassLoader createClassLoader(Set<String> paths) { + + Set<URL> urls = new HashSet<URL>(); + + for (String fileName : paths) { + File pathElem = new File(fileName); + try { + URL url = pathElem.toURI().toURL(); + urls.add(url); + getLog().debug("Added classpathElement URL " + url); + } catch (MalformedURLException e) { + throw new RuntimeException( + "Error in adding the classpath " + pathElem, e); + } + } + + return new URLClassLoader( + urls.toArray(new URL[urls.size()]), + Thread.currentThread().getContextClassLoader()); + } +} Copied: trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/config/AggregateApplicationConfigReport.java (from rev 2512, trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/plugin/report/AggregateApplicationConfigReport.java) =================================================================== --- trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/config/AggregateApplicationConfigReport.java (rev 0) +++ trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/config/AggregateApplicationConfigReport.java 2013-03-03 15:20:18 UTC (rev 2521) @@ -0,0 +1,78 @@ +package org.nuiton.util.config; + +/* + * #%L + * Nuiton Utils :: Maven Report Plugin + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 - 2013 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>. + * #L% + */ + +import org.apache.maven.artifact.DependencyResolutionRequiredException; +import org.apache.maven.plugins.annotations.Execute; +import org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.plugins.annotations.ResolutionScope; +import org.apache.maven.project.MavenProject; +import org.apache.maven.reporting.MavenReportException; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +/** + * Generates a report for declarated application config via the + * {@link ApplicationConfigProvider} mecanism on a aggregate mojo. + * <p/> + * For each configuration, you can find all his options and actions. + * + * @author tchemit <chemit@codelutin.com> + * @since 2.6.10 + */ +@Mojo(name = "aggregate-config-report", aggregator = true, + requiresProject = true, requiresReports = true, + requiresDependencyResolution = ResolutionScope.RUNTIME) +@Execute(phase = LifecyclePhase.COMPILE) +public class AggregateApplicationConfigReport extends AbstractApplicationConfigReport { + + /** + * The projects in the reactor. + * + * @since 2.6.10 + */ + @Parameter(property = "reactorProjects", readonly = true, required = true) + protected List<?> reactorProjects; + + @Override + protected ClassLoader createClassLoader() throws MavenReportException { + Set<String> paths = new HashSet<String>(); + + for (Object o : reactorProjects) { + MavenProject p = (MavenProject) o; + try { + List runtimeClasspathElements = p.getRuntimeClasspathElements(); + paths.addAll(runtimeClasspathElements); + } catch (DependencyResolutionRequiredException e) { + throw new MavenReportException("Could not obtain dependencies for project " + p); + } + } + return createClassLoader(paths); + } +} Copied: trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/config/ApplicationConfigReport.java (from rev 2512, trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/plugin/report/ApplicationConfigReport.java) =================================================================== --- trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/config/ApplicationConfigReport.java (rev 0) +++ trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/config/ApplicationConfigReport.java 2013-03-03 15:20:18 UTC (rev 2521) @@ -0,0 +1,62 @@ +package org.nuiton.util.config; + +/* + * #%L + * Nuiton Utils :: Maven Report Plugin + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 - 2013 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>. + * #L% + */ + +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.plugins.annotations.ResolutionScope; + +import java.util.HashSet; +import java.util.List; + +/** + * Generates a report for declarated application config via the + * {@link ApplicationConfigProvider} mecanism. + * <p/> + * For each configuration, you can find all his options and actions. + * + * @author tchemit <chemit@codelutin.com> + * @since 2.6.10 + */ +@Mojo(name = "config-report", + requiresProject = true, requiresReports = true, + requiresDependencyResolution = ResolutionScope.RUNTIME) +public class ApplicationConfigReport extends AbstractApplicationConfigReport { + + /** + * List of all class-path elements. + * + * @since 2.6.10 + */ + @Parameter(property = "project.runtimeClasspathElements", + required = true, readonly = true) + protected List<String> runtimeClasspathElements; + + @Override + protected ClassLoader createClassLoader() { + return createClassLoader(new HashSet<String>(runtimeClasspathElements)); + } + +} Copied: trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/config/ApplicationConfigReportRenderer.java (from rev 2512, trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/plugin/report/ApplicationConfigReportRenderer.java) =================================================================== --- trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/config/ApplicationConfigReportRenderer.java (rev 0) +++ trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/config/ApplicationConfigReportRenderer.java 2013-03-03 15:20:18 UTC (rev 2521) @@ -0,0 +1,513 @@ +package org.nuiton.util.config; + +/* + * #%L + * Nuiton Utils :: Maven Report Plugin + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 - 2013 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>. + * #L% + */ + +import org.apache.commons.collections.CollectionUtils; +import org.apache.maven.doxia.sink.Sink; +import org.apache.maven.doxia.sink.SinkEventAttributeSet; +import org.apache.maven.reporting.AbstractMavenReportRenderer; +import org.codehaus.plexus.i18n.I18N; +import org.codehaus.plexus.util.StringUtils; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import java.util.Locale; +import java.util.Set; + +import static org.nuiton.i18n.I18n.l_; + +/** + * Render the {@link ApplicationConfigReport} report. + * + * @author tchemit <chemit@codelutin.com> + * @since 2.6.10 + */ +public class ApplicationConfigReportRenderer extends AbstractMavenReportRenderer { + + /** + * Internationalization component. + * + * @since 2.6.10 + */ + protected final I18N i18n; + + /** + * The locale we are rendering for. + * + * @since 2.6.10 + */ + protected final Locale locale; + + /** + * The name of the bundle containing our I18n resources. + * + * @since 2.6.10 + */ + protected final String bundleName; + + /** + * Set of config providers to generate. + * + * @since 2.6.10 + */ + protected final Set<ApplicationConfigProvider> configProviders; + + + /** + * To show option in detail. + * + * @since 2.6.10 + */ + protected final boolean optionWithDetail; + + public ApplicationConfigReportRenderer(Sink sink, + I18N i18n, + Locale locale, + String bundleName, + Set<ApplicationConfigProvider> configProviders, + boolean optionWithDetail) { + super(sink); + this.i18n = i18n; + this.locale = locale; + this.bundleName = bundleName; + this.sink = sink; + this.configProviders = configProviders; + this.optionWithDetail = optionWithDetail; + } + + @Override + public String getTitle() { + return getText("report.title"); + } + + @Override + public void renderBody() { + + sink.section1(); + sink.sectionTitle1(); + sink.text(getText("report.overview.title")); + sink.sectionTitle1_(); + sink.lineBreak(); + sink.paragraph(); + sink.text(getText("report.overview.text")); + sink.paragraph_(); + + sink.paragraph(); + sink.link("http://maven-site.nuiton.org/nuiton-utils/nuiton-utils/ApplicationConfig.htm..."); + sink.text(getText("report.overview.more.information")); + sink.link_(); + sink.paragraph_(); + sink.lineBreak(); + + renderProviderSummaryTable(); + + sink.section1_(); + + if (CollectionUtils.isNotEmpty(configProviders)) { + + sink.section1(); + sink.sectionTitle1(); + sink.text(getText("report.detail.title")); + sink.sectionTitle1_(); + sink.lineBreak(); + sink.paragraph(); + sink.text(getText("report.detail.text")); + sink.paragraph_(); + + for (ApplicationConfigProvider configProvider : configProviders) { + + renderConfigProviderDetail(configProvider); + } + + sink.section1_(); + } + } + + protected void renderProviderSummaryTable() { + + if (CollectionUtils.isEmpty(configProviders)) { + + sink.text(getText("report.detail.text.noConfig")); + + } else { + sink.table(); + + sink.tableRow(); + sinkHeaderCellText(getText("report.config.name")); + sinkHeaderCellText(getText("report.config.description")); + sinkHeaderCellText(getText("report.config.nbOptions")); + sinkHeaderCellText(getText("report.config.nbActions")); + sink.tableRow_(); + + for (ApplicationConfigProvider configProvider : configProviders) { + + sink.tableRow(); + sinkCellLink(configProvider.getName(), "./application-config-report.html#detail_" + configProvider.getName()); + sinkCellText(configProvider.getDescription(locale)); + sinkCellText(configProvider.getOptions().length + ""); + sinkCellText(configProvider.getActions().length + ""); + sink.tableRow_(); + } + sink.table_(); + } + } + + protected void renderConfigProviderDetail(ApplicationConfigProvider configProvider) { + + sink.section2(); + sink.sectionTitle2(); + sink.anchor("detail_" + configProvider.getName()); + sink.text(getText("report.detail.configuration.title") + " " + + configProvider.getName()); + sink.anchor_(); + sink.sectionTitle2_(); + + sink.lineBreak(); + sink.paragraph(); + sink.text(getText("report.config.name") + " : "); + sink.bold(); + sink.text(configProvider.getName()); + sink.bold_(); + sink.paragraph_(); + + sink.lineBreak(); + sink.paragraph(); + sink.text(getText("report.config.description") + " : "); + sink.bold(); + sink.text(configProvider.getDescription(locale)); + sink.bold_(); + sink.paragraph_(); + + sink.section3(); + sink.sectionTitle3(); + sink.anchor("detail_options_" + configProvider.getName()); + + sink.text(getText("report.detail.options.title")); + sink.anchor_(); + sink.sectionTitle3_(); + sink.lineBreak(); + + Collection<ConfigOptionDef> options = + getOptions(configProvider); + + renderOptionDefsTable(configProvider, options); + + if (optionWithDetail) { + + for (ConfigOptionDef option : options) { + + renderProviderOptionDetail(configProvider, option); + } + } + + sink.section3_(); + + sink.section3(); + sink.sectionTitle3(); + sink.text(getText("report.detail.actions.title")); + sink.sectionTitle3_(); + sink.lineBreak(); + + renderActionDefsTable(configProvider.getActions()); + + sink.section3_(); + + sink.section2_(); + } + + protected void renderOptionDefsTable(ApplicationConfigProvider configProvider, + Collection<ConfigOptionDef> options) { + + if (options.isEmpty()) { + + sink.paragraph(); + sink.bold(); + sink.text(getText("report.detail.options.noOptions")); + sink.bold_(); + sink.paragraph_(); + + } else { + + sink.table(); + sink.tableRow(); + + sinkHeaderCellText(getText("report.config.option.key")); + sinkHeaderCellText(getText("report.config.option.description")); + if (!optionWithDetail) { + sinkHeaderCellText(getText("report.config.option.type")); + } + sinkHeaderCellText(getText("report.config.option.defaultValue")); + + if (!optionWithDetail) { + sinkHeaderCellText(getText("report.config.option.final")); + sinkHeaderCellText(getText("report.config.option.transient")); + } + sink.tableRow_(); + + for (ConfigOptionDef option : options) { + + sink.tableRow(); + if (optionWithDetail) { + sinkCellLink( + option.getKey(), + "./application-config-report.html#detail_" + + configProvider.getName() + "_" + option.getKey()); + } else { + sinkCellText(option.getKey()); + } + sinkCellText(l_(locale, option.getDescription())); + if (!optionWithDetail) { + sinkCellText(option.getType().getName()); + } + sinkCellVerbatimText(getDefaultValue(option)); + if (!optionWithDetail) { + sinkCellText(getText(!option.isFinal())); + sinkCellText(getText(!option.isTransient())); + } + sink.tableRow_(); + } + + sink.table_(); + + } + } + + protected void renderActionDefsTable(ConfigActionDef... actions) { + + if (actions.length == 0) { + + sink.paragraph(); + sink.bold(); + sink.text(getText("report.detail.actions.noActions")); + sink.bold_(); + sink.paragraph_(); + + } else { + + sink.table(); + + sink.tableRow(); + sinkHeaderCellText(getText("report.config.action.action")); + sinkHeaderCellText(getText("report.config.action.aliases")); + sink.tableRow_(); + + for (ConfigActionDef action : actions) { + sink.tableRow(); + sinkCellText(action.getAction()); + sinkCellText(l_(locale, Arrays.toString(action.getAliases()))); + sink.tableRow_(); + } + + sink.table_(); + } + } + + protected void renderProviderOptionDetail(ApplicationConfigProvider configProvider, + ConfigOptionDef option) { + + final String cellWidth = "80%"; + final String headerWidth = "20%"; + + sink.section4(); + sink.sectionTitle4(); + sink.anchor("detail_" + configProvider.getName() + "_" + option.getKey()); + sink.text(getText("report.config.option.detail") + " '" + option.getKey() + + "'"); + sink.sectionTitle4_(); + sink.lineBreak(); + + sink.table(); + sink.tableRows(new int[]{Sink.JUSTIFY_RIGHT, Sink.JUSTIFY_LEFT}, false); + + sink.tableRow(); + sinkHeaderCellText(headerWidth, getText("report.config.option.key")); + sink.tableCell(cellWidth); + sink.nonBreakingSpace(); + sink.bold(); + sink.text(option.getKey()); + sink.bold_(); + sink.tableCell_(); + sink.tableRow_(); + + sink.tableRow(); + sinkHeaderCellText(headerWidth, getText("report.config.option.description")); + sink.tableCell(cellWidth); + sink.nonBreakingSpace(); + sink.text(l_(locale, option.getDescription())); + sink.tableCell_(); + sink.tableRow_(); + + sink.tableRow(); + sinkHeaderCellText(headerWidth, getText("report.config.option.defaultValue")); + sink.tableCell(cellWidth); + sink.nonBreakingSpace(); + sink.bold(); + sink.text(getDefaultValue(option)); + sink.bold_(); + sink.tableCell_(); + sink.tableRow_(); + + sink.tableRow(); + sinkHeaderCellText(headerWidth, getText("report.config.option.type")); + sink.tableCell(cellWidth); + sink.nonBreakingSpace(); + sink.text(option.getType().getName()); + sink.tableCell_(); + sink.tableRow_(); + + sink.tableRow(); + sinkHeaderCellText(headerWidth, getText("report.config.option.final")); + sink.tableCell(cellWidth); + sink.nonBreakingSpace(); + sink.text(getText(!option.isFinal())); + sink.tableCell_(); + sink.tableRow_(); + + sink.tableRow(); + sinkHeaderCellText(headerWidth, getText("report.config.option.transient")); + sink.tableCell(cellWidth); + sink.nonBreakingSpace(); + sink.text(getText(!option.isTransient())); + sink.tableCell_(); + sink.tableRow_(); + + sink.table_(); + + sink.paragraph(); + sink.link("./application-config-report.html#detail_options_" + configProvider.getName()); + sink.text(getText("report.back.options.table")); + sink.link_(); + sink.paragraph_(); + + sink.section4_(); + + } + + protected String getText(boolean key) { + return getText("report." + String.valueOf(key)); + } + + /** + * Gets the localized message for this report. + * + * @param key the message key. + * @return the message. + */ + protected String getText(String key) { + return i18n.getString(bundleName, locale, key); + } + + protected String getDefaultValue(ConfigOptionDef option) { + String defaultValue = option.getDefaultValue(); + if (StringUtils.isBlank(defaultValue)) { + defaultValue = getText("report.noDefaultValue"); + } + return defaultValue; + } + + protected void renderWarningIcon() { + sink.figure(); + sink.figureGraphics("images/icon_warning_sml.gif"); + sink.figure_(); + } + + protected void renderErrorIcon() { + sink.figure(); + sink.figureGraphics("images/icon_error_sml.gif"); + sink.figure_(); + } + + protected void renderSuccessIcon() { + sink.figure(); + sink.figureGraphics("images/icon_success_sml.gif"); + sink.figure_(); + } + + protected void renderInfoIcon() { + sink.figure(); + sink.figureGraphics("images/icon_info_sml.gif"); + sink.figure_(); + } + + protected void sinkHeaderCellText(String text) { + sink.tableHeaderCell(); + sink.text(text); + sink.tableHeaderCell_(); + } + + protected void sinkHeaderCellText(String width, String text) { + sink.tableHeaderCell(width); + sink.text(text); + sink.tableHeaderCell_(); + } + + protected void sinkCellText(String width, String text) { + sink.tableCell(width); + sink.text(text); + sink.tableCell_(); + } + + protected void sinkCellText(String text) { + sink.tableCell(); + sink.text(text); + sink.tableCell_(); + } + + protected void sinkCellVerbatimText(String text) { + sink.tableCell(); + sink.verbatim(SinkEventAttributeSet.MONOSPACED); + sink.text(text); + sink.verbatim_(); + sink.tableCell_(); + } + + protected void sinkCellLink(String text, String url) { + sink.tableCell(); + sink.link(url); + sink.text(text); + sink.link_(); + sink.tableCell_(); + } + + protected Collection<ConfigOptionDef> getOptions( + ApplicationConfigProvider configProvider) { + List<ConfigOptionDef> result = + new ArrayList<ConfigOptionDef>( + Arrays.asList(configProvider.getOptions())); + Collections.sort(result, new Comparator<ConfigOptionDef>() { + @Override + public int compare(ConfigOptionDef o1, + ConfigOptionDef o2) { + return o1.getKey().compareTo(o2.getKey()); + } + }); + return result; + } + +} Modified: trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/plugin/report/AbstractApplicationConfigReport.java =================================================================== --- trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/plugin/report/AbstractApplicationConfigReport.java 2013-02-26 15:30:54 UTC (rev 2520) +++ trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/plugin/report/AbstractApplicationConfigReport.java 2013-03-03 15:20:18 UTC (rev 2521) @@ -52,7 +52,9 @@ * * @author tchemit <chemit@codelutin.com> * @since 2.4.9 + * @deprecated since 2.6.10, use now {@link org.nuiton.util.config.AbstractApplicationConfigReport} */ +@Deprecated public abstract class AbstractApplicationConfigReport extends AbstractMavenReport { /** Modified: trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/plugin/report/AggregateApplicationConfigReport.java =================================================================== --- trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/plugin/report/AggregateApplicationConfigReport.java 2013-02-26 15:30:54 UTC (rev 2520) +++ trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/plugin/report/AggregateApplicationConfigReport.java 2013-03-03 15:20:18 UTC (rev 2521) @@ -45,11 +45,13 @@ * * @author tchemit <chemit@codelutin.com> * @since 2.4.9 + * @deprecated since 2.6.10, use now {@link org.nuiton.util.config.AggregateApplicationConfigReport} */ @Mojo(name = "aggregate-application-config-report", aggregator = true, requiresProject = true, requiresReports = true, requiresDependencyResolution = ResolutionScope.RUNTIME) @Execute(phase = LifecyclePhase.COMPILE) +@Deprecated public class AggregateApplicationConfigReport extends AbstractApplicationConfigReport { /** Modified: trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/plugin/report/ApplicationConfigReport.java =================================================================== --- trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/plugin/report/ApplicationConfigReport.java 2013-02-26 15:30:54 UTC (rev 2520) +++ trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/plugin/report/ApplicationConfigReport.java 2013-03-03 15:20:18 UTC (rev 2521) @@ -40,10 +40,12 @@ * * @author tchemit <chemit@codelutin.com> * @since 2.4.8 + * @deprecated since 2.6.10, use now {@link org.nuiton.util.config.ApplicationConfigReport} */ @Mojo(name = "application-config-report", requiresProject = true, requiresReports = true, requiresDependencyResolution = ResolutionScope.RUNTIME) +@Deprecated public class ApplicationConfigReport extends AbstractApplicationConfigReport { /** Modified: trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/plugin/report/ApplicationConfigReportRenderer.java =================================================================== --- trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/plugin/report/ApplicationConfigReportRenderer.java 2013-02-26 15:30:54 UTC (rev 2520) +++ trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/plugin/report/ApplicationConfigReportRenderer.java 2013-03-03 15:20:18 UTC (rev 2521) @@ -49,7 +49,9 @@ * * @author tchemit <chemit@codelutin.com> * @since 2.4.8 + * @deprecated since 2.6.10, use now {@link org.nuiton.util.config.ApplicationConfigReportRenderer} */ +@Deprecated public class ApplicationConfigReportRenderer extends AbstractMavenReportRenderer { /**
participants (1)
-
tchemit@users.nuiton.org