use of org.codehaus.plexus.interpolation.PrefixAwareRecursionInterceptor in project maven-plugins by apache.
the class DefaultAssemblyReader method readAssembly.
public Assembly readAssembly(Reader reader, final String locationDescription, final File assemblyDir, final AssemblerConfigurationSource configSource) throws AssemblyReadException, InvalidAssemblerConfigurationException {
Assembly assembly;
final MavenProject project = configSource.getProject();
try {
InterpolationState is = new InterpolationState();
final RecursionInterceptor interceptor = new PrefixAwareRecursionInterceptor(InterpolationConstants.PROJECT_PREFIXES, true);
is.setRecursionInterceptor(interceptor);
FixedStringSearchInterpolator interpolator = AssemblyInterpolator.fullInterpolator(project, createProjectInterpolator(project), configSource);
AssemblyXpp3Reader.ContentTransformer transformer = AssemblyInterpolator.assemblyInterpolator(interpolator, is, getLogger());
final AssemblyXpp3Reader r = new AssemblyXpp3Reader(transformer);
assembly = r.read(reader);
ComponentXpp3Reader.ContentTransformer ctrans = AssemblyInterpolator.componentInterpolator(interpolator, is, getLogger());
mergeComponentsWithMainAssembly(assembly, assemblyDir, configSource, ctrans);
debugPrintAssembly("After assembly is interpolated:", assembly);
AssemblyInterpolator.checkErrors(AssemblyId.createAssemblyId(assembly), is, getLogger());
reader.close();
reader = null;
} catch (final IOException e) {
throw new AssemblyReadException("Error reading descriptor: " + locationDescription + ": " + e.getMessage(), e);
} catch (final XmlPullParserException e) {
throw new AssemblyReadException("Error reading descriptor: " + locationDescription + ": " + e.getMessage(), e);
} finally {
IOUtil.close(reader);
}
if (assembly.isIncludeSiteDirectory()) {
includeSiteInAssembly(assembly, configSource);
}
return assembly;
}
use of org.codehaus.plexus.interpolation.PrefixAwareRecursionInterceptor in project galley by Commonjava.
the class MavenPomView method resolveExpressions.
public String resolveExpressions(final String value, RecursionInterceptor ri, final String... activeProfileIds) {
if (null == ri) {
List<String> prefixs = new ArrayList<>();
prefixs.add(PrefixAwareRecursionInterceptor.DEFAULT_START_TOKEN);
ri = new PrefixAwareRecursionInterceptor(prefixs);
}
StringSearchInterpolator ssi = new StringSearchInterpolator();
ssi.addValueSource(new MavenPomViewVS(this, ri, activeProfileIds));
try {
String result = ssi.interpolate(value, ri);
if (result == null || result.trim().length() < 1) {
result = value;
}
return result;
} catch (final InterpolationException e) {
logger.error(String.format("Failed to resolve expressions in: '%s'. Reason: %s", value, e.getMessage()), e);
return value;
}
}
Aggregations