r835 - in trunk: eugene/src/main/java/org/nuiton/eugene/writer maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/writer
Author: tchemit Date: 2010-03-04 19:03:17 +0100 (Thu, 04 Mar 2010) New Revision: 835 Log: - improve javadoc - reformat code (80 car max per line) Modified: trunk/eugene/src/main/java/org/nuiton/eugene/writer/AbstractChainedFileWriter.java trunk/eugene/src/main/java/org/nuiton/eugene/writer/ChainedFileWriter.java trunk/eugene/src/main/java/org/nuiton/eugene/writer/ChainedFileWriterConfiguration.java trunk/eugene/src/main/java/org/nuiton/eugene/writer/ChainedFileWriterEntry.java trunk/eugene/src/main/java/org/nuiton/eugene/writer/ChainedWriterEngine.java trunk/eugene/src/main/java/org/nuiton/eugene/writer/DefaultChainedWriterEngine.java trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/AvailableDataMojo.java trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/CopyVersionFiles.java trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/EugeneAbstractMojo.java trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/EugenePlugin.java trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/SmartGenerateMojo.java trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/Xmi2Model.java trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/Xmi2ObjectModel.java trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/Xmi2StateModel.java trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/Zargo2Xmi.java trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/writer/BaseChainedFileWriter.java trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/writer/ModelChainedFileWriter.java trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/writer/XmiChainedFileWriter.java trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/writer/ZargoChainedFileWriter.java Modified: trunk/eugene/src/main/java/org/nuiton/eugene/writer/AbstractChainedFileWriter.java =================================================================== --- trunk/eugene/src/main/java/org/nuiton/eugene/writer/AbstractChainedFileWriter.java 2010-03-04 16:44:13 UTC (rev 834) +++ trunk/eugene/src/main/java/org/nuiton/eugene/writer/AbstractChainedFileWriter.java 2010-03-04 18:03:17 UTC (rev 835) @@ -22,7 +22,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.nuiton.eugene.models.Model; import java.io.File; import java.io.IOException; @@ -35,42 +34,45 @@ * @since 2.0.0 */ public abstract class AbstractChainedFileWriter implements ChainedFileWriter { - /** - * Logger - */ - private static final Log log = LogFactory.getLog(AbstractChainedFileWriter.class); - /** - * entries to treate with this writer - */ + /** Logger */ + private static final Log log = + LogFactory.getLog(AbstractChainedFileWriter.class); + /** entries to treate with this writer */ protected List<ChainedFileWriterEntry> entries; - /** - * previous writer (can be null) - */ + /** previous writer (can be null) */ protected ChainedFileWriter previousWriter; - /** - * next writer (can be null) - */ + /** next writer (can be null) */ protected ChainedFileWriter nextWriter; /** - * universe of authorized properties (keys are property names, values are property descriptions). + * universe of authorized properties (keys are property names, values are + * property descriptions). */ protected final Map<String, String> authorizedPropertyDescriptions; /** - * real properties obtained fro a configuration in {@link #initWriter(ChainedFileWriterConfiguration)} method + * real properties obtained fro a configuration in {@link + * #initWriter(ChainedFileWriterConfiguration)} method */ protected Map<String, Object> properties; protected AbstractChainedFileWriter(String... propertyNameAndDescriptions) { if (propertyNameAndDescriptions.length % 2 != 0) { - throw new IllegalArgumentException("propertyNameAndDescriptions must be couple of (property key, property description), but was " + Arrays.toString(propertyNameAndDescriptions)); + throw new IllegalArgumentException( + "propertyNameAndDescriptions must be couple of " + + "(property key, property description), but was " + + Arrays.toString(propertyNameAndDescriptions)); } entries = new ArrayList<ChainedFileWriterEntry>(); properties = new TreeMap<String, Object>(); - Map<String, String> authorizedPropertyDescriptions = new TreeMap<String, String>(); - for (int i = 0, max = propertyNameAndDescriptions.length / 2; i < max; i++) { - authorizedPropertyDescriptions.put(propertyNameAndDescriptions[2 * i], propertyNameAndDescriptions[2 * i + 1]); + Map<String, String> authorizedPropertyDescriptions = + new TreeMap<String, String>(); + for (int i = 0, max = propertyNameAndDescriptions.length / 2; + i < max; i++) { + authorizedPropertyDescriptions.put( + propertyNameAndDescriptions[2 * i], + propertyNameAndDescriptions[2 * i + 1]); } - this.authorizedPropertyDescriptions = Collections.unmodifiableMap(authorizedPropertyDescriptions); + this.authorizedPropertyDescriptions = + Collections.unmodifiableMap(authorizedPropertyDescriptions); } /** @@ -82,7 +84,11 @@ * @param includePattern pattern of files to include * @throws IOException for any IO pb. */ - protected abstract void generate(ChainedFileWriterConfiguration configuration, File outputDir, File inputDirectory, String includePattern) throws IOException; + protected abstract void generate( + ChainedFileWriterConfiguration configuration, + File outputDir, + File inputDirectory, + String includePattern) throws IOException; @Override public Map<String, String> getAuthorizedPropertyDescriptions() { @@ -113,30 +119,43 @@ } @Override - public void generate(ChainedFileWriterConfiguration configuration) throws IOException { + public void generate(ChainedFileWriterConfiguration configuration) + throws IOException { if (log.isDebugEnabled()) { - log.debug("[" + getInputProtocol() + "] Start generate with writer " + this); + log.debug("[" + getInputProtocol() + + "] Start generate with writer " + this); } initWriter(configuration); try { - File outputDir = getOutputDirectory(configuration.getOutputDirectory(), configuration.isTestPhase()); + File outputDir = getOutputDirectory( + configuration.getOutputDirectory(), + configuration.isTestPhase() + ); if (!outputDir.exists()) { if (log.isDebugEnabled()) { - log.debug("[" + getInputProtocol() + "] Create output directory " + outputDir); + log.debug("[" + getInputProtocol() + + "] Create output directory " + outputDir); } boolean b = outputDir.mkdirs(); if (!b) { - throw new IOException("Could not creat directory " + outputDir); + throw new IOException("Could not creat directory " + + outputDir); } } for (ChainedFileWriterEntry e : entries) { if (log.isDebugEnabled()) { - log.debug("[" + getInputProtocol() + "] Will generate entry " + e.getInputDirectory() + " : " + e.getIncludePattern()); + log.debug("[" + getInputProtocol() + + "] Will generate entry " + e.getInputDirectory() + + " : " + e.getIncludePattern()); } - generate(configuration, outputDir, e.getInputDirectory(), e.getIncludePattern()); + generate(configuration, + outputDir, + e.getInputDirectory(), + e.getIncludePattern() + ); } } finally { clear(); @@ -151,7 +170,10 @@ @Override public File getOutputDirectory(File outputBasedir, boolean testPhase) { - return new File(outputBasedir, testPhase ? getDefaultTestOutputDirectory() : getDefaultOutputDirectory()); + return new File(outputBasedir, testPhase ? + getDefaultTestOutputDirectory() : + getDefaultOutputDirectory() + ); } @Override @@ -180,11 +202,12 @@ Map<String, Object> map = configuration.getProperties(); for (String key : getAuthorizedPropertyNames()) { - //TODO-TC-20091217, should prefix keys by the inputProtocol to avoid collisions ? + //TODO-TC-20091217, should prefix keys by the inputProtocol to + //TODO-TC-20091217 avoid collisions ? if (map.containsKey(key)) { // keep this property properties.put(key, map.get(key)); } } } -} \ No newline at end of file +} Modified: trunk/eugene/src/main/java/org/nuiton/eugene/writer/ChainedFileWriter.java =================================================================== --- trunk/eugene/src/main/java/org/nuiton/eugene/writer/ChainedFileWriter.java 2010-03-04 16:44:13 UTC (rev 834) +++ trunk/eugene/src/main/java/org/nuiton/eugene/writer/ChainedFileWriter.java 2010-03-04 18:03:17 UTC (rev 835) @@ -24,33 +24,34 @@ import java.io.IOException; import java.util.List; import java.util.Map; +import java.util.regex.Matcher; /** - * Contract to generate files from any incoming sources (zargo, xmi, ...) to any other ones. + * Contract to generate files from any incoming sources (zargo, xmi, ...) to any + * other ones. * <p/> - * User: chemit - * Date: 27 nov. 2009 - * Time: 11:20:39 + * User: chemit Date: 27 nov. 2009 Time: 11:20:39 * * @since 2.0.0 */ public interface ChainedFileWriter { - /** - * @return the accepted incoming protocol - */ + /** @return the accepted incoming protocol */ String getInputProtocol(); /** - * Obtain the input protocol of this writer given the passed {@code modelType}. + * Obtain the input protocol of this writer given the passed {@code + * modelType}. * * @param modelType the type of model used - * @return the input protocol or {@code null} if this writer does not accept the type of model + * @return the input protocol or {@code null} if this writer does not accept + * the type of model */ String getInputProtocol(String modelType); /** - * Obtain the output protocol of this writer given the passed {@code modelType}. + * Obtain the output protocol of this writer given the passed {@code + * modelType}. * * @param modelType the type of model used * @return the output protocol or {@code null} if should not be chained @@ -61,7 +62,8 @@ * Test if a type of model can be treated by this writer. * * @param modelType model type to test - * @return {@code true} if this writer accept the given type of model, {@code false} otherwise. + * @return {@code true} if this writer accept the given type of model, + * {@code false} otherwise. */ boolean acceptModel(String modelType); @@ -69,32 +71,32 @@ * Test in a entry can be treated by this writer. * * @param include the include to test - * @return {@code true} if the writer accept the entry, {@code false} otherwise. + * @return {@code true} if the writer accept the entry, {@code false} + * otherwise. */ boolean acceptInclude(String include); /** - * @return the default includes files to be treated by the writer (can be an ant-like expression) + * @return the default includes files to be treated by the writer (can be an + * ant-like expression) */ String getDefaultIncludes(); - /** - * @return the defalt relative path where to pick files to treate. - */ + /** @return the defalt relative path where to pick files to treate. */ String getDefaultInputDirectory(); /** - * @return the defalt relative path where to pick files to treate on a test phase. + * @return the defalt relative path where to pick files to treate on a test + * phase. */ String getDefaultTestInputDirectory(); - /** - * @return the default relative path to add to output basedir - */ + /** @return the default relative path to add to output basedir */ String getDefaultOutputDirectory(); /** - * @return the default relative path to add to output basedir on a test phase. + * @return the default relative path to add to output basedir on a test + * phase. */ String getDefaultTestOutputDirectory(); @@ -105,7 +107,8 @@ * * @param outputBasedir the output base directory * @param testPhase {@code true} if writer is used in a test phase - * @return the real output directory where to generate for this particular writer + * @return the real output directory where to generate for this particular + * writer */ File getOutputDirectory(File outputBasedir, boolean testPhase); @@ -115,11 +118,10 @@ * @param configuration the share configuration of all writers. * @throws IOException if any io pb. */ - void generate(ChainedFileWriterConfiguration configuration) throws IOException; + void generate(ChainedFileWriterConfiguration configuration) + throws IOException; - /** - * Clear all internal states - */ + /** Clear all internal states */ void clear(); /** @@ -129,14 +131,12 @@ */ void addEntry(ChainedFileWriterEntry entry); - /** - * @return the array of properties names authorized for the chanied writer. - */ + /** @return the array of properties names authorized for the chanied writer. */ String[] getAuthorizedPropertyNames(); /** - * @return the dictionnary of authorized property descriptions (keys are property names and - * values are descriptions). + * @return the dictionnary of authorized property descriptions (keys are + * property names and values are descriptions). */ Map<String, String> getAuthorizedPropertyDescriptions(); @@ -150,8 +150,6 @@ */ <T> T getProperty(String key, Class<T> type); - /** - * @return the list of all entries registered - */ + /** @return the list of all entries registered */ List<ChainedFileWriterEntry> getEntries(); } Modified: trunk/eugene/src/main/java/org/nuiton/eugene/writer/ChainedFileWriterConfiguration.java =================================================================== --- trunk/eugene/src/main/java/org/nuiton/eugene/writer/ChainedFileWriterConfiguration.java 2010-03-04 16:44:13 UTC (rev 834) +++ trunk/eugene/src/main/java/org/nuiton/eugene/writer/ChainedFileWriterConfiguration.java 2010-03-04 18:03:17 UTC (rev 835) @@ -27,83 +27,57 @@ import java.util.Map; /** - * Shared configuration of a {@link ChainedFileWriter}, should be the same for all writers - * to use at a time. + * Shared configuration of a {@link ChainedFileWriter}, should be the same for + * all writers to use at a time. * * @author tchemit * @since 2.0.0 */ public interface ChainedFileWriterConfiguration { - /** - * @return the type of model used - */ + /** @return the type of model used */ String getModelType(); -// /** -// * @return the type of model used -// */ -// Class<? extends Model> getModelClass(); - - /** - * @return project base directory - */ + /** @return project base directory */ File getBasedir(); - /** - * @return base directory where to generate - */ + /** @return base directory where to generate */ File getOutputDirectory(); /** - * @return {@code true} if must regenerate files even if they are up to date + * @return {@code true} if must regenerate files even if they are up to + * date */ boolean isOverwrite(); /** - * @return {@code true} if build is off-line and should not be able to access outside resources. + * @return {@code true} if build is off-line and should not be able to + * access outside resources. */ boolean isOffline(); - /** - * @return {@code true} if build is verbose. - */ + /** @return {@code true} if build is verbose. */ boolean isVerbose(); - /** - * @return {@code true} if build is done on a test phase. - */ + /** @return {@code true} if build is done on a test phase. */ boolean isTestPhase(); - /** - * @return encoding to use to read and write files - */ + /** @return encoding to use to read and write files */ String getEncoding(); - /** - * @return the universe of availables writers - */ + /** @return the universe of availables writers */ Map<String, ChainedFileWriter> getWriters(); - /** - * @return the universe of available model readers - */ + /** @return the universe of available model readers */ Map<String, ModelReader<?>> getModelReaders(); - /** - * @return the universe of available model templates - */ + /** @return the universe of available model templates */ Map<String, Template<?>> getModelTemplates(); - /** - * @return properties to pass to writers - */ + /** @return properties to pass to writers */ Map<String, Object> getProperties(); - /** - * - * @return the classloader to use to seek for resources - */ + /** @return the classloader to use to seek for resources */ ClassLoader getClassLoader(); } Modified: trunk/eugene/src/main/java/org/nuiton/eugene/writer/ChainedFileWriterEntry.java =================================================================== --- trunk/eugene/src/main/java/org/nuiton/eugene/writer/ChainedFileWriterEntry.java 2010-03-04 16:44:13 UTC (rev 834) +++ trunk/eugene/src/main/java/org/nuiton/eugene/writer/ChainedFileWriterEntry.java 2010-03-04 18:03:17 UTC (rev 835) @@ -3,16 +3,26 @@ import java.io.File; /** + * Definition of of the chained writer entry. + * + * Created: 04 mars. 2010 * + * @author Tony Chemit <chemit@codelutin.com> Copyright Code Lutin + * @version $Revision$ + * <p/> + * Mise a jour: $Date$ + * par : $Author: tchemit $ + * @since 2.0.0 + * */ public class ChainedFileWriterEntry { /** - * + * input directory of entry */ protected File inputDirectory; /** - * + * include pattern of entry */ protected String includePattern; Modified: trunk/eugene/src/main/java/org/nuiton/eugene/writer/ChainedWriterEngine.java =================================================================== --- trunk/eugene/src/main/java/org/nuiton/eugene/writer/ChainedWriterEngine.java 2010-03-04 16:44:13 UTC (rev 834) +++ trunk/eugene/src/main/java/org/nuiton/eugene/writer/ChainedWriterEngine.java 2010-03-04 18:03:17 UTC (rev 835) @@ -9,36 +9,105 @@ * <p/> * You can register inputs via the method {@link #registerInclude(String)}. * <p/> - * And later obtain of the selected writers for your inputs via the method {@link #getSelectedWriters()}. + * And later obtain of the selected writers for your inputs via the method + * {@link #getSelectedWriters()}. * <p/> * Created: 17 déc. 2009 * * @author Tony Chemit <chemit@codelutin.com> Copyright Code Lutin * @version $Revision$ * <p/> - * Mise a jour: $Date$ par : - * $Author: tchemit $ + * Mise a jour: $Date$ + * par : $Author: tchemit $ * @since 2.0.0 */ public interface ChainedWriterEngine { + /** + * Register in engine a new input source. + * <p/> + * this method will detects writers to register and chain them if + * necessary. + * + * @param include the new include to digest + */ + void registerInclude(String include); + /** @return the common configuration of engine */ ChainedFileWriterConfiguration getConfiguration(); + /** + * Sets the common configuration. + * + * @param configuration the new configuration ot use. + */ void setConfiguration(ChainedFileWriterConfiguration configuration); + /** @return the set of all available writers discovered at runtime */ Set<ChainedFileWriter> getAvailableWriters(); + /** @return the list of selected writers after having registred some inputs. */ List<ChainedFileWriter> getSelectedWriters(); + /** + * Tests if there is a selected writer using the given input protocol. + * + * @param inputProtocol the inputProtocol to test + * @return {@code true} if there is a selected writer using this input + * protocol + * @see ChainedFileWriter#getInputProtocol() + * @see #getSelectedWriters() + */ boolean containsWriter(String inputProtocol); - Set<ChainedFileWriter> filterWriterForModelType(Map<String, ChainedFileWriter> universe, String modelType); + /** + * Filter the given {@code universe} of writers which accept the given + * {@code modelType}. + * + * @param universe the list of writers to filter + * @param modelType the accepted model type + * @return the set of filtered writers + * @see ChainedFileWriter#acceptModel(String) + */ + Set<ChainedFileWriter> filterWriterForModelType( + Map<String, ChainedFileWriter> universe, + String modelType); - ChainedFileWriter getWriterForInputProtocol(Set<ChainedFileWriter> universe, String inputProtocol, String modelType); + /** + * Filter the given {@code universe} of writers which accept the given + * {@code modelType} and {@code inputProtocol}. + * + * @param universe the list of writers to filter + * @param inputProtocol the accepted input protocol + * @param modelType the accepted model type + * @return the set of filtered writers + * @see ChainedFileWriter#acceptModel(String) + * @see ChainedFileWriter#getInputProtocol() + * @see ChainedFileWriter#getInputProtocol(String) + */ + ChainedFileWriter getWriterForInputProtocol( + Set<ChainedFileWriter> universe, + String inputProtocol, + String modelType); - ChainedFileWriter getWriterForInclude(Set<ChainedFileWriter> universe, String include, String modelType); + /** + * Filter the given {@code universe} of writers which accept the given + * {@code modelType} and {@code include}. + * <p/> + * The include can have several forms : <ul> <li></li> <li></li> </ul> + * + * @param universe the list of writers to filter + * @param include the include configuration + * @param modelType the accepted model type + * @return the set of filtered writers + * @see ChainedFileWriter#acceptModel(String) + * @see ChainedFileWriter#getInputProtocol() + * @see ChainedFileWriter#getInputProtocol(String) + */ + ChainedFileWriter getWriterForInclude( + Set<ChainedFileWriter> universe, + String include, + String modelType); - void registerInclude(String include); - + /** clean internal states */ void clear(); } Modified: trunk/eugene/src/main/java/org/nuiton/eugene/writer/DefaultChainedWriterEngine.java =================================================================== --- trunk/eugene/src/main/java/org/nuiton/eugene/writer/DefaultChainedWriterEngine.java 2010-03-04 16:44:13 UTC (rev 834) +++ trunk/eugene/src/main/java/org/nuiton/eugene/writer/DefaultChainedWriterEngine.java 2010-03-04 18:03:17 UTC (rev 835) @@ -26,7 +26,8 @@ /** * Logger */ - private static final Log log = LogFactory.getLog(DefaultChainedWriterEngine.class); + private static final Log log = + LogFactory.getLog(DefaultChainedWriterEngine.class); /** * shared configuration */ @@ -73,7 +74,10 @@ public Set<ChainedFileWriter> getAvailableWriters() { if (availableWriters == null) { checkConfiguration("getAvailableWriters"); - availableWriters = filterWriterForModelType(getConfiguration().getWriters(), getConfiguration().getModelType()); + availableWriters = filterWriterForModelType( + getConfiguration().getWriters(), + getConfiguration().getModelType() + ); } return availableWriters; } @@ -94,7 +98,8 @@ // obtain the good type of entry and the corresponding matcher - for (ModelFileWriterEntryType type : ModelFileWriterEntryType.values()) { + for (ModelFileWriterEntryType type : + ModelFileWriterEntryType.values()) { matcher = type.getMatcher(include); if (matcher != null) { // get a matcher @@ -105,15 +110,18 @@ if (selectedType == null) { // no writer - throw new IllegalArgumentException("could not find a writer for include pattern : " + include); + throw new IllegalArgumentException("could not find a writer for " + + "include pattern : " + include); } // obtain the writer - ChainedFileWriter writer = selectedType.getWriter(this, include, matcher); + ChainedFileWriter writer = + selectedType.getWriter(this, include, matcher); // create the new entry - ChainedFileWriterEntry writerEntry = selectedType.newEntry(this, include, matcher, writer); + ChainedFileWriterEntry writerEntry = + selectedType.newEntry(this, include, matcher, writer); // register the new entry @@ -143,17 +151,26 @@ // the writer need the includes of another writer if (log.isDebugEnabled()) { - log.debug("[" + include + "]" + " writer " + writer.getClass().getSimpleName() + " require a next writer of protocol " + outpoutProtocol); + log.debug("[" + include + "]" + " writer " + + writer.getClass().getSimpleName() + + " require a next writer of protocol " + outpoutProtocol); } - ChainedFileWriter nextWriter = ((AbstractChainedFileWriter) writer).getNextWriter(); + ChainedFileWriter nextWriter = + ((AbstractChainedFileWriter) writer).getNextWriter(); if (nextWriter == null) { // the next writer was not initialize, just have to add new entry - nextWriter = getWriterForInputProtocol(getAvailableWriters(), outpoutProtocol, modelType); + nextWriter = getWriterForInputProtocol( + getAvailableWriters(), + outpoutProtocol, + modelType + ); if (nextWriter == null) { - throw new IllegalArgumentException("could not find a writer for protocole " + outpoutProtocol + " on model " + modelType); + throw new IllegalArgumentException( + "could not find a writer for protocole " + + outpoutProtocol + " on model " + modelType); } // chain writer ((AbstractChainedFileWriter) writer).setNextWriter(nextWriter); @@ -163,11 +180,14 @@ String basedirpath = configuration.getBasedir().getAbsolutePath(); - String outputpath = writer.getOutputDirectory(configuration.getOutputDirectory(), configuration.isTestPhase()).getAbsolutePath(); + String outputpath = writer.getOutputDirectory( + configuration.getOutputDirectory(), + configuration.isTestPhase()).getAbsolutePath(); String path = outputpath.substring(basedirpath.length() + 1); - String newInclude = outpoutProtocol + ":" + path + ":" + nextWriter.getDefaultIncludes(); + String newInclude = outpoutProtocol + ":" + path + ":" + + nextWriter.getDefaultIncludes(); registerInclude(newInclude); @@ -193,7 +213,8 @@ } @Override - public Set<ChainedFileWriter> filterWriterForModelType(Map<String, ChainedFileWriter> universe, String modelType) { + public Set<ChainedFileWriter> filterWriterForModelType( + Map<String, ChainedFileWriter> universe, String modelType) { Set<ChainedFileWriter> result = new HashSet<ChainedFileWriter>(); for (ChainedFileWriter w : universe.values()) { if (w.acceptModel(modelType)) { @@ -207,7 +228,10 @@ } @Override - public ChainedFileWriter getWriterForInputProtocol(Set<ChainedFileWriter> universe, String inputProtocol, String modelType) { + public ChainedFileWriter getWriterForInputProtocol( + Set<ChainedFileWriter> universe, + String inputProtocol, + String modelType) { for (ChainedFileWriter writer : universe) { if (inputProtocol.equals(writer.getInputProtocol(modelType))) { return writer; @@ -217,7 +241,10 @@ } @Override - public ChainedFileWriter getWriterForInclude(Set<ChainedFileWriter> universe, String include, String modelType) { + public ChainedFileWriter getWriterForInclude( + Set<ChainedFileWriter> universe, + String include, + String modelType) { for (ChainedFileWriter w : universe) { if (w.acceptInclude(include)) { return w; @@ -226,9 +253,11 @@ return null; } - protected void checkConfiguration(String method) throws IllegalStateException { + protected void checkConfiguration(String method) + throws IllegalStateException { if (getConfiguration() == null) { - throw new IllegalStateException("can not acces to " + method + "before configuration is set!"); + throw new IllegalStateException("can not acces to " + method + + "before configuration is set!"); } } @@ -240,30 +269,50 @@ ONLY_PROTOCOL_PATTERN(Pattern.compile("^([a-zA-Z]+)$")) { @Override - public ChainedFileWriter getWriter(ChainedWriterEngine engine, String include, Matcher matcher) { - ChainedFileWriterConfiguration configuration = engine.getConfiguration(); + public ChainedFileWriter getWriter(ChainedWriterEngine engine, + String include, + Matcher matcher) { + ChainedFileWriterConfiguration configuration = + engine.getConfiguration(); Set<ChainedFileWriter> universe = engine.getAvailableWriters(); String protocol = matcher.group(1).toLowerCase(); - ChainedFileWriter writer = engine.getWriterForInputProtocol(universe, protocol, configuration.getModelType()); + ChainedFileWriter writer = engine.getWriterForInputProtocol( + universe, + protocol, + configuration.getModelType() + ); if (writer == null) { - throw new IllegalArgumentException("could not find the writer named '" + protocol + "', use one of " + universe); + throw new IllegalArgumentException( + "could not find the writer named '" + protocol + + "', use one of " + universe); } if (log.isDebugEnabled()) { - log.debug("[" + include + "] " + "writer = (" + writer + ")"); + log.debug("[" + include + "] " + "writer = (" + writer + + ")"); } return writer; } @Override - public ChainedFileWriterEntry newEntry(ChainedWriterEngine engine, String include, Matcher matcher, ChainedFileWriter writer) { - ChainedFileWriterConfiguration configuration = engine.getConfiguration(); + public ChainedFileWriterEntry newEntry( + ChainedWriterEngine engine, + String include, + Matcher matcher, + ChainedFileWriter writer) { + ChainedFileWriterConfiguration configuration = + engine.getConfiguration(); if (log.isDebugEnabled()) { - log.debug("[" + include + "] " + "detected pattern (" + name() + ")"); + log.debug("[" + include + "] " + "detected pattern (" + + name() + ")"); } ChainedFileWriterEntry writerEntry = new ChainedFileWriterEntry( - new File(configuration.getBasedir(), configuration.isTestPhase() ? writer.getDefaultTestInputDirectory() : writer.getDefaultInputDirectory()), + new File(configuration.getBasedir(), + configuration.isTestPhase() ? + writer.getDefaultTestInputDirectory() : + writer.getDefaultInputDirectory() + ), writer.getDefaultIncludes() ); return writerEntry; @@ -272,8 +321,11 @@ NO_PROTOCOL_PATTERN(Pattern.compile("^([^:]+):([^:]+)$")) { @Override - public ChainedFileWriter getWriter(ChainedWriterEngine engine, String include, Matcher matcher) { - ChainedFileWriterConfiguration configuration = engine.getConfiguration(); + public ChainedFileWriter getWriter(ChainedWriterEngine engine, + String include, + Matcher matcher) { + ChainedFileWriterConfiguration configuration = + engine.getConfiguration(); Set<ChainedFileWriter> universe = engine.getAvailableWriters(); String modelType = configuration.getModelType(); @@ -281,23 +333,32 @@ // pattern is discover from the includes // discover the writer from the given pattern - ChainedFileWriter writer = engine.getWriterForInclude(universe, include, modelType); + ChainedFileWriter writer = engine.getWriterForInclude( + universe, include, modelType + ); if (writer == null) { - throw new IllegalArgumentException("could not find a writer for include " + include); + throw new IllegalArgumentException( + "could not find a writer for include " + include); } if (log.isDebugEnabled()) { - log.debug("[" + include + "] " + "writer = (" + writer + ")"); + log.debug("[" + include + "] " + "writer = (" + + writer + ")"); } return writer; } @Override - public ChainedFileWriterEntry newEntry(ChainedWriterEngine engine, String include, Matcher matcher, ChainedFileWriter writer) { - ChainedFileWriterConfiguration configuration = engine.getConfiguration(); + public ChainedFileWriterEntry newEntry(ChainedWriterEngine engine, + String include, + Matcher matcher, + ChainedFileWriter writer) { + ChainedFileWriterConfiguration configuration = + engine.getConfiguration(); // with no protocol pattern // pattern is discover from the includes if (log.isDebugEnabled()) { - log.debug("[" + include + "] " + "detected pattern (" + name() + ")"); + log.debug("[" + include + "] " + "detected pattern (" + + name() + ")"); } String inputPath = matcher.group(1); @@ -313,31 +374,43 @@ FULL_PATTERN(Pattern.compile("^(\\w+):([^:]+):([^:]+)$")) { @Override - public ChainedFileWriter getWriter(ChainedWriterEngine engine, String include, Matcher matcher) { + public ChainedFileWriter getWriter(ChainedWriterEngine engine, + String include, + Matcher matcher) { // with full pattern (protocol + directory + includes) // pattern is discover from the includes - ChainedFileWriterConfiguration configuration = engine.getConfiguration(); + ChainedFileWriterConfiguration configuration = + engine.getConfiguration(); Set<ChainedFileWriter> universe = engine.getAvailableWriters(); String protocol = matcher.group(1).toLowerCase(); - ChainedFileWriter writer = engine.getWriterForInputProtocol(universe, protocol, configuration.getModelType()); + ChainedFileWriter writer = engine.getWriterForInputProtocol( + universe, protocol, configuration.getModelType()); if (writer == null) { - throw new IllegalArgumentException("could not find the writer named '" + protocol + "', use one of " + universe); + throw new IllegalArgumentException( + "could not find the writer named '" + protocol + + "', use one of " + universe); } if (log.isDebugEnabled()) { - log.debug("[" + include + "] " + "writer = (" + writer + ")"); + log.debug("[" + include + "] " + "writer = (" + writer + + ")"); } return writer; } @Override - public ChainedFileWriterEntry newEntry(ChainedWriterEngine engine, String include, Matcher matcher, ChainedFileWriter writer) { - ChainedFileWriterConfiguration configuration = engine.getConfiguration(); + public ChainedFileWriterEntry newEntry(ChainedWriterEngine engine, + String include, + Matcher matcher, + ChainedFileWriter writer) { + ChainedFileWriterConfiguration configuration = + engine.getConfiguration(); // with full pattern (protocol + directory + includes) // pattern is discover from the includes if (log.isDebugEnabled()) { - log.debug("[" + include + "] " + "detected pattern (" + name() + ")"); + log.debug("[" + include + "] " + "detected pattern (" + + name() + ")"); } String inputPath = matcher.group(2); @@ -365,9 +438,15 @@ return matcher.matches() ? matcher : null; } - public abstract ChainedFileWriterEntry newEntry(ChainedWriterEngine engine, String include, Matcher matcher, ChainedFileWriter writer); + public abstract ChainedFileWriterEntry newEntry( + ChainedWriterEngine engine, + String include, + Matcher matcher, ChainedFileWriter writer); - public abstract ChainedFileWriter getWriter(ChainedWriterEngine engine, String include, Matcher matcher); + public abstract ChainedFileWriter getWriter( + ChainedWriterEngine engine, + String include, + Matcher matcher); } } Modified: trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/AvailableDataMojo.java =================================================================== --- trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/AvailableDataMojo.java 2010-03-04 16:44:13 UTC (rev 834) +++ trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/AvailableDataMojo.java 2010-03-04 18:03:17 UTC (rev 835) @@ -38,18 +38,16 @@ /** * Obtain the list of some known data informations. * <p/> - * Use the {@code dataTypes} property to specify a specific data type to use (otherwise - * will display all known data types). + * Use the {@code dataTypes} property to specify a specific data type to use + * (otherwise will display all known data types). * <p/> - * User: chemit - * Date: 24 nov. 2009 - * Time: 00:22:37 * * @goal available-data * @requiresProject true * @requiresDirectInvocation true * @requiresDependencyResolution test * @since 2.0.0 + * @author tchemit <chemit@codelutin.com> */ public class AvailableDataMojo extends AbstractMojo { @@ -73,8 +71,8 @@ protected String dataTypes; /** - * All available models (obtain by plexus, keys are plexus roles, values are a - * instance of corresponding model). + * All available models (obtain by plexus, keys are plexus roles, values + * are a instance of corresponding model). * * @component role="org.nuiton.eugene.models.Model" */ @@ -125,7 +123,9 @@ } safeDataTypes.add(data); } catch (IllegalArgumentException e) { - getLog().warn("does not know data type : " + s + " use one of " + Arrays.toString(AvailableData.values())); + getLog().warn( + "does not know data type : " + s + " use one of " + + Arrays.toString(AvailableData.values())); } } } @@ -135,7 +135,8 @@ appendData(data, buffer); } - getLog().info("Get datas for data types : " + safeDataTypes + buffer.toString()); + getLog().info("Get datas for data types : " + safeDataTypes + + buffer.toString()); } protected void appendData(AvailableData data, StringBuilder buffer) { @@ -149,12 +150,20 @@ } else if (size == 1) { buffer.append("\nFound one ").append(dataType).append(" : "); } else { - buffer.append("\nFound ").append(size).append(" ").append(dataType).append("s : "); + buffer.append("\nFound "); + buffer.append(size); + buffer.append(" "); + buffer.append(dataType); + buffer.append("s : "); } for (Map.Entry<String, ?> e : map.entrySet()) { String name = e.getKey(); Object value = e.getValue(); - buffer.append("\n [").append(name).append("] with implementation '").append(data.toString(value)).append("'"); + buffer.append("\n ["); + buffer.append(name); + buffer.append("] with implementation '"); + buffer.append(data.toString(value)); + buffer.append('\''); } } @@ -174,11 +183,16 @@ String toString(Object data) { ChainedFileWriter w = (ChainedFileWriter) data; StringBuilder b = new StringBuilder(super.toString(data)); - b.append("\n").append(" inputProtocol : ").append(w.getInputProtocol()); - b.append("\n").append(" outputProtocol : ").append(w.getOutputProtocol(ObjectModel.NAME)); - b.append("\n").append(" defaultIncludes : ").append(w.getDefaultIncludes()); - b.append("\n").append(" defaultInputDirectory : ").append(w.getDefaultInputDirectory()); - b.append("\n").append(" defaultTestInputDirectory : ").append(w.getDefaultTestInputDirectory()); + b.append("\n").append(" inputProtocol : "); + b.append(w.getInputProtocol()); + b.append("\n").append(" outputProtocol : "); + b.append(w.getOutputProtocol(ObjectModel.NAME)); + b.append("\n").append(" defaultIncludes : "); + b.append(w.getDefaultIncludes()); + b.append("\n").append(" defaultInputDirectory : "); + b.append(w.getDefaultInputDirectory()); + b.append("\n").append(" defaultTestInputDirectory : "); + b.append(w.getDefaultTestInputDirectory()); return b.toString(); } }, @@ -202,4 +216,4 @@ } } -} \ No newline at end of file +} Modified: trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/CopyVersionFiles.java =================================================================== --- trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/CopyVersionFiles.java 2010-03-04 16:44:13 UTC (rev 834) +++ trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/CopyVersionFiles.java 2010-03-04 18:03:17 UTC (rev 835) @@ -46,7 +46,8 @@ * * <p/> * - * En entrée on demande des répertoires où chercher les fichiers objectmodel a convertir. + * En entrée on demande des répertoires où chercher les fichiers + * objectmodel a convertir. * <p/> * En sortie on demande le répertoire ou generer les classes java. * <p/> @@ -125,21 +126,27 @@ // find version and model name findVersionAndModelName(); - if (versionFound == null || !versionFound.matches("[0-9]+(\\.[0-9]+)*")) { + if (versionFound == null || + !versionFound.matches("[0-9]+(\\.[0-9]+)*")) { versionFound = "0"; - getLog().info("No version found in model files, setting version to '" + versionFound + "'"); + getLog().info( + "No version found in model files, setting version to '" + + versionFound + "'"); } else { - getLog().info("Version '" + versionFound + "' found in model description"); + getLog().info("Version '" + versionFound + + "' found in model description"); } - String destDir = copyVersionDir.replace("%MODELNAME%", modelNameFound) + File.separator + versionFound; + String destDir = copyVersionDir.replace("%MODELNAME%", modelNameFound) + + File.separator + versionFound; fVersionDir = new File(destDir); if (overwrite || !checkExistence()) { -// try { - PluginHelper.copyFiles(copyVersionResources.getOutput(), fVersionDir, new String[]{copyVersionFiles}, null, true); -// } catch (IOException ex) { -// throw new MojoExecutionException("could not copy some files for reason " + ex.getMessage(), ex); -// } + PluginHelper.copyFiles(copyVersionResources.getOutput(), + fVersionDir, + new String[]{copyVersionFiles}, + null, + true + ); } } @@ -151,28 +158,41 @@ @Override protected PluginIOContext initResources() { - File defaultIn = getFileFromBasedir("target", "generated-sources", "models"); - File defaultOut = getFileFromBasedir("target", "generated-sources", "java"); + File defaultIn = getFileFromBasedir("target", "generated-sources", + "models"); + File defaultOut = getFileFromBasedir("target", "generated-sources", + "java"); - File defaultTestIn = getFileFromBasedir("target", "generated-sources", "test-models"); - File defaultTestOut = getFileFromBasedir("target", "generated-sources", "test-java"); + File defaultTestIn = getFileFromBasedir("target", "generated-sources", + "test-models"); + File defaultTestOut = getFileFromBasedir("target", "generated-sources", + "test-java"); - copyVersionResources = initResources(defaultIn, defaultOut, defaultTestIn, defaultTestOut); + copyVersionResources = initResources( + defaultIn, + defaultOut, + defaultTestIn, + defaultTestOut + ); return copyVersionResources; } /** - * Check if previous saved files are already present - * @return <code>true</code> if already present,<code>false</code> otherwise. + * Check if previous saved files are already present. + * + * @return {@code true} if already present,{@code false} otherwise. */ protected boolean checkExistence() { boolean exist = false; if (fVersionDir.exists() && fVersionDir.listFiles().length > 0) { - getLog().warn("[COPY] Warning saved files for version '" + versionFound + "' and name '" + modelNameFound + "' already exists"); - getLog().warn("[COPY] Copy won't be done unless copyOverwrite " + "parameter is set to 'true' or version is updated"); + getLog().warn("[COPY] Warning saved files for version '" + + versionFound + "' and name '" + modelNameFound + + "' already exists"); + getLog().warn("[COPY] Copy won't be done unless copyOverwrite " + + "parameter is set to 'true' or version is updated"); exist = true; } @@ -180,38 +200,8 @@ return exist; } -// /** -// * Copy hibernate files. -// * -// * Using ant task -// * @throws IOException -// */ -// protected void copyAction() throws IOException { - // creation du repertoire -// fVersionDir.mkdirs(); -// destDirGen.mkdirs(); -// -// /* Création d'un projet ant */ -// Project p = createProject(); -// -// /* Création de la tâche ant Copy */ -// Copy copy = createCopyTask(p); -// -// /* Configuration */ -// copy.setTodir(fVersionDir); -// copy.setOverwrite(true); -// -// FileSet fileSet = new FileSet(); -//// fileSet.setDir(destDirGen); -// fileSet.setDir(copyVersionResources.getOutput()); -// fileSet.setIncludes(copyVersionFiles); -// copy.addFileset(fileSet); -// -// /* Execution */ -// copy.execute(); -// } /** - * Find version and name in object model files + * Find version and name in object model files. */ protected void findVersionAndModelName() { @@ -220,7 +210,8 @@ File[] modelFiles = srcModelDir.listFiles(this); - //FIXME TC-20090820 this is a bit funny iterate and keep the last model values ? + //FIXME TC-20090820 this is a bit funny iterate and keep the last + //FIXME TC-20090820 model values ? // should iterate and do the treatment for each model for (File modelFile : modelFiles) { SAXReader saxR = new SAXReader(); @@ -246,8 +237,9 @@ public boolean accept(File arg0) { String fullPath = arg0.getAbsolutePath(); // regex - String regexInclude = includes.replaceAll("\\.", "\\.").replaceAll( - "([^\\*])\\*([^\\*])", "$1[^/]*$2").replaceAll("\\*\\*", ".*") + "$"; + String regexInclude = includes.replaceAll("\\.", "\\."). + replaceAll("([^\\*])\\*([^\\*])", "$1[^/]*$2"). + replaceAll("\\*\\*", ".*") + "$"; return fullPath.matches(regexInclude); } } Modified: trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/EugeneAbstractMojo.java =================================================================== --- trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/EugeneAbstractMojo.java 2010-03-04 16:44:13 UTC (rev 834) +++ trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/EugeneAbstractMojo.java 2010-03-04 18:03:17 UTC (rev 835) @@ -76,7 +76,8 @@ */ protected String encoding; /** - * A flag to mark the mojo to be used in a test phase. This will permits to add generated sources in test compile roots. + * A flag to mark the mojo to be used in a test phase. This will permits + * to add generated sources in test compile roots. * * @parameter expression="${eugene.testPhase}" default-value="false" * @since 0.64 @@ -111,7 +112,10 @@ * @param defaultTestOut the default test output directory * @return the new {@link PluginIOContext} to use in the goal */ - protected PluginIOContext initResources(File defaultIn, File defaultOut, File defaultTestIn, File defaultTestOut) { + protected PluginIOContext initResources(File defaultIn, + File defaultOut, + File defaultTestIn, + File defaultTestOut) { PluginIOContext resources = getResources(); if (resources == null) { @@ -125,9 +129,11 @@ } else { resources.setInput(defaultIn); } - getLog().info(" using default in : " + Arrays.asList(resources.getInputs())); + getLog().info(" using default in : " + + Arrays.asList(resources.getInputs())); } else { - getLog().info(" in : " + Arrays.asList(resources.getInputs())); + getLog().info(" in : " + + Arrays.asList(resources.getInputs())); } if (resources.getOutput() == null) { @@ -146,7 +152,6 @@ @Override protected void init() throws Exception { -// protected boolean init() throws Exception { // init goal io context PluginIOContext p = initResources(); @@ -159,13 +164,6 @@ } createDirectoryIfNecessary(p.getOutput()); -// if (!p.getOutput().exists()) { -// boolean b = p.getOutput().mkdirs(); -// if (!b) { -// throw new IOException("could not create directory " + p.getOutput()); -// } -// } -// return true; } @Override Modified: trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/EugenePlugin.java =================================================================== --- trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/EugenePlugin.java 2010-03-04 16:44:13 UTC (rev 834) +++ trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/EugenePlugin.java 2010-03-04 18:03:17 UTC (rev 835) @@ -58,7 +58,8 @@ * <p/> * <p/> * <p/> - * En entrée on demande des répertoires où chercher les fichiers objectmodel a convertir. + * En entrée on demande des répertoires où chercher les fichiers + * objectmodel a convertir. * <p/> * En sortie on demande le répertoire ou generer les classes java. * <p/> @@ -172,8 +173,8 @@ fixCompileSourceRoots(); } - protected <M extends Model> void generate(File[] modelFiles, ModelReader<M> modelReader) throws Exception { -// protected <M extends Model> void generate(File[] modelFiles, ModelReader<M> modelReader) throws MojoFailureException, MojoExecutionException { + protected <M extends Model> void generate( + File[] modelFiles, ModelReader<M> modelReader) throws Exception { if (modelReader == null) { // can skip @@ -182,8 +183,6 @@ } M model = modelReader.read(modelFiles); - //List<String> packages = getPackagesToGenerate(); - if (StringUtils.isEmpty(generatedPackages)) { getLog().info(" generating all packages"); } else { @@ -193,13 +192,10 @@ List<Template<M>> templatesList = getTemplates(modelReader); for (Template<M> template : templatesList) { - getLog().info("Apply " + template.getClass().getSimpleName() + " generator"); + getLog().info("Apply " + template.getClass().getSimpleName() + + " generator"); -// try { - template.applyTemplate(model, generateResources.getOutput()); -// } catch (IOException eee) { -// throw new MojoExecutionException("Generation problem", eee); -// } + template.applyTemplate(model, generateResources.getOutput()); } } @@ -211,13 +207,22 @@ @Override protected PluginIOContext initResources() { - File defaultIn = getFileFromBasedir("target", "generated-sources", "models"); - File defaultOut = getFileFromBasedir("target", "generated-sources", "java"); + File defaultIn = getFileFromBasedir("target", "generated-sources", + "models"); + File defaultOut = getFileFromBasedir("target", "generated-sources", + "java"); - File defaultTestIn = getFileFromBasedir("target", "generated-sources", "test-models"); - File defaultTestOut = getFileFromBasedir("target", "generated-sources", "test-java"); + File defaultTestIn = getFileFromBasedir("target", "generated-sources", + "test-models"); + File defaultTestOut = getFileFromBasedir("target", "generated-sources", + "test-java"); - generateResources = initResources(defaultIn, defaultOut, defaultTestIn, defaultTestOut); + generateResources = initResources( + defaultIn, + defaultOut, + defaultTestIn, + defaultTestOut + ); return generateResources; } @@ -234,42 +239,61 @@ for (File srcDirGen : generateResources.getInputs()) { if (verbose) { - getLog().info("Search for " + Arrays.toString(includePatterns) + " in " + srcDirGen.getAbsolutePath()); + getLog().info("Search for " + Arrays.toString(includePatterns) + + " in " + srcDirGen.getAbsolutePath()); } - List<File> currentFiles = PluginHelper.getIncludedFiles(srcDirGen, includePatterns, null); + List<File> currentFiles = PluginHelper.getIncludedFiles( + srcDirGen, + includePatterns, + null + ); modelFiles.addAll(currentFiles); } return modelFiles.toArray(new File[modelFiles.size()]); } - protected ModelReader<?> getReader() throws MojoFailureException, MojoExecutionException { + protected ModelReader<?> getReader() throws MojoFailureException, + MojoExecutionException { ModelReader<?> modelReader; try { ClassLoader fixedClassLoader = fixClassLoader(); - modelReader = (ModelReader<?>) Class.forName(reader, true, fixedClassLoader).newInstance(); + modelReader = (ModelReader<?>) Class.forName( + reader, + true, + fixedClassLoader).newInstance(); } catch (InstantiationException eee) { - throw new MojoFailureException("Can't instantiate reader : " + reader, eee); + throw new MojoFailureException("Can't instantiate reader : " + + reader, eee); } catch (IllegalAccessException eee) { - throw new MojoFailureException("Can't access reader : " + reader, eee); + throw new MojoFailureException("Can't access reader : " + reader, + eee); } catch (ClassNotFoundException eee) { - throw new MojoFailureException("Can't found reader : " + reader, eee); + throw new MojoFailureException("Can't found reader : " + reader, + eee); } return modelReader; } @SuppressWarnings("unchecked") - protected <M extends Model> List<Template<M>> getTemplates(ModelReader<M> modelReader) + protected <M extends Model> List<Template<M>> getTemplates( + ModelReader<M> modelReader) throws MojoFailureException, MojoExecutionException { // init generators Properties templateProperties = new Properties(); - templateProperties.setProperty(Template.PROP_DEFAULT_PACKAGE, defaultPackage); - templateProperties.setProperty(Template.PROP_OVERWRITE, String.valueOf(overwrite)); + templateProperties.setProperty(Template.PROP_DEFAULT_PACKAGE, + defaultPackage); + templateProperties.setProperty(Template.PROP_OVERWRITE, + String.valueOf(overwrite)); templateProperties.setProperty(Template.PROP_ENCODING, encoding); - templateProperties.setProperty(Template.PROP_LAST_MODIFIED_SOURCE, String.valueOf(modelReader.getLastModifiedSource())); + templateProperties.setProperty( + Template.PROP_LAST_MODIFIED_SOURCE, + String.valueOf(modelReader.getLastModifiedSource())); if (generatedPackages != null) { - templateProperties.setProperty(Template.PROP_GENERATED_PACKAGES, generatedPackages); + templateProperties.setProperty(Template.PROP_GENERATED_PACKAGES, + generatedPackages); } - templateProperties.setProperty(Template.PROP_EXCLUDE_TEMPLATES, getExcludeTemplatesAsString()); + templateProperties.setProperty(Template.PROP_EXCLUDE_TEMPLATES, + getExcludeTemplatesAsString()); List<Template<M>> templatesList = new ArrayList<Template<M>>(); String[] templatesNames = templates.split(","); @@ -284,11 +308,14 @@ template.setProperties(templateProperties); templatesList.add(template); } catch (InstantiationException e) { - throw new MojoFailureException("Can't instantiate generator : " + templateName, e); + throw new MojoFailureException("Can't instantiate generator : " + + templateName, e); } catch (IllegalAccessException e) { - throw new MojoFailureException("Can't access generator : " + templateName, e); + throw new MojoFailureException("Can't access generator : " + + templateName, e); } catch (ClassNotFoundException e) { - throw new MojoFailureException("Can't found generator : " + templateName, e); + throw new MojoFailureException("Can't found generator : " + + templateName, e); } } return templatesList; @@ -306,14 +333,15 @@ } /** - * permet d'ajout le répertoire de génération des fichiers java dans les répertoires - * de compilation du projet Maven. + * permet d'ajout le répertoire de génération des fichiers java dans les + * répertoires de compilation du projet Maven. */ protected void fixCompileSourceRoots() { if (project == null) { // no project defined, can not fix anything - // this case could appears if we wanted to do some tests of the plugin + // this case could appears if we wanted to do some tests of the + // plugin return; } @@ -332,7 +360,8 @@ project.addTestResource(resources); } } else { - if (!project.getCompileSourceRoots().contains(destDirGen.getPath())) { + if (!project.getCompileSourceRoots().contains( + destDirGen.getPath())) { getLog().info("Add compile source root : " + destDirGen); project.addCompileSourceRoot(destDirGen.getPath()); Resource resources = new Resource(); @@ -361,24 +390,38 @@ ClassLoader loader = null; if (extraClassPathDirectory != null) { if (verbose) { - getLog().info("Add extra directory in generator's classLoader : " + extraClassPathDirectory); + getLog().info("Add extra directory in generator's" + + " classLoader : " + extraClassPathDirectory); } - addDirectoryToUrlsList(extraClassPathDirectory, urls, urlsAsString); + addDirectoryToUrlsList( + extraClassPathDirectory, + urls, + urlsAsString + ); } if (project.getProjectReferences() != null) { - // this case is for multi-module when calling from a parent module + // this case is for multi-module when calling from a parent + // module for (Object o : project.getProjectReferences().entrySet()) { Entry<?, ?> entry = (Entry<?, ?>) o; - MavenProject relatedProject = (MavenProject) entry.getValue(); + MavenProject relatedProject = + (MavenProject) entry.getValue(); if (verbose) { - getLog().info("Add project reference in generator's classLoader : '" + relatedProject.getArtifact() + "'"); + getLog().info("Add project reference in " + + "generator's classLoader : '" + + relatedProject.getArtifact() + "'"); } //TODO il faudrait peut-etre aussi ajouter les dependances ? - addDirectoryToUrlsList(relatedProject.getArtifact().getFile(), urls, urlsAsString); + addDirectoryToUrlsList( + relatedProject.getArtifact().getFile(), + urls, + urlsAsString + ); } } if (!project.getArtifacts().isEmpty()) { - // this is a special case when artifacts were resolved (for example in site phase) + // this is a special case when artifacts were resolved (for + // example in site phase) if (verbose) { getLog().info("Use resolved artifacts to build class-path"); } Modified: trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/SmartGenerateMojo.java =================================================================== --- trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/SmartGenerateMojo.java 2010-03-04 16:44:13 UTC (rev 834) +++ trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/SmartGenerateMojo.java 2010-03-04 18:03:17 UTC (rev 835) @@ -72,11 +72,11 @@ * <pre> * [writer:]directory:includes * </pre> - * where {@code includes} is the pattern to find files from the directory given and must be terminated by the extension - * of files. + * where {@code includes} is the pattern to find files from the directory + * given and must be terminated by the extension of files. * <p/> - * Specifying the {@code writer} can be usefull when you want to use a writer for an unknown extension - * by any writer. + * Specifying the {@code writer} can be usefull when you want to use a + * writer for an unknown extension by any writer. * <p/> * Example : * <pre> @@ -140,7 +140,8 @@ */ protected String encoding; /** - * A flag to mark the mojo to be used in a test phase. This will permits to add generated sources in test compile roots. + * A flag to mark the mojo to be used in a test phase. This will permits + * to add generated sources in test compile roots. * * @parameter expression="${eugene.testPhase}" default-value="false" * @since 2.0.0 @@ -156,13 +157,6 @@ * @since 2.0.0 */ protected String modelType; -// /** -// * An extra directory to be added to the classpath. -// * - // * @parameter expression="${eugene.extraClassPathDirectory}" -// * @since 2.0.0 -// */ -// protected File extraClassPathDirectory; /** * Properties to pass to writer. * @@ -184,29 +178,25 @@ * @since 2.0.0 */ protected String fullPackagePath; -// /** -// * Nom du paquetage à générer (xmi input sepcific). -// * - // * @parameter expression="${generator.extractedPackages}" default-value="${project.groupId}.${project.artifactId}" -// * @since 2.0.0 -// */ -// protected String extractedPackages; /** - * Nom du resolver a utiliser pour les transformations xmi vers model (xmi input sepcific). + * Nom du resolver a utiliser pour les transformations xmi vers model + * (xmi input sepcific). * * @parameter expression="${generator.resolver}" default-value="org.nuiton.util.ResourceResolver" * @since 2.0.0 */ protected String resolver; /** - * Templates à utiliser, séparés par des virgules pour les transformations depuis les models (model input sepcific). + * Templates à utiliser, séparés par des virgules pour les transformations + * depuis les models (model input sepcific). * * @parameter expression="${eugene.templates}" * @since 0.50 */ protected String templates; /** - * Templates à ne pas utiliser lors de la transformations des models (model input sepcific). + * Templates à ne pas utiliser lors de la transformations des models + * (model input sepcific). * * @parameter expression="${eugene.excludeTemplates}" * @since 0.63 @@ -246,8 +236,8 @@ protected Settings settings; /** - * All available models (obtain by plexus, keys are plexus roles, values are a - * instance of corresponding model). + * All available models (obtain by plexus, keys are plexus roles, + * values are a instance of corresponding model). * * @component role="org.nuiton.eugene.models.Model" */ @@ -271,15 +261,11 @@ */ protected Map<String, Template<?>> modelTemplates; /** - * The engine to compute {@link org.nuiton.eugene.writer.ChainedFileWriter} from inputs entries. + * The engine to compute {@link ChainedFileWriter} from inputs entries. * * @component role="org.nuiton.eugene.writer.ChainedWriterEngine" */ protected ChainedWriterEngine engine; -// /** -// * class instance of the given {@link #modelType} -// */ -// protected Class<? extends Model> modelClass; /** * fixed classloader */ @@ -287,7 +273,6 @@ @Override protected void init() throws Exception { -// protected boolean init() throws Exception { modelType = modelType.trim().toLowerCase(); @@ -295,21 +280,26 @@ // pouvoir associé un nom à un type de service). Model model = _models.get(modelType); if (model == null) { - throw new MojoExecutionException("No modelType named '" + modelType + "', use one of " + _models.keySet()); + throw new MojoExecutionException( + "No modelType named '" + modelType + "', use one of " + + _models.keySet()); } -// modelClass = model.getClass(); if (inputs.length == 0) { - throw new MojoExecutionException("Must specify something to include using the includes property"); + throw new MojoExecutionException( + "Must specify something to include using the includes " + + "property"); } //FIXME-TC20091217 use a configurator in plexus ? - // Actually we obtain a different instance of the mojo conflit with mojo and plexus :) + // Actually we obtain a different instance of the mojo conflit with + // mojo and plexus :) engine.setConfiguration(this); Set<ChainedFileWriter> availableWriters = engine.getAvailableWriters(); if (availableWriters.isEmpty()) { - throw new MojoExecutionException("Could not find any writer in class-path."); + throw new MojoExecutionException( + "Could not find any writer in class-path."); } for (ChainedFileWriter writer : availableWriters) { @@ -328,8 +318,6 @@ if (engine.getSelectedWriters().isEmpty()) { return; -// getLog().warn("No phase was detected, skip the goal."); -// return false; } if (properties == null) { @@ -340,7 +328,8 @@ // add xmi writer support - properties.put(XmiChainedFileWriter.PROP_FULL_PACKAGE_PATH, fullPackagePath); + properties.put(XmiChainedFileWriter.PROP_FULL_PACKAGE_PATH, + fullPackagePath); //properties.put("extractedPackages", extractedPackages); properties.put(XmiChainedFileWriter.PROP_RESOLVER, resolver); } @@ -349,13 +338,14 @@ // add model writer support - properties.put(ModelChainedFileWriter.PROP_DEFAULT_PACKAGE, defaultPackage); - properties.put(ModelChainedFileWriter.PROP_GENERATED_PACKAGES, generatedPackages); + properties.put(ModelChainedFileWriter.PROP_DEFAULT_PACKAGE, + defaultPackage); + properties.put(ModelChainedFileWriter.PROP_GENERATED_PACKAGES, + generatedPackages); properties.put(ModelChainedFileWriter.PROP_TEMPLATES, templates); - properties.put(ModelChainedFileWriter.PROP_EXCLUDE_TEMPLATES, getExcludeTemplatesAsString()); + properties.put(ModelChainedFileWriter.PROP_EXCLUDE_TEMPLATES, + getExcludeTemplatesAsString()); } - -// return true; } @Override @@ -392,18 +382,24 @@ for (ChainedFileWriter writer : engine.getSelectedWriters()) { if (skipInputList.contains(writer.getInputProtocol())) { - getLog().info("Skip phase [" + writer.getInputProtocol() + "] as required in skipInputs configuration."); + getLog().info("Skip phase [" + writer.getInputProtocol() + + "] as required in skipInputs configuration."); continue; } int size = writer.getEntries().size(); if (size == 1) { - getLog().info("Process phase [" + writer.getInputProtocol() + "] for one entry."); + getLog().info( + "Process phase [" + writer.getInputProtocol() + + "] for one entry."); } else { - getLog().info("Process phase [" + writer.getInputProtocol() + "] for " + size + " entries."); + getLog().info( + "Process phase [" + writer.getInputProtocol() + + "] for " + size + " entries."); } if (dryRun || isVerbose()) { for (ChainedFileWriterEntry entry : writer.getEntries()) { - getLog().info(" entry : " + entry.getInputDirectory() + " - " + entry.getIncludePattern()); + getLog().info(" entry : " + entry.getInputDirectory() + + " - " + entry.getIncludePattern()); } if (dryRun) { continue; @@ -413,23 +409,21 @@ getLog().debug("Generating files and copying resources..."); } -// try { - writer.generate(this); -// } catch (Exception e) { -// throw new MojoExecutionException("could not generate for writer " + writer.getInputProtocol(), e); -// } + writer.generate(this); if ("model".equals(writer.getInputProtocol())) { // must fix source compile roots - File outputDir = writer.getOutputDirectory(getOutputDirectory(), isTestPhase()); + File outputDir = writer.getOutputDirectory( + getOutputDirectory(), isTestPhase()); fixCompileSourceRoots(outputDir); } } } finally { - // always clear everything to avoid side-effects in goal is invoked more than once + // always clear everything to avoid side-effects in goal is + // invoked more than once properties.clear(); engine.clear(); } @@ -470,7 +464,7 @@ try { return getFixedClassLoader(); } catch (MojoExecutionException e) { - throw new IllegalStateException("could not obtain classLoader",e); + throw new IllegalStateException("could not obtain classLoader", e); } } @@ -519,11 +513,6 @@ return modelType; } -// @Override -// public Class<? extends Model> getModelClass() { -// return modelClass; -// } - @Override public Map<String, ChainedFileWriter> getWriters() { return writers; @@ -545,7 +534,8 @@ } /** - * @return the string representation of excludesTemplates (separated by comma) + * @return the string representation of excludesTemplates + * (separated by comma) */ protected String getExcludeTemplatesAsString() { String result = ""; @@ -561,7 +551,8 @@ /** * Prepare le classLoader a utiliser dans le generateur. * <p/> - * Si le mojo est en phase de test {@link #testPhase} a été renseigné, target/classes est rajouté. + * Si le mojo est en phase de test {@link #testPhase} a été renseigné, + * target/classes est rajouté. * <p/> * Si des références à des sibling modules, ils seront rajoutés aussi. * @@ -577,33 +568,55 @@ ClassLoader loader; if (testPhase) { - File extraClassPathDirectory = new File(getProject().getBuild().getOutputDirectory()); + File extraClassPathDirectory = new File( + getProject().getBuild().getOutputDirectory()); // if (verbose) { - getLog().info("Add in generator's classLoader : " + extraClassPathDirectory); + getLog().info("Add in generator's classLoader : " + + extraClassPathDirectory); // } - addDirectoryToUrlsList(extraClassPathDirectory, urls, urlsAsString); + addDirectoryToUrlsList( + extraClassPathDirectory, + urls, + urlsAsString + ); } if (project.getProjectReferences() != null) { - // this case is for multi-module when calling from a parent module - for (Object o : project.getProjectReferences().entrySet()) { + // this case is for multi-module when calling from a + // parent module + for (Object o : + project.getProjectReferences().entrySet()) { Map.Entry<?, ?> entry = (Map.Entry<?, ?>) o; - MavenProject relatedProject = (MavenProject) entry.getValue(); + MavenProject relatedProject = + (MavenProject) entry.getValue(); if (verbose) { - getLog().info("Add project reference in generator's classLoader : '" + relatedProject.getArtifact() + "'"); + getLog().info("Add project reference in " + + "generator's classLoader : '" + + relatedProject.getArtifact() + "'"); } - //TODO il faudrait peut-etre aussi ajouter les dependances ? - addDirectoryToUrlsList(relatedProject.getArtifact().getFile(), urls, urlsAsString); + //TODO il faudrait peut-etre aussi ajouter les + //TODO dependances ? + addDirectoryToUrlsList( + relatedProject.getArtifact().getFile(), + urls, + urlsAsString + ); } } if (!project.getArtifacts().isEmpty()) { - // this is a special case when artifacts were resolved (for example in site phase) + // this is a special case when artifacts were resolved + // (for example in site phase) if (verbose) { - getLog().info("Use resolved artifacts to build class-path"); + getLog().info( + "Use resolved artifacts to build class-path"); } for (Object o : project.getArtifacts()) { Artifact a = (Artifact) o; if (!a.getScope().equals("provided")) { - addDirectoryToUrlsList(a.getFile(), urls, urlsAsString); + addDirectoryToUrlsList( + a.getFile(), + urls, + urlsAsString + ); } } } @@ -628,7 +641,8 @@ } } if (!urls.isEmpty()) { - loader = new URLClassLoader(urls.toArray(new URL[urls.size()]), + loader = new URLClassLoader( + urls.toArray(new URL[urls.size()]), loader); } if (getLog().isDebugEnabled()) { @@ -648,23 +662,26 @@ } /** - * permet d'ajout le répertoire de génération des fichiers java dans les répertoires - * de compilation du projet Maven. + * permet d'ajout le répertoire de génération des fichiers java dans + * les répertoires de compilation du projet Maven. * * @param destDirGen le repertoire a traiter */ protected void fixCompileSourceRoots(File destDirGen) { - //FIXME-TC20091215 : should never have a null project, this is not normal + //FIXME-TC20091215 : should never have a null project, this is not + //FIXME-TC20091215 : normal if (project == null) { // no project defined, can not fix anything - // this case could appears if we wanted to do some tests of the plugin + // this case could appears if we wanted to do some tests of the + // plugin return; } //TODO-TC20091016 should use AbstractPlugin api if (isTestPhase()) { - if (!project.getTestCompileSourceRoots().contains(destDirGen.getPath())) { + if (!project.getTestCompileSourceRoots().contains( + destDirGen.getPath())) { getLog().info("Add test compile source root : " + destDirGen); project.addTestCompileSourceRoot(destDirGen.getPath()); Resource resources = new Resource(); @@ -674,7 +691,8 @@ project.addTestResource(resources); } } else { - if (!project.getCompileSourceRoots().contains(destDirGen.getPath())) { + if (!project.getCompileSourceRoots().contains( + destDirGen.getPath())) { getLog().info("Add compile source root : " + destDirGen); project.addCompileSourceRoot(destDirGen.getPath()); Resource resources = new Resource(); @@ -685,4 +703,4 @@ } } } -} \ No newline at end of file +} Modified: trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/Xmi2Model.java =================================================================== --- trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/Xmi2Model.java 2010-03-04 16:44:13 UTC (rev 834) +++ trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/Xmi2Model.java 2010-03-04 18:03:17 UTC (rev 835) @@ -66,9 +66,11 @@ * * <p/> * - * En entrée on demande des répertoires où chercher les fichiers xmi a convertir. + * En entrée on demande des répertoires où chercher les fichiers xmi a + * convertir. * <p/> - * En sortie on demande le répertoire ou extraire les xmi et copier les resources. + * En sortie on demande le répertoire ou extraire les xmi et copier les + * resources. * <p/> * Par défaut on a les valeurs suivantes : * </p> @@ -172,24 +174,27 @@ for (File dir : xmiResources.getInputs()) { // recuperation des fichiers a traiter - List<File> files = PluginHelper.getIncludedFiles(dir, includes, null); + List<File> files = + PluginHelper.getIncludedFiles(dir, includes, null); // lancement des traitements xsl sur les fichiers trouvés // dans le repertoire - actionXsl(dir, files, factory, fixedClassLoader, acceptedTypesAsArray); + actionXsl(dir, + files, + factory, + fixedClassLoader, + acceptedTypesAsArray + ); } } finally { - getLog().info("xsl done in " + StringUtil.convertTime(System.nanoTime() - t0)); + getLog().info("xsl done in " + + StringUtil.convertTime(System.nanoTime() - t0)); } getLog().info("Copy resources files"); -// try { - String[] excludes = getSuffixPattern("**/*"); - PluginHelper.copyFiles(xmiResources, null, excludes, overwrite); -// } catch (IOException ex) { -// throw new MojoExecutionException("could not copy some files for reason " + ex.getMessage(), ex); -// } + String[] excludes = getSuffixPattern("**/*"); + PluginHelper.copyFiles(xmiResources, null, excludes, overwrite); } @Override @@ -200,12 +205,21 @@ @Override protected PluginIOContext initResources() { - File defaultIn = getFileFromBasedir("target", "generated-sources", "xmi"); - File defaultOut = getFileFromBasedir("target", "generated-sources", "models"); - File defaultTestIn = getFileFromBasedir("target", "generated-sources", "test-xmi"); - File defaultTestOut = getFileFromBasedir("target", "generated-sources", "test-models"); + File defaultIn = getFileFromBasedir("target", "generated-sources", + "xmi"); + File defaultOut = getFileFromBasedir("target", "generated-sources", + "models"); + File defaultTestIn = getFileFromBasedir("target", "generated-sources", + "test-xmi"); + File defaultTestOut = getFileFromBasedir("target", "generated-sources", + "test-models"); - xmiResources = initResources(defaultIn, defaultOut, defaultTestIn, defaultTestOut); + xmiResources = initResources( + defaultIn, + defaultOut, + defaultTestIn, + defaultTestOut + ); return xmiResources; } @@ -220,22 +234,32 @@ return patterns; } - protected void actionXsl(File dir, List<File> files, TransformerFactory factory, ClassLoader fixedClassLoader, String[] acceptedSuffixes) throws MojoExecutionException { + protected void actionXsl(File dir, + List<File> files, + TransformerFactory factory, + ClassLoader fixedClassLoader, + String[] acceptedSuffixes) + throws MojoExecutionException { for (File file : files) { try { if (getLog().isDebugEnabled()) { getLog().debug("treate file : " + file); } // Prepare resolver, stylesheet - URIResolver fileResolver = getUriResolver(file, fixedClassLoader); + URIResolver fileResolver = getUriResolver(file, + fixedClassLoader); String styleSheet = getStyleSheet(file); URL xsl = Resource.getURL(styleSheet); //TC-20090820 : using recursive for xmi // File result = new File(destDirModel, FileUtil.basename(file, // acceptedSuffixes).concat(".").concat(getExtension())); - String filename = FileUtil.basename(file, acceptedSuffixes).concat(".").concat(getExtension()); - String relatifPath = file.getParentFile().getAbsolutePath().substring(dir.getAbsolutePath().length()); + String filename = FileUtil.basename( + file, + acceptedSuffixes).concat(".").concat(getExtension() + ); + String relatifPath = file.getParentFile().getAbsolutePath(). + substring(dir.getAbsolutePath().length()); File dstDir = xmiResources.getOutput(); if (!relatifPath.isEmpty()) { dstDir = new File(dstDir, relatifPath); @@ -252,7 +276,8 @@ } // Create the xsl transformer and set parameters - Transformer transformer = factory.newTransformer(new StreamSource(xsl.openStream())); + Transformer transformer = factory.newTransformer( + new StreamSource(xsl.openStream())); transformer.setParameter("fullPackagePath", fullPackagePath); transformer.setParameter("extraPackages", extractedPackages); @@ -297,13 +322,15 @@ // Try to set the base using the constructor try { // Look for a constructor with a String parameter (base) - Constructor<?> withBaseConstructor = clazz.getConstructor(String.class); + Constructor<?> withBaseConstructor = + clazz.getConstructor(String.class); // Set the xmi folder as the base String base = model.getParentFile().getAbsolutePath(); // Instantiate result = (URIResolver) withBaseConstructor.newInstance(base); } catch (Exception eee) { - getLog().warn("Unable to instantiate resolver with String parameter", + getLog().warn( + "Unable to instantiate resolver with String parameter", eee); } @@ -324,7 +351,8 @@ } } catch (Exception eee) { - getLog().warn("Unable to instantiate resolver using the default constructor", eee); + getLog().warn("Unable to instantiate resolver using the default " + + "constructor", eee); } return result; @@ -347,24 +375,38 @@ ClassLoader loader; if (extraClassPathDirectory != null) { if (verbose) { - getLog().info("Add extra directory in generator's classLoader : " + extraClassPathDirectory); + getLog().info("Add extra directory in generator's " + + "classLoader : " + extraClassPathDirectory); } - addDirectoryToUrlsList(extraClassPathDirectory,urls,urlsAsString); + addDirectoryToUrlsList( + extraClassPathDirectory, + urls, + urlsAsString + ); } if (project.getProjectReferences() != null) { - // this case is for multi-module when calling from a parent module + // this case is for multi-module when calling from a parent + // module for (Object o : project.getProjectReferences().entrySet()) { Entry<?, ?> entry = (Entry<?, ?>) o; - MavenProject relatedProject = (MavenProject) entry.getValue(); + MavenProject relatedProject = + (MavenProject) entry.getValue(); if (verbose) { - getLog().info("Add project reference in generator's classLoader : '" + relatedProject.getArtifact() + "'"); + getLog().info("Add project reference in" + + " generator's classLoader : '" + + relatedProject.getArtifact() + "'"); } //TODO il faudrait peut-etre aussi ajouter les dependances ? - addDirectoryToUrlsList(relatedProject.getArtifact().getFile(), urls, urlsAsString); + addDirectoryToUrlsList( + relatedProject.getArtifact().getFile(), + urls, + urlsAsString + ); } } if (!project.getArtifacts().isEmpty()) { - // this is a special case when artifacts were resolved (for example in site phase) + // this is a special case when artifacts were resolved + // (for example in site phase) if (verbose) { getLog().info("Use resolved artifacts to build class-path"); } Modified: trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/Xmi2ObjectModel.java =================================================================== --- trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/Xmi2ObjectModel.java 2010-03-04 16:44:13 UTC (rev 834) +++ trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/Xmi2ObjectModel.java 2010-03-04 18:03:17 UTC (rev 835) @@ -41,7 +41,6 @@ @Override public void doAction() throws Exception { -// public void doAction() throws MojoExecutionException, MojoFailureException { getLog().info("Conversion of XMI files into ObjectModel"); super.doAction(); } Modified: trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/Xmi2StateModel.java =================================================================== --- trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/Xmi2StateModel.java 2010-03-04 16:44:13 UTC (rev 834) +++ trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/Xmi2StateModel.java 2010-03-04 18:03:17 UTC (rev 835) @@ -29,7 +29,6 @@ @Override public void doAction() throws Exception { -// public void doAction() throws MojoExecutionException, MojoFailureException { getLog().info("Conversion of XMI files into StateModel"); super.doAction(); } @@ -41,7 +40,8 @@ @Override protected String getStyleSheet(File model) { - //TODO when StateModel will be supported in 2.1, compute the version to resolve the correct stylesheet + //TODO when StateModel will be supported in 2.1, compute the version + //TODO to resolve the correct stylesheet return "xmi1.2ToStateModel.xsl"; } } Modified: trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/Zargo2Xmi.java =================================================================== --- trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/Zargo2Xmi.java 2010-03-04 16:44:13 UTC (rev 834) +++ trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/Zargo2Xmi.java 2010-03-04 18:03:17 UTC (rev 835) @@ -36,16 +36,20 @@ */ public class Zargo2Xmi extends EugeneAbstractMojo { - public static final String[] ZARGO_FILE_FILTER = new String[]{"**/*.zargo", "**/*.zuml"}; - public static final String[] XMI_FILE_FILTER = new String[]{"*.xmi", "**/*.xmi"}; + public static final String[] ZARGO_FILE_FILTER = + new String[]{"**/*.zargo", "**/*.zuml"}; + public static final String[] XMI_FILE_FILTER = + new String[]{"*.xmi", "**/*.xmi"}; /** * Les entrées-sorties du plugin. * * <p/> * - * En entrée on demande des répertoires où chercher les fichiers zargo a convertir. + * En entrée on demande des répertoires où chercher les fichiers zargo a + * convertir. * <p/> - * En sortie on demande le répertoire ou extraire les xmi et copier les resources. + * En sortie on demande le répertoire ou extraire les xmi et copier les + * resources. * <p/> * Par défaut on a les valeurs suivantes : * </p> @@ -79,23 +83,16 @@ @Override public void doAction() throws Exception { -// public void doAction() throws MojoExecutionException, MojoFailureException { - getLog().info("Extract zipped XMI files from zargo archive and copy resources"); + getLog().info("Extract zipped XMI files from zargo archive and " + + "copy resources"); getLog().info("Extract zipped XMI files"); -// try { - PluginHelper.expandFiles(zargoResources, ZARGO_FILE_FILTER, null, XMI_FILE_FILTER, overwrite); -// } catch (IOException ex) { -// throw new MojoExecutionException("could not expand files for reason " + ex.getMessage(), ex); -// } + PluginHelper.expandFiles(zargoResources, ZARGO_FILE_FILTER, null, + XMI_FILE_FILTER, overwrite); getLog().info("Copy resources"); -// try { - PluginHelper.copyFiles(zargoResources, null, ZARGO_FILE_FILTER, overwrite); -// } catch (IOException ex) { -// throw new MojoExecutionException("could not copy some files for reason " + ex.getMessage(), ex); -// } - + PluginHelper.copyFiles(zargoResources, null, ZARGO_FILE_FILTER, + overwrite); } @Override @@ -107,12 +104,19 @@ protected PluginIOContext initResources() { File defaultIn = getFileFromBasedir("src", "main", "xmi"); - File defaultOut = getFileFromBasedir("target", "generated-sources", "xmi"); + File defaultOut = getFileFromBasedir("target", "generated-sources", + "xmi"); File defaultTestIn = getFileFromBasedir("src", "test", "xmi"); - File defaultTestOut = getFileFromBasedir("target", "generated-sources", "test-xmi"); + File defaultTestOut = getFileFromBasedir("target", "generated-sources", + "test-xmi"); - zargoResources = initResources(defaultIn, defaultOut, defaultTestIn, defaultTestOut); + zargoResources = initResources( + defaultIn, + defaultOut, + defaultTestIn, + defaultTestOut + ); return zargoResources; } Modified: trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/writer/BaseChainedFileWriter.java =================================================================== --- trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/writer/BaseChainedFileWriter.java 2010-03-04 16:44:13 UTC (rev 834) +++ trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/writer/BaseChainedFileWriter.java 2010-03-04 18:03:17 UTC (rev 835) @@ -31,7 +31,8 @@ import java.util.Set; /** - * Surcharge de l'implentation abstraite pour avoir le logger de la console maven. + * Surcharge de l'implentation abstraite pour avoir le logger de la console + * maven. * * @author tchemit * @since 2.0.0 @@ -66,18 +67,33 @@ // log writer config StringBuilder buffer = new StringBuilder(); - Set<Map.Entry<String, String>> set = getAuthorizedPropertyDescriptions().entrySet(); + Set<Map.Entry<String, String>> set = + getAuthorizedPropertyDescriptions().entrySet(); if (set.isEmpty()) { - buffer.append("Writer [").append(getInputProtocol()).append("]").append(" does not use any specific properties."); + buffer.append("Writer ["); + buffer.append(getInputProtocol()); + buffer.append("]"); + buffer.append(" does not use any specific properties."); } else { - buffer.append("Writer [").append(getInputProtocol()).append("]").append(" use ").append(properties.size()).append(" properties :"); + buffer.append("Writer ["); + buffer.append(getInputProtocol()); + buffer.append("]"); + buffer.append(" use "); + buffer.append(properties.size()); + buffer.append(" properties :"); if (getLog().isInfoEnabled()) { for (Map.Entry<String, String> e : set) { String key = e.getKey(); Object value = properties.get(key); if (value != null) { - buffer.append("\n").append(" [").append(key).append("] (").append(e.getValue()).append(") : ").append(value); + buffer.append("\n"); + buffer.append(" ["); + buffer.append(key); + buffer.append("] ("); + buffer.append(e.getValue()); + buffer.append(") : "); + buffer.append(value); } } } @@ -87,7 +103,8 @@ protected boolean acceptObjectModelOrStateModel(String modelType) { modelType = modelType.trim().toLowerCase(); - return ObjectModel.NAME.equals(modelType) || StateModel.NAME.equals(modelType); + return ObjectModel.NAME.equals(modelType) || + StateModel.NAME.equals(modelType); } Modified: trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/writer/ModelChainedFileWriter.java =================================================================== --- trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/writer/ModelChainedFileWriter.java 2010-03-04 16:44:13 UTC (rev 834) +++ trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/writer/ModelChainedFileWriter.java 2010-03-04 18:03:17 UTC (rev 835) @@ -83,7 +83,9 @@ @Override public boolean acceptInclude(String include) { - return include.startsWith("model:") || include.endsWith(".objectmodel") || include.endsWith(".statemodel"); + return include.startsWith("model:") || + include.endsWith(".objectmodel") || + include.endsWith(".statemodel"); } @Override @@ -152,32 +154,47 @@ String reader = getReader(); try { ClassLoader fixedClassLoader = loader; - ModelReader<?> modelReader = (ModelReader<?>) Class.forName(reader, true, fixedClassLoader).newInstance(); - //TODO : should check that the reader is compatible with given modelType + ModelReader<?> modelReader = (ModelReader<?>) + Class.forName(reader, true, + fixedClassLoader).newInstance(); + //TODO : should check that the reader is compatible with + //TODO : given modelType properties.put(PROP_MODEL_READER, modelReader); } catch (Exception eee) { - throw new IllegalStateException("could not obtain reader " + reader, eee); + throw new IllegalStateException("could not obtain reader " + + reader, eee); } } else { String modelType = configuration.getModelType(); - ModelReader<?> modelReader = configuration.getModelReaders().get(modelType); + ModelReader<?> modelReader = + configuration.getModelReaders().get(modelType); if (modelReader == null) { - throw new IllegalStateException("could not find a model reader for modelType : " + modelType + ", availables readers : " + configuration.getModelReaders().values()); + throw new IllegalStateException( + "could not find a model reader for modelType : " + + modelType + ", availables readers : " + + configuration.getModelReaders().values()); } properties.put(PROP_MODEL_READER, modelReader); } } Properties templateProperties = new Properties(); - templateProperties.setProperty(Template.PROP_DEFAULT_PACKAGE, getDefaultPackage()); - templateProperties.setProperty(Template.PROP_OVERWRITE, String.valueOf(configuration.isOverwrite())); - templateProperties.setProperty(Template.PROP_ENCODING, configuration.getEncoding()); - templateProperties.setProperty(Template.PROP_LAST_MODIFIED_SOURCE, String.valueOf(getModelReader().getLastModifiedSource())); + templateProperties.setProperty(Template.PROP_DEFAULT_PACKAGE, + getDefaultPackage()); + templateProperties.setProperty( + Template.PROP_OVERWRITE, + String.valueOf(configuration.isOverwrite())); + templateProperties.setProperty(Template.PROP_ENCODING, + configuration.getEncoding()); + templateProperties.setProperty( + Template.PROP_LAST_MODIFIED_SOURCE, + String.valueOf(getModelReader().getLastModifiedSource())); String generatedPackages = getGeneratedPackages(); if (StringUtils.isEmpty(generatedPackages)) { getLog().info(" generating all packages"); } else { - templateProperties.put(Template.PROP_GENERATED_PACKAGES, generatedPackages); + templateProperties.put(Template.PROP_GENERATED_PACKAGES, + generatedPackages); getLog().info(" generating only for packages " + generatedPackages); } @@ -190,14 +207,19 @@ templateName = templateName.trim(); Template<Model> template; - template = (Template<Model>) configuration.getModelTemplates().get(templateName); + template = (Template<Model>) + configuration.getModelTemplates().get(templateName); if (template == null) { - getLog().warn("template [" + templateName + "] is not registred via plexus, try to load it directly"); + getLog().warn("template [" + templateName + "] is not " + + "registred via plexus, try to load it directly"); try { - template = (Template<Model>) Class.forName(templateName, true, loader).newInstance(); + template = (Template<Model>) Class.forName( + templateName, true, loader).newInstance(); } catch (Exception e) { - throw new IllegalStateException("Can't obtain template [" + templateName + "] for reason " + e.getMessage(), e); + throw new IllegalStateException( + "Can't obtain template [" + templateName + + "] for reason " + e.getMessage(), e); } } else { getLog().info("will use the template [" + templateName + "]"); @@ -215,7 +237,10 @@ @Override - public void generate(ChainedFileWriterConfiguration configuration, File outputDir, File inputDirectory, String includePattern) throws IOException { + public void generate(ChainedFileWriterConfiguration configuration, + File outputDir, + File inputDirectory, + String includePattern) throws IOException { PluginIOContext ioContext = new PluginIOContext(); ioContext.setInput(inputDirectory); @@ -226,25 +251,30 @@ List<File> modelFiles = new ArrayList<File>(); String[] includePatterns = includePattern.split(","); - getLog().info("Generating from " + inputDirectory + " : " + includePattern); + getLog().info("Generating from " + inputDirectory + " : " + + includePattern); for (File srcDirGen : ioContext.getInputs()) { if (configuration.isVerbose()) { - getLog().info("Search for " + Arrays.toString(includePatterns) + " in " + srcDirGen.getAbsolutePath()); + getLog().info("Search for " + Arrays.toString(includePatterns) + + " in " + srcDirGen.getAbsolutePath()); } - List<File> currentFiles = PluginHelper.getIncludedFiles(srcDirGen, includePatterns, null); + List<File> currentFiles = PluginHelper.getIncludedFiles( + srcDirGen, includePatterns, null); modelFiles.addAll(currentFiles); } // read the model - Model model = getModelReader().read(modelFiles.toArray(new File[modelFiles.size()])); + Model model = getModelReader().read(modelFiles.toArray( + new File[modelFiles.size()])); // apply all templates to the model for (Template<Model> template : getTemplatesList()) { - getLog().info("Apply " + template.getClass().getSimpleName() + " generator"); + getLog().info("Apply " + template.getClass().getSimpleName() + + " generator"); // apply template template.applyTemplate(model, ioContext.getOutput()); @@ -254,4 +284,4 @@ } -} \ No newline at end of file +} Modified: trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/writer/XmiChainedFileWriter.java =================================================================== --- trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/writer/XmiChainedFileWriter.java 2010-03-04 16:44:13 UTC (rev 834) +++ trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/writer/XmiChainedFileWriter.java 2010-03-04 18:03:17 UTC (rev 835) @@ -20,7 +20,6 @@ */ package org.nuiton.eugene.plugin.writer; -import org.nuiton.eugene.models.Model; import org.nuiton.eugene.models.object.ObjectModel; import org.nuiton.eugene.models.state.StateModel; import org.nuiton.eugene.writer.ChainedFileWriterConfiguration; @@ -363,4 +362,4 @@ } -} \ No newline at end of file +} Modified: trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/writer/ZargoChainedFileWriter.java =================================================================== --- trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/writer/ZargoChainedFileWriter.java 2010-03-04 16:44:13 UTC (rev 834) +++ trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/writer/ZargoChainedFileWriter.java 2010-03-04 18:03:17 UTC (rev 835) @@ -20,7 +20,6 @@ */ package org.nuiton.eugene.plugin.writer; -import org.nuiton.eugene.models.Model; import org.nuiton.eugene.writer.ChainedFileWriterConfiguration; import org.nuiton.plugin.PluginHelper; import org.nuiton.plugin.PluginIOContext;
participants (1)
-
tchemit@users.nuiton.org