Skip to main content

Java

Build actions for Java projects using Apache Maven.

Available Actions

ActionDescription
java-maven-setupInstall Java and Maven
java-maven-repository-loginConfigure Maven repositories
java-maven-buildBuild and test
java-maven-cut-tagBump version and create tag
java-maven-repository-publishDeploy to Maven repository

Version File

Maven reads and writes versions in pom.xml:

<project>
<groupId>com.example</groupId>
<artifactId>my-service</artifactId>
<version>1.2.3</version>
</project>

Example Usage

steps:
- uses: actions/checkout@v4

- uses: p6m-actions/java-maven-setup@v1
with:
java-version: '21'

- uses: p6m-actions/java-maven-repository-login@v1
with:
server-id: artifactory
username: ${{ secrets.ARTIFACTORY_USERNAME }}
password: ${{ secrets.ARTIFACTORY_IDENTITY_TOKEN }}

- uses: p6m-actions/java-maven-build@v1

- uses: p6m-actions/java-maven-repository-publish@v1

Dockerfile

note

Dockerfile patterns depend on your specific project structure. Java projects typically use a Dockerfile that copies the JAR built by Maven.

See Containerization for general patterns including:

  • Multi-stage builds vs copying pre-built artifacts
  • Non-root user configuration
  • Health check setup