Package org.apache.maven.plugin

Examples of org.apache.maven.plugin.MojoExecutionException


           TargetModuleID[] targetIds = manager.getNonRunningModules(null, targets);

           TargetModuleID[] found = findModules(moduleId, targetIds);

           if (found.length == 0) {
               throw new MojoExecutionException("Module is not deployed: " + moduleId);
           }

           log.info("Starting module: " + moduleId);
           ProgressObject progress = manager.start(found);

           DeploymentStatus status = waitFor(progress);
           if (status.isFailed()) {
               throw new MojoExecutionException("Failed to start module: " + moduleId);
           }

           log.info("Started module(s):");
           logModules(found, "    ");
        }
View Full Code Here


           }

           TargetModuleID[] found = findModules(moduleId, targetIds);

           if (found.length == 0) {
               throw new MojoExecutionException("Module not deployed: " + moduleId);
           }

           log.info("Stopping module: " + moduleId);
           ProgressObject progress = manager.stop(found);

           DeploymentStatus status = waitFor(progress);
           if (status.isFailed()) {
               throw new MojoExecutionException("Failed to stop module: " + moduleId);
           }

           log.info("Stopped module(s):");
           logModules(found, "    ");
         }
View Full Code Here

          log.info("Undeploying module: " + moduleId);
          ProgressObject progress = manager.undeploy(found);

          DeploymentStatus status = waitFor(progress);
          if (status.isFailed()) {
              throw new MojoExecutionException("Failed to undeploy module: " + moduleId);
          }

          log.info("Undeployed module(s):");
          logModules(found, "    ");
        }
View Full Code Here

        String geronimoHomeStr = server.getGeronimoHome();
       
        log.info("Geronimo Home: " + geronimoHomeStr);

        if (geronimoHomeStr == null) {
            throw new MojoExecutionException("Unable to determine Geronimo installation directory");
        }

        File geronimoHome = new File(geronimoHomeStr);
       
        if (!geronimoHome.exists()) {
            throw new MojoExecutionException("Geronimo installation directory does not exist: " + geronimoHomeStr);
        }

        log.info("Starting Geronimo client...");
       
        Java java = (Java)createTask("java");
View Full Code Here

                }
            }
            Collections.sort(candidates);
        }
        if ( candidates.size() == 0 ) {
            throw new MojoExecutionException("No model files found in " + systemsDirectory);
        }
        for(final String name : candidates) {
            logger.debug("Reading model " + name + " in project " + project.getId());
            try {
                final File f = new File(systemsDirectory, name);
                final FileReader reader = new FileReader(f);
                try {
                    final Model current = ModelReader.read(reader, f.getAbsolutePath());
                    final Map<Traceable, String> errors = ModelUtility.validate(current);
                    if (errors != null ) {
                        throw new MojoExecutionException("Invalid model at " + name + " : " + errors);
                    }
                    ModelUtility.merge(result, current);
                } finally {
                    IOUtils.closeQuietly(reader);
                }
            } catch ( final IOException io) {
                throw new MojoExecutionException("Unable to read " + name, io);
            }
        }

        final Map<Traceable, String> errors = ModelUtility.validate(result);
        if (errors != null ) {
            throw new MojoExecutionException("Invalid assembled model : " + errors);
        }

        return result;
    }
View Full Code Here

                        depModel = new Model();
                    }
                    final Model readModel = ModelReader.read(r, file.getAbsolutePath());
                    final Map<Traceable, String> errors = ModelUtility.validate(readModel);
                    if (errors != null ) {
                        throw new MojoExecutionException("Invalid model at " + file + " : " + errors);
                    }
                    ModelUtility.merge(depModel, readModel);
                } finally {
                    IOUtils.closeQuietly(r);
                }
            }
            final Model result;
            if ( depModel != null ) {
                Map<Traceable, String> errors = ModelUtility.validate(depModel);
                if (errors != null ) {
                    throw new MojoExecutionException("Invalid model : " + errors);
                }
                ModelUtility.merge(depModel, localModel);
                errors = ModelUtility.validate(depModel);
                if (errors != null ) {
                    throw new MojoExecutionException("Invalid model : " + errors);
                }

                result = depModel;
            } else {
                result = localModel;
            }
            return result;
        } catch ( final IOException ioe) {
            throw new MojoExecutionException("Unable to cache model", ioe);
        }
    }
View Full Code Here

    }

    public static org.apache.sling.provisioning.model.Artifact getBaseArtifact(final Model model) throws MojoExecutionException {
        final Feature base = model.getFeature(ModelConstants.FEATURE_LAUNCHPAD);
        if ( base == null ) {
            throw new MojoExecutionException("No launchpad feature found.");
        }
        // get global run mode
        final RunMode runMode = base.getRunMode(null);
        if ( runMode == null ) {
            throw new MojoExecutionException("No global run mode found in launchpad feature.");
        }
        if ( runMode.getArtifactGroups().isEmpty() ) {
            throw new MojoExecutionException("No base artifacts defined.");
        }
        if ( runMode.getArtifactGroups().size() > 1 ) {
            throw new MojoExecutionException("Base run mode should only have a single start level.");
        }
        org.apache.sling.provisioning.model.Artifact firstArtifact = null;
        for(final org.apache.sling.provisioning.model.Artifact a : runMode.getArtifactGroups().get(0)) {
            if ( firstArtifact == null ) {
                firstArtifact = a;
            } else {
                throw new MojoExecutionException("Base run mode should contain exactly one artifact.");
            }
        }
        return firstArtifact;
    }
View Full Code Here

                classifier,
                artifactHandlerManager.getArtifactHandler(type));
        try {
            resolver.resolve(prjArtifact, project.getRemoteArtifactRepositories(), session.getLocalRepository());
        } catch (final ArtifactResolutionException e) {
            throw new MojoExecutionException("Unable to get artifact for " + groupId + ":" + artifactId + ":" + version, e);
        } catch (final ArtifactNotFoundException e) {
            throw new MojoExecutionException("Unable to get artifact for " + groupId + ":" + artifactId + ":" + version, e);
        }
        return prjArtifact;
    }
View Full Code Here

            final String contents = (String)project.getContextValue(RAW_MODEL_TXT);
            try {
                result = ModelReader.read(new StringReader(contents), null);
                project.setContextValue(RAW_MODEL, result);
            } catch ( final IOException ioe) {
                throw new MojoExecutionException("Unable to read cached model.", ioe);
            }
        }
        return result;
    }
View Full Code Here

            final String contents = (String)project.getContextValue(EFFECTIVE_MODEL_TXT);
            try {
                result = ModelUtility.getEffectiveModel(ModelReader.read(new StringReader(contents), null), null);
                project.setContextValue(EFFECTIVE_MODEL, result);
            } catch ( final IOException ioe) {
                throw new MojoExecutionException("Unable to read cached model.", ioe);
            }
        }
        return result;
    }
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.