Class AbstractDockerMojo

java.lang.Object
org.apache.maven.plugin.AbstractMojo
io.micronaut.maven.AbstractMicronautMojo
io.micronaut.maven.AbstractDockerMojo
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo
Direct Known Subclasses:
DockerCracMojo, DockerfileMojo, DockerMojo, DockerNativeMojo, DockerPushMojo

public abstract class AbstractDockerMojo extends AbstractMicronautMojo
Abstract base class for mojos related to Docker files and builds.
Since:
1.1
Author:
Álvaro Sánchez-Mariscal, Iván López
  • Field Details

  • Constructor Details

  • Method Details

    • javaVersion

      protected org.apache.maven.artifact.versioning.ArtifactVersion javaVersion()
      Returns:
      the Java version from either the maven.compiler.target property or the java.version property.
    • graalVmJvmVersion

      Returns:
      the JVM version to use for GraalVM.
    • graalVmDownloadUrl

      Returns:
      the GraalVM download URL depending on the Java version.
    • graalVmArch

      protected String graalVmArch()
      Returns:
      the OS architecture to use for GraalVM depending on the os.arch system property.
    • getFrom

      protected String getFrom()
      Returns:
      the base FROM image for the native image.
    • graalVmTag

      protected String graalVmTag(String graalVmJvmVersion, Boolean staticNativeImage, String oracleLinuxVersion)
      Parameters:
      graalVmJvmVersion - the JVM version string
      staticNativeImage - whether to produce a static native image
      oracleLinuxVersion - the Oracle Linux version to use
      Returns:
      the GraalVM Docker image tag based on the provided parameters
    • isArm

      protected boolean isArm()
      Check os.arch against known ARM architecture identifiers.
      Returns:
      true if we think we're running on an arm JDK
    • getFromImage

      Returns:
      the base image from the jib configuration (if any).
    • getJibFromImageSystemProperty

      Returns:
      the base image from the Jib system property override, if any.
    • getTags

      protected Set<String> getTags()
      Returns:
      the Docker image tags by looking at the Jib plugin configuration.
    • getPorts

      protected String getPorts()
      Returns:
      the application ports to expose by looking at the Jib configuration or the application configuration.
    • copyDependencies

      protected void copyDependencies() throws IOException
      Copy project dependencies to a target/dependency directory.
      Throws:
      IOException
    • getCmd

      protected String getCmd() throws org.apache.maven.plugin.MojoExecutionException
      Returns:
      the Docker CMD command.
      Throws:
      org.apache.maven.plugin.MojoExecutionException
    • getLambdaBootstrapCommand

      protected String getLambdaBootstrapCommand() throws org.apache.maven.plugin.MojoExecutionException
      Returns:
      the generated AWS Lambda bootstrap command.
      Throws:
      org.apache.maven.plugin.MojoExecutionException
    • lambdaBootstrapCommand

      protected void lambdaBootstrapCommand(File dockerfile) throws IOException, org.apache.maven.plugin.MojoExecutionException
      Applies the generated AWS Lambda bootstrap script to a dockerfile template.
      Parameters:
      dockerfile - the docker file
      Throws:
      IOException
      org.apache.maven.plugin.MojoExecutionException
    • validateDockerfileValue

      protected static String validateDockerfileValue(String source, String value) throws org.apache.maven.plugin.MojoExecutionException
      Throws:
      org.apache.maven.plugin.MojoExecutionException
    • validateImageReference

      protected static String validateImageReference(String source, String value) throws org.apache.maven.plugin.MojoExecutionException
      Throws:
      org.apache.maven.plugin.MojoExecutionException
    • validateExposedPorts

      protected static String validateExposedPorts(String source, String value) throws org.apache.maven.plugin.MojoExecutionException
      Throws:
      org.apache.maven.plugin.MojoExecutionException
    • validateDownloadUrl

      protected static String validateDownloadUrl(String source, String value) throws org.apache.maven.plugin.MojoExecutionException
      Throws:
      org.apache.maven.plugin.MojoExecutionException
    • jsonStringLiteral

      protected static String jsonStringLiteral(String source, String value) throws org.apache.maven.plugin.MojoExecutionException
      Throws:
      org.apache.maven.plugin.MojoExecutionException
    • escapeJsonString

      protected static String escapeJsonString(String source, String value) throws org.apache.maven.plugin.MojoExecutionException
      Throws:
      org.apache.maven.plugin.MojoExecutionException
    • shellLiteral

      protected static String shellLiteral(String source, String value) throws org.apache.maven.plugin.MojoExecutionException
      Throws:
      org.apache.maven.plugin.MojoExecutionException
    • escapeShellDoubleQuoted

      protected static String escapeShellDoubleQuoted(String source, String value) throws org.apache.maven.plugin.MojoExecutionException
      Throws:
      org.apache.maven.plugin.MojoExecutionException
    • getNetworkMode

      Returns:
      Networking mode for the RUN instructions during build (if any).
    • getProxyBuildArgs

      Returns:
      Map of proxy-related build arguments for Docker builds.
    • getBaseImage

      protected String getBaseImage()
      Returns:
      the base image to use for the Dockerfile.
    • oracleCloudFunctionCmd

      protected void oracleCloudFunctionCmd(File dockerfile) throws IOException, org.apache.maven.plugin.MojoExecutionException
      Adds cmd to docker oracle cloud function file.
      Parameters:
      dockerfile - the docker file
      Throws:
      IOException
      org.apache.maven.plugin.MojoExecutionException