Package org.apache.maven.plugin

Examples of org.apache.maven.plugin.MojoExecutionException


        {
            if (throwable instanceof MojoExecutionException)
            {
                throw (MojoExecutionException)throwable;
            }
            throw new MojoExecutionException("An error occurred during application cleanup operation", throwable);
        }
    }
View Full Code Here


      }
         
        }
        catch (Throwable throwable)
        {
            throw new MojoExecutionException("Error exporting MagicDraw project file to EMF XMI", throwable);
        }
    }
View Full Code Here

      String source = StringUtils.replace(dest, UML2EXT, MDEXT1);
    URL sourceUrl = null;
    try {
      sourceUrl = new URL(ResourceUtils.normalizePath(source));
    } catch (MalformedURLException e) {
      throw new MojoExecutionException("Invalid source model file name [" + source + "]: " + e.getMessage());
    }

      //check for for second MD extension
      File sourceFile = new File(sourceUrl.getFile());
        if (sourceFile == null || !sourceFile.exists())
        {
            source = StringUtils.replace(dest, UML2EXT, MDEXT2);
        try {
          sourceUrl = new URL(ResourceUtils.normalizePath(source));
        } catch (MalformedURLException e) {
          throw new MojoExecutionException("Invalid source model file name [" + source + "]: " + e.getMessage());
        }
        }
        sourceFile = new File(sourceUrl.getFile());
        if (sourceFile == null || !sourceFile.exists())
      {
        throw new MojoExecutionException("Model file [" + source + "] does not exist");
      }

        //check for destination (emf) file
    URL destUrl = null;
    try {
      destUrl = new URL(ResourceUtils.normalizePath(dest));
    } catch (MalformedURLException e) {
      throw new MojoExecutionException("Invalid destination model file name [" + dest + "]: " + e.getMessage());
    }
   
        File destFile = new File(destUrl.getFile());
      if (destFile == null || !destFile.exists())
      {
        getLog().debug("No old model file [" + dest + "] existing");
      }
      else
      {
        if (getLog().isDebugEnabled())
        {
          Format formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
          getLog().debug("- MagicDraw model file ["+sourceFile.getName()+"] date = " + formatter.format(new Date(sourceFile.lastModified())));
          getLog().debug("- EMF model file ["+destFile.getName()+"] date = " + formatter.format(new Date(destFile.lastModified())));
        }
        if (destFile.lastModified() >= sourceFile.lastModified())
        {
          getLog().info("Model file [" + dest + "] is up-to-date");
          return;
        }
      }

      //check for valid magic draw installation
      checkForMagicDraw();
     
      //perform the export via MagicDraw
      getLog().info("Exporting model file [" + source + "] ...");
      String command = "\"" + exporterPath + "\""
          + " project_file=\"" + sourceFile.getPath() + "\""
          + " destination_dir=\"" + sourceFile.getParent() + "\""
          + " load_all_modules=true";
      Process process = Runtime.getRuntime().exec(command);
     
      //since at least the windows version forks the magicdraw process,
      //we have to synchronize via input stream reading
      InputStream is = process.getInputStream();
      final byte[] buf = new byte[128];
      int length;
      while ((length = is.read(buf)) > 0)
      {
        getLog().info(new String(buf, 0, length));
      }
      process.waitFor();      
      process.destroy();
      int err = process.exitValue();
      if (err != 0)
      {
        throw new MojoExecutionException("MagicDraw export returned error code " + err);
      }
      getLog().info("Successfully exported model file.");
    }
View Full Code Here

          magicDrawHome = System.getenv(MD_HOME);
        }
       
        if (magicDrawHome == null)
        {
          throw new MojoExecutionException("MagicDraw home directory not defined: please define either a configuration variable \"magicDrawHome\" in your pom or the environment variable \""+ MD_HOME + "\"!");
        }
       
        File home = new File(magicDrawHome);
        if (home == null || !home.exists())
        {
          throw new MojoExecutionException("Invalid MagicDraw home directory specified: " + magicDrawHome);
        }

        //check for running os
        String os = System.getProperty("os.name");
        if (os.indexOf("Windows") != -1)
        {
          exportExt = ".exe";
        }
       
        //check for plugin name (has changed from MD 11.5 to 11.6)
        String pluginName115 = "com.nomagic.magicdraw.emfuml2export";
        String pluginName116 = "com.nomagic.magicdraw.emfuml2xmi";
        exporterPath = magicDrawHome
        + File.separator + "plugins"
        + File.separator + pluginName116
        + File.separator + "exportEMFXMI" + exportExt;
        File exporter = new File(exporterPath);
        if (exporter == null || !exporter.exists())
        {
          exporterPath = magicDrawHome
        + File.separator + "plugins"
        + File.separator + pluginName115
        + File.separator + "exportEMFXMI" + exportExt;
        }
       
        exporter = new File(exporterPath);
        if (exporter == null || !exporter.exists())
        {
          throw new MojoExecutionException("No exporter plugin found in MagicDraw home directory " + magicDrawHome);
        }

        checkedMagicDraw = true;
    }
  }
View Full Code Here

                this.executeModules(this.modules);
            }
        }
        catch (final Throwable throwable)
        {
            throw new MojoExecutionException("Error executing modules", throwable);
        }
    }
View Full Code Here

                reactorManager,
                projectSession.getEventDispatcher());
        }
        catch (final Throwable throwable)
        {
            throw new MojoExecutionException("An error occured while attempting to execute projects", throwable);
        }
    }
View Full Code Here

                        }
                    }
                }
                catch (ProjectBuildingException exception)
                {
                    throw new MojoExecutionException("Error loading POM --> '" + pom + "'", exception);
                }
            }
        }
        return projects;
    }
View Full Code Here

        {
            AndroMDALogger.initialize();
            final URL configurationUri = ResourceUtils.toURL(this.configurationUri);
            if (configurationUri == null)
            {
                throw new MojoExecutionException("Configuration could not be loaded from '" + this.configurationUri +
                    "'");
            }
           
            // - setup the classpath
            this.addPluginDependencies(
                Constants.ARTIFACT_ID,
                Artifact.SCOPE_RUNTIME);
            this.initializeClasspathFromClassPathElements(this.project.getRuntimeClasspathElements());
            final Configuration configuration = this.getConfiguration(configurationUri);
            this.execute(configuration);
        }
        catch (Throwable throwable)
        {
            String message = "Error running AndroMDA";
            throwable = ExceptionUtils.getRootCause(throwable);
            if (throwable instanceof MalformedURLException || throwable instanceof FileNotFoundException)
            {
                message = "Configuration is not valid '" + this.configurationUri + "'";
            }
            throw new MojoExecutionException(message, throwable);
        }
    }
View Full Code Here

                project.getCompileSourceRoots().addAll((List)originalCompileSourceRoots.get(project));
            }
        }
        catch (Throwable throwable)
        {
            throw new MojoExecutionException("Error creating eclipse configuration", throwable);
        }
    }
View Full Code Here

                        }
                    }
                }
                catch (ProjectBuildingException exception)
                {
                    throw new MojoExecutionException("Error loading " + pom, exception);
                }
            }
        }
        return projects;
    }
View Full Code Here

TOP

Related Classes of org.apache.maven.plugin.MojoExecutionException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.