Examples of RegexBasedInterpolator


Examples of org.codehaus.plexus.interpolation.RegexBasedInterpolator

    {
        addFilterWrapper( new FileUtils.FilterWrapper()
        {
            public Reader getReader( Reader reader )
            {
                Interpolator propertiesInterpolator = new RegexBasedInterpolator( startRegExp, endRegExp );
                propertiesInterpolator.addValueSource( valueSource );
                return new InterpolatorFilterReaderLineEnding( reader, propertiesInterpolator, startToken, endToken,
                                                               false );
            }
        } );
    }
View Full Code Here

Examples of org.codehaus.plexus.interpolation.RegexBasedInterpolator

            String rawInput = sWriter.toString();

            try
            {
                RegexBasedInterpolator interpolator = new RegexBasedInterpolator();
                interpolator.addValueSource( new EnvarBasedValueSource() );

                rawInput = interpolator.interpolate( rawInput, "settings" );
            }
            catch ( Exception e )
            {
                log( "Failed to initialize environment variable resolver. Skipping environment substitution in "
                     + "settings." );
View Full Code Here

Examples of org.codehaus.plexus.interpolation.RegexBasedInterpolator

        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.getUserProperties() ) );

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

        try
        {
            path = interpolator.interpolate( path, "" );
        }
        catch ( Exception e )
        {
            problems.add( Severity.ERROR, "Failed to interpolate file location " + path + " for profile "
                + profile.getId() + ": " + e.getMessage(), file.getLocation( missing ? "missing" : "exists" ), e );
View Full Code Here

Examples of org.codehaus.plexus.interpolation.RegexBasedInterpolator

                String rawInput = sWriter.toString();

                try
                {
                    RegexBasedInterpolator interpolator = new RegexBasedInterpolator();
                    interpolator.addValueSource( new EnvarBasedValueSource() );

                    rawInput = interpolator.interpolate( rawInput, "settings" );
                }
                catch ( Exception e )
                {
                    getLogger().warn( "Failed to initialize environment variable resolver. Skipping environment "
                                          + "substitution in " + PROFILES_XML_FILE + "." );
View Full Code Here

Examples of org.codehaus.plexus.interpolation.RegexBasedInterpolator

        if ( actFile != null )
        {
            // check if the file exists, if it does then the profile will be active
            String fileString = actFile.getExists();

            RegexBasedInterpolator interpolator = new RegexBasedInterpolator();
            try
            {
                interpolator.addValueSource( new EnvarBasedValueSource() );
            }
            catch ( IOException e )
            {
                // ignored
            }
            interpolator.addValueSource( new MapBasedValueSource( System.getProperties() ) );

            try
            {
                if ( StringUtils.isNotEmpty( fileString ) )
                {
                    fileString = StringUtils.replace( interpolator.interpolate( fileString, "" ), "\\", "/" );
                    return FileUtils.fileExists( fileString );
                }

                // check if the file is missing, if it is then the profile will be active
                fileString = actFile.getMissing();

                if ( StringUtils.isNotEmpty( fileString ) )
                {
                    fileString = StringUtils.replace( interpolator.interpolate( fileString, "" ), "\\", "/" );
                    return !FileUtils.fileExists( fileString );
                }
            }
            catch ( InterpolationException e )
            {
View Full Code Here

Examples of org.codehaus.plexus.interpolation.RegexBasedInterpolator

            throw new IllegalStateException( "Failed to serialize settings to memory", e );
        }

        String serializedSettings = writer.toString();

        RegexBasedInterpolator interpolator = new RegexBasedInterpolator();

        interpolator.addValueSource( new PropertiesBasedValueSource( request.getUserProperties() ) );

        interpolator.addValueSource( new PropertiesBasedValueSource( request.getSystemProperties() ) );

        try
        {
            interpolator.addValueSource( new EnvarBasedValueSource() );
        }
        catch ( IOException e )
        {
            problems.add( SettingsProblem.Severity.WARNING, "Failed to use environment variables for interpolation: "
                + e.getMessage(), -1, -1, e );
        }

        interpolator.addPostProcessor( new InterpolationPostProcessor()
        {
            public Object execute( String expression, Object value )
            {
                if ( value != null )
                {
                    // we're going to parse this back in as XML so we need to escape XML markup
                    value = value.toString().replace( "&", "&amp;" ).replace( "<", "&lt;" ).replace( ">", "&gt;" );
                    return value;
                }
                return null;
            }
        } );

        try
        {
            serializedSettings = interpolator.interpolate( serializedSettings, "settings" );
        }
        catch ( InterpolationException e )
        {
            problems.add( SettingsProblem.Severity.ERROR, "Failed to interpolate settings: " + e.getMessage(), -1, -1,
                          e );
View Full Code Here

Examples of org.codehaus.plexus.interpolation.RegexBasedInterpolator

        if ( !value.contains( "${" ) )
        {
            return value.trim();
        }

        RegexBasedInterpolator interpolator = new RegexBasedInterpolator();
        try
        {
            interpolator.addValueSource( new EnvarBasedValueSource() );
        }
        catch ( IOException e )
        {
        }
        interpolator.addValueSource( new PropertiesBasedValueSource( System.getProperties() ) );
        interpolator.addValueSource( new PropertiesBasedValueSource( project.getProperties() ) );
        interpolator.addValueSource( new PrefixedObjectValueSource( "project", project ) );
        interpolator.addValueSource( new PrefixedObjectValueSource( "pom", project ) );
        interpolator.addValueSource( new ObjectBasedValueSource( project )
        {
            @Override
            public Object getValue( String expression )
            {
                try
                {
                    return ReflectionValueExtractor.evaluate( expression, project, true );
                }
                catch ( Exception e )
                {
                    addFeedback( "Failed to extract \'" + expression + "\' from: " + project, e );
                }

                return null;
            }
        } );

        if ( settings != null )
        {
            interpolator.addValueSource( new PrefixedObjectValueSource( "settings", settings ) );
        }

        String interpolatedValue = value;
        try
        {
            interpolatedValue = interpolator.interpolate( value ).trim();
        }
        catch ( InterpolationException e )
        {
        }
View Full Code Here

Examples of org.codehaus.plexus.interpolation.RegexBasedInterpolator

            String rawInput = sWriter.toString();

            try
            {
                RegexBasedInterpolator interpolator = new RegexBasedInterpolator();
                interpolator.addValueSource( new EnvarBasedValueSource() );

                rawInput = interpolator.interpolate( rawInput, "settings" );
            }
            catch ( Exception e )
            {
                log( "Failed to initialize environment variable resolver. Skipping environment substitution in "
                     + "settings." );
View Full Code Here

Examples of org.codehaus.plexus.interpolation.RegexBasedInterpolator

      this.evaluators = new ArrayList<>(builder.evaluators);
      this.decryptor = builder.decryptor;
      this.hiddenValueKeys = new HashSet<>(builder.hiddenValueKeys);
     
      if (builder.interpolationBuilder.enabled) {
        this.interpolator = new RegexBasedInterpolator();
        if (builder.interpolationBuilder.envVariableInterpolation) {
          try {
            this.interpolator.addValueSource(new EnvarBasedValueSource());
          } catch (Exception ex) {
            throw new JuRuntimeException("Couldn't create EnvarBasedValueSource", ex);
View Full Code Here

Examples of org.codehaus.plexus.interpolation.RegexBasedInterpolator

    {
    }

    protected Interpolator createInterpolator()
    {
        return new RegexBasedInterpolator( true );
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.