[Lutingenerator-commits] r420 - in maven-generator-plugin/trunk: . src/main/java/org/codelutin/generator/plugin src/main/java/org/codelutin/generator/plugin/helper src/site src/site/rst/fr
Author: chatellier Date: 2009-02-10 11:24:35 +0000 (Tue, 10 Feb 2009) New Revision: 420 Modified: maven-generator-plugin/trunk/changelog.txt maven-generator-plugin/trunk/pom.xml maven-generator-plugin/trunk/src/main/java/org/codelutin/generator/plugin/CopyVersionFiles.java maven-generator-plugin/trunk/src/main/java/org/codelutin/generator/plugin/GeneratorPlugin.java maven-generator-plugin/trunk/src/main/java/org/codelutin/generator/plugin/Xmi2Model.java maven-generator-plugin/trunk/src/main/java/org/codelutin/generator/plugin/Xmi2ObjectModel.java maven-generator-plugin/trunk/src/main/java/org/codelutin/generator/plugin/Xmi2StateModel.java maven-generator-plugin/trunk/src/main/java/org/codelutin/generator/plugin/Zargo2Xmi.java maven-generator-plugin/trunk/src/main/java/org/codelutin/generator/plugin/helper/ResourceResolver.java maven-generator-plugin/trunk/src/site/rst/fr/index.rst maven-generator-plugin/trunk/src/site/site.xml Log: Ajout des valeurs par d?\195?\169faut sur les options. Tr?\195?\168s peu sont requises maintenant. Modified: maven-generator-plugin/trunk/changelog.txt =================================================================== --- maven-generator-plugin/trunk/changelog.txt 2009-02-09 20:11:48 UTC (rev 419) +++ maven-generator-plugin/trunk/changelog.txt 2009-02-10 11:24:35 UTC (rev 420) @@ -1,6 +1,8 @@ 0.64 ?? 200812?? - * 20090209 [chemit] - fix bug when using sibling dependencies in a multi-module project - * 20090129 [chemit] - use lutinproject 3.4 (suppress javadoc plugin invocation) + * 20090210 [chatellier] add info and debug maven log messages + * 20090210 [chatellier] add default value on all non required parameters + * 20090209 [chemit] fix bug when using sibling dependencies in a multi-module project + * 20090129 [chemit] use lutinproject 3.4 (suppress javadoc plugin invocation) 0.63 chemit 20081215 * 20081215 [chemit] follow lutingenerator release Modified: maven-generator-plugin/trunk/pom.xml =================================================================== --- maven-generator-plugin/trunk/pom.xml 2009-02-09 20:11:48 UTC (rev 419) +++ maven-generator-plugin/trunk/pom.xml 2009-02-10 11:24:35 UTC (rev 420) @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> @@ -69,35 +69,32 @@ <build> <defaultGoal>install</defaultGoal> + <plugins> <plugin> - <groupId>org.codehaus.plexus</groupId> - <artifactId>plexus-maven-plugin</artifactId> + <groupId>org.codehaus.plexus</groupId> + <artifactId>plexus-maven-plugin</artifactId> <version>1.3.8</version> + <executions> + <execution> + <goals> + <goal>descriptor</goal> + </goals> + </execution> + </executions> + </plugin> - <executions> - <execution> - <goals> - <goal>descriptor</goal> - </goals> - </execution> - </executions> - </plugin> - <plugin> <artifactId>maven-plugin-plugin</artifactId> <version>2.4.3</version> <configuration> - <requirements> - - </requirements> - </configuration> + <requirements/> + </configuration> <executions> <execution> <goals> <goal>addPluginArtifactMetadata</goal> </goals> - </execution> </executions> </plugin> Modified: maven-generator-plugin/trunk/src/main/java/org/codelutin/generator/plugin/CopyVersionFiles.java =================================================================== --- maven-generator-plugin/trunk/src/main/java/org/codelutin/generator/plugin/CopyVersionFiles.java 2009-02-09 20:11:48 UTC (rev 419) +++ maven-generator-plugin/trunk/src/main/java/org/codelutin/generator/plugin/CopyVersionFiles.java 2009-02-10 11:24:35 UTC (rev 420) @@ -1,5 +1,5 @@ /* *##% Plugin maven Generator - * Copyright (C) 2006 - 2008 CodeLutin + * Copyright (C) 2006 - 2009 CodeLutin * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as @@ -34,42 +34,50 @@ import org.dom4j.io.SAXReader; import org.dom4j.Document; -/* - * CopyVersionFiles +/** + * Copy a file set to a versionned directory structure. * * @author chatellier * * @version $Revision$ * * Last update : $Date$ By : $Author$ - */ -/** - * CopyVersionFiles.java * * @goal copyVersionFiles */ public class CopyVersionFiles extends AbstractMojo implements FileFilter { /** - * Fichiers objectModel a lire pour determiner la version + * Fichiers objectModel a lire pour determiner la version. * - * @parameter - * @required + * @parameter expression="${generator.includes}" default-value="*.*model" + * @since 0.51 */ protected String includes; /** - * Répertoire source + * Répertoire source où sont situer les modeles. * - * @parameter alias="srcGenDest" - * @required + * @parameter expression="${generator.srcGenDest}" alias="srcGenDest" default-value="target/generated-sources/models" + * @since 0.51 */ protected File srcDirGen; /** - * Le dossier de destination des mappings + * Répertoire sources des fichiers générés à copier. + * + * @parameter expression="${generator.destDirGen}" default-value="target/generated-sources/java" + * @since 0.51 + */ + protected File destDirGen; + + /** + * Le dossier de destination des fichiers copiés. * - * @parameter + * Doit contenir un nom de modele : <tt>%MODELNAME%</tt> + * + * @parameter expression="${generator.copyVersionDir}" + * @since 0.51 * @required */ protected String copyVersionDir; @@ -77,23 +85,17 @@ /** * Les mappings a sauvegarder * - * @parameter + * @parameter expression="${generator.copyVersionFiles}" + * @since 0.51 * @required */ protected String copyVersionFiles; /** - * Répertoire cible - * - * @parameter - * @required - */ - protected File destDirGen; - - /** * Ecrase les fichiers deja presents ? * - * @parameter default-value="false" + * @parameter expression="${generator.copyOverwrite}" default-value="false" + * @since 0.51 */ protected boolean copyOverwrite = false; Modified: maven-generator-plugin/trunk/src/main/java/org/codelutin/generator/plugin/GeneratorPlugin.java =================================================================== --- maven-generator-plugin/trunk/src/main/java/org/codelutin/generator/plugin/GeneratorPlugin.java 2009-02-09 20:11:48 UTC (rev 419) +++ maven-generator-plugin/trunk/src/main/java/org/codelutin/generator/plugin/GeneratorPlugin.java 2009-02-10 11:24:35 UTC (rev 420) @@ -1,5 +1,5 @@ /* *##% Plugin maven Generator - * Copyright (C) 2006 - 2008 CodeLutin + * Copyright (C) 2006 - 2009 CodeLutin * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as @@ -15,18 +15,6 @@ * License along with this program. If not, see * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*/ -/* * - * GeneratorPlugin.java - * - * Created: 14 avril 2006 - * - * @author ruchaud - * @version $Revision$ - * - * Last update: $Date$ - * by : $Author$ - */ - package org.codelutin.generator.plugin; import org.apache.maven.model.Resource; @@ -52,6 +40,12 @@ * Effectue toutes les générations et copie les fichiers générés * dans le répertoire de compilation * + * @author ruchaud + * @version $Revision$ + * + * Last update: $Date$ + * by : $Author$ + * * @goal generate * @projectRequired true */ @@ -61,52 +55,56 @@ * @description Dépendance du projet. * @parameter default-value="${project}" * @readonly + * @since 0.50 */ protected MavenProject project; /** * Répertoire source * - * @parameter expression="${generator.srcGenDest}" alias="srcGenDest" - * @required + * @parameter expression="${generator.srcGenDest}" alias="srcGenDest" default-value="target/generated-sources/models" + * @since 0.50 */ protected File srcDirGen; /** * Répertoire cible * - * @parameter expression="${generator.destDirGen}" - * @required + * @parameter expression="${generator.destDirGen}" default-value="target/generated-sources/java" + * @since 0.50 */ protected File destDirGen; /** - * Templates à utiliser, séparés par des virgules + * Templates à utiliser, séparés par des virgules. * * @parameter expression="${generator.templates}" * @required + * @since 0.50 */ protected String templates; /** - * Templates à ne pas utiliser + * Templates à ne pas utiliser. * * @parameter expression="${generator.excludeTemplates}" + * @since 0.63 */ protected String[] excludeTemplates; /** - * Fichier à inclure + * Fichier à inclure. * - * @parameter expression="${generator.includes}" - * @required + * @parameter expression="${generator.includes}" default-value="*.*model" + * @since 0.50 */ protected String includes; /** - * Nom par défaut du paquetage généré + * Nom par défaut du paquetage généré. * - * @parameter expression="org.codelutin.${project.artifactId}" + * @parameter expression="${generator.defaultPackage}" default-value="${project.groupId}.${project.artifactId}" + * @since 0.50 */ protected String defaultPackage; @@ -114,28 +112,35 @@ * Ecrase les fichiers générés * * @parameter expression="${generator.overwrite}" default-value="false" + * @since 0.50 */ private boolean overwrite = false; /** - * An extra direcotry to be added to the classpath. + * An extra directory to be added to the classpath. * * @parameter expression="${generator.extraClassPathDirectory}" + * @since 0.63 */ protected File extraClassPathDirectory; /** * Encoding to be used for generation of files. * - * @parameter expression="${generator.encoding}" default-value="${maven.compile.encoding} + * @parameter expression="${generator.encoding}" default-value="${maven.compile.encoding}" + * @since 0.60 */ protected String encoding; - + @Override public void execute() throws MojoExecutionException, MojoFailureException { - getLog().info("Effectue toutes les générations et copie les fichiers générés " - + "dans le répertoire de compilation"); + getLog().info("Generating model using : "); + getLog().info(" using template : " + templates); + getLog().info(" using defaultPackage : " + defaultPackage); + getLog().info(" generating from : " + srcDirGen + File.separator + includes); + getLog().info(" generating to : " + destDirGen); + /* Création d'un projet ant */ Project project = new Project(); @@ -167,7 +172,10 @@ generator.setProperties("defaultPackage=" + defaultPackage); generator.setIncludes(includes); - generator.setExcludeTemplates(excludeTemplates == null || excludeTemplates.length == 0 ? java.util.Collections.<String>emptyList() : java.util.Arrays.asList(excludeTemplates)); + generator.setExcludeTemplates(excludeTemplates == null + || excludeTemplates.length == 0 ? java.util.Collections + .<String> emptyList() : java.util.Arrays + .asList(excludeTemplates)); ClassLoader loader = fixClassLoader(); generator.setLoader(loader); @@ -181,13 +189,15 @@ */ protected void fixCompileSourceRoots() { - if (project != null && !project.getCompileSourceRoots().contains(destDirGen.getPath())) { - getLog().info("add compile source root : " + destDirGen); + if (project != null + && !project.getCompileSourceRoots().contains( + destDirGen.getPath())) { + getLog().info("Add compile source root : " + destDirGen); project.addCompileSourceRoot(destDirGen.getPath()); Resource resources = new Resource(); resources.setDirectory(destDirGen.getAbsolutePath()); resources.setExcludes(Arrays.asList("**/*.java")); - getLog().info("add resource root :" + resources); + getLog().info("Add resource root :" + resources); project.addResource(resources); } } @@ -206,22 +216,27 @@ try { List<URL> urls = new ArrayList<URL>(); if (extraClassPathDirectory != null) { - getLog().info("add extra directory in generator's classLoader : '" + extraClassPathDirectory + "'"); + getLog().info("Add extra directory in generator's classLoader : " + + extraClassPathDirectory); urls.add(extraClassPathDirectory.toURI().toURL()); } if (project.getProjectReferences() != null) { for (Object o : project.getProjectReferences().entrySet()) { Entry entry = (Entry) o; - MavenProject relatedProject = (MavenProject) entry.getValue(); - getLog().info("add project reference in generator's classLoader : '" + relatedProject.getArtifact() + "'"); + MavenProject relatedProject = (MavenProject) entry + .getValue(); + getLog().info("Add project reference in generator's classLoader : '" + + relatedProject.getArtifact() + "'"); //TODO il faudrait peut-etre aussi ajouter les dependances ? - urls.add(relatedProject.getArtifact().getFile().toURI().toURL()); + urls.add(relatedProject.getArtifact().getFile().toURI() + .toURL()); } } // we ask to add the directory in classloader ClassLoader loader = getClass().getClassLoader(); if (!urls.isEmpty()) { - loader = new URLClassLoader(urls.toArray(new URL[urls.size()]), loader); + loader = new URLClassLoader(urls.toArray(new URL[urls.size()]), + loader); } return loader; } catch (MalformedURLException e) { Modified: maven-generator-plugin/trunk/src/main/java/org/codelutin/generator/plugin/Xmi2Model.java =================================================================== --- maven-generator-plugin/trunk/src/main/java/org/codelutin/generator/plugin/Xmi2Model.java 2009-02-09 20:11:48 UTC (rev 419) +++ maven-generator-plugin/trunk/src/main/java/org/codelutin/generator/plugin/Xmi2Model.java 2009-02-10 11:24:35 UTC (rev 420) @@ -15,18 +15,6 @@ * License along with this program. If not, see * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*/ -/* * - * Xmi2Model.java - * - * Created: 14 avril 2006 - * - * @author ruchaud - * @version $Revision$ - * - * Last update: $Date$ - * by : $Author$ - */ - package org.codelutin.generator.plugin; import java.io.File; @@ -57,134 +45,134 @@ * Converti les fichiers XMI en fichier Model via une transformation XSLT a * définir. * - * Class abstraite sans feuille de style. + * Class abstraite sans feuille de style ni extension. + * + * @author ruchaud + * @version $Revision$ + * + * Last update: $Date$ + * by : $Author$ */ public abstract class Xmi2Model extends AbstractMojo { - /** - * Répertoire source des fichiers XMI - * - * @parameter alias="srcXmiDest" - * @required - */ - protected File srcDirXmi; + /** + * Répertoire source des fichiers XMI + * + * @parameter alias="srcXmiDest" expression=${generator.srcDirXmi} default-value="target/generated-sources/xmi" + * @since 0.50 + */ + protected File srcDirXmi; - /** - * Répertoire cible des fichiers générés - * - * @parameter alias="srcGenDest" - * @required - */ - protected File destDirObjectModel; + /** + * Répertoire cible des fichiers générés + * + * @parameter alias="srcGenDest" expression=${generator.srcGenDest} default-value="target/generated-sources/models" + * @since 0.50 + */ + protected File destDirModel; - /** - * Nom du paquetage pour les fichiers générés - * - * @parameter expression="org.codelutin.${project.artifactId}" - */ - protected String fullPackagePath; + /** + * Ecrase les fichiers générés + * + * @parameter expression=${generator.overwrite} default-value="false" + * @since 0.50 + */ + private boolean overwrite = false; - /** - * Nom du paquetage à généré - * - * @parameter - */ - protected String extractedPackages = ""; + @Override + public void execute() throws MojoExecutionException, MojoFailureException { + actionXsl(); + actionCopy(); + } - /** - * Ecrase les fichiers générés - * - * @parameter default-value="false" - */ - private boolean overwrite = false; + protected void actionXsl() throws MojoExecutionException { + + getLog().info("Processing XSL tranformation"); + getLog().info(" processing from " + srcDirXmi + " to " + destDirModel); + + List<File> files = FileUtil.getFilteredElements(srcDirXmi, + new FileFilter() { + public boolean accept(File pathname) { + return pathname != null + && pathname.getName().endsWith(".xmi"); + } + }, false); - public void execute() throws MojoExecutionException, MojoFailureException { - actionXsl(); - actionCopy(); - } + destDirModel.mkdirs(); - private void actionXsl() throws MojoExecutionException { - List<File> files = FileUtil.getFilteredElements(srcDirXmi, new FileFilter() { - public boolean accept(File pathname) { - return pathname != null && pathname.getName().endsWith(".xmi"); - } - }, false); - - destDirObjectModel.mkdirs(); - - TransformerFactory factory = TransformerFactory.newInstance(); - URIResolver resolver = new ResourceResolver(); + TransformerFactory factory = TransformerFactory.newInstance(); + URIResolver resolver = new ResourceResolver(); URL xsl = Resource.getURL(getStyleSheet()); - - for (File file : files) { - try { - File result = new File(destDirObjectModel, FileUtil.basename(file, ".xmi").concat( - ".").concat(getExtension())); - if (!overwrite && file.lastModified() < result.lastModified()) { - getLog().info("file up-to-date : "+result); + + for (File file : files) { + try { + File result = new File(destDirModel, FileUtil.basename(file, + ".xmi").concat(".").concat(getExtension())); + if (!overwrite && file.lastModified() < result.lastModified()) { + getLog().info("file up-to-date : " + result); continue; } - Transformer transformer = factory - .newTransformer(new StreamSource(xsl.openStream())); - transformer.setURIResolver(resolver); - transformer.transform(new StreamSource(file), new StreamResult( - new FileOutputStream(result))); + Transformer transformer = factory + .newTransformer(new StreamSource(xsl.openStream())); + transformer.setURIResolver(resolver); + transformer.transform(new StreamSource(file), new StreamResult( + new FileOutputStream(result))); - } catch (Exception e) { - throw new MojoExecutionException(e.getMessage(),e); - } - } - } + } catch (Exception e) { + throw new MojoExecutionException(e.getMessage(), e); + } + } + } - private void actionCopy() { - /* Création d'un projet ant */ - Project project = createProject(); + protected void actionCopy() { + /* Création d'un projet ant */ + Project project = createProject(); - /* Création de la tâche ant Copy */ - Copy copy = new Copy(); - copy.setProject(project); - copy.setTaskName("Copy ressources"); + /* Création de la tâche ant Copy */ + Copy copy = new Copy(); + copy.setProject(project); + copy.setTaskName("Copy ressources"); - /* Configuration */ - copy.setTodir(destDirObjectModel); - copy.setOverwrite(overwrite); + /* Configuration */ + copy.setTodir(destDirModel); + copy.setOverwrite(overwrite); - FileSet fileSet = new FileSet(); - fileSet.setProject(project); - fileSet.setDir(srcDirXmi); - fileSet.setExcludes("**/*.xmi"); - copy.addFileset(fileSet); + FileSet fileSet = new FileSet(); + fileSet.setProject(project); + fileSet.setDir(srcDirXmi); + fileSet.setExcludes("**/*.xmi"); + copy.addFileset(fileSet); - /* Execution */ - copy.execute(); - } + /* Execution */ + copy.execute(); + } - private Project createProject() { - /* Création d'un projet ant */ - Project project = new Project(); + protected Project createProject() { + /* Création d'un projet ant */ + Project project = new Project(); - BuildLogger logger = new NoBannerLogger(); - logger.setMessageOutputLevel(org.apache.tools.ant.Project.MSG_INFO); - logger.setOutputPrintStream(System.out); - logger.setErrorPrintStream(System.err); + BuildLogger logger = new NoBannerLogger(); + logger.setMessageOutputLevel(org.apache.tools.ant.Project.MSG_INFO); + logger.setOutputPrintStream(System.out); + logger.setErrorPrintStream(System.err); - project.init(); - project.getBaseDir(); - project.addBuildListener(logger); - return project; - } + project.init(); + project.getBaseDir(); + project.addBuildListener(logger); + return project; + } - /** - * Set extention - * - * @return the extention - */ - protected abstract String getExtension(); + /** + * Get extension. + * + * @return the extension + */ + protected abstract String getExtension(); - /** - * Set style sheet - * - * @return the stylesheet - */ - protected abstract String getStyleSheet(); + /** + * Get style sheet. + * + * @return the stylesheet + */ + protected abstract String getStyleSheet(); } Modified: maven-generator-plugin/trunk/src/main/java/org/codelutin/generator/plugin/Xmi2ObjectModel.java =================================================================== --- maven-generator-plugin/trunk/src/main/java/org/codelutin/generator/plugin/Xmi2ObjectModel.java 2009-02-09 20:11:48 UTC (rev 419) +++ maven-generator-plugin/trunk/src/main/java/org/codelutin/generator/plugin/Xmi2ObjectModel.java 2009-02-10 11:24:35 UTC (rev 420) @@ -1,6 +1,5 @@ -/* - * *##% Plugin maven Generator - * Copyright (C) 2006 - 2008 CodeLutin +/* *##% Plugin maven Generator + * Copyright (C) 2006 - 2009 CodeLutin * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as @@ -28,7 +27,7 @@ */ public class Xmi2ObjectModel extends Xmi2Model { - /* (non-Javadoc) + /* * @see org.codelutin.generator.plugin.Xmi2Model#execute() */ @Override @@ -37,14 +36,14 @@ super.execute(); } - /* (non-Javadoc) + /* * @see org.codelutin.generator.plugin.Xmi2Model#getExtention() */ public String getExtension() { return "objectmodel"; } - /* (non-Javadoc) + /* * @see org.codelutin.generator.plugin.Xmi2Model#getStyleSheet() */ protected String getStyleSheet() { Modified: maven-generator-plugin/trunk/src/main/java/org/codelutin/generator/plugin/Xmi2StateModel.java =================================================================== --- maven-generator-plugin/trunk/src/main/java/org/codelutin/generator/plugin/Xmi2StateModel.java 2009-02-09 20:11:48 UTC (rev 419) +++ maven-generator-plugin/trunk/src/main/java/org/codelutin/generator/plugin/Xmi2StateModel.java 2009-02-10 11:24:35 UTC (rev 420) @@ -1,5 +1,5 @@ /* *##% Plugin maven Generator - * Copyright (C) 2006 - 2008 CodeLutin + * Copyright (C) 2006 - 2009 CodeLutin * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as @@ -20,7 +20,6 @@ import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; - /** * Converti les fichiers XMI en fichier StateModel * @@ -28,7 +27,7 @@ */ public class Xmi2StateModel extends Xmi2Model { - /* (non-Javadoc) + /* * @see org.codelutin.generator.plugin.Xmi2Model#execute() */ @Override @@ -37,14 +36,14 @@ super.execute(); } - /* (non-Javadoc) + /* * @see org.codelutin.generator.plugin.Xmi2Model#getExtention() */ protected String getExtension() { return "statemodel"; } - /* (non-Javadoc) + /* * @see org.codelutin.generator.plugin.Xmi2Model#getStyleSheet() */ protected String getStyleSheet() { Modified: maven-generator-plugin/trunk/src/main/java/org/codelutin/generator/plugin/Zargo2Xmi.java =================================================================== --- maven-generator-plugin/trunk/src/main/java/org/codelutin/generator/plugin/Zargo2Xmi.java 2009-02-09 20:11:48 UTC (rev 419) +++ maven-generator-plugin/trunk/src/main/java/org/codelutin/generator/plugin/Zargo2Xmi.java 2009-02-10 11:24:35 UTC (rev 420) @@ -1,5 +1,5 @@ /* *##% Plugin maven Generator - * Copyright (C) 2006 - 2008 CodeLutin + * Copyright (C) 2006 - 2009 CodeLutin * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as @@ -15,18 +15,6 @@ * License along with this program. If not, see * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*/ -/* * - * Zargo2Xmi.java - * - * Created: 14 avril 2006 - * - * @author ruchaud - * @version $Revision$ - * - * Last update: $Date$ - * by : $Author$ - */ - package org.codelutin.generator.plugin; import java.io.File; @@ -43,74 +31,89 @@ import org.apache.tools.ant.types.PatternSet; /** - * Extrait le fichier XMI des fichiers zargo + * Extract zipped XMI files from zargo archive. * + * @author ruchaud + * @version $Revision$ + * + * Last update: $Date$ + * by : $Author$ + * * @goal zargo2xmi */ public class Zargo2Xmi extends AbstractMojo { - + /** - * Répertoire source des fichier Zargo + * Répertoire source des fichier Zargo. * - * @parameter alias="srcDirZuml" - * @required + * @parameter expression=${generator.srcDirZuml} default-value="src/main/xmi" + * @since 0.50 */ - protected File srcDirUml; + protected File srcDirZUml; /** - * Répertoire cible des fichiers extraits + * Répertoire cible des fichiers extraits. * - * @parameter alias="srcXmiDest" - * @required + * @parameter alias="srcXmiDest" expression=${generator.destDirXmi} default-value="target/generated-sources/xmi" + * @since 0.50 */ protected File destDirXmi; /** - * Ecrase les fichiers générés + * Ecrase les fichiers générés. * * @parameter default-value="false" */ - private boolean overwrite = false; + protected boolean overwrite = false; + @Override public void execute() throws MojoExecutionException, MojoFailureException { - getLog().info("Extrait le fichier XMI des fichiers zargo"); - + getLog().info("Extract zipped XMI files from zargo archive"); + getLog().info(" extracting from " + srcDirZUml + " to " + destDirXmi); + actionZip(); actionCopy(); } - private void actionZip() { + protected void actionZip() { + + getLog().debug("Executing unzip action in **/*.zargo,**/*.zuml"); + /* Création d'un projet ant */ Project project = createProject(); - + /* Création de la tâche */ Expand zip = new Expand(); zip.setProject(project); zip.setTaskName("Extract"); - + /* Configuration */ zip.setOverwrite(overwrite); /* Source */ FileSet fileSet = new FileSet(); fileSet.setProject(project); // resolve NullPointerException - fileSet.setDir(srcDirUml); + fileSet.setDir(srcDirZUml); fileSet.setIncludes("**/*.zargo,**/*.zuml"); zip.addFileset(fileSet); /* Target */ destDirXmi.mkdirs(); zip.setDest(destDirXmi); - + PatternSet patternSet = new PatternSet(); patternSet.setIncludes("*.xmi,**/*.xmi"); zip.addPatternset(patternSet); - + /* Execution */ zip.execute(); } - private void actionCopy(){ + protected void actionCopy() { + + getLog().debug("Executing copy from " + srcDirZUml + " to " + destDirXmi); + getLog().debug(" excluded resources : **/*.zargo,**/*.zuml"); + /* Création d'un projet ant */ Project project = createProject(); @@ -122,20 +125,20 @@ /* Configuration */ copy.setTodir(destDirXmi); copy.setOverwrite(overwrite); - + FileSet fileSet = new FileSet(); - fileSet.setDir(srcDirUml); + fileSet.setDir(srcDirZUml); fileSet.setExcludes("**/*.zargo,**/*.zuml"); copy.addFileset(fileSet); - + /* Execution */ copy.execute(); } - private Project createProject() { + protected Project createProject() { /* Création d'un projet ant */ Project project = new Project(); - + BuildLogger logger = new NoBannerLogger(); logger.setMessageOutputLevel(org.apache.tools.ant.Project.MSG_INFO); logger.setOutputPrintStream(System.out); @@ -146,5 +149,5 @@ project.addBuildListener(logger); return project; } - + } Modified: maven-generator-plugin/trunk/src/main/java/org/codelutin/generator/plugin/helper/ResourceResolver.java =================================================================== --- maven-generator-plugin/trunk/src/main/java/org/codelutin/generator/plugin/helper/ResourceResolver.java 2009-02-09 20:11:48 UTC (rev 419) +++ maven-generator-plugin/trunk/src/main/java/org/codelutin/generator/plugin/helper/ResourceResolver.java 2009-02-10 11:24:35 UTC (rev 420) @@ -1,3 +1,19 @@ +/* *##% Plugin maven Generator + * Copyright (C) 2008 - 2009 CodeLutin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*/ package org.codelutin.generator.plugin.helper; import java.net.MalformedURLException; @@ -8,7 +24,6 @@ import javax.xml.transform.stream.StreamSource; import org.codelutin.util.Resource; -import org.codelutin.generator.ObjectModelGenerator; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -40,12 +55,12 @@ private static final Log log = LogFactory.getLog(ResourceResolver.class); /** - * resolve href on local resource. + * Resolve href on local resource. * * @return null if local resource not found */ + @Override public Source resolve(String href, String base) { - // System.out.println("[ResourceResolver] " + href); String filename = null; try { filename = new URL(href).getPath(); @@ -63,7 +78,7 @@ return findSource(filename); } - Source findSource(String filename) { + protected Source findSource(String filename) { // System.out.println("[ResourceResolver] " + filename); String extension = null; Modified: maven-generator-plugin/trunk/src/site/rst/fr/index.rst =================================================================== (Binary files differ) Modified: maven-generator-plugin/trunk/src/site/site.xml =================================================================== --- maven-generator-plugin/trunk/src/site/site.xml 2009-02-09 20:11:48 UTC (rev 419) +++ maven-generator-plugin/trunk/src/site/site.xml 2009-02-10 11:24:35 UTC (rev 420) @@ -1,10 +1,12 @@ <?xml version="1.0" encoding="UTF-8"?> <project name="${project.name}"> + <publishDate format="dd/MM/yyyy"/> + <skin> <groupId>org.codelutin</groupId> <artifactId>maven-lutin-skin</artifactId> - <version>0.2.1</version> + <version>0.2.2</version> </skin> <bannerLeft> @@ -32,7 +34,11 @@ <menu name="Utilisateur"> <item href="index.html" name="Accueil"/> <item name="Goals" href="plugin-info.html"> + <item name="zargo2xmi" href="zargo2xmi-mojo.html"/> + <item name="xmi2statemodel" href="xmi2statemodel-mojo.html"/> + <item name="xmi2objectmodel" href="xmi2objectmodel-mojo.html"/> <item name="generate" href="generate-mojo.html"/> + <item name="copyVersionFiles" href="copyVersionFiles-mojo.html"/> <item name="help" href="help-mojo.html"/> </item> </menu>
participants (1)
-
chatellier@users.labs.libre-entreprise.org