Java 类org.apache.maven.model.building.ModelProblemCollector 实例源码

项目:oceano    文件:DefaultLifecycleBindingsInjector.java   
public void injectLifecycleBindings( Model model, ModelBuildingRequest request, ModelProblemCollector problems )
{
    String packaging = model.getPackaging();

    Collection<Plugin> defaultPlugins = lifecycle.getPluginsBoundByDefaultToAllLifecycles( packaging );

    if ( defaultPlugins == null )
    {
        problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE)
                .setMessage( "Unknown packaging: " + packaging )
                .setLocation( model.getLocation( "packaging" )));
    }
    else if ( !defaultPlugins.isEmpty() )
    {
        Model lifecycleModel = new Model();
        lifecycleModel.setBuild( new Build() );
        lifecycleModel.getBuild().getPlugins().addAll( defaultPlugins );

        merger.merge( model, lifecycleModel );
    }
}
项目:oceano    文件:DefaultModelValidator.java   
private void validate20EffectivePluginDependencies( ModelProblemCollector problems, Plugin plugin,
                                                  ModelBuildingRequest request )
{
    List<Dependency> dependencies = plugin.getDependencies();

    if ( !dependencies.isEmpty() )
    {
        String prefix = "build.plugins.plugin[" + plugin.getKey() + "].dependencies.dependency.";

        Severity errOn30 = getSeverity( request, ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_0 );

        for ( Dependency d : dependencies )
        {
            validateEffectiveDependency( problems, d, false, prefix, request );

            validateVersion( prefix + "version", problems, errOn30, Version.BASE, d.getVersion(), d.getManagementKey(), d );

            validateEnum( prefix + "scope", problems, errOn30, Version.BASE, d.getScope(), d.getManagementKey(), d, "compile",
                          "runtime", "system" );
        }
    }
}
项目:oceano    文件:DefaultModelValidator.java   
private void validate20EffectiveRepository( ModelProblemCollector problems, Repository repository, String prefix,
                                 ModelBuildingRequest request )
{
    if ( repository != null )
    {
        Severity errOn31 = getSeverity( request, ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_1 );

        validateBannedCharacters( prefix + ".id", problems, errOn31, Version.V20, repository.getId(), null, repository,
                                  ILLEGAL_REPO_ID_CHARS );

        if ( "local".equals( repository.getId() ) )
        {
            addViolation( problems, errOn31, Version.V20, prefix + ".id", null, "must not be 'local'"
                + ", this identifier is reserved for the local repository"
                + ", using it for other repositories will corrupt your repository metadata.", repository );
        }

        if ( "legacy".equals( repository.getLayout() ) )
        {
            addViolation( problems, Severity.WARNING, Version.V20, prefix + ".layout", repository.getId(),
                          "uses the unsupported value 'legacy', artifact resolution might fail.", repository );
        }
    }
}
项目:oceano    文件:DefaultModelValidator.java   
private boolean validateId( String fieldName, ModelProblemCollector problems, Severity severity, Version version, String id,
                            String sourceHint, InputLocationTracker tracker )
{
    if ( !validateStringNotEmpty( fieldName, problems, severity, version, id, sourceHint, tracker ) )
    {
        return false;
    }
    else
    {
        boolean match = ID_REGEX.matcher( id ).matches();
        if ( !match )
        {
            addViolation( problems, severity, version, fieldName, sourceHint, "with value '" + id
                + "' does not match a valid id pattern.", tracker );
        }
        return match;
    }
}
项目:oceano    文件:DefaultModelValidator.java   
/**
 * Asserts:
 * <p/>
 * <ul>
 * <li><code>string != null</code>
 * <li><code>string.length > 0</code>
 * </ul>
 */
