use of org.codehaus.plexus.interpolation.PropertiesBasedValueSource 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.PropertiesBasedValueSource in project maven-plugins by apache.
the class DoapUtil method interpolate.
/**
* Interpolate a string with project and settings.
*
* @param value could be null
* @param project not null
* @param settings could be null
* @return the value trimmed and interpolated or null if the interpolation doesn't work.
* @since 1.1
*/
public static String interpolate(String value, final MavenProject project, Settings settings) {
if (project == null) {
throw new IllegalArgumentException("project is required");
}
if (value == null) {
return value;
}
if (!value.contains("${")) {
return value.trim();
}
RegexBasedInterpolator interpolator = new RegexBasedInterpolator();
try {
interpolator.addValueSource(new EnvarBasedValueSource());
} catch (IOException e) {
// ignore
}
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) {
// ignore
}
if (interpolatedValue.startsWith("${")) {
return null;
}
return interpolatedValue;
}
use of org.codehaus.plexus.interpolation.PropertiesBasedValueSource 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.");
}
});
}
use of org.codehaus.plexus.interpolation.PropertiesBasedValueSource in project indy by Commonjava.
the class CacheProducer method interpolateStrFromStream.
private String interpolateStrFromStream(InputStream inputStream, String path) {
String configuration;
try {
configuration = IOUtils.toString(inputStream);
} catch (IOException e) {
throw new RuntimeException("Cannot read infinispan configuration from : " + path, e);
}
StringSearchInterpolator interpolator = new StringSearchInterpolator();
interpolator.addValueSource(new PropertiesBasedValueSource(System.getProperties()));
try {
configuration = interpolator.interpolate(configuration);
} catch (InterpolationException e) {
throw new RuntimeException("Cannot resolve expressions in infinispan configuration from: " + path, e);
}
return configuration;
}
use of org.codehaus.plexus.interpolation.PropertiesBasedValueSource in project spring-boot by spring-projects.
the class RepositoryConfigurationFactory method addActiveProfileRepositories.
private static void addActiveProfileRepositories(List<Profile> activeProfiles, List<RepositoryConfiguration> configurations) {
for (Profile activeProfile : activeProfiles) {
Interpolator interpolator = new RegexBasedInterpolator();
interpolator.addValueSource(new PropertiesBasedValueSource(activeProfile.getProperties()));
for (Repository repository : activeProfile.getRepositories()) {
configurations.add(getRepositoryConfiguration(interpolator, repository));
}
}
}
Aggregations