Eugene-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
June 2010
- 3 participants
- 21 discussions
r932 - in trunk: . ant-eugene-task eugene maven-eugene-plugin
by tchemit@users.nuiton.org 29 Jun '10
by tchemit@users.nuiton.org 29 Jun '10
29 Jun '10
Author: tchemit
Date: 2010-06-29 14:30:01 +0200 (Tue, 29 Jun 2010)
New Revision: 932
Url: http://nuiton.org/repositories/revision/eugene/932
Log:
pass to version 2.1
Modified:
trunk/ant-eugene-task/pom.xml
trunk/eugene/pom.xml
trunk/maven-eugene-plugin/pom.xml
trunk/pom.xml
Modified: trunk/ant-eugene-task/pom.xml
===================================================================
--- trunk/ant-eugene-task/pom.xml 2010-06-29 11:50:43 UTC (rev 931)
+++ trunk/ant-eugene-task/pom.xml 2010-06-29 12:30:01 UTC (rev 932)
@@ -34,7 +34,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>eugene</artifactId>
- <version>2.0.3-SNAPSHOT</version>
+ <version>2.1-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.eugene</groupId>
Modified: trunk/eugene/pom.xml
===================================================================
--- trunk/eugene/pom.xml 2010-06-29 11:50:43 UTC (rev 931)
+++ trunk/eugene/pom.xml 2010-06-29 12:30:01 UTC (rev 932)
@@ -33,7 +33,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>eugene</artifactId>
- <version>2.0.3-SNAPSHOT</version>
+ <version>2.1-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.eugene</groupId>
Modified: trunk/maven-eugene-plugin/pom.xml
===================================================================
--- trunk/maven-eugene-plugin/pom.xml 2010-06-29 11:50:43 UTC (rev 931)
+++ trunk/maven-eugene-plugin/pom.xml 2010-06-29 12:30:01 UTC (rev 932)
@@ -34,7 +34,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>eugene</artifactId>
- <version>2.0.3-SNAPSHOT</version>
+ <version>2.1-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.eugene</groupId>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-06-29 11:50:43 UTC (rev 931)
+++ trunk/pom.xml 2010-06-29 12:30:01 UTC (rev 932)
@@ -37,7 +37,7 @@
</parent>
<artifactId>eugene</artifactId>
- <version>2.0.3-SNAPSHOT</version>
+ <version>2.1-SNAPSHOT</version>
<modules>
<module>eugene</module>
1
0
r931 - in trunk: . maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin
by tchemit@users.nuiton.org 29 Jun '10
by tchemit@users.nuiton.org 29 Jun '10
29 Jun '10
Author: tchemit
Date: 2010-06-29 13:50:43 +0200 (Tue, 29 Jun 2010)
New Revision: 931
Url: http://nuiton.org/repositories/revision/eugene/931
Log:
Evolution #713: Remove deprecated mojos
Evolution #735: Use mavenpom 2.2.2
Evolution #736: Use maven-helper-plugin 1.2.6
Removed:
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/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
Modified:
trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/SmartGenerateMojo.java
trunk/pom.xml
Deleted: 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-06-28 13:35:15 UTC (rev 930)
+++ trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/EugeneAbstractMojo.java 2010-06-29 11:50:43 UTC (rev 931)
@@ -1,193 +0,0 @@
-/*
- * #%L
- * EUGene :: Maven plugin
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2006 - 2010 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-
-package org.nuiton.eugene.plugin;
-
-import org.nuiton.plugin.PluginIOContext;
-
-import java.io.File;
-import java.util.Arrays;
-
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.project.MavenProject;
-import org.apache.maven.settings.Settings;
-import org.nuiton.plugin.AbstractPlugin;
-
-/**
- * La classe de base pour definir des mojos dans eugene.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0.0-rc-8
- */
-public abstract class EugeneAbstractMojo extends AbstractPlugin {
-
- /**
- * Maven project.
- *
- * @parameter default-value="${project}"
- * @readonly
- * @since 1.0.0-rc-8
- */
- protected MavenProject project;
- /**
- * Le settings (pour obtenir le mode offline).
- *
- * @parameter default-value="${settings}"
- * @readonly
- * @since 1.0.0-rc-4
- */
- protected Settings settings;
- /**
- * Ecrase les fichiers générés.
- *
- * @parameter expression="${eugene.overwrite}" default-value="false"
- * @since 0.50
- */
- protected boolean overwrite;
- /**
- * Pour activer le mode verbeux.
- *
- * @parameter expression="${eugene.verbose}" default-value="${maven.verbose}"
- * @since 1.0.0-rc-8
- */
- protected boolean verbose;
- /**
- * Encoding to be used for generation of files.
- *
- * @parameter expression="${eugene.encoding}" default-value="${project.build.sourceEncoding}"
- * @since 0.60
- */
- 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.
- *
- * @parameter expression="${eugene.testPhase}" default-value="false"
- * @since 0.64
- */
- protected boolean testPhase;
-
- /**
- * Note : l'objet peut etre {@code null} si la configuration ne definit
- * pas la propriété associées dans l'implentation.
- * <p/>
- * Dans tous les cas, une fois la methode {@link #initResources()} appele,
- * l'objet devrait ne plus être null!
- *
- * @return l'io du plugin ou {@code null} si non initialisé
- */
- protected abstract PluginIOContext getResources();
-
- /**
- * Initialiser les io du plugins.
- *
- * @return l'io intialisé (avec les valeurs par défaut, là où rien n'a
- * été renseigné).
- */
- protected abstract PluginIOContext initResources();
-
- /**
- * Build the {@link #getResources()} data.
- *
- * @param defaultIn the default input directory
- * @param defaultOut the default output directory
- * @param defaultTestIn the default test input directory
- * @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) {
-
- PluginIOContext resources = getResources();
- if (resources == null) {
- resources = new PluginIOContext();
- }
-
- // adding default inputs only if not consumed
- if (resources.getInputs() == null) {
- if (testPhase) {
- resources.setInput(defaultTestIn);
- } else {
- resources.setInput(defaultIn);
- }
- getLog().info(" using default in : " +
- Arrays.asList(resources.getInputs()));
- } else {
- getLog().info(" in : " +
- Arrays.asList(resources.getInputs()));
- }
-
- if (resources.getOutput() == null) {
- if (testPhase) {
- resources.setOutput(defaultTestOut);
- } else {
- resources.setOutput(defaultOut);
- }
- getLog().info(" using default out : " + resources.getOutput());
- } else {
- getLog().info(" out : " + resources.getOutput());
- }
-
- return resources;
- }
-
- @Override
- protected void init() throws Exception {
-
- // init goal io context
- PluginIOContext p = initResources();
-
- if (p.getInputs() == null || p.getInputs().length == 0) {
- throw new MojoExecutionException("no input defined");
- }
- if (p.getOutput() == null) {
- throw new MojoExecutionException("no output defined");
- }
-
- createDirectoryIfNecessary(p.getOutput());
- }
-
- @Override
- public MavenProject getProject() {
- return project;
- }
-
- @Override
- public boolean isVerbose() {
- return verbose;
- }
-
- @Override
- public void setProject(MavenProject project) {
- this.project = project;
- }
-
- @Override
- public void setVerbose(boolean verbose) {
- this.verbose = verbose;
- }
-}
Deleted: 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-06-28 13:35:15 UTC (rev 930)
+++ trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/EugenePlugin.java 2010-06-29 11:50:43 UTC (rev 931)
@@ -1,458 +0,0 @@
-/*
- * #%L
- * EUGene :: Maven plugin
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2006 - 2010 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-
-package org.nuiton.eugene.plugin;
-
-import org.apache.commons.lang.StringUtils;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.model.Resource;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.project.MavenProject;
-import org.nuiton.eugene.DefaultTemplateConfiguration;
-import org.nuiton.eugene.ModelReader;
-import org.nuiton.eugene.Template;
-import org.nuiton.eugene.models.Model;
-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
- *
- * @author ruchaud
- * @version $Revision$
- * <p/>
- * Last update: $Date$
- * by : * @goal generate
- * @requiresProject true
- * @deprecated since 2.0.0, use now the {@link SmartGenerateMojo}.
- */
-@Deprecated
-public class EugenePlugin extends EugeneAbstractMojo {
-
- /**
- * Les entrées sorties du plugin.
- * <p/>
- * <p/>
- * <p/>
- * 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/>
- * Par défaut on a les valeurs suivantes :
- * </p>
- * <pre>
- * <generateResources>
- * </p>
- * <input>target/generated-sources/models</input>
- * </p>
- * <output>target/generated-sources/java</output>
- * </p>
- * </generateResources>
- * </pre>
- * </p>
- * <p/>
- * Note: si {@link #testPhase} est activée, les valeurs par défaut sont :
- * </p>
- * <pre>
- * <generateResources>
- * </p>
- * <input>target/generated-sources/test-models</input>
- * </p>
- * <output>target/generated-sources/test-java</output>
- * </p>
- * </generateResources>
- * </pre>
- *
- * @parameter
- * @since 1.0.0-rc-8
- */
- protected PluginIOContext generateResources;
- /**
- * Templates à utiliser, séparés par des virgules.
- *
- * @parameter expression="${eugene.templates}"
- * @required
- * @since 0.50
- */
- protected String templates;
- /**
- * Templates à ne pas utiliser.
- *
- * @parameter expression="${eugene.excludeTemplates}"
- * @since 0.63
- */
- protected String[] excludeTemplates;
- /**
- * Fichier à inclure.
- *
- * @parameter expression="${eugene.includes}" default-value="*.*model"
- * @since 0.50
- */
- protected String includes;
- /**
- * Nom par défaut du paquetage généré.
- *
- * @parameter expression="${eugene.defaultPackage}" default-value="${project.groupId}.${project.artifactId}"
- * @since 0.50
- */
- protected String defaultPackage;
- /**
- * An extra directory to be added to the classpath.
- *
- * @parameter expression="${eugene.extraClassPathDirectory}"
- * @since 0.63
- */
- protected File extraClassPathDirectory;
- /**
- * List of packages to generate (comma separated).
- * <p/>
- * If the parameter is not filled, will generate all packages.
- *
- * @parameter expression="${eugene.generatedPackages}"
- * @since 1.0.0-rc-8
- */
- protected String generatedPackages;
-
- /**
- * Reader for transform input files in a Model to generate
- *
- * @parameter expression="${eugene.reader}"
- * @since 1.1.0
- */
- protected String reader;
-
-
- @Override
- public void doAction() throws Exception {
-
- getLog().info("Generating java sources from models");
- getLog().info(" reader : " + reader);
- getLog().info(" includes : " + includes);
- getLog().info(" using template : " + templates);
- getLog().info(" using defaultPackage : " + defaultPackage);
-
- File[] modelFiles = getModelFiles();
- if (modelFiles.length == 0) {
- // can skip
- getLog().warn("no model to treate");
- return;
- }
- if (verbose) {
- for (File m : modelFiles) {
- getLog().info("will treate model file : " + m);
- }
- }
- ModelReader<?> modelReader = getReader();
- generate(modelFiles, modelReader);
-
- fixCompileSourceRoots();
- }
-
- protected <M extends Model> void generate(
- File[] modelFiles, ModelReader<M> modelReader) throws Exception {
-
- if (modelReader == null) {
- // can skip
- getLog().warn("no reader to use");
- return;
- }
- M model = modelReader.read(modelFiles);
-
- if (StringUtils.isEmpty(generatedPackages)) {
- getLog().info(" generating all packages");
- } else {
- getLog().info(" generating only for packages " + generatedPackages);
- }
-
- List<Template<M>> templatesList = getTemplates(modelReader);
-
- for (Template<M> template : templatesList) {
- getLog().info("Apply " + template.getClass().getSimpleName() +
- " generator");
-
- template.applyTemplate(model, generateResources.getOutput());
- }
- }
-
- @Override
- protected PluginIOContext getResources() {
- return generateResources;
- }
-
- @Override
- protected PluginIOContext initResources() {
-
- 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");
-
- generateResources = initResources(
- defaultIn,
- defaultOut,
- defaultTestIn,
- defaultTestOut
- );
-
- return generateResources;
- }
-
- /**
- * Recuperation de la liste des fichiers de modele a traite.
- *
- * @return la liste des modeles a utiliser
- */
- protected File[] getModelFiles() {
- List<File> modelFiles = new ArrayList<File>();
- String[] includePatterns = includes.split(",");
-
- for (File srcDirGen : generateResources.getInputs()) {
-
- if (verbose) {
- getLog().info("Search for " + Arrays.toString(includePatterns)
- + " in " + srcDirGen.getAbsolutePath());
- }
- List<File> currentFiles = PluginHelper.getIncludedFiles(
- srcDirGen,
- includePatterns,
- null
- );
- modelFiles.addAll(currentFiles);
- }
- return modelFiles.toArray(new File[modelFiles.size()]);
- }
-
- protected ModelReader<?> getReader() throws MojoFailureException,
- MojoExecutionException {
- ModelReader<?> modelReader;
- try {
- ClassLoader fixedClassLoader = fixClassLoader();
- modelReader = (ModelReader<?>) Class.forName(
- reader,
- true,
- fixedClassLoader).newInstance();
- } catch (InstantiationException eee) {
- throw new MojoFailureException("Can't instantiate reader : " +
- reader, eee);
- } catch (IllegalAccessException eee) {
- throw new MojoFailureException("Can't access reader : " + reader,
- eee);
- } catch (ClassNotFoundException 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)
- 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_ENCODING, encoding);
- 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_EXCLUDE_TEMPLATES,
- getExcludeTemplatesAsString());
-
- List<Template<M>> templatesList = new ArrayList<Template<M>>();
- String[] templatesNames = templates.split(",");
- ClassLoader fixedClassLoader = fixClassLoader();
- for (String templateName : templatesNames) {
- // remove trailing spaces
- templateName = templateName.trim();
- try {
- Template<M> template = (Template<M>) Class.forName(templateName,
- true, fixedClassLoader).newInstance();
- // configuration
- template.setConfiguration(new DefaultTemplateConfiguration(templateProperties));
-// template.setProperties(templateProperties);
- templatesList.add(template);
- } catch (InstantiationException e) {
- throw new MojoFailureException("Can't instantiate generator : "
- + templateName, e);
- } catch (IllegalAccessException e) {
- throw new MojoFailureException("Can't access generator : " +
- templateName, e);
- } catch (ClassNotFoundException e) {
- throw new MojoFailureException("Can't found generator : " +
- templateName, e);
- }
- }
- return templatesList;
- }
-
- protected String getExcludeTemplatesAsString() {
- String result = "";
- for (int i = 0; i < excludeTemplates.length; i++) {
- result += excludeTemplates[i];
- if (i != excludeTemplates.length - 1) {
- result += ",";
- }
- }
- return result;
- }
-
- /**
- * 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
- return;
- }
-
- File destDirGen = generateResources.getOutput();
-
- //TODO-TC20091016 should use AbstractPlugin api
- if (testPhase) {
- if (!project.getTestCompileSourceRoots().contains(
- destDirGen.getPath())) {
- getLog().info("Add test compile source root : " + destDirGen);
- project.addTestCompileSourceRoot(destDirGen.getPath());
- Resource resources = new Resource();
- resources.setDirectory(destDirGen.getAbsolutePath());
- resources.setExcludes(Arrays.asList("**/*.java"));
- getLog().info("Add test resource root :" + resources);
- project.addTestResource(resources);
- }
- } else {
- if (!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);
- project.addResource(resources);
- }
- }
- }
-
- /**
- * Prepare le classLoader a utiliser dans le generateur.
- * <p/>
- * Si un {@link #extraClassPathDirectory} a été renseigné, il est rajouté.
- * <p/>
- * Si des références à des sibling modules, ils seront rajoutés aussi.
- *
- * @return le class loader modifie
- * @throws MojoExecutionException if any pb
- */
- protected ClassLoader fixClassLoader() throws MojoExecutionException {
- List<URL> urls = new ArrayList<URL>();
- Set<String> urlsAsString = new HashSet<String>();
- try {
- ClassLoader loader = null;
- if (extraClassPathDirectory != null) {
- if (verbose) {
- getLog().info("Add extra directory in generator's" +
- " classLoader : " + extraClassPathDirectory);
- }
- 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()) {
- Entry<?, ?> entry = (Entry<?, ?>) o;
- MavenProject relatedProject =
- (MavenProject) entry.getValue();
- if (verbose) {
- 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
- );
- }
- }
- if (!project.getArtifacts().isEmpty()) {
- // 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");
- }
- for (Object o : project.getArtifacts()) {
- Artifact a = (Artifact) o;
- if (!a.getScope().equals("provided")) {
- addDirectoryToUrlsList(a.getFile(), urls, urlsAsString);
- }
- }
- }
- // we ask to add the directory in classloader
- loader = getClass().getClassLoader();
- if (!urls.isEmpty()) {
- loader = new URLClassLoader(urls.toArray(new URL[urls.size()]),
- loader);
- }
- return loader;
- } catch (MalformedURLException e) {
- throw new MojoExecutionException(e.getMessage());
- } finally {
- urls.clear();
- urlsAsString.clear();
- }
-
- }
-}
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-06-28 13:35:15 UTC (rev 930)
+++ trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/SmartGenerateMojo.java 2010-06-29 11:50:43 UTC (rev 931)
@@ -44,6 +44,7 @@
import org.nuiton.eugene.writer.ChainedWriterEngine;
import org.nuiton.eugene.writer.WriterReport;
import org.nuiton.plugin.AbstractPlugin;
+import org.nuiton.plugin.PluginWithEncoding;
import org.nuiton.util.StringUtil;
import java.io.File;
@@ -71,7 +72,7 @@
* @requiresProject true
* @requiresDependencyResolution compile
*/
-public class SmartGenerateMojo extends AbstractPlugin implements ChainedFileWriterConfiguration {
+public class SmartGenerateMojo extends AbstractPlugin implements ChainedFileWriterConfiguration, PluginWithEncoding {
/**
* Inputs files to used to generate the required model files.
@@ -153,6 +154,9 @@
/**
* Encoding to be used for generation of files.
+ * <p/>
+ * <b>Note:</b> If nothing is filled here, we will use the system
+ * property {@code file.encoding}.
*
* @parameter expression="${eugene.encoding}" default-value="${project.build.sourceEncoding}"
* @since 2.0.0
@@ -574,6 +578,11 @@
}
@Override
+ public void setEncoding(String encoding) {
+ this.encoding = encoding;
+ }
+
+ @Override
public boolean isOverwrite() {
return overwrite;
}
Deleted: 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-06-28 13:35:15 UTC (rev 930)
+++ trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/Xmi2Model.java 2010-06-29 11:50:43 UTC (rev 931)
@@ -1,466 +0,0 @@
-/*
- * #%L
- * EUGene :: Maven plugin
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2006 - 2010 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-
-package org.nuiton.eugene.plugin;
-
-import org.nuiton.plugin.PluginIOContext;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.lang.reflect.Constructor;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-
-import java.util.Map.Entry;
-import java.util.Set;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.URIResolver;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
-
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.project.MavenProject;
-import org.nuiton.plugin.PluginHelper;
-import org.nuiton.util.FasterCachedResourceResolver;
-import org.nuiton.util.FileUtil;
-import org.nuiton.util.Resource;
-import org.nuiton.util.ResourceResolver;
-import org.nuiton.util.StringUtil;
-
-/**
- * Converti les fichiers XMI en fichier Model via une transformation XSLT a
- * définir.
- *
- * Class abstraite sans feuille de style ni extension.
- *
- * @author ruchaud
- * @version $Revision$
- *
- * Last update: $Date$
- * by : */
-public abstract class Xmi2Model extends EugeneAbstractMojo {
-
- /**
- * Les entrées sorties du plugin.
- *
- * <p/>
- *
- * 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.
- * <p/>
- * Par défaut on a les valeurs suivantes :
- * </p>
- * <pre>
- * <xmiResources>
- * </p>
- * <input>target/generated-sources/xmi<\input>
- * </p>
- * <output>target/generated-sources/models<\output>
- * </p>
- * </xmiResources>
- * </pre>
- *
- * </p>
- *
- * Note: si {@link #testPhase} est activée, les valeurs par défaut sont :
- * </p>
- * <pre>
- * <xmiResources>
- * </p>
- * <input>target/generated-sources/xmi<\input>
- * </p>
- * <output>target/generated-sources/test-models<\output>
- * </p>
- * </xmiResources>
- * </p>
- * </pre>
- *
- * @parameter
- * @since 1.0.0-rc-8
- */
- protected PluginIOContext xmiResources;
- /**
- * Nom du paquetage pour les fichiers générés
- *
- * @parameter expression="${generator.fullPackagePath}" default-value="${project.groupId}.${project.artifactId}"
- * @since 0.50
- */
- protected String fullPackagePath;
- /**
- * Nom du paquetage à généré
- *
- * @parameter expression="${generator.extractedPackages}" default-value="${project.groupId}.${project.artifactId}"
- * @since 0.50
- */
- protected String extractedPackages;
- /**
- * Liste des types de modeles acceptés séparés par des vigules.
- *
- * @parameter expression="${generator.acceptedXmiTypes}" default-value="xmi,uml"
- * @since 1.0.0-rc-4
- */
- protected String acceptedXmiTypes;
- /**
- * Nom du resolver a utiliser
- *
- * @parameter expression="${generator.resolver}" default-value="org.nuiton.util.ResourceResolver"
- * @since 1.0.0-rc-4
- */
- protected String resolver;
- /**
- * An extra directory to be added to the classpath.
- *
- * @parameter expression="${eugene.extraClassPathDirectory}"
- * @since 1.0.0-rc-4
- */
- protected File extraClassPathDirectory;
-
- /**
- * Get extension.
- *
- * @return the extension
- */
- protected abstract String getExtension();
-
- /**
- * Get style sheet.
- *
- * @param model the model file used to determine the stylesheet to use
- * @return the stylesheet name
- */
- protected abstract String getStyleSheet(File model);
-
- @Override
- public void doAction() throws Exception {
- long t0 = System.nanoTime();
- try {
-
- getLog().info("Processing XSL tranformation");
- getLog().info(" with fullPackagePath : " + fullPackagePath);
- getLog().info(" with extractedPackages : " + extractedPackages);
- getLog().info(" with acceptedXmiTypes : " + acceptedXmiTypes);
- getLog().info(" with resolver : " + resolver);
-
- TransformerFactory factory = TransformerFactory.newInstance();
-
- ClassLoader fixedClassLoader = fixClassLoader();
- String[] includes = getSuffixPattern("*");
-
- String[] acceptedTypesAsArray = getAcceptedTypesAsArray();
-
- for (File dir : xmiResources.getInputs()) {
- // recuperation des fichiers a traiter
- 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
- );
- }
- } finally {
- getLog().info("xsl done in " +
- StringUtil.convertTime(System.nanoTime() - t0));
- }
-
- getLog().info("Copy resources files");
-
- String[] excludes = getSuffixPattern("**/*");
- PluginHelper.copyFiles(xmiResources, null, excludes, overwrite);
- }
-
- @Override
- protected PluginIOContext getResources() {
- return xmiResources;
- }
-
- @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");
-
- xmiResources = initResources(
- defaultIn,
- defaultOut,
- defaultTestIn,
- defaultTestOut
- );
-
- return xmiResources;
- }
-
- protected String[] getSuffixPattern(String prefix) {
- String[] acceptedSuffixes = getAcceptedTypesAsArray();
- int max = acceptedSuffixes.length;
- String[] patterns = new String[max];
- for (int i = 0; i < max; i++) {
- patterns[i] = prefix + acceptedSuffixes[i];
- }
- return patterns;
- }
-
- 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);
- 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());
- File dstDir = xmiResources.getOutput();
- if (!relatifPath.isEmpty()) {
- dstDir = new File(dstDir, relatifPath);
- createDirectoryIfNecessary(dstDir);
-// dstDir.mkdirs();
- }
- File result = new File(dstDir, filename);
- if (!overwrite && file.lastModified() < result.lastModified()) {
- getLog().info("file up-to-date : " + result);
- continue;
- }
- if (getLog().isDebugEnabled()) {
- getLog().debug("generate " + result);
- }
-
- // Create the xsl transformer and set parameters
- Transformer transformer = factory.newTransformer(
- new StreamSource(xsl.openStream()));
-
- transformer.setParameter("fullPackagePath", fullPackagePath);
- transformer.setParameter("extraPackages", extractedPackages);
-
- transformer.setURIResolver(fileResolver);
- transformer.transform(
- new StreamSource(file),
- new StreamResult(new FileOutputStream(result))
- );
-
- } catch (Exception e) {
- throw new MojoExecutionException(e.getMessage(), e);
- }
- }
- }
-
- /**
- * Look for the types declared in property "acceptedXmiTypes", split it
- * on ',' and check for the leading '.'.
- *
- * @return an array with all the accepted xmi types and a leading '.'
- */
- protected String[] getAcceptedTypesAsArray() {
- String[] splittedTypes = acceptedXmiTypes.split(",");
- String[] result = new String[splittedTypes.length];
-
- for (int i = 0; i < splittedTypes.length; i++) {
- String type = splittedTypes[i];
- if (!type.startsWith(".")) {
- type = "." + type;
- }
- result[i] = type;
- }
-
- return result;
- }
-
- protected URIResolver getUriResolver(File model, ClassLoader cl) {
- URIResolver result = null;
-
- try {
- Class<?> clazz = Class.forName(resolver, true, cl);
-
- // Try to set the base using the constructor
- try {
- // Look for a constructor with a String parameter (base)
- 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",
- eee);
- }
-
- // If resolver is still not created, create it using the default
- // constructor
- if (result == null) {
- result = (URIResolver) clazz.newInstance();
- }
-
- if (result instanceof ResourceResolver) {
- ((ResourceResolver) result).setVerbose(verbose);
- ((ResourceResolver) result).setCl(cl);
- if (result instanceof FasterCachedResourceResolver) {
- boolean offline = settings.isOffline();
- getLog().debug("using offline mode ? : " + offline);
- ((FasterCachedResourceResolver) result).setOffline(offline);
- }
- }
-
- } catch (Exception eee) {
- getLog().warn("Unable to instantiate resolver using the default " +
- "constructor", eee);
- }
-
- return result;
- }
-
- /**
- * Prepare le classLoader a utiliser dans le generateur.
- * <p/>
- * Si un {@link #extraClassPathDirectory} a été renseigné, il est rajouté.
- * <p/>
- * Si des références à des sibling modules, ils seront rajoutés aussi.
- *
- * @return le class loader modifie
- * @throws MojoExecutionException if any pb
- */
- protected ClassLoader fixClassLoader() throws MojoExecutionException {
- Set<String> urlsAsString = new HashSet<String>();
- List<URL> urls = new ArrayList<URL>();
- try {
- ClassLoader loader;
- if (extraClassPathDirectory != null) {
- if (verbose) {
- getLog().info("Add extra directory in generator's " +
- "classLoader : " + extraClassPathDirectory);
- }
- 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()) {
- Entry<?, ?> entry = (Entry<?, ?>) o;
- MavenProject relatedProject =
- (MavenProject) entry.getValue();
- if (verbose) {
- 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
- );
- }
- }
- if (!project.getArtifacts().isEmpty()) {
- // 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");
- }
- for (Object o : project.getArtifacts()) {
- Artifact a = (Artifact) o;
- if (!a.getScope().equals("provided")) {
- addDirectoryToUrlsList(a.getFile(), urls, urlsAsString);
- }
- }
- }
- // we ask to add the directory in classloader
- loader = getClass().getClassLoader();
- if (getLog().isDebugEnabled()) {
- getLog().info("original classloader " + loader);
- }
- if (loader instanceof URLClassLoader) {
- // on reinjecte les urls de loader de base
- // car sinon on risque de ne pas retrouver les resources...
- for (URL u : ((URLClassLoader) loader).getURLs()) {
- addUrlToUrlsList(u, urls, urlsAsString);
- if (getLog().isDebugEnabled()) {
- getLog().debug("original cp entry: " + u);
- }
- }
- // et on force l'utilisation du classloader parent
- // s'il existe
- if (loader.getParent() != null) {
- loader = loader.getParent();
- }
- }
- if (!urls.isEmpty()) {
- loader = new URLClassLoader(urls.toArray(new URL[urls.size()]),
- loader);
- }
- if (getLog().isDebugEnabled()) {
- for (URL u : urls) {
- getLog().debug("cp entry: " + u);
- }
- }
- return loader;
- } catch (MalformedURLException e) {
- throw new MojoExecutionException(e.getMessage());
- } finally {
- urls.clear();
- urlsAsString.clear();
- }
-
- }
-}
Deleted: 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-06-28 13:35:15 UTC (rev 930)
+++ trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/Xmi2ObjectModel.java 2010-06-29 11:50:43 UTC (rev 931)
@@ -1,136 +0,0 @@
-/*
- * #%L
- * EUGene :: Maven plugin
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2006 - 2010 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-
-package org.nuiton.eugene.plugin;
-
-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;
-
-/**
- * Converti les fichiers XMI en fichier ObjectModel
- *
- * @goal xmi2objectmodel
- *
- * @requiresDependencyResolution compile
- * @requiresProject
- */
-public class Xmi2ObjectModel extends Xmi2Model {
-
- @Override
- public void doAction() throws Exception {
- getLog().info("Conversion of XMI files into ObjectModel");
- super.doAction();
- }
-
- @Override
- public String getExtension() {
- return "objectmodel";
- }
-
- @Override
- protected String getStyleSheet(File model) {
- String styleSheet = null;
-
- String version = getXmiVersion(model);
- if (version.startsWith("1.")) {
- styleSheet = "xmi1.2ToObjectModel.xsl";
- } else if (version.startsWith("2.")) {
- styleSheet = "xmi2.1ToObjectModel.xsl";
- } else {
- getLog().error("Unsupported xmi version [" + version + "]");
- }
-
- return styleSheet;
- }
-
- /**
- * Try to find xmi version on a file.
- *
- * @param xmiFile
- * file to inspect
- * @return version or null if version can't have been found
- */
- protected String getXmiVersion(File xmiFile) {
- String version = null;
-
- SAXParserFactory factory = SAXParserFactory.newInstance();
-
- try {
- SAXParser parser = factory.newSAXParser();
-
- XmiVersionHandler handler = new XmiVersionHandler();
- parser.parse(xmiFile, handler);
-
- version = handler.getVersion();
- } catch (ParserConfigurationException e) {
- getLog().debug("Can't parse file as xmi", e);
- } catch (SAXException e) {
- getLog().debug("Can't parse file as xmi", e);
- } catch (IOException e) {
- getLog().debug("Can't parse file as xmi", e);
- }
-
- return version;
- }
-
- /**
- * Sax handler to find xmi version into xmi document.
- */
- protected class XmiVersionHandler extends DefaultHandler {
-
- public String version;
-
- public XmiVersionHandler() {
- }
-
- public String getVersion() {
- return version;
- }
-
- @Override
- public void startElement(String uri, String localName, String qName,
- Attributes attributes) throws SAXException {
-
- if (qName.equals("XMI")) {
- version = attributes.getValue("xmi.version");
- getLog().debug("XMI version found : " + version);
- }
-
- if (version == null) {
- version = attributes.getValue("xmi:version");
- getLog().debug("XMI version found : " + version);
- }
-
- }
- }
-
-}
Deleted: 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-06-28 13:35:15 UTC (rev 930)
+++ trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/Xmi2StateModel.java 2010-06-29 11:50:43 UTC (rev 931)
@@ -1,54 +0,0 @@
-/*
- * #%L
- * EUGene :: Maven plugin
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2006 - 2010 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-
-package org.nuiton.eugene.plugin;
-
-import java.io.File;
-
-/**
- * Converti les fichiers XMI en fichier StateModel
- *
- * @goal xmi2statemodel
- */
-public class Xmi2StateModel extends Xmi2Model {
-
- @Override
- public void doAction() throws Exception {
- getLog().info("Conversion of XMI files into StateModel");
- super.doAction();
- }
-
- @Override
- protected String getExtension() {
- return "statemodel";
- }
-
- @Override
- protected String getStyleSheet(File model) {
- //TODO when StateModel will be supported in 2.1, compute the version
- //TODO to resolve the correct stylesheet
- return "xmi1.2ToStateModel.xsl";
- }
-}
Deleted: 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-06-28 13:35:15 UTC (rev 930)
+++ trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/Zargo2Xmi.java 2010-06-29 11:50:43 UTC (rev 931)
@@ -1,129 +0,0 @@
-/*
- * #%L
- * EUGene :: Maven plugin
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2006 - 2010 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-
-package org.nuiton.eugene.plugin;
-
-import org.nuiton.plugin.PluginHelper;
-import org.nuiton.plugin.PluginIOContext;
-
-import java.io.File;
-
-/**
- * Extract zipped XMI files from zargo archive.
- *
- * @author ruchaud
- * @version $Revision$
- *
- * Last update: $Date$
- * by : *
- * @goal zargo2xmi
- */
-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"};
- /**
- * Les entrées-sorties du plugin.
- *
- * <p/>
- *
- * 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.
- * <p/>
- * Par défaut on a les valeurs suivantes :
- * </p>
- * <pre>
- * <zargoResources>
- * </p>
- * <input>src/main/xmi</input>
- * </p>
- * <output>target/generated-sources/xmi</ouput>
- * </p>
- * </zargoResources>
- * </pre>
- * </p>
- *
- * Note: si {@link #testPhase} est activée, les valeurs par défaut sont :
- * </p>
- * <pre>
- * <zargoResources>
- * </p>
- * <input>src/test/xmi</input>
- * </p>
- * <output>target/generated-sources/test-xmi</ouput>
- * </p>
- * <zargoResources>
- * </pre>
- *
- * @parameter
- * @since 1.0.0-rc-8
- */
- protected PluginIOContext zargoResources;
-
- @Override
- public void doAction() throws Exception {
- getLog().info("Extract zipped XMI files from zargo archive and " +
- "copy resources");
-
- getLog().info("Extract zipped XMI files");
- PluginHelper.expandFiles(zargoResources, ZARGO_FILE_FILTER, null,
- XMI_FILE_FILTER, overwrite);
-
- getLog().info("Copy resources");
- PluginHelper.copyFiles(zargoResources, null, ZARGO_FILE_FILTER,
- overwrite);
- }
-
- @Override
- protected PluginIOContext getResources() {
- return zargoResources;
- }
-
- @Override
- protected PluginIOContext initResources() {
-
- File defaultIn = getFileFromBasedir("src", "main", "xmi");
- File defaultOut = getFileFromBasedir("target", "generated-sources",
- "xmi");
-
- File defaultTestIn = getFileFromBasedir("src", "test", "xmi");
- File defaultTestOut = getFileFromBasedir("target", "generated-sources",
- "test-xmi");
-
- zargoResources = initResources(
- defaultIn,
- defaultOut,
- defaultTestIn,
- defaultTestOut
- );
-
- return zargoResources;
- }
-}
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-06-28 13:35:15 UTC (rev 930)
+++ trunk/pom.xml 2010-06-29 11:50:43 UTC (rev 931)
@@ -33,7 +33,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom4redmine</artifactId>
- <version>2.2.1</version>
+ <version>2.2.2-SNAPSHOT</version>
</parent>
<artifactId>eugene</artifactId>
1
0
r930 - trunk/eugene/src/main/java/org/nuiton/eugene/models/object
by fdesbois@users.nuiton.org 28 Jun '10
by fdesbois@users.nuiton.org 28 Jun '10
28 Jun '10
Author: fdesbois
Date: 2010-06-28 15:35:15 +0200 (Mon, 28 Jun 2010)
New Revision: 930
Url: http://nuiton.org/repositories/revision/eugene/930
Log:
identify problem for Ano #720
Modified:
trunk/eugene/src/main/java/org/nuiton/eugene/models/object/ObjectModelGenerator.java
Modified: trunk/eugene/src/main/java/org/nuiton/eugene/models/object/ObjectModelGenerator.java
===================================================================
--- trunk/eugene/src/main/java/org/nuiton/eugene/models/object/ObjectModelGenerator.java 2010-06-28 07:23:24 UTC (rev 929)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/ObjectModelGenerator.java 2010-06-28 13:35:15 UTC (rev 930)
@@ -269,7 +269,7 @@
* @return le nom du fichier a generer
*/
public String getFilenameForModel(ObjectModel model) {
- // TODO throw exception when model.getName() == null or empty
+ // FIXME-2009-11-24 : Ano #720 throw exception when model.getName() == null or empty
return model.getName();
}
1
0
r929 - in trunk: ant-eugene-task/src ant-eugene-task/src/license eugene/src eugene/src/license maven-eugene-plugin/src maven-eugene-plugin/src/license
by tchemit@users.nuiton.org 28 Jun '10
by tchemit@users.nuiton.org 28 Jun '10
28 Jun '10
Author: tchemit
Date: 2010-06-28 09:23:24 +0200 (Mon, 28 Jun 2010)
New Revision: 929
Url: http://nuiton.org/repositories/revision/eugene/929
Log:
consolidate THIRD-PARTY
Added:
trunk/ant-eugene-task/src/license/
trunk/ant-eugene-task/src/license/THIRD-PARTY.properties
trunk/eugene/src/license/
trunk/eugene/src/license/THIRD-PARTY.properties
trunk/maven-eugene-plugin/src/license/
trunk/maven-eugene-plugin/src/license/THIRD-PARTY.properties
Added: trunk/ant-eugene-task/src/license/THIRD-PARTY.properties
===================================================================
--- trunk/ant-eugene-task/src/license/THIRD-PARTY.properties (rev 0)
+++ trunk/ant-eugene-task/src/license/THIRD-PARTY.properties 2010-06-28 07:23:24 UTC (rev 929)
@@ -0,0 +1,19 @@
+# Generated by org.nuiton.license.plugin.AddThirdPartyMojo
+#-------------------------------------------------------------------------------
+# Already used licenses in project :
+# - Common Public License Version 1.0
+# - LGPL
+# - Lesser General Public License (LGPL) v 3.0
+# - The Apache Software License, Version 2.0
+#-------------------------------------------------------------------------------
+# Please fill the missing licenses for dependencies :
+#
+#
+#Mon Jun 28 09:19:52 CEST 2010
+commons-primitives--commons-primitives--1.0=The Apache Software License, Version 2.0
+dom4j--dom4j--1.6.1=BSD
+jaxen--jaxen--1.1.1=http://jaxen.codehaus.org/license.html
+jdom--jdom--1.0=The Apache Software License, Version 2.0
+org.apache.ant--ant--1.8.0=The Apache Software License, Version 2.0
+org.apache.ant--ant-launcher--1.8.0=The Apache Software License, Version 2.0
+xalan--xalan--2.6.0=The Apache Software License, Version 2.0
Property changes on: trunk/ant-eugene-task/src/license/THIRD-PARTY.properties
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/eugene/src/license/THIRD-PARTY.properties
===================================================================
--- trunk/eugene/src/license/THIRD-PARTY.properties (rev 0)
+++ trunk/eugene/src/license/THIRD-PARTY.properties 2010-06-28 07:23:24 UTC (rev 929)
@@ -0,0 +1,18 @@
+# Generated by org.nuiton.license.plugin.AddThirdPartyMojo
+#-------------------------------------------------------------------------------
+# Already used licenses in project :
+# - Common Public License Version 1.0
+# - Eclipse Public License - v 1.0
+# - LGPL
+# - Lesser General Public License (LGPL) v 3.0
+# - The Apache Software License, Version 2.0
+#-------------------------------------------------------------------------------
+# Please fill the missing licenses for dependencies :
+#
+#
+#Sun Jun 27 09:01:58 CEST 2010
+commons-primitives--commons-primitives--1.0=The Apache Software License, Version 2.0
+dom4j--dom4j--1.6.1=BSD
+jaxen--jaxen--1.1.1=http://jaxen.codehaus.org/license.html
+jdom--jdom--1.0=The Apache Software License, Version 2.0
+xalan--xalan--2.6.0=The Apache Software License, Version 2.0
Property changes on: trunk/eugene/src/license/THIRD-PARTY.properties
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/maven-eugene-plugin/src/license/THIRD-PARTY.properties
===================================================================
--- trunk/maven-eugene-plugin/src/license/THIRD-PARTY.properties (rev 0)
+++ trunk/maven-eugene-plugin/src/license/THIRD-PARTY.properties 2010-06-28 07:23:24 UTC (rev 929)
@@ -0,0 +1,22 @@
+# Generated by org.nuiton.license.plugin.AddThirdPartyMojo
+#-------------------------------------------------------------------------------
+# Already used licenses in project :
+# - BSD
+# - Common Public License Version 1.0
+# - LGPL
+# - Lesser General Public License (LGPL) v 3.0
+# - Public Domain
+# - The Apache Software License, Version 2.0
+# - http://jaxen.codehaus.org/license.html
+#-------------------------------------------------------------------------------
+# Please fill the missing licenses for dependencies :
+#
+#
+#Mon Jun 28 09:22:18 CEST 2010
+classworlds--classworlds--1.1-alpha-2=http\://classworlds.codehaus.org/license.html
+commons-primitives--commons-primitives--1.0=The Apache Software License, Version 2.0
+dom4j--dom4j--1.6.1=BSD
+jaxen--jaxen--1.1.1=http\://jaxen.codehaus.org/license.html
+jdom--jdom--1.0=The Apache Software License, Version 2.0
+org.codehaus.plexus--plexus-container-default--1.0-alpha-9-stable-1=The Apache Software License, Version 2.0
+xalan--xalan--2.6.0=The Apache Software License, Version 2.0
Property changes on: trunk/maven-eugene-plugin/src/license/THIRD-PARTY.properties
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
1
0
27 Jun '10
Author: fdesbois
Date: 2010-06-27 14:50:47 +0200 (Sun, 27 Jun 2010)
New Revision: 928
Url: http://nuiton.org/repositories/revision/eugene/928
Log:
Evo #712 : Add documentation to clone
Modified:
trunk/eugene/src/main/java/org/nuiton/eugene/java/ObjectModelTransformerToJava.java
Modified: trunk/eugene/src/main/java/org/nuiton/eugene/java/ObjectModelTransformerToJava.java
===================================================================
--- trunk/eugene/src/main/java/org/nuiton/eugene/java/ObjectModelTransformerToJava.java 2010-06-27 06:35:23 UTC (rev 927)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/java/ObjectModelTransformerToJava.java 2010-06-27 12:50:47 UTC (rev 928)
@@ -28,6 +28,7 @@
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.nuiton.eugene.GeneratorUtil;
import org.nuiton.eugene.Template;
import org.nuiton.eugene.models.object.ObjectModel;
import org.nuiton.eugene.models.object.ObjectModelAttribute;
@@ -331,20 +332,31 @@
*/
public ObjectModelOperation cloneOperationSignature(ObjectModelOperation source,
ObjectModelClassifier destination,
+ boolean documentation,
ObjectModelModifier... modifiers) {
- ObjectModelOperation result =
+ ObjectModelOperation outputOperation =
addOperation(destination, source.getName(), source.getReturnType(), modifiers);
+ if (documentation && GeneratorUtil.hasDocumentation(source)) {
+ setDocumentation(outputOperation, source.getDocumentation());
+ }
+
for (ObjectModelParameter parameter : source.getParameters()) {
- addParameter(result, parameter.getType(), parameter.getName());
+
+ ObjectModelParameter outputParam =
+ addParameter(outputOperation, parameter.getType(), parameter.getName());
+
+ if (documentation && GeneratorUtil.hasDocumentation(parameter)) {
+ setDocumentation(outputParam, parameter.getDocumentation());
+ }
}
for (String exception : source.getExceptions()) {
- addException(result, exception);
+ addException(outputOperation, exception);
}
- return result;
+ return outputOperation;
}
/**
1
0
Author: tchemit
Date: 2010-06-27 08:35:23 +0200 (Sun, 27 Jun 2010)
New Revision: 927
Url: http://nuiton.org/repositories/revision/eugene/927
Log:
Utilisation de mavenpom4redmine 2.2.1
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-06-25 15:33:26 UTC (rev 926)
+++ trunk/pom.xml 2010-06-27 06:35:23 UTC (rev 927)
@@ -33,7 +33,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom4redmine</artifactId>
- <version>2.2</version>
+ <version>2.2.1</version>
</parent>
<artifactId>eugene</artifactId>
1
0
r926 - in trunk/maven-eugene-plugin/src: it main/java/org/nuiton/eugene/plugin
by fdesbois@users.nuiton.org 25 Jun '10
by fdesbois@users.nuiton.org 25 Jun '10
25 Jun '10
Author: fdesbois
Date: 2010-06-25 17:33:26 +0200 (Fri, 25 Jun 2010)
New Revision: 926
Url: http://nuiton.org/repositories/revision/eugene/926
Log:
Remove deprecated copyVersionFiles goal
Removed:
trunk/maven-eugene-plugin/src/it/copyVersionFiles/
trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/CopyVersionFiles.java
Deleted: 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-06-25 10:18:33 UTC (rev 925)
+++ trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/CopyVersionFiles.java 2010-06-25 15:33:26 UTC (rev 926)
@@ -1,257 +0,0 @@
-/*
- * #%L
- * EUGene :: Maven plugin
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2006 - 2010 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-
-package org.nuiton.eugene.plugin;
-
-import org.nuiton.plugin.PluginIOContext;
-import java.io.File;
-import java.util.List;
-
-import org.dom4j.DocumentException;
-import org.dom4j.Node;
-import org.dom4j.io.SAXReader;
-import org.dom4j.Document;
-import org.nuiton.plugin.PluginHelper;
-
-/**
- * Copy a file set to a versionned directory structure.
- *
- * @author chatellier
- *
- * @version $Revision$
- *
- * Last update : $Date$ By : *
- * @goal copyVersionFiles
- * @deprecated since 2.0.2, will not be replaced (ToPIA migration service does not need old mapping files any longer).
- */
-@Deprecated
-public class CopyVersionFiles extends EugeneAbstractMojo { //implements FileFilter {
-
- /**
- * Les entrées sorties du plugin.
- *
- * <p/>
- *
- * 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/>
- * Par défaut on a les valeurs suivantes :
- * </p>
- * <pre>
- * <copyVersionResources>
- * </p>
- * <input>target/generated-sources/models</input>
- * </p>
- * <output>target/generated-sources/java</output>
- * </p>
- * </copyVersionResources>
- * </pre>
- * </p>
- *
- * Note: si {@link #testPhase} est activée, les valeurs par défaut sont :
- * </p>
- * <pre>
- * <copyVersionResources>
- * </p>
- * <input>target/generated-sources/test-models</input>
- * </p>
- * <output>target/generated-sources/test-java</output>
- * </p>
- * </copyVersionResources>
- * </pre>
- *
- * @parameter
- * @since 1.0.0-rc-8
- */
- protected PluginIOContext copyVersionResources;
- /**
- * Fichiers objectModel a lire pour determiner la version.
- *
- * @parameter expression="${generator.includes}" default-value="*.*model"
- * @since 0.51
- */
- protected String includes;
- /**
- * Le dossier de destination des fichiers copiés.
- *
- * Doit contenir un nom de modele : <tt>%MODELNAME%</tt>
- *
- * @parameter expression="${generator.copyVersionDir}"
- * @since 0.51
- * @required
- */
- protected String copyVersionDir;
- /**
- * Les mappings a sauvegarder
- *
- * @parameter expression="${generator.copyVersionFiles}"
- * @since 0.51
- * @required
- */
- protected String copyVersionFiles;
- /**
- * Version trouvee dans les fichiers objectModel.
- *
- * Type string, parce que elle peut avoir la forme "1.3.2" par exemple
- */
- protected String versionFound;
- /**
- * Nom du model sauvegarde
- */
- protected String modelNameFound;
- /**
- * Dossier incluant le nom de la version
- */
- protected File fVersionDir;
-
- @Override
- public void doAction() throws Exception {
-
- getLog().warn("---- Warning -----\n\n" +
- "This goal is deprecated since version 2.0.2 and will be removed in version 2.1\n\n" +
- "---- Warning -----");
-
- File srcModelDir = copyVersionResources.getInputs()[0];
-
- List<File> modelFiles = PluginHelper.getIncludedFiles(
- srcModelDir,
- new String[]{includes},
- null
- );
-
- if (modelFiles.isEmpty()) {
- getLog().warn("No model file found.");
- return;
- }
-
- //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) {
- if (getLog().isDebugEnabled()) {
- getLog().debug("Try to find version on file " + modelFile);
- }
- SAXReader saxR = new SAXReader();
- Document document;
- try {
- document = saxR.read(modelFile);
- Node node;
- node = document.selectSingleNode("/objectModel/@version");
- if (node != null) {
- versionFound = node.getStringValue();
- }
- node = document.selectSingleNode("/objectModel/@name");
- if (node != null) {
- modelNameFound = node.getStringValue();
- }
- } catch (DocumentException e) {
- getLog().error("Can't read document", e);
- }
- }
- //TODO-TC20100403 : should use VersionUtil to detects a version ?
- if (versionFound == null ||
- !versionFound.matches("[0-9]+(\\.[0-9]+)*")) {
- versionFound = "0";
- getLog().info(
- "No version found in model files, setting version to '" +
- versionFound + "'");
- } else {
- getLog().info("Version '" + versionFound +
- "' found in model description");
- }
-
- String destDir = copyVersionDir.replace("%MODELNAME%", modelNameFound)
- + File.separator + versionFound;
- fVersionDir = new File(destDir);
-
- if (getLog().isDebugEnabled()) {
- getLog().debug("destination directory : " + fVersionDir);
- }
-
- boolean exist = false;
-
- if (!overwrite) {
-
- 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");
-
- exist = true;
- }
- }
-
- if (!exist) {
-
- // copy back mappings to fVersionDir
-
- if (getLog().isDebugEnabled()) {
- getLog().debug("copy files from " +
- copyVersionResources.getOutput());
- }
- PluginHelper.copyFiles(
- copyVersionResources.getOutput(),
- fVersionDir,
- new String[]{copyVersionFiles},
- null,
- true
- );
- }
- }
-
- @Override
- protected PluginIOContext getResources() {
- return copyVersionResources;
- }
-
- @Override
- protected PluginIOContext initResources() {
-
- 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");
-
- copyVersionResources = initResources(
- defaultIn,
- defaultOut,
- defaultTestIn,
- defaultTestOut
- );
-
- return copyVersionResources;
- }
-}
1
0
25 Jun '10
Author: fdesbois
Date: 2010-06-25 12:18:33 +0200 (Fri, 25 Jun 2010)
New Revision: 925
Url: http://nuiton.org/repositories/revision/eugene/925
Log:
Evo #712 : add method cloneOperationSignature
Modified:
trunk/eugene/src/main/java/org/nuiton/eugene/java/ObjectModelTransformerToJava.java
Modified: trunk/eugene/src/main/java/org/nuiton/eugene/java/ObjectModelTransformerToJava.java
===================================================================
--- trunk/eugene/src/main/java/org/nuiton/eugene/java/ObjectModelTransformerToJava.java 2010-06-24 21:52:01 UTC (rev 924)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/java/ObjectModelTransformerToJava.java 2010-06-25 10:18:33 UTC (rev 925)
@@ -47,6 +47,7 @@
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
/**
@@ -319,6 +320,34 @@
}
/**
+ * Clone the {@code source} operation into the {@code destination} classifier.
+ * Name, returnType, Parameters and Exceptions will be cloned. You can specify
+ * {@code modifiers} for the result operation.
+ *
+ * @param source operation to clone
+ * @param destination classifier where result operation will be added
+ * @param modifiers extra modifiers
+ * @return the new operation created in destination classifier
+ */
+ public ObjectModelOperation cloneOperationSignature(ObjectModelOperation source,
+ ObjectModelClassifier destination,
+ ObjectModelModifier... modifiers) {
+
+ ObjectModelOperation result =
+ addOperation(destination, source.getName(), source.getReturnType(), modifiers);
+
+ for (ObjectModelParameter parameter : source.getParameters()) {
+ addParameter(result, parameter.getType(), parameter.getName());
+ }
+
+ for (String exception : source.getExceptions()) {
+ addException(result, exception);
+ }
+
+ return result;
+ }
+
+ /**
* Search in {@code input} model, for a enumeration dependency named
* {@link JavaGeneratorUtil#DEPENDENCIES_CONSTANTS}.
* <p/>
1
0
24 Jun '10
Author: fdesbois
Date: 2010-06-24 23:52:01 +0200 (Thu, 24 Jun 2010)
New Revision: 924
Url: http://nuiton.org/repositories/revision/eugene/924
Log:
Evo #711 : use inheritance between JavaBuilder and ObjectModelBuilder
Modified:
trunk/eugene/src/main/java/org/nuiton/eugene/java/JavaBuilder.java
Modified: trunk/eugene/src/main/java/org/nuiton/eugene/java/JavaBuilder.java
===================================================================
--- trunk/eugene/src/main/java/org/nuiton/eugene/java/JavaBuilder.java 2010-06-24 18:24:23 UTC (rev 923)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/java/JavaBuilder.java 2010-06-24 21:52:01 UTC (rev 924)
@@ -48,7 +48,7 @@
import java.util.Set;
/**
- * JavaBuilder TODO heritates it from ModelBuilder
+ * JavaBuilder
* <p/>
* Created: 29 oct. 2009
* <p/>
@@ -61,17 +61,14 @@
* JavaBuilder is also based on ObjectModelBuilder for the simple filling of
* the model.
*
- * @author fdesbois
- * @version $Revision$
- * <p/>
+ * @author fdesbois <fdesbois(a)codelutin.com>
+ * @author tchemit <tchemit(a)codelutin.com>
+ * @version $Id$
*/
-public class JavaBuilder {
+public class JavaBuilder extends ObjectModelBuilder {
private static final Log log = LogFactory.getLog(JavaBuilder.class);
- /** Builder where the filling is based on */
- protected ObjectModelBuilder modelBuilder;
-
/** ObjectModel extension to manage imports : one ImportsManager by classifier */
protected ImportsManagerExtension importsManagerExtension;
@@ -85,7 +82,7 @@
protected CodesManagerExtension codesManagerExtension;
public JavaBuilder(String modelName) {
- modelBuilder = new ObjectModelBuilder(modelName);
+ super(modelName);
importsManagerExtension = getModel().getExtension(
ImportsManagerExtension.OBJECTMODEL_EXTENSION,
@@ -105,26 +102,162 @@
}
/**
- * Get the model which is built
+ * Add an interface to a classifier (interface, class, enum).
+ * IMPORTS interfaceQualifiedName.
*
- * @return an ObjectModel
+ * @param classifier the classifier on which to add the interface
+ * @param interfaceQualifiedName fully qualified name of the interface
+ * @see ObjectModelBuilder#addInterface(ObjectModelClassifier, String)
*/
- public ObjectModel getModel() {
- return modelBuilder.getModel();
+ @Override
+ public void addInterface(ObjectModelClassifier classifier,
+ String interfaceQualifiedName) {
+ super.addInterface(classifier, interfaceQualifiedName);
+ addImport(classifier, interfaceQualifiedName);
}
+ @Override
+ public void addSuperclass(ObjectModelClass clazz, String superclassQualifiedName)
+ throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("This operation can't be used" +
+ " to generate Java, use setSuperClass method instead");
+ }
+
/**
- * Sets the documentation to the given {@code element}.
+ * Add a new attribute to a classifier.
+ * IMPORTS type.
*
- * @param element the element on which add the documentation
- * @param documentation the documentation to add
+ * @param classifier the classifier on which to add the attribute
+ * @param name name of attribute
+ * @param type type of attribute
+ * @param value initializer value of attribute
+ * @param modifiers modifiers of the attribute
+ * @return a new ObjectModelAttribute
+ * @see ObjectModelBuilder#addAttribute(ObjectModelClassifier, String, String, String, ObjectModelModifier...)
*/
- public void setDocumentation(ObjectModelElement element,
- String documentation) {
- modelBuilder.setDocumentation(element, documentation);
+ @Override
+ public ObjectModelAttribute addAttribute(ObjectModelClassifier classifier,
+ String name,
+ String type,
+ String value,
+ ObjectModelModifier... modifiers) {
+ addImport(classifier, type);
+ // ANO#474 FD-20100408 : problem with import from defaultValue, will
+ // not be supported from version 2.0.1
+ //this.addImport(classifier, value);
+ return super.addAttribute(classifier,
+ name,
+ type,
+ value,
+ modifiers
+ );
}
/**
+ * Add a new attribute to a classifier with no default value.
+ * Default visibility is set to PROTECTED.
+ * IMPORTS type.
+ *
+ * @param classifier the classifier on which add the attribute
+ * @param name name of the attribute
+ * @param type type of the attribute
+ * @return a new ObjectModelAttribute
+ */
+ @Override
+ public ObjectModelAttribute addAttribute(ObjectModelClassifier classifier,
+ String name,
+ String type) {
+ return addAttribute(classifier,
+ name,
+ type,
+ "",
+ ObjectModelModifier.PROTECTED
+ );
+ }
+
+ /**
+ * Add a new operation to a classifier.
+ *
+ * @param classifier the classifier on which to add the operation
+ * @param name the name of the operation
+ * @param type the return type of the operation
+ * @param modifiers the modifiers of the operation
+ * @return a new ObjectModelOperation
+ * @see ObjectModelBuilder#addOperation(ObjectModelClassifier, String, String, ObjectModelModifier...)
+ */
+ @Override
+ public ObjectModelOperation addOperation(ObjectModelClassifier classifier,
+ String name,
+ String type,
+ ObjectModelModifier... modifiers) {
+ addImport(classifier, type);
+ return super.addOperation(classifier, name, type, modifiers);
+ }
+
+ /**
+ * Add a new parameter to an existing operation.
+ *
+ * @param operation the operation on which to add a parameter
+ * @param type the type of the parameter
+ * @param name the name of the parameter
+ * @return a new ObjectModelParameter
+ * @see ObjectModelBuilder#addParameter(ObjectModelOperation, String, String)
+ */
+ @Override
+ public ObjectModelParameter addParameter(ObjectModelOperation operation,
+ String type,
+ String name) {
+ addImport((ObjectModelClassifier) operation.getDeclaringElement(),
+ type);
+ return super.addParameter(operation, type, name);
+ }
+
+ /**
+ * Add an exception to an operation.
+ *
+ * @param operation the operation on which to add a exeception
+ * @param exception the exception to add
+ * @see ObjectModelBuilder#addException(ObjectModelOperation, String)
+ */
+ @Override
+ public void addException(ObjectModelOperation operation, String exception) {
+ addImport((ObjectModelClassifier) operation.getDeclaringElement(),
+ exception);
+ super.addException(operation, exception);
+ }
+
+ /**
+ * Set the operation body code.
+ *
+ * @param operation the operation on which to add the body code
+ * @param body the body code to set on the operation
+ * @throws IllegalArgumentException if operation is abstract
+ * @see ObjectModelBuilder#setOperationBody(ObjectModelOperation, String)
+ */
+ @Override
+ public void setOperationBody(ObjectModelOperation operation, String body)
+ throws IllegalArgumentException {
+ if (operation.isAbstract()) {
+ throw new IllegalArgumentException(
+ "Unable to add body for an abstract method");
+ }
+ super.setOperationBody(operation, body);
+ }
+
+ /**
+ * Create a new abstract class in the model.
+ *
+ * @param name the name of the abstract class to create
+ * @param packageName package's name of the class to create
+ * @return a new ObjectModelClass
+ * @see ObjectModelBuilder#createClass(String, String, ObjectModelModifier...)
+ */
+ public ObjectModelClass createAbstractClass(String name,
+ String packageName) {
+ return createClass(name, packageName, ObjectModelModifier.ABSTRACT);
+ }
+
+ /**
* Add an import to a classifier. Imports are automatic for lots of
* JavaBuilder's methods except body code of operations.
* <pre>
@@ -153,7 +286,7 @@
manager.addImport(oneType);
if (log.isDebugEnabled()) {
log.debug("Add import for : " + classifier.getQualifiedName() +
- " _ import: " + oneType);
+ " _ import: " + oneType);
}
}
}
@@ -178,170 +311,28 @@
manager.addAnnotation(element, annotation);
if (log.isDebugEnabled()) {
log.debug("Add annotation for <" + classifier.getQualifiedName() +
- ":" + element.getName() + "> : " + annotation);
+ ":" + element.getName() + "> : " + annotation);
}
}
/**
- * Add a body code to the operation of a classifier.
- *
- * @param classifier where the body code will be added.
- * @param operation operation on which add body code
- * @param code code to add
- */
- public void addBodyCode(ObjectModelClassifier classifier,
- ObjectModelOperation operation,
- String code) {
- if (code == null) {
- return;
- }
- CodesManager manager =
- codesManagerExtension.getManager(classifier);
- code = code.trim();
-
- manager.addCode(operation, code);
- if (log.isDebugEnabled()) {
- log.debug("Add code for <" + classifier.getQualifiedName() +
- ":" + operation.getName() + "> : " + code);
- }
- }
-
- /**
- * Converts the given {@code propertyName} to a constant name.
- * <p/>
- * For example :
- * <pre>
- * "CONSTANT_A" = getConstantName("constantA");
- * </pre>
- *
- * @param propertyName the name of the property to convert
- * @return the constant name
- */
- public String getConstantName(String propertyName) {
- String result = constantsManagerExtension.getConstantName(propertyName);
- if (log.isDebugEnabled()) {
- log.debug("get constant name for <" + propertyName + "> : " +
- result);
- }
- return result;
- }
-
-
- /**
- * Create a new class in the model.
- *
- * @param name the name of the new class to create
- * @param packageName package's name of the class to create
- * @return a new ObjectModelClass
- * @see ObjectModelBuilder#createClass(String, String, ObjectModelModifier...)
- */
- public ObjectModelClass createClass(String name, String packageName) {
- return modelBuilder.createClass(name, packageName);
- }
-
- /**
- * Create a new abstract class in the model.
- *
- * @param name the name of the abstract class to create
- * @param packageName package's name of the class to create
- * @return a new ObjectModelClass
- * @see ObjectModelBuilder#createClass(String, String, ObjectModelModifier...)
- */
- public ObjectModelClass createAbstractClass(String name,
- String packageName) {
- return modelBuilder.createClass(name, packageName,
- ObjectModelModifier.ABSTRACT);
- }
-
- /**
- * Create a new interface in the model
- *
- * @param name the name of the interface to create
- * @param packageName package's name of the interface to create
- * @return a new ObjectModelInterface
- * @see ObjectModelBuilder#createInterface(String, String)
- */
- public ObjectModelInterface createInterface(String name,
- String packageName) {
- return modelBuilder.createInterface(name, packageName);
- }
-
- /**
- * Create a new enumration in the model
- *
- * @param name the name of the enumeration to create
- * @param packageName package's name of the enumeration to create
- * @return a new ObjectModelEnumeration
- */
- public ObjectModelEnumeration createEnumeration(String name,
- String packageName) {
- return modelBuilder.createEnumeration(name, packageName);
- }
-
- /**
* Set the superclass of an other class. Only one superclass can be set
* to the class.
* IMPORTS superclassQualifiedName.
*
* @param classifier the classifier on which to set the super class
* @param superclassQualifiedName fully qualified name of the super class
- * @see ObjectModelBuilder#addInterface(
- *ObjectModelClassifier, String)
*/
public void setSuperClass(ObjectModelClass classifier,
String superclassQualifiedName) {
ObjectModelClassImpl impl = (ObjectModelClassImpl) classifier;
// suppress all existing superclass: only one can be set for java
impl.clearSuperclasses();
- modelBuilder.addSuperclass(impl, superclassQualifiedName);
+ super.addSuperclass(impl, superclassQualifiedName);
addImport(classifier, superclassQualifiedName);
}
/**
- * Add an interface to a classifier (interface, class, enum).
- * IMPORTS interfaceQualifiedName.
- *
- * @param classifier the classifier on which to add the interface
- * @param interfaceQualifiedName fully qualified name of the interface
- * @see ObjectModelBuilder#addInterface(
- *ObjectModelClassifier, String)
- */
- public void addInterface(ObjectModelClassifier classifier,
- String interfaceQualifiedName) {
- modelBuilder.addInterface(classifier, interfaceQualifiedName);
- addImport(classifier, interfaceQualifiedName);
- }
-
- /**
- * Add a new attribute to a classifier.
- * IMPORTS type, value.
- *
- * @param classifier the classifier on which to add the attribute
- * @param name name of attribute
- * @param type type of attribute
- * @param value initializer value of attribute
- * @param modifiers modifiers of the attribute
- * @return a new ObjectModelAttribute
- * @see ObjectModelBuilder#addAttribute(ObjectModelClassifier, String, String, String, ObjectModelModifier...)
- */
- public ObjectModelAttribute addAttribute(ObjectModelClassifier classifier,
- String name,
- String type,
- String value,
- ObjectModelModifier... modifiers) {
- addImport(classifier, type);
- // ANO#474 FD-20100408 : problem with import from defaultValue, will
- // not be supported from version 2.0.1
- //this.addImport(classifier, value);
- return modelBuilder.addAttribute(classifier,
- name,
- type,
- value,
- modifiers
- );
- }
-
- /**
* Add a new constant to a classifier. A constant is static and final
* and have a value.
* IMPORTS type, value.
@@ -363,41 +354,64 @@
if (!visibility.isVisibility()) {
throw new IllegalArgumentException(
"Illegal visibility type : " + visibility.name() +
- " for " + classifier.getQualifiedName());
+ " for " + classifier.getQualifiedName());
}
return addAttribute(classifier,
- name,
- type,
- value,
- visibility,
- ObjectModelModifier.STATIC,
- ObjectModelModifier.FINAL
+ name,
+ type,
+ value,
+ visibility,
+ ObjectModelModifier.STATIC,
+ ObjectModelModifier.FINAL
);
}
/**
- * Add a new attribute to a classifier with no default value.
- * Default visibility is set to PROTECTED.
- * IMPORTS type.
+ * Add a body code to the operation of a classifier.
*
- * @param classifier the classifier on which add the attribute
- * @param name name of the attribute
- * @param type type of the attribute
- * @return a new ObjectModelAttribute
+ * @param classifier where the body code will be added.
+ * @param operation operation on which add body code
+ * @param code code to add
*/
- public ObjectModelAttribute addAttribute(ObjectModelClassifier classifier,
- String name,
- String type) {
- return addAttribute(classifier,
- name,
- type,
- "",
- ObjectModelModifier.PROTECTED
- );
+ public void addBodyCode(ObjectModelClassifier classifier,
+ ObjectModelOperation operation,
+ String code) {
+ if (code == null) {
+ return;
+ }
+ CodesManager manager =
+ codesManagerExtension.getManager(classifier);
+ code = code.trim();
+
+ manager.addCode(operation, code);
+ if (log.isDebugEnabled()) {
+ log.debug("Add code for <" + classifier.getQualifiedName() +
+ ":" + operation.getName() + "> : " + code);
+ }
}
/**
+ * Converts the given {@code propertyName} to a constant name.
+ * <p/>
+ * For example :
+ * <pre>
+ * "CONSTANT_A" = getConstantName("constantA");
+ * </pre>
+ *
+ * @param propertyName the name of the property to convert
+ * @return the constant name
+ */
+ public String getConstantName(String propertyName) {
+ String result = constantsManagerExtension.getConstantName(propertyName);
+ if (log.isDebugEnabled()) {
+ log.debug("get constant name for <" + propertyName + "> : " +
+ result);
+ }
+ return result;
+ }
+
+ /**
* Add a new attribute to a classifier from an existing attribute.
* IMPORTS attribute.getType() and attribute.getDefaultValue().
*
@@ -436,24 +450,6 @@
}
/**
- * Add a new operation to a classifier.
- *
- * @param classifier the classifier on which to add the operation
- * @param name the name of the operation
- * @param type the return type of the operation
- * @param modifiers the modifiers of the operation
- * @return a new ObjectModelOperation
- * @see ObjectModelBuilder#addOperation(ObjectModelClassifier, String, String, ObjectModelModifier...)
- */
- public ObjectModelOperation addOperation(ObjectModelClassifier classifier,
- String name,
- String type,
- ObjectModelModifier... modifiers) {
- addImport(classifier, type);
- return modelBuilder.addOperation(classifier, name, type, modifiers);
- }
-
- /**
* Add a new block to a classifier.
*
* @param classifier the classifier on which to add the block
@@ -464,7 +460,7 @@
public ObjectModelOperation addBlock(ObjectModelClassifier classifier,
ObjectModelModifier... modifiers) {
ObjectModelOperationImpl operation = (ObjectModelOperationImpl)
- modelBuilder.addOperation(classifier, null, null, modifiers);
+ addOperation(classifier, null, null, modifiers);
if (Arrays.asList(modifiers).contains(ObjectModelModifier.STATIC)) {
operation.setStatic(true);
}
@@ -473,82 +469,22 @@
/**
* Add a constructor to a class.
+ * FIXME-fdesbois-2010-06-23 : need to take care of generic case
*
* @param clazz the classifier on which to add the constructor
* @param visibility the visibility of the operation
* @return a new ObjectModelOperation
* @throws IllegalArgumentException if the modifier is not a visibility
- * @see ObjectModelBuilder#addOperation(ObjectModelClassifier, String, String, ObjectModelModifier...)
*/
public ObjectModelOperation addConstructor(ObjectModelClass clazz,
ObjectModelModifier visibility)
throws IllegalArgumentException {
- if (!visibility.isVisibility()) {
- throw new IllegalArgumentException(
- "Illegal visibility type : " + visibility.name() +
- " for " + clazz.getQualifiedName());
- }
-
- return addOperation(clazz, clazz.getName(), null, visibility);
+ return addConstructorForClassifier(clazz, visibility);
}
/**
- * Add a new parameter to an existing operation.
- *
- * @param operation the operation on which to add a parameter
- * @param type the type of the parameter
- * @param name the name of the parameter
- * @return a new ObjectModelParameter
- * @see ObjectModelBuilder#addParameter(ObjectModelOperation, String, String)
- */
- public ObjectModelParameter addParameter(ObjectModelOperation operation,
- String type,
- String name) {
- addImport((ObjectModelClassifier) operation.getDeclaringElement(),
- type);
- return modelBuilder.addParameter(operation, type, name);
- }
-
- /**
- * Add an exception to an operation.
- *
- * @param operation the operation on which to add a exeception
- * @param exception the exception to add
- * @see ObjectModelBuilder#addException(ObjectModelOperation, String)
- */
- public void addException(ObjectModelOperation operation, String exception) {
- addImport((ObjectModelClassifier) operation.getDeclaringElement(),
- exception);
- modelBuilder.addException(operation, exception);
- }
-
- /**
- * Set the operation body code.
- *
- * @param operation the operation on which to add the body code
- * @param body the body code to set on the operation
- * @throws IllegalArgumentException if operation is abstract
- * @see ObjectModelBuilder#setOperationBody(ObjectModelOperation, String)
- */
- public void setOperationBody(ObjectModelOperation operation, String body)
- throws IllegalArgumentException {
- if (operation.isAbstract()) {
- throw new IllegalArgumentException(
- "Unable to add body for an abstract method");
- }
- modelBuilder.setOperationBody(operation, body);
- }
-
- public ObjectModelClassifier addInnerClassifier(ObjectModelClass clazz,
- ObjectModelType type,
- String name,
- ObjectModelModifier... modifiers)
- throws IllegalArgumentException {
- return modelBuilder.addInnerClassifier(clazz, type, name, modifiers);
- }
-
- /**
* Add a constructor to a enumeration.
+ * FIXME-fdesbois-2010-06-23 : need to take care of generic case
*
* @param enumeration the enumeration on which to add the constructor
* @param visibility the visibility of the constructor (should always to private...)
@@ -558,26 +494,17 @@
public ObjectModelOperation addConstructor(ObjectModelEnumeration enumeration,
ObjectModelModifier visibility)
throws IllegalArgumentException {
+ return addConstructorForClassifier(enumeration, visibility);
+ }
+
+ protected ObjectModelOperation addConstructorForClassifier(
+ ObjectModelClassifier classifier, ObjectModelModifier visibility) {
+
if (!visibility.isVisibility()) {
throw new IllegalArgumentException(
"Illegal visibility type : " + visibility.name() +
- " for " + enumeration.getQualifiedName());
+ " for " + classifier.getQualifiedName());
}
-
- return addOperation(enumeration,
- enumeration.getName(),
- null,
- visibility
- );
+ return addOperation(classifier, classifier.getName(), null, visibility);
}
-
- /**
- * Add a literal to the given {@code classifier}.
- *
- * @param classifier the enumeration on which to add the literal
- * @param name the name of the literal to add
- */
- public void addLiteral(ObjectModelEnumeration classifier, String name) {
- modelBuilder.addLiteral(classifier, name);
- }
}
1
0
Author: athimel
Date: 2010-06-24 20:24:23 +0200 (Thu, 24 Jun 2010)
New Revision: 923
Url: http://nuiton.org/repositories/revision/eugene/923
Log:
Fix JRST url
Modified:
trunk/src/site/site_en.xml
trunk/src/site/site_fr.xml
Modified: trunk/src/site/site_en.xml
===================================================================
--- trunk/src/site/site_en.xml 2010-06-24 14:45:31 UTC (rev 922)
+++ trunk/src/site/site_en.xml 2010-06-24 18:24:23 UTC (rev 923)
@@ -33,7 +33,7 @@
<poweredBy>
<logo href="http://maven.apache.org" name="Maven" img="${project.url}/images/logos/maven-feather.png"/>
- <logo href="http://jrst.labs.libre-entreprise.org" name="JRst" img="${project.url}/images/jrst-logo.png"/>
+ <logo href="http://maven-site.nuiton.org/jrst/" name="JRst" img="${project.url}/images/jrst-logo.png"/>
<logo href="http://docutils.sourceforge.net/rst.html" name="ReStructuredText" img="${project.url}/images/restructuredtext-logo.png"/>
</poweredBy>
Modified: trunk/src/site/site_fr.xml
===================================================================
--- trunk/src/site/site_fr.xml 2010-06-24 14:45:31 UTC (rev 922)
+++ trunk/src/site/site_fr.xml 2010-06-24 18:24:23 UTC (rev 923)
@@ -33,7 +33,7 @@
<poweredBy>
<logo href="http://maven.apache.org" name="Maven" img="${project.url}/images/logos/maven-feather.png"/>
- <logo href="http://jrst.labs.libre-entreprise.org" name="JRst" img="${project.url}/images/jrst-logo.png"/>
+ <logo href="http://maven-site.nuiton.org/jrst/" name="JRst" img="${project.url}/images/jrst-logo.png"/>
<logo href="http://docutils.sourceforge.net/rst.html" name="ReStructuredText" img="${project.url}/images/restructuredtext-logo.png"/>
</poweredBy>
1
0