Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
charphi committed Nov 29, 2022
2 parents 81881e1 + d08c08b commit 3e95c92
Show file tree
Hide file tree
Showing 8 changed files with 150 additions and 37 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/java-ea-maven.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Java-EA with Maven

on:
push:
branches:
- develop
workflow_dispatch:

jobs:
build-and-test-job:
strategy:
fail-fast: false
matrix:
java: [ '-ea' ]
os: [ ubuntu-latest ]

name: JDK${{ matrix.java }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}

steps:
- name: Checkout source code
uses: actions/checkout@v3
with:
submodules: true
fetch-depth: 0

- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: ${{ matrix.java }}
cache: 'maven'

- name: Build and (headless) test with Maven
uses: GabrielBB/xvfb-action@v1
with:
run: mvn -U -B -ntp package
7 changes: 1 addition & 6 deletions .github/workflows/java8-maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,15 @@ on: [ push, pull_request ]

jobs:
build-and-test-job:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
strategy:
fail-fast: false
matrix:
java: [ 8, 17 ]
os: [ ubuntu-latest, macOS-latest, windows-latest ]
experimental: [ false ]
include:
- java: '-ea'
os: ubuntu-latest
experimental: true

name: JDK${{ matrix.java }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}

steps:
- name: Checkout source code
Expand Down
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [0.5.0] - 2022-11-29

### Added

