Skip to content

eitco/docker-helper-maven-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build status Maven Central Version

Docker Helper Maven Plugin

This Maven plugin provides tools to use docker containers in a maven project. For example, it resolves a local project path so it can be used as a Docker volume path and exposes the result as a Maven property.

The typical use case is a Maven project that starts Docker containers with local volume mappings. On Linux, Docker can use absolute paths directly. On Windows with Docker in WSL, a path like C:\myproject must be passed as /mnt/c/myproject.

Goal

docker-helper:resolve-volume-path

The goal runs in the validate phase by default.

Default behavior

Without further configuration, ${project.basedir} is resolved and stored in the Maven property docker.volumes.resolvedPath.

Examples:

C:\myproject -> /mnt/c/myproject
/home/me/myproject -> /home/me/myproject

Usage

<plugin>
  <groupId>de.eitco.cicd</groupId>
  <artifactId>docker-helper-maven-plugin</artifactId>
  <version>1.0-SNAPSHOT</version>
  <executions>
    <execution>
      <id>resolve-docker-volume-path</id>
      <phase>validate</phase>
      <goals>
        <goal>resolve-volume-path</goal>
      </goals>
    </execution>
  </executions>
</plugin>

The property can then be used in later Maven phases:

${docker.volumes.resolvedPath}

Custom Property

<plugin>
  <groupId>de.eitco.cicd</groupId>
  <artifactId>docker-helper-maven-plugin</artifactId>
  <version>1.0-SNAPSHOT</version>
  <executions>
    <execution>
      <id>resolve-docker-volume-path</id>
      <phase>validate</phase>
      <goals>
        <goal>resolve-volume-path</goal>
      </goals>
      <configuration>
        <propertyName>my.docker.volume.path</propertyName>
      </configuration>
    </execution>
  </executions>
</plugin>

Usage:

${my.docker.volume.path}

Custom Local Path

By default, ${project.basedir} is used. A different path can be configured with localPath.

<configuration>
  <localPath>${project.basedir}/src/test/resources</localPath>
  <propertyName>test.resources.docker.path</propertyName>
</configuration>

Docker Plugin Example

<volume>${docker.volumes.resolvedPath}:/app</volume>

Make sure that resolve-volume-path runs in an earlier phase than the plugin that starts the Docker containers.

Parameters

Parameter Maven Property Default Description
localPath docker.volumes.localPath ${project.basedir} Local path that is resolved for Docker.
propertyName docker.volumes.propertyName docker.volumes.resolvedPath Name of the Maven property that receives the resolved path.

Build

mvn clean verify

continuous integration

The directories .github and deployment contain the CI. While the directory .github contains actions that build each commit and release the project on demand, the directory deployment contains configuration for the release. A lot of the build however is configured by the project object model (pom.xml).

.mvn

The .mvn directory activates and configures the maven-git-versioning-extension. This extension changes the projects version depending on the current branch. This way every branch can be deployed without their artifacts overriding each other.

About

A plugin that provides tools to help building maven projects using docker containers

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

Generated from eitco/maven-template