use of org.codehaus.plexus.interpolation.StringSearchInterpolator 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;
}
}
use of org.codehaus.plexus.interpolation.StringSearchInterpolator in project indy by Commonjava.
the class BootOptions method resolve.
public String resolve(final String value) throws InterpolationException {
if (value == null || value.trim().length() < 1) {
return null;
}
if (bootProps == null) {
if (indyHome == null) {
return value;
} else {
bootProps = new Properties();
}
}
bootProps.setProperty("indy.home", indyHome);
if (interp == null) {
interp = new StringSearchInterpolator();
interp.addValueSource(new PropertiesBasedValueSource(bootProps));
}
return interp.interpolate(value);
}
use of org.codehaus.plexus.interpolation.StringSearchInterpolator in project maven-plugins by apache.
the class GenerateApplicationXmlMojo method buildEnvEntries.
/**
* Builds the env-entries based on the configuration.
*
* @return a list of EnvEntry object(s)
* @throws EarPluginException if the configuration is invalid
*/
private List<EnvEntry> buildEnvEntries() throws EarPluginException {
final List<EnvEntry> result = new ArrayList<EnvEntry>();
if (envEntries == null) {
return result;
}
try {
StringSearchInterpolator ssi = new StringSearchInterpolator();
ValueSource vs = new MapBasedValueSource(project.getProperties());
ssi.addValueSource(vs);
final PlexusConfiguration[] allEnvEntries = envEntries.getChildren(EnvEntry.ENV_ENTRY);
getLog().debug("buildEnvEntries: allEnvEntries:" + allEnvEntries);
getLog().debug("buildEnvEntries: allEnvEntries size:" + allEnvEntries.length);
for (PlexusConfiguration envEntry : allEnvEntries) {
// CHECKSTYLE_OFF: LineLength
final String childDescription = interpolate(ssi, envEntry.getChild(EnvEntry.DESCRIPTION).getValue());
final String childEnvEntryName = interpolate(ssi, envEntry.getChild(EnvEntry.ENV_ENTRY_NAME).getValue());
final String childEnvEntryType = interpolate(ssi, envEntry.getChild(EnvEntry.ENV_ENTRY_TYPE).getValue());
final String childEnvEntryValue = interpolate(ssi, envEntry.getChild(EnvEntry.ENV_ENTRY_VALUE).getValue());
final String childEnvLookupNameValue = interpolate(ssi, envEntry.getChild(EnvEntry.ENV_LOOKUP_NAME).getValue());
try {
result.add(new EnvEntry(childDescription, childEnvEntryName, childEnvEntryType, childEnvEntryValue, childEnvLookupNameValue));
} catch (IllegalArgumentException e) {
throw new EarPluginException("Invalid env-entry [" + envEntry + "]", e);
}
}
return result;
} catch (InterpolationException e) {
throw new EarPluginException("Interpolation exception:", e);
}
}
use of org.codehaus.plexus.interpolation.StringSearchInterpolator in project indy by Commonjava.
the class KojiUtils method getRepositoryName.
public String getRepositoryName(final KojiBuildInfo build) {
StringSearchInterpolator interpolator = new StringSearchInterpolator();
interpolator.addValueSource(new ObjectBasedValueSource(build));
try {
return interpolator.interpolate(isBinaryBuild(build) ? config.getBinayNamingFormat() : config.getNamingFormat());
} catch (InterpolationException e) {
throw new RuntimeException("Cannot resolve expressions in Koji configuration.", e);
}
}
use of org.codehaus.plexus.interpolation.StringSearchInterpolator in project indy by Commonjava.
the class AbstractKojiIT method initTestConfig.
@Override
protected void initTestConfig(CoreServerFixture fixture) throws IOException {
super.initTestConfig(fixture);
withNewClient((client) -> {
try {
File clientKeyCertPem = getClientKeyCertPem(client);
File serverCertsPem = getServerCertsPem(client);
Properties properties = System.getProperties();
properties.setProperty("client.pem", clientKeyCertPem.getAbsolutePath());
properties.setProperty("server.pem", serverCertsPem.getAbsolutePath());
properties.setProperty("hub.url", formatSSLUrl("kojihub"));
properties.setProperty("storage.url", formatSSLUrl("kojifiles"));
properties.setProperty("extra.config", getKojiExtraConfig());
StringSearchInterpolator ssi = new StringSearchInterpolator();
ssi.addValueSource(new PropertiesBasedValueSource(properties));
RecursionInterceptor ri = new SimpleRecursionInterceptor();
String kojiConf = readTestResource("test-koji.conf");
try {
kojiConf = ssi.interpolate(kojiConf, ri);
} catch (InterpolationException e) {
e.printStackTrace();
fail("Interpolation of test koji.conf failed!");
}
writeConfigFile("conf.d/koji.conf", kojiConf);
} catch (IOException e) {
e.printStackTrace();
fail("Cannot setup SSL config files for Koji.");
}
});
}
Aggregations