@Test public void testGetArtifactFileFromProjectDependenciesWithEmptySet() throws Exception { MyMojo mojo = new MyMojo(); mojo.project = mock(MavenProject.class); when(mojo.project.getArtifacts()).thenReturn(Collections.<Artifact>emptySet()); assertThat(DependencyFinder.getArtifactFileFromProjectDependencies(mojo, "any", "jar")) .isNull(); }
public static File getArtifactFileFromProjectDependencies(AbstractWisdomMojo mojo, String artifactId, String type) { Preconditions.checkNotNull(mojo); Preconditions.checkNotNull(artifactId); Preconditions.checkNotNull(type); for (Artifact artifact : mojo.project.getArtifacts()) { if (artifact.getArtifactId().equals(artifactId) && artifact.getType().equals(type)) { return artifact.getFile(); } } return null; }
DependencyFinder { public static File getArtifactFileFromProjectDependencies(AbstractWisdomMojo mojo, String artifactId, String type) { Preconditions.checkNotNull(mojo); Preconditions.checkNotNull(artifactId); Preconditions.checkNotNull(type); for (Artifact artifact : mojo.project.getArtifacts()) { if (artifact.getArtifactId().equals(artifactId) && artifact.getType().equals(type)) { return artifact.getFile(); } } return null; } }
DependencyFinder { public static File getArtifactFileFromProjectDependencies(AbstractWisdomMojo mojo, String artifactId, String type) { Preconditions.checkNotNull(mojo); Preconditions.checkNotNull(artifactId); Preconditions.checkNotNull(type); for (Artifact artifact : mojo.project.getArtifacts()) { if (artifact.getArtifactId().equals(artifactId) && artifact.getType().equals(type)) { return artifact.getFile(); } } return null; } private  DependencyFinder(); }
DependencyFinder { public static File getArtifactFileFromProjectDependencies(AbstractWisdomMojo mojo, String artifactId, String type) { Preconditions.checkNotNull(mojo); Preconditions.checkNotNull(artifactId); Preconditions.checkNotNull(type); for (Artifact artifact : mojo.project.getArtifacts()) { if (artifact.getArtifactId().equals(artifactId) && artifact.getType().equals(type)) { return artifact.getFile(); } } return null; } private  DependencyFinder(); static File getArtifactFileFromPluginDependencies(AbstractWisdomMojo mojo, String artifactId, String type); static File getArtifactFileFromProjectDependencies(AbstractWisdomMojo mojo, String artifactId,
                                                              String type); static File getArtifactFile(AbstractWisdomMojo mojo, String artifactId, String type); static File resolve(AbstractWisdomMojo mojo, String groupId, String artifactId, String version,
                               String type, String classifier); static File resolve(AbstractWisdomMojo mojo, String coords); }
DependencyFinder { public static File getArtifactFileFromProjectDependencies(AbstractWisdomMojo mojo, String artifactId, String type) { Preconditions.checkNotNull(mojo); Preconditions.checkNotNull(artifactId); Preconditions.checkNotNull(type); for (Artifact artifact : mojo.project.getArtifacts()) { if (artifact.getArtifactId().equals(artifactId) && artifact.getType().equals(type)) { return artifact.getFile(); } } return null; } private  DependencyFinder(); static File getArtifactFileFromPluginDependencies(AbstractWisdomMojo mojo, String artifactId, String type); static File getArtifactFileFromProjectDependencies(AbstractWisdomMojo mojo, String artifactId,
                                                              String type); static File getArtifactFile(AbstractWisdomMojo mojo, String artifactId, String type); static File resolve(AbstractWisdomMojo mojo, String groupId, String artifactId, String version,
                               String type, String classifier); static File resolve(AbstractWisdomMojo mojo, String coords);  }