Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
1d87abb
Refactor artifact mapping and introduce DependencyGraphMojo implement…
bsels Feb 12, 2026
0b50022
Add MavenProjectToArtifact test and update .gitignore
bsels Feb 12, 2026
81952dd
Add unit test for DependencyGraphMojo and enhance dependency graph ge…
bsels Feb 12, 2026
d7c8c0a
Refactor `DependencyGraphMojo` to support relative and absolute paths…
bsels Feb 12, 2026
7459651
Enhance `DependencyGraphMojo` structure by introducing `MinDependency…
bsels Feb 13, 2026
452189d
Refactor `DependencyGraphMojo` to streamline dependency mapping and e…
bsels Feb 13, 2026
935f1ea
Add unit tests for JSON serialization and improve artifact serializer…
bsels Feb 13, 2026
de4c274
Refactor `DependencyGraphMojo` to improve dependency mapping logic by…
bsels Feb 13, 2026
ac5ab5b
Add integration tests for chained dependencies and refactor artifact …
bsels Feb 14, 2026
51cc1be
Refactor `DependencyGraphMojo` to enhance dependency graph generation…
bsels Feb 14, 2026
7ea5f05
Refactor `DependencyGraphMojo` to support configurable graph output f…
bsels Feb 14, 2026
11c5cae
Add `<packaging>pom</packaging>` to POM files and improve documentati…
bsels Feb 14, 2026
b09dc11
Improve `DependencyGraphMojo` documentation with detailed class and c…
bsels Feb 14, 2026
ecefa0a
Add unit tests for `ArtifactLocation`, `DetailedGraphNode`, and `Grap…
bsels Feb 14, 2026
1776fca
Add extensive unit tests for `DependencyGraphMojo` to validate single…
bsels Feb 14, 2026
5b04697
Add unit test for `MavenArtifactArtifactOnlySerializer` to validate a…
bsels Feb 14, 2026
88e3971
Refactor test method names in `DependencyGraphMojoTest` to align with…
bsels Feb 14, 2026
f07a90c
Update `README.md` to document the new `graph` goal with usage exampl…
bsels Feb 14, 2026
3b68fac
Created version Markdown file for 1 project(s)
bsels Feb 14, 2026
6e87068
Update project to release version 1.2.0 and upgrade plugin and depend…
bsels Feb 14, 2026
b1e3e34
Create versioning file and update dependencies: upgrade `maven-depend…
bsels Feb 14, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ buildNumber.properties
.classpath

# JetBrains
.idea
.idea
.junie
5 changes: 5 additions & 0 deletions .versioning/versioning-20260214170109.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
io.github.bsels:semantic-version-maven-plugin: "MINOR"
---

Added new `graph` goal, to list the different project and their internal dependencies.
8 changes: 8 additions & 0 deletions .versioning/versioning-20260214170800.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
io.github.bsels:semantic-version-maven-plugin: "PATCH"
---

Updated the following project dependencies:
- `maven-dependency-plugin` from `3.9.0` to `3.10.0`
- `maven-compiler-plugin` from `3.14.1` to `3.15.0`
- `assertj-core` from `3.27.6` to `3.27.7`
97 changes: 97 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ A Maven plugin for automated semantic versioning with Markdown-based changelog m
- [create](#create)
- [update](#update)
- [verify](#verify)
- [graph](#graph)
- [Configuration Properties](#configuration-properties)
- [Examples](#examples)
- [License](#license)
Expand Down Expand Up @@ -246,6 +247,94 @@ mvn io.github.bsels:semantic-version-maven-plugin:verify \
-Dversioning.verification.consistent=true
```

---

### graph

**Full name**: `io.github.bsels:semantic-version-maven-plugin:graph`

**Description**: Generates a JSON representation of the dependency graph for Maven projects within the current execution
scope. It identifies internal dependencies between projects and can output the graph either to the console or to a
specified file. The output includes transitive dependencies sorted in build order (topological order).

**Phase**: Not bound to any lifecycle phase (standalone goal)

