Search in sources :

Example 1 with PlugIn

use of org.guvnor.ala.build.maven.model.PlugIn 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)

Example 2 with PlugIn

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

the class MavenProjectConfigExecutor method apply.

@Override
public Optional<ProjectConfig> apply(final Source source, final MavenProjectConfig mavenProjectConfig) {
    final Path projectRoot = source.getPath().resolve(mavenProjectConfig.getProjectDir());
    final InputStream pomStream = Files.newInputStream(projectRoot.resolve("pom.xml"));
    final MavenProject project = MavenProjectLoader.parseMavenPom(pomStream);
    final Collection<PlugIn> buildPlugins = extractPlugins(project);
    final String expectedBinary = project.getArtifact().getArtifactId() + "-" + project.getArtifact().getVersion() + "." + calculateExtension(project.getArtifact().getType());
    final String _tempDir = mavenProjectConfig.getProjectTempDir().trim();
    final RepositoryVisitor repositoryVisitor;
    if (_tempDir.isEmpty()) {
        repositoryVisitor = new RepositoryVisitor(projectRoot, project.getName());
    } else {
        repositoryVisitor = new RepositoryVisitor(projectRoot, _tempDir, mavenProjectConfig.recreateTempDir());
    }
    final org.guvnor.ala.build.maven.model.MavenProject mavenProject = new MavenProjectImpl(project.getId(), project.getArtifact().getType(), project.getName(), expectedBinary, source.getPath(), source.getPath().resolve(mavenProjectConfig.getProjectDir()), source.getPath().resolve("target").resolve(expectedBinary).toAbsolutePath(), repositoryVisitor.getRoot().getAbsolutePath(), buildPlugins);
    sourceRegistry.registerProject(source, mavenProject);
    return Optional.of(mavenProject);
}
Also used : Path(org.uberfire.java.nio.file.Path) MavenProject(org.apache.maven.project.MavenProject) InputStream(java.io.InputStream) RepositoryVisitor(org.guvnor.ala.build.maven.util.RepositoryVisitor) MavenProjectImpl(org.guvnor.ala.build.maven.model.impl.MavenProjectImpl) PlugIn(org.guvnor.ala.build.maven.model.PlugIn)

Example 3 with PlugIn

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

the class MavenProjectConfigExecutor method extractPlugins.

private Collection<PlugIn> extractPlugins(final MavenProject project) {
    final Collection<PlugIn> result = new ArrayList<>(project.getBuildPlugins().size());
    for (org.apache.maven.model.Plugin plugin : project.getBuildPlugins()) {
        final Map<String, Object> config = extractConfig(plugin.getConfiguration());
        result.add(new PlugIn() {

            @Override
            public String getId() {
                return plugin.getKey();
            }

            @Override
            public Map<String, ?> getConfiguration() {
                return config;
            }
        });
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) HashMap(java.util.HashMap) Map(java.util.Map) PlugIn(org.guvnor.ala.build.maven.model.PlugIn)

Aggregations

PlugIn (org.guvnor.ala.build.maven.model.PlugIn)3 Map (java.util.Map)2 JsonIgnore (com.fasterxml.jackson.annotation.JsonIgnore)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 MavenProject (org.apache.maven.project.MavenProject)1 MavenProject (org.guvnor.ala.build.maven.model.MavenProject)1 MavenProjectImpl (org.guvnor.ala.build.maven.model.impl.MavenProjectImpl)1 RepositoryVisitor (org.guvnor.ala.build.maven.util.RepositoryVisitor)1 Path (org.uberfire.java.nio.file.Path)1