Package org.apache.maven.model

Examples of org.apache.maven.model.ActivationFile


     * @param parser
     */
    private ActivationFile parseActivationFile(String tagName, XmlPullParser parser, boolean strict, String encoding)
        throws IOException, XmlPullParserException
    {
        ActivationFile activationFile = new ActivationFile();
        activationFile.setModelEncoding( encoding );
        java.util.Set parsed = new java.util.HashSet();
        while ( parser.nextTag() == XmlPullParser.START_TAG )
        {
            if ( parser.getName().equals( "missing" )  )
            {
                if ( parsed.contains( "missing" ) )
                {
                    throw new XmlPullParserException( "Duplicated tag: '" + parser.getName() + "'", parser, null);
                }
                parsed.add( "missing" );
                activationFile.setMissing( getTrimmedValue( parser.nextText()) );
            }
            else if ( parser.getName().equals( "exists" )  )
            {
                if ( parsed.contains( "exists" ) )
                {
                    throw new XmlPullParserException( "Duplicated tag: '" + parser.getName() + "'", parser, null);
                }
                parsed.add( "exists" );
                activationFile.setExists( getTrimmedValue( parser.nextText()) );
            }
            else
            {
                if ( strict )
                {
View Full Code Here


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

        ActivationFile file = activation.getFile();

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

        String path;
        boolean missing;

        if ( StringUtils.isNotEmpty( file.getExists() ) )
        {
            path = file.getExists();
            missing = false;
        }
        else if ( StringUtils.isNotEmpty( file.getMissing() ) )
        {
            path = file.getMissing();
            missing = true;
        }
        else
        {
            return false;
        }

        RegexBasedInterpolator interpolator = new RegexBasedInterpolator();

        final File basedir = context.getProjectDirectory();

        if ( basedir != null )
        {
            interpolator.addValueSource( new AbstractValueSource( false )
            {
                public Object getValue( String expression )
                {
                    /*
                     * NOTE: We intentionally only support ${basedir} and not ${project.basedir} as the latter form
                     * would suggest that other project.* expressions can be used which is however beyond the design.
                     */
                    if ( "basedir".equals( expression ) )
                    {
                        return basedir.getAbsolutePath();
                    }
                    return null;
                }
            } );
        }
        else if ( path.contains( "${basedir}" ) )
        {
            return false;
        }

        interpolator.addValueSource( new MapBasedValueSource( context.getProjectProperties() ) );

        interpolator.addValueSource( new MapBasedValueSource( context.getUserProperties() ) );

        interpolator.addValueSource( new MapBasedValueSource( context.getSystemProperties() ) );

        try
        {
            path = interpolator.interpolate( path, "" );
        }
        catch ( Exception e )
        {
            problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE )
                    .setMessage( "Failed to interpolate file location " + path + " for profile " + profile.getId() + ": " + e.getMessage() )
                    .setLocation( file.getLocation( missing ? "missing" : "exists" ) )
                    .setException( e ) );
            return false;
        }

        path = pathTranslator.alignToBaseDirectory( path, basedir );

        // replace activation value with interpolated value
        if ( missing )
        {
            file.setMissing( path );
        }
        else
        {
            file.setExists( path );
        }

        File f = new File( path );

        if ( !f.isAbsolute() )
View Full Code Here

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

        ActivationFile file = activation.getFile();

        if ( file == null )
        {
            return false;
        }
View Full Code Here

        if ( activation == null )
        {
            return;
        }

        ActivationFile file = activation.getFile();

        if ( file != null )
        {
            String path;
            boolean missing;

            if ( StringUtils.isNotEmpty( file.getExists() ) )
            {
                path = file.getExists();
                missing = false;
            }
            else if ( StringUtils.isNotEmpty( file.getMissing() ) )
            {
                path = file.getMissing();
                missing = true;
            }
            else
            {
                return;
            }

            if ( path.contains( "${project.basedir}" ) )
            {
                addViolation( problems,
                              Severity.WARNING,
                              Version.V30,
                              prefix + ( missing ? ".file.missing" : ".file.exists" ),
                              null,
                              "Failed to interpolate file location "
                                  + path
                                  + " for profile "
                                  + sourceHint
                                  + ": ${project.basedir} expression not supported during profile activation, use ${basedir} instead",
                              file.getLocation( missing ? "missing" : "exists" ) );
            }
            else if ( hasProjectExpression( path ) )
            {
                addViolation( problems,
                              Severity.WARNING,
                              Version.V30,
                              prefix + ( missing ? ".file.missing" : ".file.exists" ),
                              null,
                              "Failed to interpolate file location "
                                  + path
                                  + " for profile "
                                  + sourceHint
                                  + ": ${project.*} expressions are not supported during profile activation",
                              file.getLocation( missing ? "missing" : "exists" ) );
            }
        }
    }
View Full Code Here

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

        ActivationFile file = activation.getFile();

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

        String path;
        boolean missing;

        if ( StringUtils.isNotEmpty( file.getExists() ) )
        {
            path = file.getExists();
            missing = false;
        }
        else if ( StringUtils.isNotEmpty( file.getMissing() ) )
        {
            path = file.getMissing();
            missing = true;
        }
        else
        {
            return false;
        }

        RegexBasedInterpolator interpolator = new RegexBasedInterpolator();

        final File basedir = context.getProjectDirectory();

        if ( basedir != null )
        {
            interpolator.addValueSource( new AbstractValueSource( false )
            {
                public Object getValue( String expression )
                {
                    /*
                     * NOTE: We intentionally only support ${basedir} and not ${project.basedir} as the latter form
                     * would suggest that other project.* expressions can be used which is however beyond the design.
                     */
                    if ( "basedir".equals( expression ) )
                    {
                        return basedir.getAbsolutePath();
                    }
                    return null;
                }
            } );
        }
        else if ( path.indexOf( "${basedir}" ) >= 0 )
        {
            return false;
        }

        interpolator.addValueSource( new MapBasedValueSource( context.getProjectProperties() ) );

        interpolator.addValueSource( new MapBasedValueSource( context.getUserProperties() ) );

        interpolator.addValueSource( new MapBasedValueSource( context.getSystemProperties() ) );

        try
        {
            path = interpolator.interpolate( path, "" );
        }
        catch ( Exception e )
        {
            problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE )
                    .setMessage( "Failed to interpolate file location " + path + " for profile " + profile.getId() + ": " + e.getMessage() )
                    .setLocation( file.getLocation( missing ? "missing" : "exists" ) )
                    .setException( e ) );
            return false;
        }

        path = pathTranslator.alignToBaseDirectory( path, basedir );
