Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@
<artifactId>maven-plugin-api</artifactId>
<version>${maven-plugin-api.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>${maven-plugin-api.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
Expand Down
31 changes: 31 additions & 0 deletions src/main/java/pl/project13/maven/git/GitCommitIdMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.google.common.collect.Lists;
import com.google.common.io.Closeables;
import com.google.common.io.Files;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.MavenProject;
Expand Down Expand Up @@ -256,6 +257,19 @@ public class GitCommitIdMojo extends AbstractMojo {
@SuppressWarnings("UnusedDeclaration")
private boolean skip = false;

/**
* In a multi-module build, only run once. This probably won't "do the right thing" if your project has more than
* one git repository. If you use this with the option 'generateGitPropertiesFile', it will only generate (or update)
* the file in the directory where you started your build.
*
* The git.* variables are available in all modules.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe reword this: variables => maven properties?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, what ever maven calls these things: ${git.branch}, do you want me to
change the name and perform another commit ?

On Wed, Dec 3, 2014 at 9:51 AM, Konrad Malawski notifications@github.com
wrote:

In src/main/java/pl/project13/maven/git/GitCommitIdMojo.java:

@@ -257,6 +258,19 @@
private boolean skip = false;

/**

  • * In a multi-module build, only run once. This probably won't "do the right thing" if your project has more than
  • * one git repository. If you use this with the option 'generateGitPropertiesFile', it will only generate (or update)
  • * the file in the directory where you started your build.
  • * The git.* variables are available in all modules.

variables => maven properties?


Reply to this email directly or view it on GitHub
https://github.com/ktoso/maven-git-commit-id-plugin/pull/143/files#r21240166
.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeap, thanks!

*
* @parameter default-value="false"
* @since 2.1.12
*/
@SuppressWarnings("UnusedDeclaration")
private boolean runOnlyOnce = false;

/**
* Can be used to exclude certain properties from being emited into the resulting file.
* May be useful when you want to hide {@code git.remote.origin.url} (maybe because it contains your repo password?),
Expand All @@ -272,6 +286,16 @@ public class GitCommitIdMojo extends AbstractMojo {
@SuppressWarnings("UnusedDeclaration")
private List<String> excludeProperties = Collections.emptyList();

/**
* The Maven Session Object
*
* @parameter expression="${session}"
* @required
* @readonly
*/
@SuppressWarnings("UnusedDeclaration")
protected MavenSession session;

/**
* The properties we store our data in and then expose them
*/
Expand All @@ -291,6 +315,13 @@ public void execute() throws MojoExecutionException {
return;
}

if (runOnlyOnce) {
if (!session.getExecutionRootDirectory().equals(session.getCurrentProject().getBasedir().getAbsolutePath())) {
log("already run once, return");
return;
}
}

if (isPomProject(project) && skipPoms) {
log("isPomProject is true and skipPoms is true, return");
return;
Expand Down