- Validate project version with Semantic Versioning specification in Maven plugin [#45](https://github.com/nbbrd/heylogs/issues/45)

### Changed

- Modify check goal in Maven plugin to raise error if changelog is missing on root project [#46](https://github.com/nbbrd/heylogs/issues/46)
- Change default phase of check goal to `VALIDATE` in Maven plugin [#47](https://github.com/nbbrd/heylogs/issues/47)

## [0.4.0] - 2022-10-20

### Added
Expand Down Expand Up @@ -56,7 +67,8 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

- Initial release

[Unreleased]: https://github.com/nbbrd/heylogs/compare/v0.4.0...HEAD
[Unreleased]: https://github.com/nbbrd/heylogs/compare/v0.5.0...HEAD
[0.5.0]: https://github.com/nbbrd/heylogs/compare/v0.4.0...v0.5.0
[0.4.0]: https://github.com/nbbrd/heylogs/compare/v0.3.2...v0.4.0
[0.3.2]: https://github.com/nbbrd/heylogs/compare/v0.3.1...v0.3.2
[0.3.1]: https://github.com/nbbrd/heylogs/compare/v0.3.0...v0.3.1
Expand Down
4 changes: 2 additions & 2 deletions heylogs-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.github.nbbrd.heylogs</groupId>
<artifactId>heylogs-parent</artifactId>
<version>0.4.0</version>
<version>0.5.0</version>
</parent>

<artifactId>heylogs-api</artifactId>
Expand Down Expand Up @@ -50,7 +50,7 @@
<dependency>
<groupId>org.semver4j</groupId>
<artifactId>semver4j</artifactId>
<version>2.1.1</version>
<version>3.0.0</version>
</dependency>

<!-- test only -->
Expand Down
6 changes: 3 additions & 3 deletions heylogs-cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.github.nbbrd.heylogs</groupId>
<artifactId>heylogs-parent</artifactId>
<version>0.4.0</version>
<version>0.5.0</version>
</parent>

<artifactId>heylogs-cli</artifactId>
Expand Down Expand Up @@ -84,7 +84,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.4.0</version>
<version>3.4.1</version>
<executions>
<execution>
<phase>package</phase>
Expand Down Expand Up @@ -150,7 +150,7 @@
<plugin>
<groupId>org.jreleaser</groupId>
<artifactId>jreleaser-maven-plugin</artifactId>
<version>1.2.0</version>
<version>1.3.1</version>
<executions>
<execution>
<phase>install</phase>
Expand Down
6 changes: 3 additions & 3 deletions heylogs-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.github.nbbrd.heylogs</groupId>
<artifactId>heylogs-parent</artifactId>
<version>0.4.0</version>
<version>0.5.0</version>
</parent>

<artifactId>heylogs-maven-plugin</artifactId>
Expand Down Expand Up @@ -38,7 +38,7 @@
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.6.4</version>
<version>3.7.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
Expand All @@ -49,7 +49,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.6.4</version>
<version>3.7.0</version>
</plugin>
</plugins>
</pluginManagement>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.semver4j.Semver;

import java.io.File;
import java.io.IOException;
import java.io.Reader;
import java.nio.file.Files;
import java.util.List;

@Mojo(name = "check", defaultPhase = LifecyclePhase.GENERATE_RESOURCES, threadSafe = true)
@Mojo(name = "check", defaultPhase = LifecyclePhase.VALIDATE, threadSafe = true)
public final class CheckMojo extends AbstractMojo {

@Parameter(defaultValue = "${project.basedir}/CHANGELOG.md", property = "heylogs.input.file")
Expand All @@ -29,39 +30,80 @@ public final class CheckMojo extends AbstractMojo {
@Parameter(defaultValue = "false", property = "heylogs.semver")
private boolean semver;

@Parameter(defaultValue = "${project.version}", readonly = true)
private String projectVersion;

@Parameter(defaultValue = "${project.basedir}", readonly = true)
private File projectBaseDir;

@Override
public void execute() throws MojoExecutionException {
if (skip) {
getLog().info("Checking has been skipped.");
return;
}

if (!inputFile.exists()) {
getLog().info("Changelog not found");
return;
if (semver) {
enableSemanticVersioning();
}

if (inputFile.exists()) {
validateFile();
} else {
if (isRootProject()) {
raiseErrorMissingFile();
} else {
notifyMissingFile();
}
}
}

private void enableSemanticVersioning() throws MojoExecutionException {
getLog().info("Using Semantic Versioning specification");
if (Semver.isValid(projectVersion)) {
getLog().info("Valid project version");
System.setProperty(Rule.ENABLE_KEY, "semver");
} else {
getLog().error(String.format("Invalid project version: '%s' must follow Semantic Versioning specification (https://semver.org/)", projectVersion));
throw new MojoExecutionException("Invalid project version. See above for details.");
}
}

private void validateFile() throws MojoExecutionException {
try {
getLog().info("Reading " + inputFile);
Document changelog = read();

if (semver) {
getLog().info("Using semver rule");
System.setProperty(Rule.ENABLE_KEY, "semver");
}

List<Failure> failures = Failure.allOf(changelog, RuleLoader.load());
if (!failures.isEmpty()) {
getLog().error("Invalid CHANGELOG");
getLog().error("Invalid changelog");
failures.forEach(failure -> getLog().error(failure.toString()));
throw new MojoExecutionException("Invalid CHANGELOG");
throw new MojoExecutionException("Invalid changelog");
}
getLog().info("Valid CHANGELOG");
getLog().info("Valid changelog");
} catch (IOException ex) {
throw new MojoExecutionException("Error while checking changelog", ex);
}
}

private boolean isRootProject() {
File parentDir = projectBaseDir.getParentFile();
if (parentDir != null) {
File parentPom = new File(parentDir, "pom.xml");
return !parentPom.exists();
}
return true;
}

private void raiseErrorMissingFile() throws MojoExecutionException {
getLog().error("Missing changelog");
throw new MojoExecutionException("Missing changelog");
}

private void notifyMissingFile() {
getLog().info("Changelog not found");
}

public Document read() throws IOException {
Parser parser = Parser.builder().build();
try (Reader reader = Files.newBufferedReader(inputFile.toPath())) {
Expand Down
47 changes: 37 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.github.nbbrd.heylogs</groupId>
<artifactId>heylogs-parent</artifactId>
<version>0.4.0</version>
<version>0.5.0</version>
<packaging>pom</packaging>

<name>heylogs</name>
Expand Down Expand Up @@ -42,7 +42,7 @@
<dependency>
<groupId>org.checkerframework</groupId>
<artifactId>checker-qual</artifactId>
<version>3.26.0</version>
<version>3.27.0</version>
</dependency>

<!-- test libraries -->
Expand Down Expand Up @@ -83,7 +83,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>3.0.1</version>
<version>3.1.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand All @@ -107,6 +107,21 @@
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<properties>
<!-- Enable parallel execution of junit5 tests -->
<configurationParameters>
junit.jupiter.execution.parallel.enabled=true
junit.jupiter.execution.parallel.mode.default=concurrent
</configurationParameters>
</properties>
</configuration>
</plugin>
</plugins>
</build>

<modules>
Expand Down Expand Up @@ -152,9 +167,9 @@
</activation>
<properties>
<lombok.version>1.18.24</lombok.version>
<java-service.version>1.5.1</java-service.version>
<java-service.version>1.5.2</java-service.version>
<java-design.version>1.3.1</java-design.version>
<picocli.version>4.6.3</picocli.version>
<picocli.version>4.7.0</picocli.version>
</properties>
<dependencyManagement>
<dependencies>
Expand Down Expand Up @@ -326,7 +341,7 @@
<dependency>
<groupId>org.kordamp.maven</groupId>
<artifactId>pomchecker-enforcer-rules</artifactId>
<version>1.3.0</version>
<version>1.4.0</version>
</dependency>
<dependency>
<groupId>org.codehaus.mojo</groupId>
Expand All @@ -342,18 +357,30 @@
</goals>
<configuration>
<rules>
<!-- Built-In Rules -->
<banDuplicatePomDependencyVersions/>
<dependencyConvergence/>
<reactorModuleConvergence/>
<requireMavenVersion>
<version>3.6.0</version>
</requireMavenVersion>
<DependencyConvergence/>
<requireNoRepositories>
<allowSnapshotRepositories>true</allowSnapshotRepositories>
</requireNoRepositories>
<!-- <requirePluginVersions/>-->
<requireReleaseDeps>
<onlyWhenRelease>true</onlyWhenRelease>
</requireReleaseDeps>
<CheckMavenCentral
<requireUpperBoundDeps/>
<!-- pomchecker-enforcer-rules -->
<checkMavenCentral
implementation="org.kordamp.maven.enforcer.checker.CheckMavenCentral">
<release>false</release>
<strict>false</strict>
</CheckMavenCentral>
</checkMavenCentral>
<!-- extra-enforcer-rules -->
<banCircularDependencies/>
<banDuplicateClasses/>
<enforceBytecodeVersion>
<maxJdkVersion>8</maxJdkVersion>
<ignoredScopes>
Expand Down Expand Up @@ -382,7 +409,7 @@
<plugin>
<groupId>org.gaul</groupId>
<artifactId>modernizer-maven-plugin</artifactId>
<version>2.4.0</version>
<version>2.5.0</version>
<configuration>
<javaVersion>1.8</javaVersion>
</configuration>
Expand Down

0 comments on commit 3e95c92

Please sign in to comment.