private boolean validateStringNotEmpty( String fieldName, ModelProblemCollector problems, Severity severity, Version version, 
                                        String string, String sourceHint, InputLocationTracker tracker )
{
    if ( !validateNotNull( fieldName, problems, severity, version, string, sourceHint, tracker ) )
    {
        return false;
    }

    if ( string.length() > 0 )
    {
        return true;
    }

    addViolation( problems, severity, version, fieldName, sourceHint, "is missing.", tracker );

    return false;
}
项目:oceano    文件:DefaultModelValidator.java   
private boolean validateBoolean( String fieldName, ModelProblemCollector problems, Severity severity, Version version,
                                 String string, String sourceHint, InputLocationTracker tracker )
{
    if ( string == null || string.length() <= 0 )
    {
        return true;
    }

    if ( "true".equalsIgnoreCase( string ) || "false".equalsIgnoreCase( string ) )
    {
        return true;
    }

    addViolation( problems, severity, version, fieldName, sourceHint, "must be 'true' or 'false' but is '" + string + "'.",
                  tracker );

    return false;
}
项目:oceano    文件:DefaultModelValidator.java   
private boolean validateEnum( String fieldName, ModelProblemCollector problems, Severity severity, Version version, String string,
                              String sourceHint, InputLocationTracker tracker, String... validValues )
{
    if ( string == null || string.length() <= 0 )
    {
        return true;
    }

    List<String> values = Arrays.asList( validValues );

    if ( values.contains( string ) )
    {
        return true;
    }

    addViolation( problems, severity, version, fieldName, sourceHint, "must be one of " + values + " but is '" + string
        + "'.", tracker );

    return false;
}
项目:oceano    文件:DefaultModelValidator.java   
private boolean validateBannedCharacters( String fieldName, ModelProblemCollector problems, Severity severity, Version version, 
                                          String string, String sourceHint, InputLocationTracker tracker,
                                          String banned )
{
    if ( string != null )
    {
        for ( int i = string.length() - 1; i >= 0; i-- )
        {
            if ( banned.indexOf( string.charAt( i ) ) >= 0 )
            {
                addViolation( problems, severity, version, fieldName, sourceHint,
                              "must not contain any of these characters " + banned + " but found "
                                  + string.charAt( i ), tracker );
                return false;
            }
        }
    }

    return true;
}
项目:oceano    文件:DefaultModelValidator.java   
private boolean validateVersion( String fieldName, ModelProblemCollector problems, Severity severity, Version version,
                                 String string, String sourceHint, InputLocationTracker tracker )
{
    if ( string == null || string.length() <= 0 )
    {
        return true;
    }

    if ( hasExpression( string ) )
    {
        addViolation( problems, severity, version, fieldName, sourceHint,
                      "must be a valid version but is '" + string + "'.", tracker );
        return false;
    }

    if ( !validateBannedCharacters( fieldName, problems, severity, version, string, sourceHint, tracker,
                                    ILLEGAL_VERSION_CHARS ) )
    {
        return false;
    }

    return true;
}
项目:oceano    文件:DefaultModelValidator.java   
private boolean validate20ProperSnapshotVersion( String fieldName, ModelProblemCollector problems, Severity severity, Version version,
                                               String string, String sourceHint, InputLocationTracker tracker )
{
    if ( string == null || string.length() <= 0 )
    {
        return true;
    }

    if ( string.endsWith( "SNAPSHOT" ) && !string.endsWith( "-SNAPSHOT" ) )
    {
        addViolation( problems, severity, version, fieldName, sourceHint, "uses an unsupported snapshot version format"
            + ", should be '*-SNAPSHOT' instead.", tracker );
        return false;
    }

    return true;
}
项目:oceano    文件:DefaultModelValidator.java   
private boolean validate20PluginVersion( String fieldName, ModelProblemCollector problems, String string,
                                       String sourceHint, InputLocationTracker tracker,
                                       ModelBuildingRequest request )
{
    if ( string == null )
    {
        // NOTE: The check for missing plugin versions is handled directly by the model builder
        return true;
    }

    Severity errOn30 = getSeverity( request, ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_0 );

    if ( !validateVersion( fieldName, problems, errOn30, Version.V20, string, sourceHint, tracker ) )
    {
        return false;
    }

    if ( string.length() <= 0 || "RELEASE".equals( string ) || "LATEST".equals( string ) )
    {
        addViolation( problems, errOn30, Version.V20, fieldName, sourceHint, "must be a valid version but is '" + string + "'.",
                      tracker );
        return false;
    }

    return true;
}
项目:oceano    文件:DefaultReportConfigurationExpander.java   
public void expandPluginConfiguration( Model model, ModelBuildingRequest request, ModelProblemCollector problems )
{
    Reporting reporting = model.getReporting();

    if ( reporting != null )
    {
        for ( ReportPlugin reportPlugin : reporting.getPlugins() )
        {
            Xpp3Dom parentDom = (Xpp3Dom) reportPlugin.getConfiguration();

            if ( parentDom != null )
            {
                for ( ReportSet execution : reportPlugin.getReportSets() )
                {
                    Xpp3Dom childDom = (Xpp3Dom) execution.getConfiguration();
                    childDom = Xpp3Dom.mergeXpp3Dom( childDom, new Xpp3Dom( parentDom ) );
                    execution.setConfiguration( childDom );
                }
            }
        }
    }
}
项目:oceano    文件:DefaultPluginConfigurationExpander.java   
public void expandPluginConfiguration( Model model, ModelBuildingRequest request, ModelProblemCollector problems )
{
    Build build = model.getBuild();

    if ( build != null )
    {
        expand( build.getPlugins() );

        PluginManagement pluginManagement = build.getPluginManagement();

        if ( pluginManagement != null )
        {
            expand( pluginManagement.getPlugins() );
        }
    }
}
项目:oceano    文件:DefaultProfileInjector.java   
public void injectProfile( Model model, Profile profile, ModelBuildingRequest request,
                           ModelProblemCollector problems )
{
    if ( profile != null )
    {
        merger.mergeModelBase( model, profile );

        if ( profile.getBuild() != null )
        {
            if ( model.getBuild() == null )
            {
                model.setBuild( new Build() );
            }
            merger.mergeBuildBase( model.getBuild(), profile.getBuild() );
        }
    }
}
项目:oceano    文件:DefaultProfileSelector.java   
private boolean isActive( Profile profile, ProfileActivationContext context, ModelProblemCollector problems )
{
    for ( ProfileActivator activator : activators )
    {
        try
        {
            if ( activator.isActive( profile, context, problems ) )
            {
                return true;
            }
        }
        catch ( RuntimeException e )
        {
            problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE)
                    .setMessage( "Failed to determine activation for profile " + profile.getId())
                    .setLocation( profile.getLocation( "" ))
                    .setException( e ));
            return false;
        }
    }
    return false;
}
项目:oceano    文件:StringSearchModelInterpolator.java   
protected void interpolateObject( Object obj, Model model, File projectDir, ModelBuildingRequest config,
                                  ModelProblemCollector problems )
{
    try
    {
        List<? extends ValueSource> valueSources = createValueSources( model, projectDir, config, problems );
        List<? extends InterpolationPostProcessor> postProcessors =
            createPostProcessors( model, projectDir, config );

        InterpolateObjectAction action =
            new InterpolateObjectAction( obj, valueSources, postProcessors, this, problems );

        AccessController.doPrivileged( action );
    }
    finally
    {
        getInterpolator().clearAnswers();
    }
}
项目:intellij-ce-playground    文件:CustomMaven3ModelInterpolator2.java   
@Override
protected List<ValueSource> createValueSources(Model model,
                                               File projectDir,
                                               ModelBuildingRequest config,
                                               ModelProblemCollector problems) {
  List<ValueSource> res = super.createValueSources(model, projectDir, config, problems);

  if (localRepository != null) {
    res.add(new SingleResponseValueSource("settings.localRepository", localRepository));
  }

  return res;
}
项目:oceano    文件:DefaultProfileManager.java   
public List getActiveProfiles()
    throws ProfileActivationException
{
    DefaultProfileActivationContext context = new DefaultProfileActivationContext();
    context.setActiveProfileIds( activatedIds );
    context.setInactiveProfileIds( deactivatedIds );
    context.setSystemProperties( System.getProperties() );
    context.setUserProperties( requestProperties );

    final List<ProfileActivationException> errors = new ArrayList<ProfileActivationException>();

    List<Profile> profiles =
        profileSelector.getActiveProfiles( profilesById.values(), context, new ModelProblemCollector()
        {

            public void add( ModelProblemCollectorRequest req )
            {
                if ( !ModelProblem.Severity.WARNING.equals( req.getSeverity() ) )
                {
                    errors.add( new ProfileActivationException( req.getMessage(), req.getException() ) );
                }
            }
        } );

    if ( !errors.isEmpty() )
    {
        throw errors.get( 0 );
    }

    return profiles;
}
项目:oceano    文件:DefaultModelValidator.java   
private void validate20RawPlugins( ModelProblemCollector problems, List<Plugin> plugins, String prefix,
                                 ModelBuildingRequest request )
{
    Severity errOn31 = getSeverity( request, ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_1 );

    Map<String, Plugin> index = new HashMap<String, Plugin>();

    for ( Plugin plugin : plugins )
    {
        String key = plugin.getKey();

        Plugin existing = index.get( key );

        if ( existing != null )
        {
            addViolation( problems, errOn31, Version.V20, prefix + ".(groupId:artifactId)", null,
                          "must be unique but found duplicate declaration of plugin " + key, plugin );
        }
        else
        {
            index.put( key, plugin );
        }

        Set<String> executionIds = new HashSet<String>();

        for ( PluginExecution exec : plugin.getExecutions() )
        {
            if ( !executionIds.add( exec.getId() ) )
            {
                addViolation( problems, Severity.ERROR, Version.V20, prefix + "[" + plugin.getKey()
                    + "].executions.execution.id", null, "must be unique but found duplicate execution with id "
                    + exec.getId(), exec );
            }
        }
    }
}
项目:oceano    文件:DefaultModelValidator.java   
private void validateEffectiveDependencies( ModelProblemCollector problems, List<Dependency> dependencies,
                                            boolean management, ModelBuildingRequest request )
{
    Severity errOn30 = getSeverity( request, ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_0 );

    String prefix = management ? "dependencyManagement.dependencies.dependency." : "dependencies.dependency.";

    for ( Dependency d : dependencies )
    {
        validateEffectiveDependency( problems, d, management, prefix, request );

        if ( request.getValidationLevel() >= ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_2_0 )
        {
            validateBoolean( prefix + "optional", problems, errOn30, Version.V20, d.getOptional(), d.getManagementKey(), d );

            if ( !management )
            {
                validateVersion( prefix + "version", problems, errOn30, Version.V20, d.getVersion(), d.getManagementKey(), d );

                /*
                 * TODO: Extensions like Flex Mojos use custom scopes like "merged", "internal", "external", etc.
                 * In order to don't break backward-compat with those, only warn but don't error out.
                 */
                validateEnum( prefix + "scope", problems, Severity.WARNING, Version.V20, d.getScope(), d.getManagementKey(), d,
                              "provided", "compile", "runtime", "test", "system" );
            }
        }
    }
}
项目:oceano    文件:DefaultModelValidator.java   
private void validateRawRepositories( ModelProblemCollector problems, List<Repository> repositories, String prefix,
                                   ModelBuildingRequest request )
{
    Map<String, Repository> index = new HashMap<String, Repository>();

    for ( Repository repository : repositories )
    {
        validateStringNotEmpty( prefix + ".id", problems, Severity.ERROR, Version.V20, repository.getId(), repository );

        validateStringNotEmpty( prefix + "[" + repository.getId() + "].url", problems, Severity.ERROR, Version.V20,
                                repository.getUrl(), repository );

        String key = repository.getId();

        Repository existing = index.get( key );

        if ( existing != null )
        {
            Severity errOn30 = getSeverity( request, ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_0 );

            addViolation( problems, errOn30, Version.V20, prefix + ".id", null, "must be unique: " + repository.getId() + " -> "
                + existing.getUrl() + " vs " + repository.getUrl(), repository );
        }
        else
        {
            index.put( key, repository );
        }
    }
}
项目:oceano    文件:DefaultModelValidator.java   
private void validate20RawResources( ModelProblemCollector problems, List<Resource> resources, String prefix,
                                ModelBuildingRequest request )
{
    Severity errOn30 = getSeverity( request, ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_0 );

    for ( Resource resource : resources )
    {
        validateStringNotEmpty( prefix + ".directory", problems, Severity.ERROR, Version.V20, resource.getDirectory(),
                                resource );

        validateBoolean( prefix + ".filtering", problems, errOn30, Version.V20, resource.getFiltering(),
                         resource.getDirectory(), resource );
    }
}
项目:oceano    文件:DefaultModelValidator.java   
private boolean validateStringNoExpression( String fieldName, ModelProblemCollector problems, Severity severity, Version version,
                                            String string, InputLocationTracker tracker )
{
    if ( !hasExpression( string ) )
    {
        return true;
    }

    addViolation( problems, severity, version, fieldName, null, "contains an expression but should be a constant.",
                  tracker );

    return false;
}
项目:oceano    文件:DefaultModelValidator.java   
/**
 * Asserts:
 * <p/>
 * <ul>
 * <li><code>string != null</code>
 * </ul>
 */
