diff --git a/pom.xml b/pom.xml
index 3782546..48f7513 100644
--- a/pom.xml
+++ b/pom.xml
@@ -86,6 +86,14 @@
contributor
+
+ JHeiner
+ Jeremy Heiner
+ https://github.com/JHeiner
+
+ contributor
+
+
@@ -203,6 +211,7 @@
**/README
**/LICENSE
.*
+ **/.keepgit
src/quality/**
src/it/resources/**
src/it/**/invoker.properties
@@ -332,6 +341,10 @@
false
${project.build.directory}/it
+
+ issues/*-pre/pom.xml
+ *-pre/pom.xml
+
*/pom.xml
issues/*/pom.xml
diff --git a/src/it/issues/issue-30-pre/pom.xml b/src/it/issues/issue-30-pre/pom.xml
new file mode 100644
index 0000000..835591c
--- /dev/null
+++ b/src/it/issues/issue-30-pre/pom.xml
@@ -0,0 +1,58 @@
+
+
+
+ 4.0.0
+
+ fr.brouillard.oss.it
+ issue-30-pre
+ 0
+
+
+ UTF-8
+
+
+ Build a jar file and install it without POM inside the repository
+
+
+
+
+ org.apache.maven.plugins
+ maven-install-plugin
+ 2.5.2
+
+
+ install-jar-without-pom
+ install
+
+ install-file
+
+
+ ${project.build.directory}/${project.build.finalName}.jar
+ fr.brouillard.oss.it
+ int-set-builder
+ 0.4
+ jar
+ false
+
+
+
+
+
+
+
diff --git a/src/it/issues/issue-30-pre/src/main/java/outside/IntSetBuilder.java b/src/it/issues/issue-30-pre/src/main/java/outside/IntSetBuilder.java
new file mode 100644
index 0000000..66d881e
--- /dev/null
+++ b/src/it/issues/issue-30-pre/src/main/java/outside/IntSetBuilder.java
@@ -0,0 +1,32 @@
+// @formatter:off
+/**
+ * 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.
+ */
+// @formatter:on
+
+package outside;
+
+public class IntSetBuilder
+ extends java.util.HashSet
+ implements java.util.function.IntConsumer
+{
+ public long accepted = 0;
+
+ public void accept( int i )
+ {
+ ++ accepted;
+ add( i );
+ }
+}
diff --git a/src/it/issues/issue-30/.mvn/extensions.xml b/src/it/issues/issue-30/.mvn/extensions.xml
new file mode 100644
index 0000000..0183989
--- /dev/null
+++ b/src/it/issues/issue-30/.mvn/extensions.xml
@@ -0,0 +1,25 @@
+
+
+
+ @project.groupId@
+ @project.artifactId@
+ @project.version@
+
+
\ No newline at end of file
diff --git a/src/it/issues/issue-30/invoker.properties b/src/it/issues/issue-30/invoker.properties
new file mode 100644
index 0000000..1ed4b1e
--- /dev/null
+++ b/src/it/issues/issue-30/invoker.properties
@@ -0,0 +1 @@
+invoker.goals = install project-info-reports:dependencies
\ No newline at end of file
diff --git a/src/it/issues/issue-30/pom.xml b/src/it/issues/issue-30/pom.xml
new file mode 100644
index 0000000..86f4ec6
--- /dev/null
+++ b/src/it/issues/issue-30/pom.xml
@@ -0,0 +1,39 @@
+
+
+
+ 4.0.0
+
+ fr.brouillard.oss.it
+ issue-30
+ 0
+
+ NullPointerException in JGitverModelProcessor.provisionModel when POM unavailable.
+
+
+ UTF-8
+
+
+
+
+ fr.brouillard.oss.it
+ int-set-builder
+ 0.4
+
+
+
diff --git a/src/it/issues/issue-30/prebuild.groovy b/src/it/issues/issue-30/prebuild.groovy
new file mode 100644
index 0000000..80c91e1
--- /dev/null
+++ b/src/it/issues/issue-30/prebuild.groovy
@@ -0,0 +1,53 @@
+/**
+ * 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.
+ */
+
+def log = new PrintWriter( new File(basedir, "prebuild.log").newWriter("UTF-8"), true )
+log.println( "Prebuild started at: " + new Date() + " in: " + basedir )
+
+[
+
+ "git --version",
+ "rm -rf .git",
+ "git init",
+ "git config user.name nobody",
+ "git config user.email nobody@nowhere.com",
+ "echo A > content",
+ "git add .",
+ "git commit --message=initial_commit",
+ "git tag -a 1.0.0 --message=release_1.0.0",
+ "echo B > content",
+ "git add -u",
+ "git commit --message=added_B_data",
+ "git log --graph --oneline"
+
+].each{ command ->
+
+ def proc = command.execute(null, basedir)
+ def sout = new StringBuilder(), serr = new StringBuilder()
+ proc.waitForProcessOutput(sout, serr)
+
+ log.println( "cmd: " + command )
+ log.println( "out:" ) ; log.println( sout.toString().trim() )
+ log.println( "err:" ) ; log.println( serr.toString().trim() )
+ log.println( "ret: " + proc.exitValue() )
+
+ assert proc.exitValue() == 0
+
+}
+
+log.println( "Prebuild completed at: " + new Date() )
+log.close()
+return true
diff --git a/src/it/issues/issue-30/src/main/java/inside/Main.java b/src/it/issues/issue-30/src/main/java/inside/Main.java
new file mode 100644
index 0000000..e649b64
--- /dev/null
+++ b/src/it/issues/issue-30/src/main/java/inside/Main.java
@@ -0,0 +1,39 @@
+// @formatter:off
+/**
+ * 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.
+ */
+// @formatter:on
+
+package inside;
+
+import outside.IntSetBuilder;
+
+public class Main
+{
+ public static double codePointsOverLength( String value )
+ {
+ IntSetBuilder isb = new IntSetBuilder();
+ value.codePoints().forEach( isb );
+ return isb.size() / (double) isb.accepted;
+ }
+
+ public static void main( String[] args )
+ {
+ String value = args.length > 0
+ ? String.join( " ", java.util.Arrays.asList(args) )
+ : "The quick brown fox jumps over the lazy dog.";
+ System.out.println( codePointsOverLength(value) + " " + value );
+ }
+}
diff --git a/src/it/issues/issue-30/verify.groovy b/src/it/issues/issue-30/verify.groovy
new file mode 100644
index 0000000..42f25e4
--- /dev/null
+++ b/src/it/issues/issue-30/verify.groovy
@@ -0,0 +1,54 @@
+/**
+ * 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.
+ */
+
+def log = new PrintWriter( new File(basedir, "verify.log").newWriter("UTF-8"), true )
+log.println( "Verify started at: " + new Date() + " in: " + basedir )
+
+[
+ "rm -rf .git"
+].each{ command ->
+
+ def proc = command.execute(null, basedir)
+ def sout = new StringBuilder(), serr = new StringBuilder()
+ proc.waitForProcessOutput(sout, serr)
+
+ log.println( "cmd: " + command )
+ log.println( "out:" ) ; log.println( sout.toString().trim() )
+ log.println( "err:" ) ; log.println( serr.toString().trim() )
+ log.println( "ret: " + proc.exitValue() )
+
+ assert proc.exitValue() == 0
+
+}
+
+def buildLog = new File(basedir, "build.log").readLines()
+
+// Check the version was used by the plugin execution
+def versionChanges = buildLog.findAll { it =~ /fr.brouillard.oss.it::issue-30::0 -> 1.0.1-SNAPSHOT/ }
+log.println( "versionChanges: " + versionChanges )
+assert 0 < versionChanges.size()
+
+// And check that the produced artifact was installed with the good version
+File installedPomFile = new File(localRepositoryPath, "fr/brouillard/oss/it/issue-30/1.0.1-SNAPSHOT/issue-30-1.0.1-SNAPSHOT.pom")
+log.println( "installedPomFile: " + installedPomFile.isFile() + " " + installedPomFile )
+assert installedPomFile.isFile()
+def installedPomFileVersion = installedPomFile.readLines().findAll { it =~ /1.0.1-SNAPSHOT<\/version>/ }
+log.println( "installedPomFileVersion: " + installedPomFileVersion )
+assert 1 == installedPomFileVersion.size()
+
+log.println( "Verify completed at: " + new Date() )
+log.close()
+return true
diff --git a/src/main/java/fr/brouillard/oss/jgitver/JGitverModelProcessor.java b/src/main/java/fr/brouillard/oss/jgitver/JGitverModelProcessor.java
index 235144d..00c2abd 100644
--- a/src/main/java/fr/brouillard/oss/jgitver/JGitverModelProcessor.java
+++ b/src/main/java/fr/brouillard/oss/jgitver/JGitverModelProcessor.java
@@ -124,12 +124,22 @@ private Model provisionModel(Model model, Map options) throws IOExcep
throw new IOException("cannot build a Model object using jgitver", ex);
}
- if (Objects.isNull(options.get(ModelProcessor.SOURCE))) {
+ Source source = (Source) options.get(ModelProcessor.SOURCE);
+ //logger.debug( "JGitverModelProcessor.provisionModel source="+source );
+ if (source == null) {
return model;
}
- Source source = Source.class.cast(options.get(ModelProcessor.SOURCE));
- File relativePath = new File(source.getLocation()).getParentFile().getCanonicalFile();
+ File location = new File(source.getLocation());
+ //logger.debug( "JGitverModelProcessor.provisionModel location="+location );
+ if (!location.isFile()) {
+ // their JavaDoc says Source.getLocation "could be a local file path, a URI or just an empty string."
+ // if it doesn't resolve to a file then calling .getParentFile will throw an exception,
+ // but if it doesn't resolve to a file then it isn't under getMultiModuleProjectDirectory,
+ return model; // therefore the model shouldn't be modified.
+ }
+
+ File relativePath = location.getParentFile().getCanonicalFile();
if (StringUtils.containsIgnoreCase(relativePath.getCanonicalPath(),
workingConfiguration.getMultiModuleProjectDirectory().getCanonicalPath())) {
@@ -245,4 +255,4 @@ private Model provisionModel(Model model, Map options) throws IOExcep
return model;
}
-}
\ No newline at end of file
+}