use of org.apache.maven.model.ActivationFile in project che by eclipse.
the class MavenModelUtil method convertToMavenActivationFile.
private static ActivationFile convertToMavenActivationFile(MavenActivationFile file) {
if (file != null) {
ActivationFile result = new ActivationFile();
result.setExists(file.getExist());
result.setMissing(file.getMissing());
return result;
}
return null;
}
use of org.apache.maven.model.ActivationFile 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.apache.maven.model.ActivationFile 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.apache.maven.model.ActivationFile in project spring-cloud-function by spring-cloud.
the class MavenSettings method createModelActivation.
private org.apache.maven.model.Activation createModelActivation(Activation activation) {
org.apache.maven.model.Activation modelActivation = new org.apache.maven.model.Activation();
modelActivation.setActiveByDefault(activation.isActiveByDefault());
if (activation.getFile() != null) {
ActivationFile activationFile = new ActivationFile();
activationFile.setExists(activation.getFile().getExists());
activationFile.setMissing(activation.getFile().getMissing());
modelActivation.setFile(activationFile);
}
modelActivation.setJdk(activation.getJdk());
if (activation.getOs() != null) {
ActivationOS os = new ActivationOS();
os.setArch(activation.getOs().getArch());
os.setFamily(activation.getOs().getFamily());
os.setName(activation.getOs().getName());
os.setVersion(activation.getOs().getVersion());
modelActivation.setOs(os);
}
if (activation.getProperty() != null) {
ActivationProperty property = new ActivationProperty();
property.setName(activation.getProperty().getName());
property.setValue(activation.getProperty().getValue());
modelActivation.setProperty(property);
}
return modelActivation;
}
use of org.apache.maven.model.ActivationFile in project spring-boot by spring-projects.
the class MavenSettings method createModelActivation.
private org.apache.maven.model.Activation createModelActivation(Activation activation) {
org.apache.maven.model.Activation modelActivation = new org.apache.maven.model.Activation();
modelActivation.setActiveByDefault(activation.isActiveByDefault());
if (activation.getFile() != null) {
ActivationFile activationFile = new ActivationFile();
activationFile.setExists(activation.getFile().getExists());
activationFile.setMissing(activation.getFile().getMissing());
modelActivation.setFile(activationFile);
}
modelActivation.setJdk(activation.getJdk());
if (activation.getOs() != null) {
ActivationOS os = new ActivationOS();
os.setArch(activation.getOs().getArch());
os.setFamily(activation.getOs().getFamily());
os.setName(activation.getOs().getName());
os.setVersion(activation.getOs().getVersion());
modelActivation.setOs(os);
}
if (activation.getProperty() != null) {
ActivationProperty property = new ActivationProperty();
property.setName(activation.getProperty().getName());
property.setValue(activation.getProperty().getValue());
modelActivation.setProperty(property);
}
return modelActivation;
}
Aggregations