Search in sources :

Example 1 with MavenBinaryImpl

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

the class MavenDependencyConfigExecutor method apply.

@Override
public Optional<MavenBinary> apply(final MavenDependencyConfig config) {
    final String artifactId = config.getArtifact();
    checkNotEmpty("artifact parameter is mandatory", artifactId);
    LOGGER.debug("Resolving Artifact: {}", artifactId);
    final Artifact artifact = resolveArtifact(artifactId);
    if (artifact == null) {
        throw new RuntimeException("Cannot resolve Maven artifact. Look at the previous logs for more information.");
    }
    final String absolutePath = artifact.getFile().getAbsolutePath();
    LOGGER.debug("Resolved Artifact path: {}", absolutePath);
    final Path path = FileSystems.getFileSystem(URI.create("file://default")).getPath(absolutePath);
    final MavenBinary binary = new MavenBinaryImpl(path, artifact.getArtifactId(), artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion());
    buildRegistry.registerBinary(binary);
    return Optional.of(binary);
}
Also used : Path(org.uberfire.java.nio.file.Path) MavenBinaryImpl(org.guvnor.ala.build.maven.model.impl.MavenBinaryImpl) MavenBinary(org.guvnor.ala.build.maven.model.MavenBinary) Artifact(org.eclipse.aether.artifact.Artifact)

Aggregations

Artifact (org.eclipse.aether.artifact.Artifact)1 MavenBinary (org.guvnor.ala.build.maven.model.MavenBinary)1 MavenBinaryImpl (org.guvnor.ala.build.maven.model.impl.MavenBinaryImpl)1 Path (org.uberfire.java.nio.file.Path)1