Search in sources :

Example 1 with ActivationFile

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;
}
Also used : ActivationFile(org.apache.maven.model.ActivationFile) MavenActivationFile(org.eclipse.che.maven.data.MavenActivationFile)

Example 2 with ActivationFile

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;
}
Also used : ActivationFile(org.apache.maven.model.ActivationFile) RegexBasedInterpolator(org.codehaus.plexus.interpolation.RegexBasedInterpolator) Activation(org.apache.maven.model.Activation) IOException(java.io.IOException) InterpolationException(org.codehaus.plexus.interpolation.InterpolationException) EnvarBasedValueSource(org.codehaus.plexus.interpolation.EnvarBasedValueSource) MapBasedValueSource(org.codehaus.plexus.interpolation.MapBasedValueSource)

Example 3 with ActivationFile

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;
}
Also used : ActivationFile(org.apache.maven.model.ActivationFile) RegexBasedInterpolator(org.codehaus.plexus.interpolation.RegexBasedInterpolator) Activation(org.apache.maven.model.Activation) IOException(java.io.IOException) InterpolationException(org.codehaus.plexus.interpolation.InterpolationException) EnvarBasedValueSource(org.codehaus.plexus.interpolation.EnvarBasedValueSource) MapBasedValueSource(org.codehaus.plexus.interpolation.MapBasedValueSource)

Example 4 with ActivationFile

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;
}
Also used : ActivationFile(org.apache.maven.model.ActivationFile) ActivationOS(org.apache.maven.model.ActivationOS) Activation(org.apache.maven.settings.Activation) ActivationProperty(org.apache.maven.model.ActivationProperty)

Example 5 with ActivationFile

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;
}
Also used : ActivationFile(org.apache.maven.model.ActivationFile) ActivationOS(org.apache.maven.model.ActivationOS) Activation(org.apache.maven.settings.Activation) ActivationProperty(org.apache.maven.model.ActivationProperty)

Aggregations

ActivationFile (org.apache.maven.model.ActivationFile)5 IOException (java.io.IOException)2 Activation (org.apache.maven.model.Activation)2 ActivationOS (org.apache.maven.model.ActivationOS)2 ActivationProperty (org.apache.maven.model.ActivationProperty)2 Activation (org.apache.maven.settings.Activation)2 EnvarBasedValueSource (org.codehaus.plexus.interpolation.EnvarBasedValueSource)2 InterpolationException (org.codehaus.plexus.interpolation.InterpolationException)2 MapBasedValueSource (org.codehaus.plexus.interpolation.MapBasedValueSource)2 RegexBasedInterpolator (org.codehaus.plexus.interpolation.RegexBasedInterpolator)2 MavenActivationFile (org.eclipse.che.maven.data.MavenActivationFile)1