Index: maven-generator-plugin/src/java/org/codelutin/generator/plugin/Zargo2Xmi.java diff -u maven-generator-plugin/src/java/org/codelutin/generator/plugin/Zargo2Xmi.java:1.2 maven-generator-plugin/src/java/org/codelutin/generator/plugin/Zargo2Xmi.java:1.3 --- maven-generator-plugin/src/java/org/codelutin/generator/plugin/Zargo2Xmi.java:1.2 Fri Apr 28 09:10:52 2006 +++ maven-generator-plugin/src/java/org/codelutin/generator/plugin/Zargo2Xmi.java Fri May 25 16:23:11 2007 @@ -23,10 +23,10 @@ * Created: 14 avril 2006 * * @author ruchaud - * @version $Revision: 1.2 $ + * @version $Revision: 1.3 $ * - * Last update: $Date: 2006/04/28 09:10:52 $ - * by : $Author: ruchaud $ + * Last update: $Date: 2007/05/25 16:23:11 $ + * by : $Author: chatellier $ */ package org.codelutin.generator.plugin; @@ -94,6 +94,7 @@ /* Source */ FileSet fileSet = new FileSet(); + fileSet.setProject(project); // resolve NullPointerException fileSet.setDir(srcDirZuml); fileSet.setIncludes("**/*.zargo,**/*.zuml"); zip.addFileset(fileSet); Index: maven-generator-plugin/src/java/org/codelutin/generator/plugin/Xmi2ObjectModel.java diff -u maven-generator-plugin/src/java/org/codelutin/generator/plugin/Xmi2ObjectModel.java:1.4 maven-generator-plugin/src/java/org/codelutin/generator/plugin/Xmi2ObjectModel.java:1.5 --- maven-generator-plugin/src/java/org/codelutin/generator/plugin/Xmi2ObjectModel.java:1.4 Fri Apr 28 09:10:52 2006 +++ maven-generator-plugin/src/java/org/codelutin/generator/plugin/Xmi2ObjectModel.java Fri May 25 16:23:11 2007 @@ -1,166 +1,35 @@ -/* *##% - * Copyright (C) 2006 - * Code Lutin, C?dric Pineau, Benjamin Poussin - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * 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 Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *##%*/ - -/* * - * Xmi2ObjectModel.java - * - * Created: 14 avril 2006 - * - * @author ruchaud - * @version $Revision: 1.4 $ - * - * Last update: $Date: 2006/04/28 09:10:52 $ - * by : $Author: ruchaud $ - */ - package org.codelutin.generator.plugin; -import java.io.File; - -import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; -import org.apache.tools.ant.BuildLogger; -import org.apache.tools.ant.NoBannerLogger; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.taskdefs.Copy; -import org.apache.tools.ant.taskdefs.XSLTProcess.Param; -import org.apache.tools.ant.types.FileSet; -import org.codelutin.xml.XSLAntTask; /** * Converti les fichiers XMI en fichier ObjectModel * * @goal xmi2objectmodel */ -public class Xmi2ObjectModel extends AbstractMojo { - /** - * Répertoire source des fichiers XMI - * - * @parameter alias="srcXmiDest" - * @required - */ - protected File srcDirXmi; - - /** - * Répertoire cible des fichiers générés - * - * @parameter alias="srcGenDest" - * @required - */ - protected File destDirObjectModel; - - /** - * Nom du paquetage pour les fichiers générés - * - * @parameter expression="org.codelutin.${project.artifactId}" - */ - protected String fullPackagePath; - - /** - * Nom du paquetage à généré - * - * @parameter - */ - protected String extractedPackages = ""; - - /** - * Ecrase les fichiers générés - * - * @parameter default-value="false" - */ - private boolean overwrite = false; - - public void execute() throws MojoExecutionException, MojoFailureException { - getLog().info("Converti les fichiers XMI en fichier ObjectModel"); - - actionXsl(); - actionCopy(); - } - - private void actionXsl() { - /* Création d'un projet ant */ - Project project = createProject(); - - /* Création de la tâche ant */ - XSLAntTask xsl = new XSLAntTask(); - xsl.setProject(project); - xsl.setTaskName("XSL"); - - /* Configuration */ - xsl.setOverwrite(overwrite); - - xsl.setSrcdir(srcDirXmi); - xsl.setIncludes("**/*.xmi"); - - destDirObjectModel.mkdirs(); - xsl.setDestdir(destDirObjectModel); - - xsl.setExtSubstitution("objectmodel"); - xsl.setStyle("xmi1.2ToObjectModel.xsl"); - - Param createParam = xsl.createParam(); - createParam.setName("fullPackagePath"); - createParam.setExpression(fullPackagePath); - createParam = xsl.createParam(); - createParam.setName("extraPackages"); - createParam.setExpression(extractedPackages); - - /* Execution */ - xsl.execute(); - } - - private 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"); - - /* Configuration */ - copy.setTodir(destDirObjectModel); - copy.setOverwrite(overwrite); - - FileSet fileSet = new FileSet(); - fileSet.setDir(srcDirXmi); - fileSet.setExcludes("**/*.xmi"); - copy.addFileset(fileSet); - - /* Execution */ - copy.execute(); - } - - private 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); - - project.init(); - project.getBaseDir(); - project.addBuildListener(logger); - return project; - } +public class Xmi2ObjectModel extends Xmi2Model { + /* (non-Javadoc) + * @see org.codelutin.generator.plugin.Xmi2Model#execute() + */ + @Override + public void execute() throws MojoExecutionException, MojoFailureException { + getLog().info("Conversion of XMI files into ObjectModel"); + 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() { + return "xmi1.2ToObjectModel.xsl"; + } } Index: maven-generator-plugin/src/java/org/codelutin/generator/plugin/Xmi2StateModel.java diff -u /dev/null maven-generator-plugin/src/java/org/codelutin/generator/plugin/Xmi2StateModel.java:1.1 --- /dev/null Fri May 25 16:23:16 2007 +++ maven-generator-plugin/src/java/org/codelutin/generator/plugin/Xmi2StateModel.java Fri May 25 16:23:11 2007 @@ -0,0 +1,54 @@ +/* *##% + * Copyright (C) 2006 Code Lutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * 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 Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ + +package org.codelutin.generator.plugin; + +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; + + +/** + * Converti les fichiers XMI en fichier StateModel + * + * @goal xmi2statemodel + */ +public class Xmi2StateModel extends Xmi2Model { + + /* (non-Javadoc) + * @see org.codelutin.generator.plugin.Xmi2Model#execute() + */ + @Override + public void execute() throws MojoExecutionException, MojoFailureException { + getLog().info("Conversion of XMI files into StateModel"); + 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() { + return "xmi1.2ToStateModel.xsl"; + } +} Index: maven-generator-plugin/src/java/org/codelutin/generator/plugin/Xmi2Model.java diff -u /dev/null maven-generator-plugin/src/java/org/codelutin/generator/plugin/Xmi2Model.java:1.1 --- /dev/null Fri May 25 16:23:17 2007 +++ maven-generator-plugin/src/java/org/codelutin/generator/plugin/Xmi2Model.java Fri May 25 16:23:11 2007 @@ -0,0 +1,174 @@ +/* *##% + * Copyright (C) 2006 + * Code Lutin, C?dric Pineau, Benjamin Poussin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * 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 Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ + +/* * + * Xmi2Model.java + * + * Created: 14 avril 2006 + * + * @author ruchaud + * @version $Revision: 1.1 $ + * + * Last update: $Date: 2007/05/25 16:23:11 $ + * by : $Author: chatellier $ + */ + +package org.codelutin.generator.plugin; + +import java.io.File; + +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.tools.ant.BuildLogger; +import org.apache.tools.ant.NoBannerLogger; +import org.apache.tools.ant.Project; +import org.apache.tools.ant.taskdefs.Copy; +import org.apache.tools.ant.taskdefs.XSLTProcess; +import org.apache.tools.ant.types.FileSet; +import org.apache.tools.ant.types.resources.URLResource; +import org.codelutin.util.Resource; + +/** + * Converti les fichiers XMI en fichier Model via une transformation XSLT + * a définir. + * + * Class abstraite sans feuille de style. + */ +public abstract class Xmi2Model extends AbstractMojo { + + /** + * Répertoire source des fichiers XMI + * + * @parameter alias="srcXmiDest" + * @required + */ + protected File srcDirXmi; + + /** + * Répertoire cible des fichiers générés + * + * @parameter alias="srcGenDest" + * @required + */ + protected File destDirObjectModel; + + /** + * Nom du paquetage pour les fichiers générés + * + * @parameter expression="org.codelutin.${project.artifactId}" + */ + protected String fullPackagePath; + + /** + * Nom du paquetage à généré + * + * @parameter + */ + protected String extractedPackages = ""; + + /** + * Ecrase les fichiers générés + * + * @parameter default-value="false" + */ + private boolean overwrite = false; + + public void execute() throws MojoExecutionException, MojoFailureException { + actionXsl(); + actionCopy(); + } + + private void actionXsl() { + /* Création d'un projet ant */ + Project project = createProject(); + + XSLTProcess xslt = new XSLTProcess(); + xslt.setProject(project); + xslt.setTaskName("XSL"); + xslt.setBasedir(srcDirXmi); + xslt.setIncludes("**/*.xmi"); + + destDirObjectModel.mkdirs(); + xslt.setDestdir(destDirObjectModel); + + xslt.setExtension("." + getExtension()); + xslt.setXslResource(new URLResource(Resource.getURL(getStyleSheet()))); + +// Param createParam = xsl.createParam(); +// createParam.setName("fullPackagePath"); +// createParam.setExpression(fullPackagePath); +// createParam = xsl.createParam(); +// createParam.setName("extraPackages"); +// createParam.setExpression(extractedPackages);*/ + + /* Execution */ + xslt.execute(); + } + + private 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"); + + /* Configuration */ + copy.setTodir(destDirObjectModel); + copy.setOverwrite(overwrite); + + FileSet fileSet = new FileSet(); + fileSet.setProject(project); + fileSet.setDir(srcDirXmi); + fileSet.setExcludes("**/*.xmi"); + copy.addFileset(fileSet); + + /* Execution */ + copy.execute(); + } + + private 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); + + project.init(); + project.getBaseDir(); + project.addBuildListener(logger); + return project; + } + + /** + * Set extention + * @return the extention + */ + protected abstract String getExtension(); + + /** + * Set style sheet + * @return the stylesheet + */ + protected abstract String getStyleSheet(); +} \ No newline at end of file