Package org.apache.maven.enforcer.rule.api

Examples of org.apache.maven.enforcer.rule.api.EnforcerRuleException


            MavenProject project = (MavenProject) helper.evaluate( "${project}" );
            rootNode = createDependencyGraphBuilder().buildDependencyGraph( project, null );
        }
        catch ( Exception e )
        {
            throw new EnforcerRuleException( "Error: Could not construct dependency tree.", e );
        }

        StringBuilder generatedMessage = null;
        if ( message == null )
        {
            generatedMessage = new StringBuilder();
        }

        try
        {
            if ( searchTree( rootNode, 0, exclusions, generatedMessage ) )
            {
                throw new EnforcerRuleException( message == null ? generatedMessage.toString() : message );
            }
        }
        catch ( InvalidVersionSpecificationException e )
        {
            throw new EnforcerRuleException( "Error: Invalid version range.", e );
        }

    }
View Full Code Here


            {
                if ( StringUtils.isEmpty( message ) )
                {
                    message = "The expression \"" + condition + "\" is not true.";
                }
                throw new EnforcerRuleException( this.message );
            }
        }
        catch ( ExpressionEvaluationException e )
        {
            throw new EnforcerRuleException( "Unable to evaluate an expression '" + condition + "'", e );
        }
    }
View Full Code Here

            evaluation = (Boolean) bsh.eval( script );
            log.debug( "Echo evaluating : " + evaluation );
        }
        catch ( EvalError ex )
        {
            throw new EnforcerRuleException( "Couldn't evaluate condition: " + script, ex );
        }
        return evaluation.booleanValue();
    }
View Full Code Here

                if ( StringUtils.isNotEmpty( message ) )
                {
                    newMsg.append( message );
                }

                throw new EnforcerRuleException( newMsg.toString() );
            }
        }
        catch ( ExpressionEvaluationException e )
        {
            throw new EnforcerRuleException( "Unable to Evaluate an Expression:" + e.getLocalizedMessage() );
        }
        catch ( ComponentLookupException e )
        {
            throw new EnforcerRuleException( "Unable to lookup a component:" + e.getLocalizedMessage() );
        }
        catch ( IllegalAccessException e )
        {
            throw new EnforcerRuleException( e.getLocalizedMessage() );
        }
        catch ( LifecycleExecutionException e )
        {
            throw new EnforcerRuleException( e.getLocalizedMessage() );
        }
        catch ( PluginNotFoundException e )
        {
            throw new EnforcerRuleException( e.getLocalizedMessage() );
        }
        catch ( ArtifactResolutionException e )
        {
            throw new EnforcerRuleException( e.getLocalizedMessage() );
        }
        catch ( ArtifactNotFoundException e )
        {
            throw new EnforcerRuleException( e.getLocalizedMessage() );
        }
        catch ( IOException e )
        {
            throw new EnforcerRuleException( e.getLocalizedMessage() );
        }
        catch ( XmlPullParserException e )
        {
            throw new EnforcerRuleException( e.getLocalizedMessage() );
        }
        catch ( MojoExecutionException e )
        {
            throw new EnforcerRuleException( e.getLocalizedMessage() );
        }
    }
View Full Code Here

                super.execute( helper );
            }
            catch ( ExpressionEvaluationException e )
            {
                throw new EnforcerRuleException( "Unable to retrieve the project.", e );
            }
        }
        else
        {
            super.execute( helper );
View Full Code Here

        {
            if ( message == null )
            {
                message = getName() + " \"" + getPropertyName() + "\" is required for this build.";
            }
            throw new EnforcerRuleException( message );
        }
        // If there is a regex, check that the property matches it
        if ( regex != null && !propValue.toString().matches( regex ) )
        {
            if ( regexMessage == null )
            {
                regexMessage = getName() + " \"" + getPropertyName() + "\" evaluates to \"" + propValue + "\".  "
                    + "This does not match the regular expression \"" + regex + "\"";
            }
            throw new EnforcerRuleException( regexMessage );
        }
    }
View Full Code Here

        } catch (final ExpressionEvaluationException e) {

            // Whoops.
            final String msg = "Could not acquire MavenProject. (Expression lookup failure for: "
                    + e.getLocalizedMessage() + ")";
            throw new EnforcerRuleException(msg, e);
        }

        // Delegate.
        try {
            performValidation(project, helper);
        } catch (RuleFailureException e) {

            // Create a somewhat verbose failure message.
            String message =
                    "\n"
                            + "\n#"
                            + "\n# Structure rule failure:"
                            + "\n# " + getShortRuleDescription()
                            + "\n# "
                            + "\n# Message: " + e.getLocalizedMessage()
                            + "\n# " + "\n# Offending project [" + project.getGroupId() + ":"
                            + project.getArtifactId() + ":" + project.getVersion() + "]" + "\n#";

            final Artifact art = e.getOffendingArtifact();
            if (art != null) {

                message += "\n# Offending artifact [" + art.getGroupId() + ":" + art.getArtifactId()
                        + ":" + art.getVersion() + "]"
                        + "\n#";
            }
            message += "\n";

            // Re-throw for pretty print
            throw new EnforcerRuleException(message);
        }
    }
View Full Code Here

    ErrorReport report = new ErrorReport(getDescription());
    doEnforce(report);

    if (report.hasErrors()) {
      throw new EnforcerRuleException(report.toString());
    }
  }
View Full Code Here

      ArtifactCollector      collector      = (ArtifactCollector)helper.getComponent(ArtifactCollector.class);
      ArtifactFilter         filter         = null; //we need to evaluate all scopes
      DependencyNode         node           = dependencyTreeBuilder.buildDependencyTree(project, repository, factory, metadataSource, filter, collector);
      return node;
    } catch (ExpressionEvaluationException e) {
      throw new EnforcerRuleException("Unable to lookup an expression " + e.getLocalizedMessage(), e);
    } catch (ComponentLookupException e){
      throw new EnforcerRuleException("Unable to lookup a component " + e.getLocalizedMessage(), e);
    } catch (DependencyTreeBuilderException e){
      throw new EnforcerRuleException("Could not build dependency tree " + e.getLocalizedMessage(), e);
    }
  }
View Full Code Here

      errorMsgs.addAll(getConvergenceErrorMsgs(visitor.getConflictedVersionNumbers()));
      for (CharSequence errorMsg : errorMsgs) {
        log.error(errorMsg);
      }
      if (errorMsgs.size() > 0) {
        throw new EnforcerRuleException("Failed while enforcing releasability the error(s) are " + errorMsgs);
      }
    } catch (ExpressionEvaluationException e) {
      throw new EnforcerRuleException("Unable to lookup an expression " + e.getLocalizedMessage(), e);
    } catch (ComponentLookupException e){
      throw new EnforcerRuleException("Unable to lookup a component " + e.getLocalizedMessage(), e);
    } catch (Exception e){
      throw new EnforcerRuleException(e.getLocalizedMessage(), e);
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.maven.enforcer.rule.api.EnforcerRuleException

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.