Skip to content

Commit

Permalink
FORGE-1279: Added null check to avoid possible NPE
Browse files Browse the repository at this point in the history
  • Loading branch information
gastaldi committed Oct 23, 2013
1 parent 0d8d154 commit cfd361f
Showing 1 changed file with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,16 @@ public void installFromProject(final DirectoryResource buildDir, final Dependenc
+ "] was not correctly marked as PROVIDED scope; this has been corrected.");
deps.addDirectDependency(DependencyBuilder.create(dependency).setScopeType(ScopeType.PROVIDED));
}
else if (dependency.getGroupId().equals("org.jboss.forge")
&& !providedDeps.contains(dependency.getArtifactId())
&& !ScopeType.TEST.equals(deps.getEffectiveDependency(dependency).getScopeTypeEnum()))
else if ("org.jboss.forge".equals(dependency.getGroupId())
&& !providedDeps.contains(dependency.getArtifactId()))
{
ShellMessages.warn(shell,
"Plugin has a dependency on internal Forge API [" + dependency
+ "] - this is not allowed and may cause failures.");
Dependency effectiveDependency = deps.getEffectiveDependency(dependency);
if (effectiveDependency != null && ScopeType.TEST != effectiveDependency.getScopeTypeEnum())
{
ShellMessages.warn(shell,
"Plugin has a dependency on internal Forge API [" + dependency
+ "] - this is not allowed and may cause failures.");
}
}
}

Expand All @@ -177,7 +180,8 @@ else if (dependency.getGroupId().equals("org.jboss.forge")
}
else
{
rootProject.getFacet(PackagingFacet.class).createBuilder().addArguments("clean", "install").runTests(false).build();
rootProject.getFacet(PackagingFacet.class).createBuilder().addArguments("clean", "install").runTests(false)
.build();
artifact = pluginProject.getFacet(PackagingFacet.class).getFinalArtifact();
}
// However, get only the necessary plugin artifact
Expand Down Expand Up @@ -355,12 +359,12 @@ private List<DependencyResource> getPluginDependencies(final Project project, No
{
DependencyFacet deps = project.getFacet(DependencyFacet.class);
List<DependencyResource> pluginDependencies = new ArrayList<DependencyResource>();

// Hack to invalidate the cached full project build result in the MavenCoreFacet
// Thie ensures that resolution of any unresolved dependencies in a multi-module project will be re-attempted.
// Thie ensures that resolution of any unresolved dependencies in a multi-module project will be re-attempted.
MavenCoreFacet mvn = project.getFacet(MavenCoreFacet.class);
mvn.setPOM(mvn.getPOM());

List<Dependency> effectiveDependenciesInScopes = deps.getEffectiveDependenciesInScopes(ScopeType.COMPILE,
ScopeType.RUNTIME);
for (Dependency d : effectiveDependenciesInScopes)
Expand Down

0 comments on commit cfd361f

Please sign in to comment.