Skip to content
file-text

GitHub Action

Java Info Action

2.1.22 Latest version

Java Info Action

file-text

Java Info Action

Fast Maven/Gradle parser detects and extracts info such as Java version, project version, encoding, build cmd and props

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Java Info Action

uses: YunaBraska/[email protected]

Learn more about this action in YunaBraska/java-info-action

Choose a version

java-info-action

Fast Maven/Gradle parser. This dynamic GitHub action automatically detects and extracts crucial information such as Java version, project version, and encoding. It also provides essential build commands and properties to make your development process more independent, efficient and streamlined.

Build Maintainable Coverage Issues Commit License Tag Size Label Label Licenses

Features

  • This action does not use any maven / gradle commands therefore no java, maven or gradle is needed.
  • JENV .java-version and ASDF .tool-versions will be taken as a fallback
  • update Shields/Badges see ShieldsDemo

Usage

# RUNNER
- name: "Read Java Info"
  id: "java_info"
  uses: YunaBraska/java-info-action@main

  # CONFIGS (Optional)
  with:
    deep: '-1'
    work-dir: '.'
    jv-fallback: 17
    pv-fallback: '0.0.1'
    pe-fallback: 'utf-8'
    custom-gradle-cmd: "clean build"
    custom-maven-cmd: "clean package"

  # PRINT
- name: "Print Java Version"
  run: |
    echo "java_version                     [${{ steps.java_info.outputs.java_version }}]"
    echo "artifact_name                    [${{ steps.java_info.outputs.artifact_name }}]"
    echo "project_version                  [${{ steps.java_info.outputs.project_version }}]"
    echo "project_encoding                 [${{ steps.java_info.outputs.project_encoding }}]"
    echo "cmd_custom                       [${{ steps.java_info.outputs.cmd_custom }}]"
    echo "is_gradle                        [${{ steps.java_info.outputs.is_gradle }}]"
    echo "is_maven                         [${{ steps.java_info.outputs.is_maven }}]"
    echo "has_wrapper                      [${{ steps.java_info.outputs.has_wrapper }}]"
    echo "builder_name                     [${{ steps.java_info.outputs.builder_name }}]"
    echo "x_sourceCompatibility            [${{ steps.java_info.outputs.x_sourceCompatibility }}]"
    echo "x_project_build_finalName        [${{ steps.java_info.outputs.x_project_build_finalName }}]"
    echo "x_groovyOptions_encoding         [${{ steps.java_info.outputs.x_groovyOptions_encoding }}]"
    echo "x_net_minidev_json-smart_version [${{ steps.java_info.outputs.x_project_dependencies_dependency_net_minidev_json-smart_version }}]"

  # SETUP JAVA
- name: "Setup Java"
  uses: actions/setup-java@main
  with:
    java-version: ${{ steps.java_info.outputs.java_version }}
    distribution: 'adopt'

  # RUN TESTS
- name: "Run tests"
  run: sh ${{ steps.java_info.outputs.cmd_test }}
  • Hint for multi-modules: The highest java version will win the race.

Inputs

parameter default description
work-dir '.' folder scan ('.' == current)
deep -1 folder scan deep (-1 == endless)
jv-fallback <Latest_LTS> fallback for "java_version" if no java version was found
pv-fallback null fallback for "project_version" if no project version was found
pe-fallback utf-8 fallback for "project_encoding" if no project encoding was found
custom-maven-cmd '' custom command for output "cmd_custom" which adds automatically gradle/maven prefix
custom-gradle-cmd '' custom command for output "cmd_custom" which adds automatically gradle/maven prefix
null-to-empty '' converts null to empty string

Outputs

Name default description
java_version <Latest_LTS> java version - parsed from build files e.g. 6,7,8,9,10,11
java_version_legacy <Latest_LTS> java version - parsed from build files e.g. 1.6,1.7,1.8,1.9,10,11
project_version null project version - parsed from build files e.g. 1.2.3
project_encoding null project encoding - parsed from build files e.g. utf-8
has_wrapper false if a wrapper exists - e.g. gradlew, mvnw,...
builder_name null Name of the builder [Gradle, Maven, null]
builder_version null version of the wrapper
is_gradle false true if a gradle build file was found
is_maven false true if a maven build file was found
artifact_name - artifact name if defined e.g. "archiveFileName, baseName, finalName"
artifact_name_jar - artifact name ending with ".jar" if defined e.g. "archiveFileName, baseName, finalName"
cmd - command e.g.
* gradle / gradlew / gradle.bat
* mvn / mvnw / mvn.bat
cmd_custom - Concatenation of 'cmd' + 'custom-gradle-cmd' or 'custom-maven-cmd'
cmd_test - command e.g.
* gradle clean test
* mvn clean test
cmd_build - command e.g.
* gradle clean build -x test
* mvn clean package -DskipTests
cmd_test_build - command e.g.
* gradle clean build
* mvn clean package
cmd_update_deps - command e.g.
* gradle check
* mvn versions:use-latest-versions -B -q -DgenerateBackupPoms=false
cmd_update_plugs - command e.g.
* gradle check
* mvn versions:use-latest-versions -B -q -DgenerateBackupPoms=false
cmd_update_props - command e.g.
* gradle check
* mvn versions:update-properties -B -q -DgenerateBackupPoms=false
cmd_update_parent - command e.g.
* gradle check
* mvn versions:update-parent -B -q -DgenerateBackupPoms=false
cmd_resolve_deps - command e.g.
* gradle check
* mvn -B -q dependency:resolve -Dmaven.test.skip=true
cmd_resolve_plugs - command e.g.
* gradle --refresh-dependencies check -x test
* mvn -B -q dependency:resolve -Dmaven.test.skip=true
cmd_update_wrapper - command
* gradle wrapper --gradle-version latest
* mvn -B -q wrapper:wrapper
x_<propertyKey> - other unhandled build script properties. These differs between maven an gradle

[DEV] Setup Environment

  • Build: npm run build to "compile" index.ts to ./lib/index.js
  • Test: npm run test
  • clean environment: ./clean_node.sh
  • NodeJs 16: do not upgrade nodeJs as GitHub actions latest version is 16