#### Configuration Properties

| Property | Type | Default | Description |
|----------------------------|---------------|-----------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `versioning.graphOutput` | `GraphOutput` | `ARTIFACT_AND_FOLDER` | Specifies the graph output format:<br/>• `ARTIFACT_ONLY`: Only Maven artifact identifiers<br/>• `FOLDER_ONLY`: Only project folder paths<br/>• `ARTIFACT_AND_FOLDER`: Both artifact identifiers and folder paths |
| `versioning.outputFile` | `Path` | `-` | Path to the output file. If not specified, the graph is printed to the console. |
| `versioning.relativePaths` | `boolean` | `true` | When `true`, project folder paths are resolved relative to the execution root; otherwise, absolute paths are used. |
| `versioning.modus` | `Modus` | `PROJECT_VERSION` | Project scope for the graph:<br/>• `PROJECT_VERSION`: All projects in multi-module builds<br/>• `REVISION_PROPERTY`: Only current project using the `revision` property<br/>• `PROJECT_VERSION_ONLY_LEAFS`: Only leaf projects (no modules) |

#### Output Format Description

The generated JSON is a map where each key is a project's artifact identifier (`groupId:artifactId`), and the value is a
list of its internal dependencies.

**ARTIFACT_ONLY**:

```json
{
"io.github.bsels:parent": [],
"io.github.bsels:child": [
"io.github.bsels:parent"
]
}
```

**FOLDER_ONLY**:

```json
{
"io.github.bsels:parent": [],
"io.github.bsels:child": [
"."
]
}
```

**ARTIFACT_AND_FOLDER**:

```json
{
"io.github.bsels:parent": [],
"io.github.bsels:child": [
{
"artifact": {
"groupId": "io.github.bsels",
"artifactId": "parent"
},
"folder": "."
}
]
}
```

#### Example Usage

**Basic usage** (print to console):

```bash
mvn io.github.bsels:semantic-version-maven-plugin:graph
```

**Write to file with absolute paths**:

```bash
mvn io.github.bsels:semantic-version-maven-plugin:graph \
-Dversioning.outputFile=graph.json \
-Dversioning.relativePaths=false
```

**Artifact-only output**:

```bash
mvn io.github.bsels:semantic-version-maven-plugin:graph \
-Dversioning.graphOutput=ARTIFACT_ONLY
```

## Configuration Properties

### Common Properties
Expand Down Expand Up @@ -290,6 +379,14 @@ These properties apply to `create`, `update`, and `verify` goals. The `verify` g
| `versioning.verification.mode` | `VerificationMode` | `ALL_PROJECTS` | Verification scope:<br/>• `NONE`: skip verification<br/>• `AT_LEAST_ONE_PROJECT`: require at least one version-marked project<br/>• `DEPENDENT_PROJECTS`: require all dependent projects to be version-marked<br/>• `ALL_PROJECTS`: all projects in scope must be version-marked |
| `versioning.verification.consistent` | `boolean` | `false` | When `true`, all version-marked projects must share the same version bump type |

### graph-Specific Properties

| Property | Type | Default | Description |
|----------------------------|---------------|-----------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `versioning.graphOutput` | `GraphOutput` | `ARTIFACT_AND_FOLDER` | Specifies the graph output format:<br/>• `ARTIFACT_ONLY`: Only artifact identifiers<br/>• `FOLDER_ONLY`: Only folder paths<br/>• `ARTIFACT_AND_FOLDER`: Artifacts and folder paths |
| `versioning.outputFile` | `Path` | `-` | Path to the output file. If not specified, output is printed to the console. |
| `versioning.relativePaths` | `boolean` | `true` | When `true`, project paths are relative to execution root; otherwise, absolute. |

## Examples

