|
1 | 1 | // Copyright © LFV |
2 | | -package se.lfv.reqstool.plugins.maven; |
| 2 | +package io.github.reqstool.plugins.maven; |
3 | 3 |
|
4 | 4 | import java.io.File; |
5 | 5 | import java.io.FileOutputStream; |
|
47 | 47 | import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; |
48 | 48 | import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator; |
49 | 49 |
|
| 50 | +/** |
| 51 | + * Maven Mojo for assembling and attaching reqstool artifacts. This plugin packages |
| 52 | + * requirements, test results, and annotations into a ZIP artifact during the verify phase |
| 53 | + * of the Maven build lifecycle. |
| 54 | + */ |
50 | 55 | @Mojo(name = "assemble-and-attach-zip-artifact", defaultPhase = LifecyclePhase.VERIFY) |
51 | 56 | public class RequirementsToolMojo extends AbstractMojo { |
52 | 57 |
|
53 | 58 | // Constants |
54 | 59 |
|
55 | 60 | private static final String[] OUTPUT_ARTIFACT_TEST_RESULTS_PATTERN = { "test_results/**/*.xml" }; |
56 | 61 |
|
| 62 | + /** Input file name for manual verification results. */ |
57 | 63 | public static final String INPUT_FILE_MANUAL_VERIFICATION_RESULTS_YML = "manual_verification_results.yml"; |
58 | 64 |
|
| 65 | + /** Input file name for requirements. */ |
59 | 66 | public static final String INPUT_FILE_REQUIREMENTS_YML = "requirements.yml"; |
60 | 67 |
|
| 68 | + /** Input file name for software verification cases. */ |
61 | 69 | public static final String INPUT_FILE_SOFTWARE_VERIFICATION_CASES_YML = "software_verification_cases.yml"; |
62 | 70 |
|
| 71 | + /** Input dataset directory path. */ |
63 | 72 | public static final String INPUT_PATH_DATASET = "reqstool"; |
64 | 73 |
|
| 74 | + /** Output file name for annotations. */ |
65 | 75 | public static final String OUTPUT_FILE_ANNOTATIONS_YML_FILE = "annotations.yml"; |
66 | 76 |
|
67 | 77 | private static final String OUTPUT_ARTIFACT_CLASSIFIER = "reqstool"; |
68 | 78 |
|
| 79 | + /** Output artifact file name for reqstool configuration. */ |
69 | 80 | public static final String OUTPUT_ARTIFACT_FILE_REQSTOOL_CONFIG_YML = "reqstool_config.yml"; |
70 | 81 |
|
| 82 | + /** Output artifact directory name for test results. */ |
71 | 83 | public static final String OUTPUT_ARTIFACT_DIR_TEST_RESULTS = "test_results"; |
72 | 84 |
|
| 85 | + /** XML element name for implementations. */ |
73 | 86 | public static final String XML_IMPLEMENTATIONS = "implementations"; |
74 | 87 |
|
| 88 | + /** XML element name for requirement annotations. */ |
75 | 89 | public static final String XML_REQUIREMENT_ANNOTATIONS = "requirement_annotations"; |
76 | 90 |
|
| 91 | + /** XML element name for tests. */ |
77 | 92 | public static final String XML_TESTS = "tests"; |
78 | 93 |
|
| 94 | + /** YAML language server schema annotation. */ |
79 | 95 | protected static final String YAML_LANG_SERVER_SCHEMA_ANNOTATIONS = "# yaml-language-server: $schema=https://raw.githubusercontent.com/Luftfartsverket/reqstool-client/main/src/reqstool/resources/schemas/v1/annotations.schema.json"; |
80 | 96 |
|
| 97 | + /** YAML language server schema for configuration. */ |
81 | 98 | protected static final String YAML_LANG_SERVER_SCHEMA_CONFIG = "# yaml-language-server: $schema=https://raw.githubusercontent.com/Luftfartsverket/reqstool-client/main/src/reqstool/resources/schemas/v1/reqstool_config.schema.json"; |
82 | 99 |
|
| 100 | + /** ObjectMapper for YAML serialization and deserialization. */ |
83 | 101 | protected static final ObjectMapper yamlMapper; |
84 | 102 |
|
85 | 103 | static { |
@@ -122,6 +140,16 @@ public class RequirementsToolMojo extends AbstractMojo { |
122 | 140 | @Parameter(property = "reqstool.skipAttachZipArtifact", defaultValue = "false") |
123 | 141 | private boolean skipAttachZipArtifact; |
124 | 142 |
|
| 143 | + /** Default constructor. */ |
| 144 | + public RequirementsToolMojo() { |
| 145 | + } |
| 146 | + |
| 147 | + /** |
| 148 | + * Executes the Mojo goal to assemble and attach the reqstool ZIP artifact. Combines |
| 149 | + * requirement and test annotations, assembles them into a ZIP file with requirements |
| 150 | + * and test results, and attaches the artifact to the Maven project. |
| 151 | + * @throws MojoExecutionException if an error occurs during execution |
| 152 | + */ |
125 | 153 | public void execute() throws MojoExecutionException { |
126 | 154 | if (skip) { |
127 | 155 | getLog().info("Skipping execution of reqstool plugin"); |
|
0 commit comments