View Full Code Here

     */
    private ActivationFile parseActivationFile( XmlPullParser parser, boolean strict )
        throws IOException, XmlPullParserException
    {
        String tagName = parser.getName();
        ActivationFile activationFile = new ActivationFile();
        for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
        {
            String name = parser.getAttributeName( i );
            String value = parser.getAttributeValue( i );

            if ( name.indexOf( ':' ) >= 0 )
            {
                // just ignore attributes with non-default namespace (for example: xmlns:xsi)
            }
            else
            {
                checkUnknownAttribute( parser, name, tagName, strict );
            }
        }
        java.util.Set parsed = new java.util.HashSet();
        while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
        {
            if ( checkFieldWithDuplicate( parser, "missing", null, parsed ) )
            {
                activationFile.setMissing( getTrimmedValue( parser.nextText() ) );
            }
            else if ( checkFieldWithDuplicate( parser, "exists", null, parsed ) )
            {
                activationFile.setExists( getTrimmedValue( parser.nextText() ) );
            }
            else
            {
                checkUnknownElement( parser, strict );
            }
View Full Code Here

     */
    private ActivationFile parseActivationFile( XmlPullParser parser, boolean strict, InputSource source )
        throws IOException, XmlPullParserException
    {
        String tagName = parser.getName();
        ActivationFile activationFile = new ActivationFile();
        InputLocation _location;
        _location = new InputLocation( parser.getLineNumber(), parser.getColumnNumber(), source );
        activationFile.setLocation( "", _location );
        for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
        {
            String name = parser.getAttributeName( i );
            String value = parser.getAttributeValue( i );

            if ( name.indexOf( ':' ) >= 0 )
            {
                // just ignore attributes with non-default namespace (for example: xmlns:xsi)
            }
            else
            {
                checkUnknownAttribute( parser, name, tagName, strict );
            }
        }
        java.util.Set parsed = new java.util.HashSet();
        while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
        {
            if ( checkFieldWithDuplicate( parser, "missing", null, parsed ) )
            {
                _location = new InputLocation( parser.getLineNumber(), parser.getColumnNumber(), source );
                activationFile.setLocation( "missing", _location );
                activationFile.setMissing( getTrimmedValue( parser.nextText() ) );
            }
            else if ( checkFieldWithDuplicate( parser, "exists", null, parsed ) )
            {
                _location = new InputLocation( parser.getLineNumber(), parser.getColumnNumber(), source );
                activationFile.setLocation( "exists", _location );
                activationFile.setExists( getTrimmedValue( parser.nextText() ) );
            }
            else
            {
                checkUnknownElement( parser, strict );
            }
View Full Code Here

                                    }
                                    p.printWithOptions( "property", options );
                                }
                            }
                            {
                                ActivationFile file = activation.getFile();
                                if ( file != null )
                                {
                                    Map<String, Object> options = new LinkedHashMap<String, Object>();
                                    if ( file.getExists() != null )
                                    {
                                        options.put( "exists", file.getExists() );
                                    }
                                    if ( file.getMissing() != null )
                                    {
                                        options.put( "missing", file.getMissing() );
                                    }
                                    p.printWithOptions( "file", options );
                                }
                            }
                            {
View Full Code Here

TOP

Related Classes of org.apache.maven.model.ActivationFile

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.