Skip to content

Commit

Permalink
maven refactor - depreicate old class names for new standerdized ones.
Browse files Browse the repository at this point in the history
  • Loading branch information
itewk authored and dwinchell committed Jul 30, 2021
1 parent 40ea411 commit c213ebc
Show file tree
Hide file tree
Showing 21 changed files with 1,153 additions and 911 deletions.
10 changes: 5 additions & 5 deletions src/ploigos_step_runner/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@
}
unit-test:
- implementer: Maven
- implementer: MavenTest
config: {
# Optional.
# fail-on-no-tests: true
Expand All @@ -330,7 +330,7 @@
}
package:
- implementer: Maven
- implementer: MavenPackage
config: {
# Optional.
#pom-file: 'pom.xml'
Expand All @@ -343,7 +343,7 @@
}
push-artifacts:
- implementer: Maven
- implementer: MavenDeploy
config: {
# Required.
# URL to the artifact repository to push the artifact to.
Expand Down Expand Up @@ -503,7 +503,7 @@
}
uat:
- implementer: MavenSeleniumCucumber
- implementer: MavenTestSeleniumCucumber
config: {}
# TODO: not yet implemented
Expand Down Expand Up @@ -820,7 +820,7 @@
readiness-probe-path: ''
uat:
- implementer: MavenSeleniumCucumber
- implementer: MavenTestSeleniumCucumber
config: {}
# TODO: not yet implemented
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""`StepImplementers` for the `package` step.
"""

from ploigos_step_runner.step_implementers.package.maven_package import MavenPackage
from ploigos_step_runner.step_implementers.package.maven import Maven
176 changes: 10 additions & 166 deletions src/ploigos_step_runner/step_implementers/package/maven.py
Original file line number Diff line number Diff line change
@@ -1,85 +1,16 @@
"""`StepImplementer` for the `package` step using Maven.
Notes
-----
.. Important::
If package not specified in pom will default to jar in result.
Step Configuration
------------------
Step configuration expected as input to this step.
Could come from:
* static configuration
* runtime configuration
* previous step results
Configuration Key | Required? | Default | Description
-----------------------------|-----------|---------|-----------
`pom-file` | Yes | `'pom.xml'` | pom used when executing maven.
`tls-verify` | No | `True` | Disables TLS Verification if set to False
`maven-profiles` | No | `[]` | List of maven profiles to use.
`maven-no-transfer-progress` | No | `True` | \
`True` to suppress the transfer progress of packages maven downloads.
`False` to have the transfer progress printed.\
See https://maven.apache.org/ref/current/maven-embedder/cli.html
`maven-additional-arguments` | No | `['-Dmaven.test.skip=true']` \
| List of additional arguments to use. \
Skipping tests by default because assuming \
a previous step already ran them.
`maven-servers` | No | | Dictionary of dictionaries of \
id, username, password
`maven-repositories` | No | | Dictionary of dictionaries of \
id, url, snapshots, releases
`maven-mirrors` | No | | Dictionary of dictionaries of \
id, url, mirror_of
`artifact-extensions` | Yes | `["jar", "war", "ear"]` \
| Extensions to look for in the `artifact-parent-dir` \
for built artifacts.
`artifact-parent-dir` | Yes | `'target'` \
| Parent directory to look for built artifacts in \
ending in `artifact-extensions`.
Result Artifacts
----------------
Results artifacts output by this step.
Result Artifact Key | Description
--------------------|------------
`maven-output` | Path to Stdout and Stderr from invoking Maven.
`packages` | An array of dictionaries with information on the built artifacts.
## package-artifacts
Keys in the dictionary elements in the `package-artifacts` array in the step results.
| Key | Description
|-----------------|------------
| `path` | Absolute path to the built artifact.
"""DEPRECATED: use ploigos_step_runner.step_implementers.package.MavenPackage instead.
This is an alias to MavenPackage so as to keep things backwards compatible,
but eventually should/can will be removed.
"""
import os

from ploigos_step_runner import StepResult, StepRunnerException
from ploigos_step_runner.step_implementers.shared.maven_generic import \
MavenGeneric

DEFAULT_CONFIG = {
'maven-additional-arguments': [
'-Dmaven.test.skip=true'
],
'artifact-extensions': ["jar", "war", "ear"],
'artifact-parent-dir': 'target'
}
from ploigos_step_runner.step_implementers.package.maven_package import MavenPackage

REQUIRED_CONFIG_OR_PREVIOUS_STEP_RESULT_ARTIFACT_KEYS = [
'pom-file'
]
class Maven(MavenPackage):
"""DEPRECATED: use ploigos_step_runner.step_implementers.package.MavenPackage instead.
class Maven(MavenGeneric):
"""`StepImplementer` for the `package` step using Maven.
This is an alias to MavenPackage so as to keep things backwards compatible,
but eventually should/can will be removed.
"""
def __init__( # pylint: disable=too-many-arguments
self,
Expand All @@ -92,94 +23,7 @@ def __init__( # pylint: disable=too-many-arguments
workflow_result=workflow_result,
parent_work_dir_path=parent_work_dir_path,
config=config,
environment=environment,
maven_phases_and_goals=['package']
environment=environment
)

@staticmethod
def step_implementer_config_defaults():
"""Getter for the StepImplementer's configuration defaults.
Returns
-------
dict
Default values to use for step configuration values.
Notes
-----
These are the lowest precedence configuration values.
"""
return {**MavenGeneric.step_implementer_config_defaults(), **DEFAULT_CONFIG}

@staticmethod
def _required_config_or_result_keys():
"""Getter for step configuration or previous step result artifacts that are required before
running this step.
See Also
--------
_validate_required_config_or_previous_step_result_artifact_keys
Returns
-------
array_list
Array of configuration keys or previous step result artifacts
that are required before running the step.
"""
return REQUIRED_CONFIG_OR_PREVIOUS_STEP_RESULT_ARTIFACT_KEYS

def _run_step(self): # pylint: disable=too-many-locals
"""Runs the step implemented by this StepImplementer.
Returns
-------
StepResult
Object containing the dictionary results of this step.
"""
step_result = StepResult.from_step_implementer(self)

pom_file = self.get_value('pom-file')
artifact_extensions = self.get_value('artifact-extensions')
artifact_parent_dir = self.get_value('artifact-parent-dir')

# package the artifacts
mvn_output_file_path = self.write_working_file('mvn_output.txt')
try:
# execute maven step (params come from config)
self._run_maven_step(
mvn_output_file_path=mvn_output_file_path
)

# find the artifacts
packages = []
pom_file_dir_name = os.path.dirname(os.path.abspath(pom_file))
artifact_parent_dir_full_path = \
os.listdir(os.path.join(
pom_file_dir_name,
artifact_parent_dir))
for filename in artifact_parent_dir_full_path:
if any(filename.endswith(ext) for ext in artifact_extensions):
packages += [{
'path': os.path.join(
pom_file_dir_name,
artifact_parent_dir,
filename
)
}]

step_result.add_artifact(
name='packages',
value=packages
)
except StepRunnerException as error:
step_result.success = False
step_result.message = "Error running 'maven package' to package artifacts. " \
f"More details maybe found in 'maven-output' report artifact: {error}"
finally:
step_result.add_artifact(
description="Standard out and standard error from maven.",
name='maven-output',
value=mvn_output_file_path
)

return step_result
print("DEPRECATED: use ploigos_step_runner.step_implementers.package.MavenPackage instead.")
Loading

0 comments on commit c213ebc

Please sign in to comment.