SLING-4880 Fix potential NPEs when resolving artifacts

git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1690839 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/java/org/apache/sling/maven/slingstart/DependencyLifecycleParticipant.java b/src/main/java/org/apache/sling/maven/slingstart/DependencyLifecycleParticipant.java
index 0e58a18..91840ae 100644
--- a/src/main/java/org/apache/sling/maven/slingstart/DependencyLifecycleParticipant.java
+++ b/src/main/java/org/apache/sling/maven/slingstart/DependencyLifecycleParticipant.java
@@ -148,10 +148,10 @@
         
         // prepare resolver options
         ResolverOptions resolverOptions = new ResolverOptions();
-        if (nodeBooleanValue(info.plugin, "usePomVariables", false)) {
+        if (nodeBooleanValue(info.plugin, "usePomVariables", false) && info.project != null) {
             resolverOptions.variableResolver(new PomVariableResolver(info.project));
         }
-        if (nodeBooleanValue(info.plugin, "usePomDependencies", false)) {
+        if (nodeBooleanValue(info.plugin, "usePomDependencies", false) && info.project != null) {
             resolverOptions.artifactVersionResolver(new PomArtifactVersionResolver(info.project));
         }
 
diff --git a/src/main/java/org/apache/sling/maven/slingstart/PomArtifactVersionResolver.java b/src/main/java/org/apache/sling/maven/slingstart/PomArtifactVersionResolver.java
index 0208310..3c0a6d5 100644
--- a/src/main/java/org/apache/sling/maven/slingstart/PomArtifactVersionResolver.java
+++ b/src/main/java/org/apache/sling/maven/slingstart/PomArtifactVersionResolver.java
@@ -47,17 +47,21 @@
         if (version != null) {
             return version;
         }
-        version = findVersion(project.getDependencyManagement().getDependencies(), artifact);
-        if (version != null) {
-            return version;
+        if (project.getDependencyManagement() != null) {
+            version = findVersion(project.getDependencyManagement().getDependencies(), artifact);
+            if (version != null) {
+                return version;
+            }
         }
         return null;
     }
     
     private String findVersion(List<Dependency> dependencies, Artifact artifact) {
-        for (Dependency dependency : project.getDependencyManagement().getDependencies()) {
-            if (artifactEquals(dependency, artifact)) {
-                return dependency.getVersion();
+        if (dependencies != null) {
+            for (Dependency dependency : dependencies) {
+                if (artifactEquals(dependency, artifact)) {
+                    return dependency.getVersion();
+                }
             }
         }
         return null;