Skip to content

Commit 94ef904

Browse files
committed
Upgrade dependencies and add comprehensive parameter validation
Major Changes: - Upgrade Java baseline requirement from Java 8 to Java 21 - Update all Maven plugin dependencies to latest versions - Update Jira REST client to 7.0.1 and Fugue to 6.1.2 - Add extensive parameter validation tests with edge case coverage New Documentation: - Add PARAMETER_VALIDATION.md documenting all parameter requirements - Add unit test README explaining test structure and patterns Testing Improvements: - Add ParameterValidationTest with comprehensive coverage - Add TestAbstractJiraMojo helper class for validation testing - Test empty strings, null values, and authentication combinations - Update AllJiraTests suite to include new tests Dependencies: - Keep Mockito at 4.x with comment explaining Java 11 baseline requirement - Add maven-settings-builder for plexus-sec-dispatcher 4.x tests - Document future plan to provide Atlassian libraries independently POM Improvements: - Improve XML formatting and readability - Add explanatory comments for dependency decisions - Consolidate version properties
1 parent c4316f3 commit 94ef904

23 files changed

+1882
-129
lines changed

PARAMETER_VALIDATION.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Jira Maven Plugin Parameter Validation
2+
3+
This document describes the parameter validation implemented in the Jira Maven Plugin.
4+
5+
## Overview
6+
7+
The Jira Maven Plugin performs validation of all parameters to ensure they are properly set before executing operations against a Jira instance. This validation helps prevent runtime errors and provides clear error messages when required parameters are missing or invalid.
8+
9+
## Common Parameter Validation
10+
11+
The following parameters are validated in all Mojos through the `AbstractJiraMojo` class:
12+
13+
| Parameter | Validation | Error Message |
14+
|-----------|------------|---------------|
15+
| `jiraURL` | Not null or empty | "JIRA URL is required. Please set jiraURL parameter." |
16+
| `jiraProjectKey` | Not null or empty | "JIRA Project Key is required. Please set jiraProjectKey parameter." |
17+
| `jiraUsername` | Not null or empty | "JIRA Username is required. Please set jiraUsername parameter." |
18+
| `jiraPassword` | Not null or empty when PAT not provided | "JIRA Password is required when not using Personal Access Token. Please set jiraPassword parameter." |
19+
| `jiraPersonalAccessToken` | Not used together with password | "Both password and Personal Access Token provided. Use only one authentication method." |
20+
21+
## Authentication Validation
22+
23+
The plugin supports two authentication methods:
24+
25+
1. **Username and Password**: Traditional basic authentication
26+
2. **Username and Personal Access Token (PAT)**: Token-based authentication
27+
28+
The validation ensures:
29+
- Only one authentication method is used at a time
30+
- Username is always provided, even when using PAT
31+
- Either password or PAT is provided
32+
33+
## Mojo-Specific Validation
34+
35+
### CreateNewVersionMojo
36+
37+
| Parameter | Validation | Error Message |
38+
|-----------|------------|---------------|
39+
| `developmentVersion` | Not null or empty | "Development version is required. Please set developmentVersion parameter." |
40+
| `finalName` | Not null or empty when `finalNameUsedForVersion` is true | "Final name is required when finalNameUsedForVersion is true. Please set finalName parameter." |
41+
42+
### ReleaseVersionMojo
43+
44+
| Parameter | Validation | Error Message |
45+
|-----------|------------|---------------|
46+
| `releaseVersion` | Not null or empty when `autoDiscoverLatestRelease` is false | "Release version is required when autoDiscoverLatestRelease is false. Please set releaseVersion parameter." |
47+
| Version existence | Checks if the specified version exists | "Version '[version]' not found in JIRA. Please check the version exists." |
48+
| Unreleased version | Checks if there's an unreleased version when auto-discovering | "No unreleased version found to release. Please create a version first." |
49+
50+
### GenerateReleaseNotesMojo
51+
52+
| Parameter | Validation | Error Message |
53+
|-----------|------------|---------------|
54+
| `releaseVersion` | Not null or empty | "Release version is required. Please set releaseVersion parameter." |
55+
| `jqlTemplate` | Not null or empty | "JQL template is required. Please set jqlTemplate parameter." |
56+
| `maxIssues` | Greater than zero | "Maximum number of issues must be greater than zero. Please set a valid maxIssues parameter." |
57+
| `targetFile` | Not null | "Target file is required. Please set targetFile parameter." |
58+
| `format` | Not null or empty | "Format is required. Please set format parameter." |
59+
| Output file | Checks if target file is a directory | "Target release note filename already exists and is a directory" |
60+
61+
## Testing
62+
63+
Parameter validation is tested in the `ParameterValidationTest` class, which verifies that appropriate exceptions are thrown when required parameters are missing or invalid.
64+
65+
## Best Practices
66+
67+
When using the Jira Maven Plugin:
68+
69+
1. Always provide all required parameters
70+
2. Use only one authentication method (either password or PAT)
71+
3. Check error messages carefully when validation fails
72+
4. Set parameters in your POM file or through Maven properties

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ Jira Maven Plugin
77

