@Test public void testGetArtifactFileFromPluginDependencies() throws Exception { MyMojo mojo = new MyMojo(); Artifact artifact1 = mock(Artifact.class); when(artifact1.getArtifactId()).thenReturn("artifact1"); when(artifact1.getType()).thenReturn("jar"); File kitten = new File("kitten"); File puppies = new File("puppies"); Artifact artifact2 = mock(Artifact.class); when(artifact2.getArtifactId()).thenReturn("artifact2"); when(artifact2.getType()).thenReturn("kitten"); when(artifact2.getFile()).thenReturn(kitten); Artifact artifact2a = mock(Artifact.class); when(artifact2a.getArtifactId()).thenReturn("artifact2"); when(artifact2a.getType()).thenReturn("puppies"); when(artifact2a.getFile()).thenReturn(puppies); Artifact artifact3 = mock(Artifact.class); when(artifact3.getArtifactId()).thenReturn("artifact3"); when(artifact3.getType()).thenReturn("putty"); mojo.pluginDependencies = ImmutableList.of( artifact1, artifact2, artifact2a, artifact3 ); assertThat(DependencyFinder.getArtifactFileFromPluginDependencies(mojo, "artifact2", "kitten")).isNotNull().isEqualTo(kitten); assertThat(DependencyFinder.getArtifactFileFromPluginDependencies(mojo, "artifact2", "puppies")).isNotNull().isEqualTo(puppies); assertThat(DependencyFinder.getArtifactFileFromPluginDependencies(mojo, "artifact4", "puppies")).isNull(); assertThat(DependencyFinder.getArtifactFileFromPluginDependencies(mojo, "artifact2", "bird")).isNull(); }
public static File getArtifactFileFromPluginDependencies(AbstractWisdomMojo mojo, String artifactId, String type) { Preconditions.checkNotNull(mojo); Preconditions.checkNotNull(artifactId); Preconditions.checkNotNull(type); for (Artifact artifact : mojo.pluginDependencies) { if (artifact.getArtifactId().equals(artifactId) && artifact.getType().equals(type)) { return artifact.getFile(); } } return null; }
DependencyFinder { public static File getArtifactFileFromPluginDependencies(AbstractWisdomMojo mojo, String artifactId, String type) { Preconditions.checkNotNull(mojo); Preconditions.checkNotNull(artifactId); Preconditions.checkNotNull(type); for (Artifact artifact : mojo.pluginDependencies) { if (artifact.getArtifactId().equals(artifactId) && artifact.getType().equals(type)) { return artifact.getFile(); } } return null; } }
DependencyFinder { public static File getArtifactFileFromPluginDependencies(AbstractWisdomMojo mojo, String artifactId, String type) { Preconditions.checkNotNull(mojo); Preconditions.checkNotNull(artifactId); Preconditions.checkNotNull(type); for (Artifact artifact : mojo.pluginDependencies) { if (artifact.getArtifactId().equals(artifactId) && artifact.getType().equals(type)) { return artifact.getFile(); } } return null; } private  DependencyFinder(); }
DependencyFinder { public static File getArtifactFileFromPluginDependencies(AbstractWisdomMojo mojo, String artifactId, String type) { Preconditions.checkNotNull(mojo); Preconditions.checkNotNull(artifactId); Preconditions.checkNotNull(type); for (Artifact artifact : mojo.pluginDependencies) { 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 getArtifactFileFromPluginDependencies(AbstractWisdomMojo mojo, String artifactId, String type) { Preconditions.checkNotNull(mojo); Preconditions.checkNotNull(artifactId); Preconditions.checkNotNull(type); for (Artifact artifact : mojo.pluginDependencies) { 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);  }