use of org.codehaus.plexus.interpolation.InterpolationException in project intellij-community by JetBrains.
the class MyFileProfileActivator method isActive.
public boolean isActive(Profile profile) {
Activation activation = profile.getActivation();
ActivationFile actFile = activation.getFile();
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 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 !fileExists(fileString);
}
} catch (InterpolationException e) {
if (logger.isDebugEnabled()) {
logger.debug("Failed to interpolate missing file location for profile activator: " + fileString, e);
} else {
logger.warn("Failed to interpolate missing file location for profile activator: " + fileString + ". Run in debug mode (-X) for more information.");
}
}
}
return false;
}
use of org.codehaus.plexus.interpolation.InterpolationException in project intellij-community by JetBrains.
the class MyFileProfileActivator method isActive.
public boolean isActive(Profile profile) {
Activation activation = profile.getActivation();
ActivationFile actFile = activation.getFile();
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 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 !fileExists(fileString);
}
} catch (InterpolationException e) {
if (logger.isDebugEnabled()) {
logger.debug("Failed to interpolate missing file location for profile activator: " + fileString, e);
} else {
logger.warn("Failed to interpolate missing file location for profile activator: " + fileString + ". Run in debug mode (-X) for more information.");
}
}
}
return false;
}
use of org.codehaus.plexus.interpolation.InterpolationException 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.InterpolationException in project indy by Commonjava.
the class BootOptions method loadFromSysprops.
public static BootOptions loadFromSysprops() throws IndyBootException {
final String bootDef = System.getProperty(BootInterface.BOOT_DEFAULTS_PROP);
File bootDefaults = null;
if (bootDef != null) {
bootDefaults = new File(bootDef);
}
try {
final String indyHome = System.getProperty(BootInterface.INDY_HOME_PROP, new File(".").getCanonicalPath());
return new BootOptions(bootDefaults, indyHome);
} catch (final IOException e) {
throw new IndyBootException("ERROR LOADING BOOT DEFAULTS: %s.\nReason: %s\n\n", e, bootDefaults, e.getMessage());
} catch (final InterpolationException e) {
throw new IndyBootException("ERROR RESOLVING BOOT DEFAULTS: %s.\nReason: %s\n\n", e, bootDefaults, e.getMessage());
}
}
use of org.codehaus.plexus.interpolation.InterpolationException in project maven-plugins by apache.
the class AbstractInvokerMojo method getInvokerProperties.
/**
* Gets the (interpolated) invoker properties for an integration test.
*
* @param projectDirectory The base directory of the IT project, must not be <code>null</code>.
* @return The invoker properties, may be empty but never <code>null</code>.
* @throws org.apache.maven.plugin.MojoExecutionException If an I/O error occurred during reading the properties.
*/
private InvokerProperties getInvokerProperties(final File projectDirectory) throws MojoExecutionException {
Properties props = new Properties();
if (invokerPropertiesFile != null) {
File propertiesFile = new File(projectDirectory, invokerPropertiesFile);
if (propertiesFile.isFile()) {
InputStream in = null;
try {
in = new FileInputStream(propertiesFile);
props.load(in);
in.close();
in = null;
} catch (IOException e) {
throw new MojoExecutionException("Failed to read invoker properties: " + propertiesFile, e);
} finally {
IOUtil.close(in);
}
}
Interpolator interpolator = new RegexBasedInterpolator();
interpolator.addValueSource(new MapBasedValueSource(getInterpolationValueSource(false)));
// CHECKSTYLE_OFF: LineLength
for (String key : props.stringPropertyNames()) {
String value = props.getProperty(key);
try {
value = interpolator.interpolate(value, "");
} catch (InterpolationException e) {
throw new MojoExecutionException("Failed to interpolate invoker properties: " + propertiesFile, e);
}
props.setProperty(key, value);
}
// CHECKSTYLE_ON: LineLength
}
return new InvokerProperties(props);
}
Aggregations