### Example 1: Single Project Workflow
Expand Down
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<packaging>maven-plugin</packaging>
<name>${project.groupId}:${project.artifactId}</name>
<description>
A Maven plugin that automates semantic versioning with markdown‑based changelog management.
A Maven plugin that automates semantic versioning with Markdown‑based changelog management.
Provides two standalone goals: create generates interactive version spec files; update applies those specs,
bumps project versions, and merges CHANGELOG entries.
</description>
Expand Down Expand Up @@ -43,8 +43,8 @@
<jacoco.version>0.8.14</jacoco.version>
<maven.plugin.api.version>3.9.12</maven.plugin.api.version>
<maven.enforcer.plugin.version>3.6.2</maven.enforcer.plugin.version>
<maven.dependency.plugin.version>3.9.0</maven.dependency.plugin.version>
<maven.compiler.plugin.version>3.14.1</maven.compiler.plugin.version>
<maven.dependency.plugin.version>3.10.0</maven.dependency.plugin.version>
<maven.compiler.plugin.version>3.15.0</maven.compiler.plugin.version>
<maven.surefire.plugin.version>3.5.4</maven.surefire.plugin.version>
<maven.plugin.plugin.version>3.15.2</maven.plugin.plugin.version>
<maven.gpg.plugin.version>3.2.8</maven.gpg.plugin.version>
Expand All @@ -53,7 +53,7 @@
<central.publishing.maven.plugin.version>0.10.0</central.publishing.maven.plugin.version>
<!--endregion-->
<!--region Dependency versions -->
<assertj.version>3.27.6</assertj.version>
<assertj.version>3.27.7</assertj.version>
<commonmark.version>0.27.1</commonmark.version>
<jackson.version>2.21.0</jackson.version>
<junit.version>6.0.2</junit.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
///
/// Any issues encountered during plugin execution may result in a [MojoExecutionException]
/// or a [MojoFailureException] being thrown.
public abstract sealed class BaseMojo extends AbstractMojo permits CreateVersionMarkdownMojo, UpdatePomMojo, VerifyMojo {
public abstract sealed class BaseMojo extends AbstractMojo permits CreateVersionMarkdownMojo, DependencyGraphMojo, UpdatePomMojo, VerifyMojo {

/// A constant string representing the filename of the changelog file, "CHANGELOG.md".
///
Expand Down Expand Up @@ -305,7 +305,7 @@ protected MarkdownMapping getMarkdownMapping(List<VersionMarkdown> versionMarkdo
protected void validateMarkdowns(MarkdownMapping markdownMapping) throws MojoFailureException {
Set<MavenArtifact> artifactsInMarkdown = markdownMapping.versionBumpMap().keySet();
Stream<MavenProject> projectsInScope = getProjectsInScope();
Set<MavenArtifact> artifacts = projectsInScope.map(project -> new MavenArtifact(project.getGroupId(), project.getArtifactId()))
Set<MavenArtifact> artifacts = projectsInScope.map(Utils::mavenProjectToArtifact)
.collect(Utils.asImmutableSet());

if (!artifacts.containsAll(artifactsInMarkdown)) {
Expand Down Expand Up @@ -418,7 +418,7 @@ protected Map<MavenArtifact, MavenProjectAndDocument> readAllPoms(List<MavenProj
throws MojoExecutionException, MojoFailureException {
Map<MavenArtifact, MavenProjectAndDocument> documents = new HashMap<>();
for (MavenProject project : projects) {
MavenArtifact mavenArtifact = new MavenArtifact(project.getGroupId(), project.getArtifactId());
MavenArtifact mavenArtifact = Utils.mavenProjectToArtifact(project);
Path pomFile = project.getFile().toPath();
MavenProjectAndDocument projectAndDocument = new MavenProjectAndDocument(
mavenArtifact,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ protected void internalExecute() throws MojoExecutionException, MojoFailureExcep

Log log = getLog();
List<MavenArtifact> projects = getProjectsInScope()
.map(mavenProject -> new MavenArtifact(mavenProject.getGroupId(), mavenProject.getArtifactId()))
.map(Utils::mavenProjectToArtifact)
.toList();
if (projects.isEmpty()) {
log.warn("No projects found in scope");
Expand Down
Loading