Skip to content

Commit

Permalink
fabric8io#252: Jube maven plugin should be able to autodownload the j…
Browse files Browse the repository at this point in the history
…ube image
  • Loading branch information
davsclaus committed Mar 17, 2015
1 parent fc8cece commit 9d37827
Showing 1 changed file with 22 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,18 @@
*/
package io.fabric8.jube.maven;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import io.fabric8.jube.util.ImageMavenCoords;
import io.fabric8.jube.util.InstallHelper;
import io.fabric8.utils.Objects;
import io.fabric8.utils.Zips;

import org.apache.commons.io.FileUtils;
import org.apache.maven.archiver.MavenArchiveConfiguration;
import org.apache.maven.artifact.Artifact;
Expand All @@ -29,6 +36,8 @@
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
import org.apache.maven.artifact.resolver.ArtifactResolver;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.AbstractMojo;
Expand All @@ -50,14 +59,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import static io.fabric8.utils.PropertiesHelper.findPropertiesWithPrefix;

/**
Expand Down Expand Up @@ -316,14 +317,23 @@ protected void unpackBaseImage(File buildDir, boolean useDefaultPrefix) throws E

ImageMavenCoords baseImageCoords = ImageMavenCoords.parse(imageName, useDefaultPrefix);
String coords = baseImageCoords.getAetherCoords();
getLog().info("Looking up Jube: " + coords);

Artifact artifact = artifactFactory.createArtifactWithClassifier(baseImageCoords.getGroupId(),
baseImageCoords.getArtifactId(), baseImageCoords.getVersion(), baseImageCoords.getType(),
baseImageCoords.getClassifier());
getLog().info("Resolving Jube image: " + artifact);

artifactResolver.resolve(artifact, pomRemoteRepositories, localRepository);
ArtifactResolutionRequest request = new ArtifactResolutionRequest();
request.setArtifact(artifact);
request.setLocalRepository(localRepository);
request.setRemoteRepositories(pomRemoteRepositories);

ArtifactResolutionResult result = artifactResolver.resolve(request);
if (!result.isSuccess()) {
throw new ArtifactNotFoundException("Cannot download Jube image", artifact);
}

System.out.println(artifact.getFile());
getLog().info("Resolved Jube image: " + artifact);

if (artifact.getFile() != null) {
File file = artifact.getFile();
Expand Down

0 comments on commit 9d37827

Please sign in to comment.