88
This Maven plugin allows the manipulation of Atlassian Jira project fixVersions within the project associated with the built component.
99

10-
**This Maven plugin tries to keep compatibility with Java 8 and beyond.**
10+
**This Maven plugin requires Java 21 baseline due to the Atlassian Jira Client minimum requirement.**
1111

1212
**_The documentation for the plugin is in the [project wiki](https://github.com/schrepfler/jira-maven-plugin/wiki)._**

pom.xml

Lines changed: 143 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
23

34
<parent>
45
<groupId>org.sonatype.oss</groupId>
@@ -24,38 +25,48 @@
2425

2526
<properties>
2627
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
27-
28+
2829
<!-- Dependency version properties below here. -->
29-
<maven.plugin.testing.annotation.version>3.10.2</maven.plugin.testing.annotation.version>
30+
<maven.plugin.testing.annotation.version>3.15.1</maven.plugin.testing.annotation.version>
3031
<maven.plugin.testing.harness.version>3.3.0</maven.plugin.testing.harness.version>
31-
<maven.enforcer.plugin.version>3.4.1</maven.enforcer.plugin.version>
32-
<maven.compiler.plugin.version>3.11.0</maven.compiler.plugin.version>
33-
<maven.gpg.plugin.version>3.1.0</maven.gpg.plugin.version>
34-
<maven.cyclonedx.plugin.version>2.7.10</maven.cyclonedx.plugin.version>
35-
<license.maven.plugin.version>2.3.0</license.maven.plugin.version>
36-
<versions.maven.plugin.version>2.16.2</versions.maven.plugin.version>
37-
<jira.rest.java.client.version>5.2.7</jira.rest.java.client.version>
38-
<fugue.version>5.0.0</fugue.version>
39-
<maven.version>3.9.5</maven.version>
40-
<gitflow.maven.plugin.version>1.20.0</gitflow.maven.plugin.version>
41-
<nexus.staging.maven.plugin.version>1.6.13</nexus.staging.maven.plugin.version>
42-
<maven.clean.plugin.version>3.3.2</maven.clean.plugin.version>
43-
<maven.deploy.plugin.version>3.1.1</maven.deploy.plugin.version>
44-
<maven.install.plugin.version>3.1.1</maven.install.plugin.version>
45-
<maven.jar.plugin.version>3.3.0</maven.jar.plugin.version>
46-
<maven.plugin.plugin.version>3.10.2</maven.plugin.plugin.version>
32+
<maven.enforcer.plugin.version>3.6.2</maven.enforcer.plugin.version>
33+
<maven.compiler.plugin.version>3.14.1</maven.compiler.plugin.version>
34+
<maven.gpg.plugin.version>3.2.8</maven.gpg.plugin.version>
35+
<maven.cyclonedx.plugin.version>2.9.1</maven.cyclonedx.plugin.version>
36+
<license.maven.plugin.version>2.7.0</license.maven.plugin.version>
37+
<versions.maven.plugin.version>2.19.1</versions.maven.plugin.version>
38+
<jira.rest.java.client.version>${jira-rest-java-client-core.version}</jira.rest.java.client.version>
39+
<fugue.version>6.1.2</fugue.version>
40+
<maven.version>3.9.11</maven.version>
41+
<gitflow.maven.plugin.version>1.21.0</gitflow.maven.plugin.version>
42+
<nexus.staging.maven.plugin.version>1.7.0</nexus.staging.maven.plugin.version>
43+
<maven.clean.plugin.version>3.5.0</maven.clean.plugin.version>
44+
<maven.deploy.plugin.version>3.1.4</maven.deploy.plugin.version>
45+
<maven.install.plugin.version>3.1.4</maven.install.plugin.version>
46+
<maven.jar.plugin.version>3.4.2</maven.jar.plugin.version>
47+
<maven.plugin.plugin.version>3.15.1</maven.plugin.plugin.version>
4748
<maven.resources.plugin.version>3.3.1</maven.resources.plugin.version>
48-
<maven.site.plugin.version>4.0.0-M12</maven.site.plugin.version>
49-
<maven.surefire.plugin.version>3.2.2</maven.surefire.plugin.version>
50-
<maven.javadoc.plugin.version>3.6.2</maven.javadoc.plugin.version>
51-
<maven-source-plugin.version>3.3.0</maven-source-plugin.version>
49+
<maven.site.plugin.version>4.0.0-M16</maven.site.plugin.version>
50+
<maven.surefire.plugin.version>3.5.4</maven.surefire.plugin.version>
51+
<maven.javadoc.plugin.version>3.12.0</maven.javadoc.plugin.version>
52+
<maven-source-plugin.version>3.3.1</maven-source-plugin.version>
5253
<!-- don't bump mockito to 5 as it requires java 11 -->
5354
<mockito.version>4.11.0</mockito.version>
5455
<junit.version>4.13.2</junit.version>
55-
<plexus-sec-dispatcher.version>2.0</plexus-sec-dispatcher.version>
56+
<plexus-sec-dispatcher.version>4.1.0</plexus-sec-dispatcher.version>
57+
<maven-shade-plugin.version>3.5.2</maven-shade-plugin.version>
58+
<maven-dependency-plugin.version>3.6.1</maven-dependency-plugin.version>
59+
<maven-assembly-plugin.version>3.7.1</maven-assembly-plugin.version>
60+
<maven-install-plugin.version>3.1.1</maven-install-plugin.version>
61+
<jira-rest-java-client-core.version>7.0.1</jira-rest-java-client-core.version>
62+
<maven.failsafe.plugin.version>3.5.4</maven.failsafe.plugin.version>
5663
</properties>
5764

5865
<repositories>
66+
67+
<!-- this library and fugue will be provided as jars exclusively as it is not available in maven central and
68+
I want this plugin to be independent on Atlassian's maven repositories. Leaving this comment to preserve this decision
69+
and for people to know where they can download and validate fugue -->
5970
<repository>
6071
<id>atlassian-public</id>
6172
<url>https://packages.atlassian.com/maven/repository/public</url>
@@ -139,20 +150,20 @@
139150

140151
<dependencies>
141152

153+
<!-- https://mvnrepository.com/artifact/com.atlassian.jira/jira-rest-java-client-core -->
142154
<dependency>
143155
<groupId>com.atlassian.jira</groupId>
144156
<artifactId>jira-rest-java-client-core</artifactId>
145-
<version>${jira.rest.java.client.version}</version>
157+
<version>${jira-rest-java-client-core.version}</version>
146158
</dependency>
147159

148160
<!-- required https://github.com/schrepfler/jira-maven-plugin/issues/59 -->
149161
<dependency>
150162
<groupId>io.atlassian.fugue</groupId>
151163
<artifactId>fugue</artifactId>
152164
<version>${fugue.version}</version>
153-
<scope>runtime</scope>
154165
</dependency>
155-
166+
156167
<dependency>
157168
<groupId>org.apache.maven</groupId>
158169
<artifactId>maven-plugin-api</artifactId>
@@ -222,6 +233,14 @@
222233
<version>${maven.plugin.testing.harness.version}</version>
223234
<scope>test</scope>
224235
</dependency>
236+
237+
<!-- Required for plexus-sec-dispatcher 4.x in tests -->
238+
<dependency>
239+
<groupId>org.apache.maven</groupId>
240+
<artifactId>maven-settings-builder</artifactId>
241+
<version>${maven.version}</version>
242+
<scope>test</scope>
243+
</dependency>
225244
</dependencies>
226245

227246
<scm>
@@ -235,41 +254,41 @@
235254
See: https://blog.sonatype.com/2010/01/how-to-generate-pgp-signatures-with-maven/
236255
-->
237256
<profiles>
238-
<profile>
239-
<id>release-sign-artifacts</id>
240-
<activation>
241-
<property>
242-
<name>performRelease</name>
243-
<value>true</value>
244-
</property>
245-
</activation>
246-
247-
<build>
248-
<plugins>
249-
<plugin>
250-
<groupId>org.apache.maven.plugins</groupId>
251-
<artifactId>maven-gpg-plugin</artifactId>
252-
<version>${maven.gpg.plugin.version}</version>
253-
<executions>
254-
<execution>
255-
<id>sign-artifacts</id>
256-
<phase>verify</phase>
257-
<goals>
258-
<goal>sign</goal>
259-
</goals>
260-
<configuration>
261-
<!-- Prevent gpg from using pinentry programs, needed for GitHub Actions -->
262-
<gpgArguments>
263-
<arg>--pinentry-mode</arg>
264-
<arg>loopback</arg>
265-
</gpgArguments>
266-
</configuration>
267-
</execution>
268-
</executions>
269-
</plugin>
270-
</plugins>
271-
</build>
272-
</profile>
257+
<profile>
258+
<id>release-sign-artifacts</id>
259+
<activation>
260+
<property>
261+
<name>performRelease</name>
262+
<value>true</value>
263+
</property>
264+
</activation>
265+
266+
<build>
267+
<plugins>
268+
<plugin>
269+
<groupId>org.apache.maven.plugins</groupId>
270+
<artifactId>maven-gpg-plugin</artifactId>
271+
<version>${maven.gpg.plugin.version}</version>
272+
<executions>
273+
<execution>
274+
<id>sign-artifacts</id>
275+
<phase>verify</phase>
276+
<goals>
277+
<goal>sign</goal>
278+
</goals>
279+
<configuration>
280+
<!-- Prevent gpg from using pinentry programs, needed for GitHub Actions -->
281+
<gpgArguments>
282+
<arg>--pinentry-mode</arg>
283+
<arg>loopback</arg>
284+
</gpgArguments>
285+
</configuration>
286+
</execution>
287+
</executions>
288+
</plugin>
289+
</plugins>
290+
</build>
291+
</profile>
273292

274293
<profile>
275294
<id>java8</id>
@@ -290,6 +309,39 @@
290309
</build>
291310
</profile>
292311

312+
<profile>
313+
<id>integration-tests</id>
314+
<build>
315+
<plugins>
316+
<plugin>
317+
<groupId>org.apache.maven.plugins</groupId>
318+
<artifactId>maven-failsafe-plugin</artifactId>
319+
<version>${maven.failsafe.plugin.version}</version>
320+
<executions>
321+
<execution>
322+
<goals>
323+
<goal>integration-test</goal>
324+
<goal>verify</goal>
325+
</goals>
326+
</execution>
327+
</executions>
328+
<configuration>
329+
<includes>
330+
<include>**/*IntegrationTest.java</include>
331+
</includes>
332+
<systemPropertyVariables>
333+
<jira.url>${jira.url}</jira.url>
334+
<jira.username>${jira.username}</jira.username>
335+
<jira.password>${jira.password}</jira.password>
336+
<jira.pat>${jira.pat}</jira.pat>
337+
<jira.projectKey>${jira.projectKey}</jira.projectKey>
338+
</systemPropertyVariables>
339+
</configuration>
340+
</plugin>
341+
</plugins>
342+
</build>
343+
</profile>
344+
293345
</profiles>
294346

295347
<build>
@@ -324,11 +376,11 @@
324376
</configuration>
325377
</plugin>
326378

327-
<plugin>
328-
<groupId>org.sonatype.plugins</groupId>
329-
<artifactId>nexus-staging-maven-plugin</artifactId>
330-
<version>${nexus.staging.maven.plugin.version}</version>
331-
</plugin>
379+
<plugin>
380+
<groupId>org.sonatype.plugins</groupId>
381+
<artifactId>nexus-staging-maven-plugin</artifactId>
382+
<version>${nexus.staging.maven.plugin.version}</version>
383+
</plugin>
332384

333385
<plugin>
334386
<groupId>org.apache.maven.plugins</groupId>
@@ -407,8 +459,8 @@
407459
<groupId>org.apache.maven.plugins</groupId>
408460
<artifactId>maven-compiler-plugin</artifactId>
409461
<configuration>
410-
<source>1.8</source>
411-
<target>1.8</target>
462+
<source>21</source>
463+
<target>21</target>
412464
</configuration>
413465
</plugin>
414466

@@ -427,16 +479,16 @@
427479
<artifactId>gitflow-maven-plugin</artifactId>
428480
</plugin>
429481

430-
<plugin>
431-
<groupId>org.sonatype.plugins</groupId>
432-
<artifactId>nexus-staging-maven-plugin</artifactId>
433-
<extensions>true</extensions>
434-
<configuration>
435-
<serverId>ossrh</serverId>
436-
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
437-
<autoReleaseAfterClose>true</autoReleaseAfterClose>
438-
</configuration>
439-
</plugin>
482+
<plugin>
483+
<groupId>org.sonatype.plugins</groupId>
484+
<artifactId>nexus-staging-maven-plugin</artifactId>
485+
<extensions>true</extensions>
486+
<configuration>
487+
<serverId>ossrh</serverId>
488+
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
489+
<autoReleaseAfterClose>true</autoReleaseAfterClose>
490+
</configuration>
491+
</plugin>
440492

441493
<plugin>
442494
<groupId>org.apache.maven.plugins</groupId>
@@ -457,6 +509,18 @@
457509
</executions>
458510
</plugin>
459511

512+
<plugin>
513+
<groupId>org.apache.maven.plugins</groupId>
514+
<artifactId>maven-surefire-plugin</artifactId>
515+
<configuration>
516+
<!-- Exclude integration tests from regular test phase -->
517+
<excludes>
518+
<exclude>**/*IntegrationTest.java</exclude>
519+
<exclude>**/integration/**/*.java</exclude>
520+
</excludes>
521+
</configuration>
522+
</plugin>
523+
460524
<plugin>
461525
<groupId>org.cyclonedx</groupId>
462526
<artifactId>cyclonedx-maven-plugin</artifactId>
@@ -470,7 +534,6 @@
470534
</execution>
471535
</executions>
472536
</plugin>
473-
474537
</plugins>
475538
</build>
476539

0 commit comments

Comments
 (0)