Author: tchemit Date: 2010-01-01 17:53:29 +0100 (Fri, 01 Jan 2010) New Revision: 781 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/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/pom.xml Log: - use last version of mavenpom and maven-helper-plugin new api - review exception management (should review it again together I think) 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 2009-12-20 16:49:46 UTC (rev 780) +++ trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/CopyVersionFiles.java 2010-01-01 16:53:29 UTC (rev 781) @@ -123,7 +123,7 @@ protected File fVersionDir; @Override - public void doAction() throws MojoExecutionException, MojoFailureException { + public void doAction() throws Exception { // find version and model name findVersionAndModelName(); @@ -138,11 +138,11 @@ String destDir = copyVersionDir.replace("%MODELNAME%", modelNameFound) + File.separator + versionFound; fVersionDir = new File(destDir); if (overwrite || !checkExistence()) { - try { +// 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); - } +// } catch (IOException ex) { +// throw new MojoExecutionException("could not copy some files for reason " + ex.getMessage(), ex); +// } } } 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 2009-12-20 16:49:46 UTC (rev 780) +++ trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/EugeneAbstractMojo.java 2010-01-01 16:53:29 UTC (rev 781) @@ -23,7 +23,6 @@ import org.nuiton.plugin.PluginIOContext; import java.io.File; -import java.io.IOException; import java.util.Arrays; import org.apache.maven.plugin.MojoExecutionException; @@ -146,7 +145,8 @@ } @Override - protected boolean init() throws Exception { + protected void init() throws Exception { +// protected boolean init() throws Exception { // init goal io context PluginIOContext p = initResources(); @@ -158,13 +158,14 @@ throw new MojoExecutionException("no output defined"); } - if (!p.getOutput().exists()) { - boolean b = p.getOutput().mkdirs(); - if (!b) { - throw new IOException("could not create directory " + p.getOutput()); - } - } - return true; + 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 2009-12-20 16:49:46 UTC (rev 780) +++ trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/EugenePlugin.java 2010-01-01 16:53:29 UTC (rev 781) @@ -18,20 +18,6 @@ * ##%*/ package org.nuiton.eugene.plugin; -import java.io.File; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLClassLoader; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Properties; -import java.util.Map.Entry; - -import java.util.Set; - import org.apache.commons.lang.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.model.Resource; @@ -41,9 +27,16 @@ import org.nuiton.eugene.ModelReader; import org.nuiton.eugene.Template; import org.nuiton.eugene.models.Model; -import org.nuiton.plugin.PluginIOContext; import org.nuiton.plugin.PluginHelper; +import org.nuiton.plugin.PluginIOContext; +import java.io.File; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.*; +import java.util.Map.Entry; + /** * Effectue toutes les générations et copie les fichiers générés * dans le répertoire de compilation @@ -154,7 +147,7 @@ @Override - public void doAction() throws MojoExecutionException, MojoFailureException { + public void doAction() throws Exception { getLog().info("Generating java sources from models"); getLog().info(" reader : " + reader); @@ -179,7 +172,8 @@ fixCompileSourceRoots(); } - 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 { +// protected <M extends Model> void generate(File[] modelFiles, ModelReader<M> modelReader) throws MojoFailureException, MojoExecutionException { if (modelReader == null) { // can skip @@ -201,11 +195,11 @@ for (Template<M> template : templatesList) { getLog().info("Apply " + template.getClass().getSimpleName() + " generator"); - try { +// try { template.applyTemplate(model, generateResources.getOutput()); - } catch (IOException eee) { - throw new MojoExecutionException("Generation problem", eee); - } +// } catch (IOException eee) { +// throw new MojoExecutionException("Generation problem", eee); +// } } } 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 2009-12-20 16:49:46 UTC (rev 780) +++ trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/SmartGenerateMojo.java 2010-01-01 16:53:29 UTC (rev 781) @@ -286,7 +286,8 @@ protected ClassLoader fixedClassLoader; @Override - protected boolean init() throws Exception { + protected void init() throws Exception { +// protected boolean init() throws Exception { modelType = modelType.trim().toLowerCase(); @@ -326,8 +327,9 @@ } if (engine.getSelectedWriters().isEmpty()) { - getLog().warn("No phase was detected, skip the goal."); - return false; + return; +// getLog().warn("No phase was detected, skip the goal."); +// return false; } if (properties == null) { @@ -353,6 +355,15 @@ properties.put(ModelChainedFileWriter.PROP_EXCLUDE_TEMPLATES, getExcludeTemplatesAsString()); } +// return true; + } + + @Override + protected boolean checkSkip() { + if (engine.getSelectedWriters().isEmpty()) { + getLog().warn("No phase was detected, skip the goal."); + return false; + } return true; } @@ -402,11 +413,11 @@ getLog().debug("Generating files and copying resources..."); } - try { +// try { writer.generate(this); - } catch (Exception e) { - throw new MojoExecutionException("could not generate for writer " + writer.getInputProtocol(), e); - } +// } catch (Exception e) { +// throw new MojoExecutionException("could not generate for writer " + writer.getInputProtocol(), e); +// } if ("model".equals(writer.getInputProtocol())) { 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 2009-12-20 16:49:46 UTC (rev 780) +++ trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/Xmi2Model.java 2010-01-01 16:53:29 UTC (rev 781) @@ -21,7 +21,6 @@ import org.nuiton.plugin.PluginIOContext; import java.io.File; import java.io.FileOutputStream; -import java.io.IOException; import java.lang.reflect.Constructor; import java.net.MalformedURLException; import java.net.URL; @@ -40,7 +39,6 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.project.MavenProject; import org.nuiton.plugin.PluginHelper; import org.nuiton.util.FasterCachedResourceResolver; @@ -155,7 +153,7 @@ protected abstract String getStyleSheet(File model); @Override - public void doAction() throws MojoExecutionException, MojoFailureException { + public void doAction() throws Exception { long t0 = System.nanoTime(); try { @@ -186,12 +184,12 @@ getLog().info("Copy resources files"); - try { +// 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); - } +// } catch (IOException ex) { +// throw new MojoExecutionException("could not copy some files for reason " + ex.getMessage(), ex); +// } } @Override @@ -241,7 +239,8 @@ File dstDir = xmiResources.getOutput(); if (!relatifPath.isEmpty()) { dstDir = new File(dstDir, relatifPath); - dstDir.mkdirs(); + createDirectoryIfNecessary(dstDir); +// dstDir.mkdirs(); } File result = new File(dstDir, filename); if (!overwrite && file.lastModified() < result.lastModified()) { 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 2009-12-20 16:49:46 UTC (rev 780) +++ trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/Xmi2ObjectModel.java 2010-01-01 16:53:29 UTC (rev 781) @@ -19,19 +19,16 @@ */ package org.nuiton.eugene.plugin; -import java.io.File; -import java.io.IOException; +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; +import org.xml.sax.helpers.DefaultHandler; import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; +import java.io.File; +import java.io.IOException; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.MojoFailureException; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; -import org.xml.sax.helpers.DefaultHandler; - /** * Converti les fichiers XMI en fichier ObjectModel * @@ -43,7 +40,8 @@ public class Xmi2ObjectModel extends Xmi2Model { @Override - public void doAction() throws MojoExecutionException, MojoFailureException { + 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 2009-12-20 16:49:46 UTC (rev 780) +++ trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/Xmi2StateModel.java 2010-01-01 16:53:29 UTC (rev 781) @@ -20,9 +20,6 @@ import java.io.File; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.MojoFailureException; - /** * Converti les fichiers XMI en fichier StateModel * @@ -31,7 +28,8 @@ public class Xmi2StateModel extends Xmi2Model { @Override - public void doAction() throws MojoExecutionException, MojoFailureException { + public void doAction() throws Exception { +// public void doAction() throws MojoExecutionException, MojoFailureException { getLog().info("Conversion of XMI files into StateModel"); super.doAction(); } 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 2009-12-20 16:49:46 UTC (rev 780) +++ trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/Zargo2Xmi.java 2010-01-01 16:53:29 UTC (rev 781) @@ -18,14 +18,11 @@ * ##%*/ package org.nuiton.eugene.plugin; -import java.io.IOException; -import java.io.File; - -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.MojoFailureException; -import org.nuiton.plugin.PluginIOContext; import org.nuiton.plugin.PluginHelper; +import org.nuiton.plugin.PluginIOContext; +import java.io.File; + /** * Extract zipped XMI files from zargo archive. * @@ -81,22 +78,23 @@ protected PluginIOContext zargoResources; @Override - public void doAction() throws MojoExecutionException, MojoFailureException { + 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"); - try { +// 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); - } +// } catch (IOException ex) { +// throw new MojoExecutionException("could not expand files for reason " + ex.getMessage(), ex); +// } getLog().info("Copy resources"); - try { +// 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); - } +// } catch (IOException ex) { +// throw new MojoExecutionException("could not copy some files for reason " + ex.getMessage(), ex); +// } } Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2009-12-20 16:49:46 UTC (rev 780) +++ trunk/pom.xml 2010-01-01 16:53:29 UTC (rev 781) @@ -9,7 +9,7 @@ <parent> <groupId>org.nuiton</groupId> <artifactId>mavenpom</artifactId> - <version>1.1.3</version> + <version>1.1.4-SNAPSHOT</version> </parent> <artifactId>eugene</artifactId>