public abstract class AbstractDockerMojo
extends org.apache.maven.plugin.AbstractMojo
implements org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable
| Modifier and Type | Field and Description |
|---|---|
static String |
API_VERSION |
protected String |
autoPull |
static String |
CONTEXT_KEY_LOG_DISPATCHER |
static String |
CONTEXT_KEY_START_CALLED |
static String |
DOCKER_HTTPS_PORT |
protected ImageConfigResolver |
imageConfigResolver |
protected boolean |
keepContainer |
protected Logger |
log |
protected String |
portPropertyFile |
protected org.apache.maven.project.MavenProject |
project |
protected String |
registry |
protected boolean |
removeVolumes |
protected ServiceHubFactory |
serviceHubFactory |
protected org.apache.maven.execution.MavenSession |
session |
protected org.apache.maven.settings.Settings |
settings |
protected boolean |
useColor |
protected boolean |
verbose |
| Constructor and Description |
|---|
AbstractDockerMojo() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
checkImageWithAutoPull(ServiceHub hub,
String image,
String registry,
boolean autoPullAlwaysAllowed)
Check an image, and, if
autoPull is set to true, fetch it. |
void |
contextualize(org.codehaus.plexus.context.Context context) |
void |
execute()
Entry point for this plugin.
|
protected abstract void |
executeInternal(ServiceHub serviceHub)
Hook for subclass for doing the real job
|
protected String |
getConfiguredRegistry(ImageConfiguration imageConfig,
String specificRegistry)
Try to get the registry from various configuration parameters
|
protected List<ImageConfiguration> |
getImages()
Get all images to use.
|
protected LogDispatcher |
getLogDispatcher(ServiceHub hub) |
protected PomLabel |
getPomLabel() |
protected boolean |
isDockerAccessRequired()
Override this if your mojo doesnt require access to a Docker host (like creating and attaching
docker tar archives)
|
protected boolean |
matchesConfiguredImages(String imageList,
ImageConfiguration imageConfig) |
protected AuthConfig |
prepareAuthConfig(ImageName image,
String configuredRegistry,
boolean isPush) |
public static final String CONTEXT_KEY_START_CALLED
public static final String CONTEXT_KEY_LOG_DISPATCHER
public static final String DOCKER_HTTPS_PORT
public static final String API_VERSION
@Parameter(defaultValue="${project}",
readonly=true)
protected org.apache.maven.project.MavenProject project
@Parameter(defaultValue="${settings}",
readonly=true)
protected org.apache.maven.settings.Settings settings
@Parameter(defaultValue="${session}",
readonly=true)
protected org.apache.maven.execution.MavenSession session
@Component protected ImageConfigResolver imageConfigResolver
@Component protected ServiceHubFactory serviceHubFactory
@Parameter(property="docker.autoPull",
defaultValue="on")
protected String autoPull
@Parameter(property="docker.keepContainer",
defaultValue="false")
protected boolean keepContainer
@Parameter(property="docker.removeVolumes",
defaultValue="false")
protected boolean removeVolumes
@Parameter(property="docker.useColor",
defaultValue="true")
protected boolean useColor
@Parameter(property="docker.verbose",
defaultValue="false")
protected boolean verbose
@Parameter(property="docker.registry") protected String registry
@Parameter protected String portPropertyFile
protected Logger log
public void execute()
throws org.apache.maven.plugin.MojoExecutionException,
org.apache.maven.plugin.MojoFailureException
executeInternal(ServiceHub)
which must be implemented by subclass.execute in interface org.apache.maven.plugin.Mojoorg.apache.maven.plugin.MojoExecutionExceptionorg.apache.maven.plugin.MojoFailureExceptionprotected boolean isDockerAccessRequired()
true as the default valueprotected abstract void executeInternal(ServiceHub serviceHub) throws DockerAccessException, org.apache.maven.plugin.MojoExecutionException
serviceHub - context for accessing backendsDockerAccessExceptionorg.apache.maven.plugin.MojoExecutionExceptionprotected List<ImageConfiguration> getImages()
protected boolean matchesConfiguredImages(String imageList, ImageConfiguration imageConfig)
public void contextualize(org.codehaus.plexus.context.Context context)
throws org.codehaus.plexus.context.ContextException
contextualize in interface org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizableorg.codehaus.plexus.context.ContextExceptionprotected PomLabel getPomLabel()
protected AuthConfig prepareAuthConfig(ImageName image, String configuredRegistry, boolean isPush) throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionExceptionprotected LogDispatcher getLogDispatcher(ServiceHub hub)
protected String getConfiguredRegistry(ImageConfiguration imageConfig, String specificRegistry)
imageConfig - image config which might contain the registryspecificRegistry - specific registryprotected void checkImageWithAutoPull(ServiceHub hub, String image, String registry, boolean autoPullAlwaysAllowed) throws DockerAccessException, org.apache.maven.plugin.MojoExecutionException
autoPull is set to true, fetch it. Otherwise if the image
is not existent, throw an errorhub - access object to lookup an image (if autoPull is enabled)image - image nameregistry - optional registry which is used if the image itself doesn't have a registry.autoPullAlwaysAllowed - whether an unconditional autopull is allowed.DockerAccessExceptionorg.apache.maven.plugin.MojoExecutionExceptionCopyright © 2016. All Rights Reserved.