From 24ea35934dd10f8ca32dea45add6c08957bb4f7c Mon Sep 17 00:00:00 2001 From: Prashant Patil Date: Wed, 25 May 2022 11:51:12 -0500 Subject: [PATCH] * Added optional `gitDirectory` parameter so that user can provide GIT directory path instead of current directory * Updated various library versions --- pom.xml | 69 ++++++++++--------- .../mavenplugins/gitlog/GenerateMojo.java | 8 ++- .../mavenplugins/gitlog/GenerateReport.java | 4 +- 3 files changed, 47 insertions(+), 34 deletions(-) diff --git a/pom.xml b/pom.xml index 13a2bdc..51f3a18 100644 --- a/pom.xml +++ b/pom.xml @@ -60,55 +60,62 @@ org.apache.maven maven-plugin-api - 2.2.1 + 3.8.5 org.apache.maven.plugin-tools maven-plugin-annotations - 3.3 - - - com.madgag - org.eclipse.jgit - 2.99.99.2.0-UNOFFICIAL-ROBERTO-RELEASE - - - jsch - com.jcraft - - + 3.6.4 + + + org.eclipse.jgit + org.eclipse.jgit + 6.1.0.202203080745-r + + + jsch + com.jcraft + + + + + org.hamcrest + hamcrest + 2.2 + test + org.apache.commons commons-lang3 - 3.0.1 + 3.12.0 junit junit - 4.13.1 + 4.13.2 test org.hamcrest hamcrest-core - 1.3 + 2.2 test org.apache.maven.reporting maven-reporting-api - 3.0 + 3.1.0 org.apache.maven.doxia doxia-sink-api - 1.0 + 1.11.1 xml-apis xml-apis - 1.3.04 + 2.0.2 @@ -131,7 +138,7 @@ maven-plugin-plugin - 3.4 + 3.6.4 default-descriptor @@ -153,15 +160,15 @@ maven-compiler-plugin - 3.1 + 3.10.1 - 1.6 - 1.6 + 11 + 11 maven-dependency-plugin - 2.9 + 3.3.0 analyze @@ -178,7 +185,7 @@ maven-site-plugin - 3.4 + 3.11.0 org.apache.maven.doxia @@ -200,11 +207,11 @@ maven-surefire-report-plugin - 2.18.1 + 2.22.2 maven-project-info-reports-plugin - 2.8 + 3.1.2 @@ -237,7 +244,7 @@ maven-source-plugin - 2.4 + 3.2.1 attach-sources @@ -249,7 +256,7 @@ maven-javadoc-plugin - 2.10.1 + 3.3.2 attach-javadocs @@ -262,7 +269,7 @@ org.apache.maven.plugins maven-gpg-plugin - 1.6 + 3.0.1 sign-artifacts @@ -276,7 +283,7 @@ com.github.github site-maven-plugin - 0.11 + 0.12 site diff --git a/src/main/java/com/github/danielflower/mavenplugins/gitlog/GenerateMojo.java b/src/main/java/com/github/danielflower/mavenplugins/gitlog/GenerateMojo.java index a288c21..d6258e4 100644 --- a/src/main/java/com/github/danielflower/mavenplugins/gitlog/GenerateMojo.java +++ b/src/main/java/com/github/danielflower/mavenplugins/gitlog/GenerateMojo.java @@ -41,6 +41,11 @@ public class GenerateMojo extends AbstractMojo { @Parameter(defaultValue = "${project.name} v${project.version} git changelog") private String reportTitle; + /** + * The GIT directory to scan. Defaults to the project base directory. + */ + @Parameter() + protected File gitDirectory; /** * If true, then a plain text changelog will be generated. @@ -330,7 +335,8 @@ public void execute() throws MojoExecutionException, MojoFailureException { Repository repository; try { - repository = generator.openRepository(); + getLog().info("Reading GIT repository at " + (gitDirectory != null ? gitDirectory : System.getProperty("user.dir"))); + repository = generator.openRepository(gitDirectory); } catch (IOException e) { getLog().warn("Error opening git repository. Is this Maven project hosted in a git repository? " + "No changelog will be generated.", e); diff --git a/src/main/java/com/github/danielflower/mavenplugins/gitlog/GenerateReport.java b/src/main/java/com/github/danielflower/mavenplugins/gitlog/GenerateReport.java index 6fa151c..ac1f52c 100644 --- a/src/main/java/com/github/danielflower/mavenplugins/gitlog/GenerateReport.java +++ b/src/main/java/com/github/danielflower/mavenplugins/gitlog/GenerateReport.java @@ -1,5 +1,6 @@ package com.github.danielflower.mavenplugins.gitlog; +import org.apache.maven.doxia.sink.Sink; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; @@ -8,7 +9,6 @@ import java.util.Locale; import org.apache.maven.reporting.MavenReport; import org.apache.maven.reporting.MavenReportException; -import org.codehaus.doxia.sink.Sink; /** * Goal which generates a changelog based on commits made to the current git repo. @@ -31,7 +31,7 @@ public void generate(Sink sink, Locale locale) } } - @Override + @Override public String getOutputName() { return "gitlog";