energytrackr.pipeline.custom_stages package

Submodules

energytrackr.pipeline.custom_stages.java_setup_stage module

JavaSetupStage: A specialized stage for setting up Java environment variables.

class energytrackr.pipeline.custom_stages.java_setup_stage.JavaEnvManager[source]

Bases: object

Manages JAVA_HOME and PATH environment variables for Java installations.

static set_java_home(java_home: str) None[source]

Set JAVA_HOME and update PATH by replacing any existing Java bin entries.

This will: 1. Remove any occurrences of the old JAVA_HOME/bin in PATH. 2. Avoid duplicating the new java_home/bin if it’s already present. 3. Prepend the new java_home/bin to PATH.

Parameters:

java_home (str) – Absolute path to the Java home directory.

Raises:

JavaHomeNotFoundError – If the provided java_home path does not exist.

class energytrackr.pipeline.custom_stages.java_setup_stage.JavaSetupStage[source]

Bases: PipelineStage

A specialized stage that sets JAVA_HOME or does other Java-specific tasks.

static extract_java_version(pom_file: str, context: dict[str, Any]) str | None[source]

Extracts the Java version from a Maven POM file.

Attempts the following methods:
  1. Look for <java.version> in the <properties> section (backward compatibility).

  2. Extract a properties map and then find the Java version from the maven-compiler-plugin configuration (supporting <release>, <source>, and <target> tags with property resolution).

  3. Also check profiles for maven-compiler-plugin configuration.

Parameters:
  • pom_file (str) – Path to the POM file.

  • context (dict[str, Any]) – The context dictionary for logging.

Returns:

The Java version specified in the POM file, or None if not found.

Return type:

Optional[str]

static map_version_to_home(version: str) str[source]

Maps a Java version string to the corresponding JAVA_HOME path.

For example, ‘1.8’ is mapped to ‘/usr/lib/jvm/java-8-openjdk’. If the extracted Java version is less than 8, then it defaults to Java 8.

Parameters:

version – The extracted Java version string from the POM file.

Returns:

A string representing the JAVA_HOME path.

run(context: dict[str, Any]) None[source]

Sets up the Java environment variables for the given commit.

Extracts the Java version from the project’s pom.xml, maps it to the corresponding JAVA_HOME path, and sets the environment variables.

Parameters:

context – A dictionary containing the current execution context.

Module contents

Custom stages for the pipeline.