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);
}
}
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);
}
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;
}
Aggregations