private boolean validateNotNull( String fieldName, ModelProblemCollector problems, Severity severity, Version version,
                                 Object object, String sourceHint, InputLocationTracker tracker )
{
    if ( object != null )
    {
        return true;
    }

    addViolation( problems, severity, version, fieldName, sourceHint, "is missing.", tracker );

    return false;
}
项目:oceano    文件:DefaultModelValidator.java   
private static void addViolation( ModelProblemCollector problems, Severity severity, Version version, String fieldName,
                                  String sourceHint, String message, InputLocationTracker tracker )
{
    StringBuilder buffer = new StringBuilder( 256 );
    buffer.append( '\'' ).append( fieldName ).append( '\'' );

    if ( sourceHint != null )
    {
        buffer.append( " for " ).append( sourceHint );
    }

    buffer.append( ' ' ).append( message );

    problems.add( new ModelProblemCollectorRequest( severity, version ).setMessage( buffer.toString() ).setLocation( getLocation( fieldName, tracker )));
}
项目:oceano    文件:DefaultInheritanceAssembler.java   
public void assembleModelInheritance( Model child, Model parent, ModelBuildingRequest request,
                                      ModelProblemCollector problems )
{
    Map<Object, Object> hints = new HashMap<Object, Object>();
    hints.put( MavenModelMerger.CHILD_PATH_ADJUSTMENT, getChildPathAdjustment( child, parent ) );
    merger.merge( child, parent, false, hints );
}
项目:oceano    文件:JdkVersionProfileActivator.java   
public boolean isActive( Profile profile, ProfileActivationContext context, ModelProblemCollector problems )
{
    Activation activation = profile.getActivation();

    if ( activation == null )
    {
        return false;
    }

    String jdk = activation.getJdk();

    if ( jdk == null )
    {
        return false;
    }

    String version = context.getSystemProperties().get( "java.version" );

    if ( version == null || version.length() <= 0 )
    {
        problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE )
                .setMessage( "Failed to determine Java version for profile " + profile.getId() )
                .setLocation(activation.getLocation( "jdk" ) ) );
        return false;
    }

    if ( jdk.startsWith( "!" ) )
    {
        return !version.startsWith( jdk.substring( 1 ) );
    }
    else if ( isRange( jdk ) )
    {
        return isInRange( version, getRange( jdk ) );
    }
    else
    {
        return version.startsWith( jdk );
    }
}
项目:oceano    文件:OperatingSystemProfileActivator.java   
public boolean isActive( Profile profile, ProfileActivationContext context, ModelProblemCollector problems )
{
    Activation activation = profile.getActivation();

    if ( activation == null )
    {
        return false;
    }

    ActivationOS os = activation.getOs();

    if ( os == null )
    {
        return false;
    }

    boolean active = ensureAtLeastOneNonNull( os );

    if ( active && os.getFamily() != null )
    {
        active = determineFamilyMatch( os.getFamily() );
    }
    if ( active && os.getName() != null )
    {
        active = determineNameMatch( os.getName() );
    }
    if ( active && os.getArch() != null )
    {
        active = determineArchMatch( os.getArch() );
    }
    if ( active && os.getVersion() != null )
    {
        active = determineVersionMatch( os.getVersion() );
    }

    return active;
}
项目:oceano    文件:DefaultModelNormalizer.java   
public void injectDefaultValues( Model model, ModelBuildingRequest request, ModelProblemCollector problems )
{
    injectDependencyDefaults( model.getDependencies() );

    Build build = model.getBuild();
    if ( build != null )
    {
        for ( Plugin plugin : build.getPlugins() )
        {
            injectDependencyDefaults( plugin.getDependencies() );
        }
    }
}
项目:oceano    文件:ProblemDetectingValueSource.java   
public ProblemDetectingValueSource( ValueSource valueSource, String bannedPrefix, String newPrefix,
                                    ModelProblemCollector problems )
{
    this.valueSource = valueSource;
    this.bannedPrefix = bannedPrefix;
    this.newPrefix = newPrefix;
    this.problems = problems;
}
项目:oceano    文件:StringSearchModelInterpolator.java   
public Model interpolateModel( Model model, File projectDir, ModelBuildingRequest config,
                               ModelProblemCollector problems )
{
    interpolateObject( model, model, projectDir, config, problems );

    return model;
}
项目:oceano    文件:StringSearchModelInterpolator.java   
public InterpolateObjectAction( Object target, List<? extends ValueSource> valueSources,
                                List<? extends InterpolationPostProcessor> postProcessors,
                                StringSearchModelInterpolator modelInterpolator,
                                ModelProblemCollector problems )
{
    this.valueSources = valueSources;
    this.postProcessors = postProcessors;

    this.interpolationTargets = new LinkedList<Object>();
    interpolationTargets.add( target );

    this.modelInterpolator = modelInterpolator;

    this.problems = problems;
}
项目:apache-archiva    文件:DummyLifecycleBindingsInjector.java   
@Override
public void injectLifecycleBindings( Model model, ModelBuildingRequest modelBuildingRequest, ModelProblemCollector modelProblemCollector )
{
    // left intentionally blank
}
项目:xmvn    文件:XMvnModelValidator.java   
@Override
public void validateEffectiveModel( Model model, ModelBuildingRequest request, ModelProblemCollector problems )
{
    customizeModel( model );
    super.validateEffectiveModel( model, request, problems );
}
项目:archiva    文件:DummyLifecycleBindingsInjector.java   
@Override
public void injectLifecycleBindings( Model model, ModelBuildingRequest modelBuildingRequest, ModelProblemCollector modelProblemCollector )
{
    // left intentionally blank
}
项目:oceano    文件:DefaultModelValidator.java   
private void validate20RawDependencies( ModelProblemCollector problems, List<Dependency> dependencies, String prefix,
                                      ModelBuildingRequest request )
{
    Severity errOn30 = getSeverity( request, ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_0 );
    Severity errOn31 = getSeverity( request, ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_1 );

    Map<String, Dependency> index = new HashMap<String, Dependency>();

    for ( Dependency dependency : dependencies )
    {
        String key = dependency.getManagementKey();

        if ( "import".equals( dependency.getScope() ) )
        {
            if ( !"pom".equals( dependency.getType() ) )
            {
                addViolation( problems, Severity.WARNING, Version.V20, prefix + ".type", key,
                              "must be 'pom' to import the managed dependencies.", dependency );
            }
            else if ( StringUtils.isNotEmpty( dependency.getClassifier() ) )
            {
                addViolation( problems, errOn30, Version.V20, prefix + ".classifier", key,
                              "must be empty, imported POM cannot have a classifier.", dependency );
            }
        }
        else if ( "system".equals( dependency.getScope() ) )
        {
            String sysPath = dependency.getSystemPath();
            if ( StringUtils.isNotEmpty( sysPath ) )
            {
                if ( !hasExpression( sysPath ) )
                {
                    addViolation( problems, Severity.WARNING, Version.V20, prefix + ".systemPath", key,
                                  "should use a variable instead of a hard-coded path " + sysPath, dependency );
                }
                else if ( sysPath.contains( "${basedir}" ) || sysPath.contains( "${project.basedir}" ) )
                {
                    addViolation( problems, Severity.WARNING, Version.V20, prefix + ".systemPath", key,
                                  "should not point at files within the project directory, " + sysPath
                                      + " will be unresolvable by dependent projects", dependency );
                }
            }
        }

        Dependency existing = index.get( key );

        if ( existing != null )
        {
            String msg;
            if ( equals( existing.getVersion(), dependency.getVersion() ) )
            {
                msg =
                    "duplicate declaration of version "
                        + StringUtils.defaultString( dependency.getVersion(), "(?)" );
            }
            else
            {
                msg =
                    "version " + StringUtils.defaultString( existing.getVersion(), "(?)" ) + " vs "
                        + StringUtils.defaultString( dependency.getVersion(), "(?)" );
            }

            addViolation( problems, errOn31, Version.V20, prefix + ".(groupId:artifactId:type:classifier)", null,
                          "must be unique: " + key + " -> " + msg, dependency );
        }
        else
        {
            index.put( key, dependency );
        }
    }
}
项目:oceano    文件:DefaultModelValidator.java   
private void validateEffectiveDependency( ModelProblemCollector problems, Dependency d, boolean management,
                                          String prefix, ModelBuildingRequest request )
{
    validateId( prefix + "artifactId", problems, Severity.ERROR, Version.BASE, d.getArtifactId(), d.getManagementKey(), d );

    validateId( prefix + "groupId", problems, Severity.ERROR, Version.BASE, d.getGroupId(), d.getManagementKey(), d );

    if ( !management )
    {
        validateStringNotEmpty( prefix + "type", problems, Severity.ERROR, Version.BASE, d.getType(), d.getManagementKey(), d );

        validateStringNotEmpty( prefix + "version", problems, Severity.ERROR, Version.BASE, d.getVersion(), d.getManagementKey(),
                                d );
    }

    if ( "system".equals( d.getScope() ) )
    {
        String systemPath = d.getSystemPath();

        if ( StringUtils.isEmpty( systemPath ) )
        {
            addViolation( problems, Severity.ERROR, Version.BASE, prefix + "systemPath", d.getManagementKey(), "is missing.",
                          d );
        }
        else
        {
            File sysFile = new File( systemPath );
            if ( !sysFile.isAbsolute() )
            {
                addViolation( problems, Severity.ERROR, Version.BASE, prefix + "systemPath", d.getManagementKey(),
                              "must specify an absolute path but is " + systemPath, d );
            }
            else if ( !sysFile.isFile() )
            {
                String msg = "refers to a non-existing file " + sysFile.getAbsolutePath();
                systemPath = systemPath.replace( '/', File.separatorChar ).replace( '\\', File.separatorChar );
                String jdkHome =
                    request.getSystemProperties().getProperty( "java.home", "" ) + File.separator + "..";
                if ( systemPath.startsWith( jdkHome ) )
                {
                    msg += ". Please verify that you run Maven using a JDK and not just a JRE.";
                }
                addViolation( problems, Severity.WARNING, Version.BASE, prefix + "systemPath", d.getManagementKey(), msg, d );
            }
        }
    }
    else if ( StringUtils.isNotEmpty( d.getSystemPath() ) )
    {
        addViolation( problems, Severity.ERROR, Version.BASE, prefix + "systemPath", d.getManagementKey(), "must be omitted."
            + " This field may only be specified for a dependency with system scope.", d );
    }

    if ( request.getValidationLevel() >= ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_2_0 )
    {
        for ( Exclusion exclusion : d.getExclusions() )
        {
            validateId( prefix + "exclusions.exclusion.groupId", problems, Severity.WARNING, Version.V20,
                        exclusion.getGroupId(), d.getManagementKey(), exclusion );

            validateId( prefix + "exclusions.exclusion.artifactId", problems, Severity.WARNING, Version.V20,
                        exclusion.getArtifactId(), d.getManagementKey(), exclusion );
        }
    }
}
项目:oceano    文件:DefaultModelValidator.java   
private boolean validateId( String fieldName, ModelProblemCollector problems, String id,
                            InputLocationTracker tracker )
{
    return validateId( fieldName, problems, Severity.ERROR, Version.BASE, id, null, tracker );
}
项目:oceano    文件:DefaultModelValidator.java   
private boolean validateStringNotEmpty( String fieldName, ModelProblemCollector problems, Severity severity, Version version,
                                        String string, InputLocationTracker tracker )
{
    return validateStringNotEmpty( fieldName, problems, severity, version, string, null, tracker );
}
项目:oceano    文件:DefaultProfileSelector.java   
public List<Profile> getActiveProfiles( Collection<Profile> profiles, ProfileActivationContext context,
                                        ModelProblemCollector problems )
{
    Collection<String> activatedIds = new HashSet<String>( context.getActiveProfileIds() );
    Collection<String> deactivatedIds = new HashSet<String>( context.getInactiveProfileIds() );

    List<Profile> activeProfiles = new ArrayList<Profile>( profiles.size() );
    List<Profile> activePomProfilesByDefault = new ArrayList<Profile>();
    boolean activatedPomProfileNotByDefault = false;

    for ( Profile profile : profiles )
    {
        if ( !deactivatedIds.contains( profile.getId() ) )
        {
            if ( activatedIds.contains( profile.getId() ) || isActive( profile, context, problems ) )
            {
                activeProfiles.add( profile );

                if ( Profile.SOURCE_POM.equals( profile.getSource() ) )
                {
                    activatedPomProfileNotByDefault = true;
                }
            }
            else if ( isActiveByDefault( profile ) )
            {
                if ( Profile.SOURCE_POM.equals( profile.getSource() ) )
                {
                    activePomProfilesByDefault.add( profile );
                }
                else
                {
                    activeProfiles.add( profile );
                }
            }

        }
    }

    if ( !activatedPomProfileNotByDefault )
    {
        activeProfiles.addAll( activePomProfilesByDefault );
    }

    return activeProfiles;
}