Search in sources :

Example 1 with MavenProject

use of org.guvnor.ala.build.maven.model.MavenProject in project kie-wb-common by kiegroup.

the class ContextAwareDockerProvisioningConfig method setContext.

@Override
@JsonIgnore
public void setContext(final Map<String, ?> context) {
    this.context = context;
    this.providerId = (ProviderId) this.context.get("docker-provider");
    try {
        final Object _project = context.get("project");
        if (_project != null && _project instanceof MavenProject) {
            final Collection<PlugIn> plugIns = ((MavenProject) _project).getBuildPlugins();
            for (final PlugIn plugIn : plugIns) {
                if (plugIn.getId().equals("io.fabric8:docker-maven-plugin")) {
                    final Map<String, Object> _config = (Map<String, Object>) plugIn.getConfiguration().get("images");
                    imageName = getValue(_config, "image").get("name").toString();
                    portNumber = getValue(getValue(getValue(_config, "image"), "build"), "ports").get("port").toString();
                    break;
                }
            }
        }
    } catch (final Exception ex) {
        LOG.warn("Error failing to parse Maven configuration for Docker Plugin: " + ex.getMessage(), ex);
    }
}
Also used : MavenProject(org.guvnor.ala.build.maven.model.MavenProject) Map(java.util.Map) PlugIn(org.guvnor.ala.build.maven.model.PlugIn) JsonIgnore(com.fasterxml.jackson.annotation.JsonIgnore)

Aggregations

JsonIgnore (com.fasterxml.jackson.annotation.JsonIgnore)1 Map (java.util.Map)1 MavenProject (org.guvnor.ala.build.maven.model.MavenProject)1 PlugIn (org.guvnor.ala.build.maven.model.PlugIn)1