org.codehaus.plexus.interpolation.InterpolationException Java Examples

The following examples show how to use org.codehaus.plexus.interpolation.InterpolationException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DataStoreSupport.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Interpolate configuration attributes when starting the data store.
 */
private Map<String, String> interpolatedAttributes() throws Exception {
  Map<String, String> attributes = configuration.getAttributes();

  Interpolator interpolator = new StringSearchInterpolator();
  interpolator.addValueSource(new SingleResponseValueSource("storeName", storeName));
  interpolator.addValueSource(new MapBasedValueSource(attributes));
  interpolator.addValueSource(new MapBasedValueSource(System.getProperties()));
  interpolator.addValueSource(new EnvarBasedValueSource());

  return attributes.entrySet().stream().collect(toMap(Entry::getKey, entry -> {
    try {
      return interpolator.interpolate(entry.getValue());
    }
    catch (InterpolationException e) {
      throw new IllegalArgumentException(e);
    }
  }));
}
 
Example #2
Source File: CiInterpolatorImpl.java    From flatten-maven-plugin with Apache License 2.0 6 votes vote down vote up
/**
 * Entry point for recursive resolution of an expression and all of its
 * nested expressions.
 */
public String interpolate( String input, RecursionInterceptor recursionInterceptor )
    throws InterpolationException
{
    try
    {
        return interpolate( input, recursionInterceptor, new HashSet<String>() );
    }
    finally
    {
        if ( !cacheAnswers )
        {
            existingAnswers.clear();
        }
    }
}
 
Example #3
Source File: GolangGetMojo.java    From mvn-golang with Apache License 2.0 5 votes vote down vote up
@Nonnull
private String interpolate(@Nonnull final String str) throws IOException, InterpolationException {
  Interpolator interpolator = new StringSearchInterpolator();
  interpolator.addValueSource(new MapBasedValueSource(this.getProject().getProperties()));
  interpolator.addValueSource(new MapBasedValueSource(System.getProperties()));
  interpolator.addValueSource(new EnvarBasedValueSource());
  return interpolator.interpolate(str);
}
 
Example #4
Source File: DependencyFactory.java    From appassembler with MIT License 5 votes vote down vote up
/**
 * Used by GenericDaemonGenerator.
 * @param artifact {@link Artifact}
 * @param layout {@link ArtifactRepositoryLayout}
 * @param outputFileNameMapping The name mapping.
 * @return the dependency.
 */
public static Dependency create( Artifact artifact, ArtifactRepositoryLayout layout, String outputFileNameMapping )
{
    Dependency dependency = new Dependency();
    dependency.setGroupId( artifact.getGroupId() );
    dependency.setArtifactId( artifact.getArtifactId() );
    dependency.setVersion( artifact.getVersion() );
    dependency.setClassifier( artifact.getClassifier() );

    String path = layout.pathOf( artifact );
    if ( StringUtils.isNotEmpty( outputFileNameMapping ) )
    {
        // Replace the file name part of the path with one that has been mapped
        File directory = new File( path ).getParentFile();

        try
        {
            String fileName = MappingUtils.evaluateFileNameMapping( outputFileNameMapping, artifact );
            File file = new File( directory, fileName );
            // Always use forward slash as path separator, because that's what layout.pathOf( artifact ) uses
            path = file.getPath().replace( '\\', '/' );
        }
        catch ( InterpolationException e )
        {
            // TODO Handle exceptions!
            // throw new MojoExecutionException("Unable to map file name.", e);
        }
    }
    dependency.setRelativePath( path );

    return dependency;
}
 
Example #5
Source File: PropertyInterpolator.java    From pom-manipulation-ext with Apache License 2.0 5 votes vote down vote up
public String interp( String value ) throws ManipulationException
{
    try
    {
        return interp.interpolate( value, ri );
    }
    catch ( final InterpolationException e )
    {
        throw new ManipulationException( "Failed to interpolate: {}. Reason: {}", value, e.getMessage(), e );
    }
}
 
Example #6
Source File: CiInterpolatorImpl.java    From flatten-maven-plugin with Apache License 2.0 4 votes vote down vote up
public String interpolate( String input, String thisPrefixPattern )
    throws InterpolationException
{
    return interpolate( input, new SimpleRecursionInterceptor() );
}
 
Example #7
Source File: CiInterpolatorImpl.java    From flatten-maven-plugin with Apache License 2.0 4 votes vote down vote up
public String interpolate( String input, String thisPrefixPattern, RecursionInterceptor recursionInterceptor )
    throws InterpolationException
{
    return interpolate( input, recursionInterceptor );
}
 
Example #8
Source File: CiInterpolatorImpl.java    From flatten-maven-plugin with Apache License 2.0 4 votes vote down vote up
public String interpolate( String input )
    throws InterpolationException
{
    return interpolate( input, new SimpleRecursionInterceptor() );
}