diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..08803c0
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+.settings/
+target/
+.classpath
+.project
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..e832b1d
--- /dev/null
+++ b/README.md
@@ -0,0 +1,40 @@
+# jgitver-maven-plugin
+
+## Example
+
+```
+rm -rf /d/demo-jgitver-maven-plugin
+mkdir /d/demo-jgitver-maven-plugin
+cd /d/demo-jgitver-maven-plugin
+git init
+cat > pom.xml << EOF
+
+ 4.0.0
+ fr.brouillard.oss.demo
+ demo-demo-jgitver-maven-plugin
+ 0
+ pom
+
+
+
+ fr.brouillard.oss
+ jgitver-maven-plugin
+ 0.0.1-SNAPSHOT
+
+
+
+
+EOF
+echo A > content
+git add pom.xml
+git add content
+git commit -m "initial commit"
+echo B > content && git add -u && git commit -m "added B data"
+git tag 1.0 -m "release 1.0"
+git tag 2.0
+echo C > content && git add -u && git commit -m "added C data"
+git checkout -b cool-feature
+echo D > content && git add -u && git commit -m "added D data"
+git checkout master
+echo E > content && git add -u && git commit -m "added E data"
+```
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..bd6201d
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,340 @@
+
+
+ 4.0.0
+
+ fr.brouillard.oss
+ jgitver-maven-plugin
+ 0.0.1-SNAPSHOT
+ maven-plugin
+
+ jgitver Maven Plugin
+ standalone maven plugin to automatically define versions using jgitver
+
+ http://oss.brouillard.fr/jgitver-maven-plugin
+
+
+ Matthieu Brouillard
+ http://oss.brouillard.fr
+
+ 2016
+
+
+
+ Apache License, Version 2.0
+ http://www.apache.org/licenses/LICENSE-2.0.txt
+ repo
+
+
+
+
+ scm:git:https://github.com/jgitver/jgitver-maven-plugin.git
+ scm:git:https://github.com/jgitver/jgitver-maven-plugin.git
+ http://oss.brouillard.fr/projects/jgitver-maven-plugin/
+ HEAD
+
+
+
+ GitHub
+ https://github.com/jgitver/jgitver-maven-plugin/issues
+
+
+
+ 1.8
+ 1.8
+ UTF-8
+
+
+
+
+ McFoggy
+ Matthieu Brouillard
+ Europe/Paris
+ http://blog.matthieu.brouillard.fr
+
+ project creator
+
+
+
+
+
+
+ org.apache.maven
+ maven-plugin-api
+ 2.0
+
+
+ org.apache.maven.plugin-tools
+ maven-plugin-annotations
+ 3.2
+ provided
+
+
+ org.codehaus.plexus
+ plexus-utils
+ 3.0.8
+
+
+ org.apache.maven
+ maven-core
+ 3.2.5
+ provided
+
+
+ org.codehaus.plexus
+ plexus-component-annotations
+ 1.5.5
+ provided
+
+
+ fr.brouillard.oss
+ jgitver
+ 0.0.1
+
+
+ junit
+ junit
+ 4.8.2
+ test
+
+
+
+
+
+
+ org.codehaus.plexus
+ plexus-component-metadata
+ 1.5.5
+
+
+
+ generate-metadata
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-plugin-plugin
+ 3.4
+
+ jgitver-maven-plugin
+
+
+
+ mojo-descriptor
+
+ descriptor
+
+ process-classes
+
+
+ help-goal
+
+ helpmojo
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+ 2.3.2
+
+
+
+ true
+ true
+
+
+ ${git.revision}
+
+
+
+
+
+ com.mycila
+ license-maven-plugin
+ 2.11
+
+ com/mycila/maven/plugin/license/templates/APACHE-2.txt
+
+ Matthieu Brouillard [http://oss.brouillard.fr/jgitver-maven-plugin]
+ matthieu@brouillard.fr
+
+
+ **/README
+ **/LICENSE
+ .*
+ src/quality/**
+ src/it/resources/**
+ src/test/resources/**
+ src/main/resources/**
+
+
+
+
+ validate
+
+ check
+
+
+
+
+
+ ru.concerteza.buildnumber
+ maven-jgit-buildnumber-plugin
+ 1.2.9
+
+
+ git-buildnumber
+
+ extract-buildnumber
+
+ prepare-package
+
+
+
+
+ org.apache.maven.plugins
+ maven-checkstyle-plugin
+ 2.17
+
+
+ com.puppycrawl.tools
+ checkstyle
+ 6.17
+
+
+
+
+ validate
+ validate
+
+ ${project.baseUri}/src/quality/checkstyle/checks.xml
+ checkstyle.suppression.file=${project.baseUri}/src/quality/checkstyle/suppressions.xml
+ UTF-8
+ true
+ true
+ false
+ true
+
+
+
+ check
+
+
+
+
+
+
+
+
+
+ org.eclipse.m2e
+ lifecycle-mapping
+ 1.0.0
+
+
+
+
+
+ com.mycila
+ license-maven-plugin
+ [2.11,)
+
+ check
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-checkstyle-plugin
+ [2.17,)
+
+ check
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-plugin-plugin
+ [3.2,)
+
+ check
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ run-its
+
+
+
+
+ org.apache.maven.plugins
+ maven-invoker-plugin
+ 1.7
+
+ true
+ ${project.build.directory}/it
+
+ */pom.xml
+
+ verify
+ ${project.build.directory}/local-repo
+ src/it/settings.xml
+
+ clean
+ test-compile
+
+
+
+
+ integration-test
+
+ install
+ integration-test
+ verify
+
+
+
+
+
+
+
+
+
diff --git a/src/it/settings.xml b/src/it/settings.xml
new file mode 100644
index 0000000..062b452
--- /dev/null
+++ b/src/it/settings.xml
@@ -0,0 +1,52 @@
+
+
+
+
+
+ it-repo
+
+ true
+
+
+
+ local.central
+ @localRepositoryUrl@
+
+ true
+
+
+ true
+
+
+
+
+
+ local.central
+ @localRepositoryUrl@
+
+ true
+
+
+ true
+
+
+
+
+
+
diff --git a/src/it/simple-it/pom.xml b/src/it/simple-it/pom.xml
new file mode 100644
index 0000000..7be36f6
--- /dev/null
+++ b/src/it/simple-it/pom.xml
@@ -0,0 +1,42 @@
+
+
+
+ 4.0.0
+
+ fr.brouillard.oss.it
+ simple-it
+ 1.0-SNAPSHOT
+
+ A simple IT verifying the basic use case.
+
+
+ UTF-8
+
+
+
+
+
+ @project.groupId@
+ @project.artifactId@
+ @project.version@
+ true
+
+
+
+
diff --git a/src/it/simple-it/verify.groovy b/src/it/simple-it/verify.groovy
new file mode 100644
index 0000000..700147d
--- /dev/null
+++ b/src/it/simple-it/verify.groovy
@@ -0,0 +1,18 @@
+/**
+ * Copyright (C) 2016 Matthieu Brouillard [http://oss.brouillard.fr/jgitver-maven-plugin] (matthieu@brouillard.fr)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+File touchFile = new File( basedir, "target/touch.txt" );
+
+assert touchFile.isFile()
diff --git a/src/main/java/fr/brouillard/oss/jgitver/GAV.java b/src/main/java/fr/brouillard/oss/jgitver/GAV.java
new file mode 100644
index 0000000..ed43e2f
--- /dev/null
+++ b/src/main/java/fr/brouillard/oss/jgitver/GAV.java
@@ -0,0 +1,83 @@
+/**
+ * Copyright (C) 2016 Matthieu Brouillard [http://oss.brouillard.fr/jgitver-maven-plugin] (matthieu@brouillard.fr)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package fr.brouillard.oss.jgitver;
+
+import org.apache.maven.project.MavenProject;
+
+public class GAV {
+ private String groupId;
+ private String artifactId;
+ private String version;
+
+ public GAV(String groupId, String artifactId, String version) {
+ this.groupId = groupId;
+ this.artifactId = artifactId;
+ this.version = version;
+ }
+
+ public String getGroupId() {
+ return groupId;
+ }
+
+ public String getArtifactId() {
+ return artifactId;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public static GAV from(MavenProject project) {
+ return new GAV(project.getGroupId(), project.getArtifactId(), project.getVersion());
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((artifactId == null) ? 0 : artifactId.hashCode());
+ result = prime * result + ((groupId == null) ? 0 : groupId.hashCode());
+ result = prime * result + ((version == null) ? 0 : version.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ GAV other = (GAV) obj;
+ if (artifactId == null) {
+ if (other.artifactId != null)
+ return false;
+ } else if (!artifactId.equals(other.artifactId))
+ return false;
+ if (groupId == null) {
+ if (other.groupId != null)
+ return false;
+ } else if (!groupId.equals(other.groupId))
+ return false;
+ if (version == null) {
+ if (other.version != null)
+ return false;
+ } else if (!version.equals(other.version))
+ return false;
+ return true;
+ }
+}
diff --git a/src/main/java/fr/brouillard/oss/jgitver/JGitverExtension.java b/src/main/java/fr/brouillard/oss/jgitver/JGitverExtension.java
new file mode 100644
index 0000000..dd16ab4
--- /dev/null
+++ b/src/main/java/fr/brouillard/oss/jgitver/JGitverExtension.java
@@ -0,0 +1,61 @@
+/**
+ * Copyright (C) 2016 Matthieu Brouillard [http://oss.brouillard.fr/jgitver-maven-plugin] (matthieu@brouillard.fr)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package fr.brouillard.oss.jgitver;
+
+import org.apache.maven.AbstractMavenLifecycleParticipant;
+import org.apache.maven.MavenExecutionException;
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
+import org.codehaus.plexus.logging.Logger;
+
+@Component( role = AbstractMavenLifecycleParticipant.class, hint = "jgitver" )
+public class JGitverExtension extends AbstractMavenLifecycleParticipant {
+ @Requirement
+ private Logger logger;
+
+ @Override
+ public void afterProjectsRead(MavenSession session) throws MavenExecutionException {
+ logger.info("jgitver-maven-plugin is about to change project version");
+
+ MavenProject rootProject = session.getTopLevelProject();
+
+ String newVersion = calculateVersionForProject(rootProject);
+ rootProject.setVersion(newVersion);
+ }
+
+ private String calculateVersionForProject(MavenProject rootProject) {
+ GitVersionCalculator gvc = null;
+
+ try {
+ gvc = GitVersionCalculator.location(rootProject.getBasedir());
+ return gvc.setAutoIncrementPatch(true)
+ .setUseDistance(true)
+ .setUseGitCommitId(false)
+ .getVersion();
+ } finally {
+ if (gvc != null) {
+ try {
+ gvc.close();
+ } catch (Exception e) {
+ logger.warn("could not close jgitver delegate properly");
+ logger.debug("GitVersionCalculator#close() sent an error", e);
+ }
+ }
+ }
+ }
+}
diff --git a/src/main/java/fr/brouillard/oss/jgitver/JGitverMojo.java b/src/main/java/fr/brouillard/oss/jgitver/JGitverMojo.java
new file mode 100644
index 0000000..8c23040
--- /dev/null
+++ b/src/main/java/fr/brouillard/oss/jgitver/JGitverMojo.java
@@ -0,0 +1,31 @@
+/**
+ * Copyright (C) 2016 Matthieu Brouillard [http://oss.brouillard.fr/jgitver-maven-plugin] (matthieu@brouillard.fr)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package fr.brouillard.oss.jgitver;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+
+/**
+ * This plugin should only be used as an extension.
+ */
+@Mojo(name = "jgitver")
+public class JGitverMojo extends AbstractMojo {
+ public void execute() throws MojoExecutionException {
+ getLog().warn("the plugin [jgitver-maven-plugin] should not be executed alone, verify true is set on the plugin configuration");
+ }
+}
diff --git a/src/quality/checkstyle/checks.xml b/src/quality/checkstyle/checks.xml
new file mode 100644
index 0000000..0039434
--- /dev/null
+++ b/src/quality/checkstyle/checks.xml
@@ -0,0 +1,215 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/quality/checkstyle/suppressions.xml b/src/quality/checkstyle/suppressions.xml
new file mode 100644
index 0000000..dd5869c
--- /dev/null
+++ b/src/quality/checkstyle/suppressions.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
\ No newline at end of file