diff --git a/.gitignore b/.gitignore
index 06d2283..6e6d5ff 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,7 @@
-.idea
-**/pom.xml.new-version
\ No newline at end of file
+.idea
+**/pom.xml.new-version
+.project
+.classpath
+.settings/
+target/
+**/.checkstyle
\ No newline at end of file
diff --git a/README.md b/README.md
index dd4413d..ffe25a4 100644
--- a/README.md
+++ b/README.md
@@ -67,6 +67,104 @@ Or how about a short git hash?
mvn install -Dexternal.version-qualifier=$(git rev-parse --short HEAD)
```
+Configuration & parameters
+-----
+
+```xml
+
+
+ org.apache.maven.plugins
+ maven-external-version-plugin
+ X.Y.Z
+ true
+
+
+ true/false
+ true/false
+
+
+
+```
+
+- `strategy#hint` key defining which strategy implementation will be used, one of
+ - file: read the version from the first line of a given file
+ - script: version is given by the first line of the output execution of a given command
+ - sysprop: allows to define project version & qualifier from system properties
+
+## Strategy : file
+
+This strategy reads the first line of a given file to extract the version to use.
+
+### Usage
+
+```xml
+
+
+ org.apache.maven.plugins
+ maven-external-version-plugin
+ X.Y.Z
+ true
+
+
+ SOME_FILE
+
+
+
+
+```
+
+### Parameters
+
+- `versionFilePath`: denotes the file which first line will be read to extract the version from. Can be a fully qualified path or a path relative to the project directory. The parameter is optional, it defaults to `VERSION`, meaning that if not provided, a file called `VERSION` will be read from the project root.
+
+## Strategy : script
+
+This strategy allows to execute a given command ; the first line of stdout output will be used as version.
+
+### Usage
+
+```xml
+
+
+ org.apache.maven.plugins
+ maven-external-version-plugin
+ X.Y.Z
+ true
+
+
+
+
+
+
+
+```
+
+### Parameters
+
+- `script`: a command to execute. The parameter is optional and defaults to `./version.sh`, meaning that if not provided a file called `version.sh` in the project root will be executed.
+
+## Strategy : sysprop
+
+This strategy uses 2 system properties to define the new project version:
+
+- `external.version`: the main version to use. If omitted, then it defaults to the current `project.version`.
+- `external.version-qualifier`: an optional qualifier that will be appended to the given version
+
+### Usage
+
+``` xml
+
+
+ org.apache.maven.plugins
+ maven-external-version-plugin
+ X.Y.Z
+ true
+
+
+
+
+
+```
TODO:
-----
diff --git a/external-version-api/pom.xml b/external-version-api/pom.xml
index 3fbe4b9..cba9d36 100644
--- a/external-version-api/pom.xml
+++ b/external-version-api/pom.xml
@@ -24,11 +24,11 @@
org.apache.maven.version
maven-external-version
- 0.1.0-SNAPSHOT
+ 0.1.1-SNAPSHOT
external-version-api
- 0.1.0-SNAPSHOT
+ 0.1.1-SNAPSHOT
diff --git a/external-version-strategies/pom.xml b/external-version-strategies/pom.xml
index 336e05b..10e83dd 100644
--- a/external-version-strategies/pom.xml
+++ b/external-version-strategies/pom.xml
@@ -25,18 +25,18 @@
org.apache.maven.version
maven-external-version
- 0.1.0-SNAPSHOT
+ 0.1.1-SNAPSHOT
external-version-strategies
- 0.1.0-SNAPSHOT
+ 0.1.1-SNAPSHOT
org.apache.maven.version
external-version-api
- 0.1.0-SNAPSHOT
+ 0.1.1-SNAPSHOT
diff --git a/maven-external-version-plugin/pom.xml b/maven-external-version-plugin/pom.xml
index 2ec648c..fcff324 100644
--- a/maven-external-version-plugin/pom.xml
+++ b/maven-external-version-plugin/pom.xml
@@ -25,12 +25,12 @@
org.apache.maven.version
maven-external-version
- 0.1.0-SNAPSHOT
+ 0.1.1-SNAPSHOT
org.apache.maven.plugins
maven-external-version-plugin
- 0.1.0-SNAPSHOT
+ 0.1.1-SNAPSHOT
maven-plugin
@@ -61,12 +61,12 @@
org.apache.maven.version
external-version-api
- 0.1.0-SNAPSHOT
+ 0.1.1-SNAPSHOT
org.apache.maven.version
external-version-strategies
- 0.1.0-SNAPSHOT
+ 0.1.1-SNAPSHOT
diff --git a/maven-external-version-plugin/src/it/multi-module/pom.xml b/maven-external-version-plugin/src/it/multi-module/pom.xml
index ae37cb9..4376a41 100644
--- a/maven-external-version-plugin/src/it/multi-module/pom.xml
+++ b/maven-external-version-plugin/src/it/multi-module/pom.xml
@@ -26,7 +26,7 @@
org.apache.maven.plugins
maven-external-version-plugin
- 0.1.0-SNAPSHOT
+ 0.1.1-SNAPSHOT
true
@@ -36,6 +36,8 @@
+ true
+ true
diff --git a/maven-external-version-plugin/src/it/simple-module/pom.xml b/maven-external-version-plugin/src/it/simple-module/pom.xml
index 162676c..b7d3c10 100644
--- a/maven-external-version-plugin/src/it/simple-module/pom.xml
+++ b/maven-external-version-plugin/src/it/simple-module/pom.xml
@@ -54,7 +54,7 @@ under the License.
org.apache.maven.plugins
maven-external-version-plugin
- 0.1.0-SNAPSHOT
+ 0.1.1-SNAPSHOT
true
diff --git a/maven-external-version-plugin/src/main/java/org/apache/maven/version/ExternalVersionExtension.java b/maven-external-version-plugin/src/main/java/org/apache/maven/version/ExternalVersionExtension.java
index 6e28cd8..f528342 100644
--- a/maven-external-version-plugin/src/main/java/org/apache/maven/version/ExternalVersionExtension.java
+++ b/maven-external-version-plugin/src/main/java/org/apache/maven/version/ExternalVersionExtension.java
@@ -214,13 +214,17 @@ private void createNewVersionPom( MavenProject mavenProject, Map
model.getParent().setVersion( newVersionForParent );
}
}
-
- File newPom = new File( mavenProject.getBasedir(), "pom.xml.new-version" );
+
+ Plugin plugin = mavenProject.getPlugin( "org.apache.maven.plugins:maven-external-version-plugin" );
+ // now we are going to wedge in the config
+ Xpp3Dom pluginConfiguration = (Xpp3Dom) plugin.getConfiguration();
+
+ File newPom = createFileFromConfiguration( mavenProject, pluginConfiguration );
+ logger.debug( ExternalVersionExtension.class.getSimpleName() + ": using new pom file => " + newPom );
fileWriter = new FileWriter( newPom );
new MavenXpp3Writer().write( fileWriter, model );
mavenProject.setFile( newPom );
-
}
finally
{
@@ -231,6 +235,50 @@ private void createNewVersionPom( MavenProject mavenProject, Map
}
+ private File createFileFromConfiguration( MavenProject mavenProject, Xpp3Dom pluginConfig ) throws IOException
+ {
+ boolean deleteTemporaryFile = shouldDeleteTemporaryFile( pluginConfig );
+ boolean generateTemporaryFile = shouldGenerateTemporaryFile( pluginConfig );
+
+ // let's keep the default file as a default
+ File f = new File( mavenProject.getBasedir(), "pom.xml.new-version" );
+
+ if ( generateTemporaryFile )
+ {
+ f = File.createTempFile( "pom", ".maven-external-version" );
+ }
+
+ if ( deleteTemporaryFile )
+ {
+ f.deleteOnExit();
+ }
+ return f;
+ }
+
+ /*
+ * Looks for generateTemporaryFile child configuration node.
+ * If not present then no deletion occurs, otherwise return true if value is true, false otherwise
+ */
+ private boolean shouldGenerateTemporaryFile( Xpp3Dom pluginConfiguration )
+ {
+ return evaluateBooleanNodeInConfiguration( pluginConfiguration, "generateTemporaryFile" );
+ }
+
+ /*
+ * Looks for deleteTemporaryFile child configuration node.
+ * If not present then no deletion occurs, otherwise return true if value is true, false otherwise
+ */
+ private boolean shouldDeleteTemporaryFile( Xpp3Dom pluginConfiguration )
+ {
+ return evaluateBooleanNodeInConfiguration( pluginConfiguration, "deleteTemporaryFile" );
+ }
+
+ private boolean evaluateBooleanNodeInConfiguration( Xpp3Dom pluginConfiguration, String nodeName )
+ {
+ Xpp3Dom n = pluginConfiguration.getChild( nodeName );
+ return n != null && Boolean.parseBoolean( n.getValue() );
+ }
+
private String getNewVersion( ExternalVersionStrategy strategy, MavenProject mavenProject )
throws ExternalVersionException
{
diff --git a/maven-external-version-plugin/src/main/java/org/apache/maven/version/ExternalVersionMojo.java b/maven-external-version-plugin/src/main/java/org/apache/maven/version/ExternalVersionMojo.java
index 07bfc66..d2faad9 100644
--- a/maven-external-version-plugin/src/main/java/org/apache/maven/version/ExternalVersionMojo.java
+++ b/maven-external-version-plugin/src/main/java/org/apache/maven/version/ExternalVersionMojo.java
@@ -42,6 +42,12 @@ public class ExternalVersionMojo
@Parameter( property = "strategy", required = true )
private String strategy;
+
+ @Parameter( property = "external-version.deleteTemporaryFile" , defaultValue = "false" )
+ private Boolean deleteTemporaryFile;
+
+ @Parameter( property = "external-version.generateTemporaryFile" , defaultValue = "false" )
+ private Boolean generateTemporaryFile;
@Override
public void execute()
diff --git a/pom.xml b/pom.xml
index 471c3d0..fa1d1dc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -30,7 +30,7 @@
org.apache.maven.version
maven-external-version
- 0.1.0-SNAPSHOT
+ 0.1.1-SNAPSHOT
pom
@@ -71,6 +71,7 @@
+ .checkstyle
DEPENDENCIES
**/src/it/**
README.md