@Test public void testPackagingOfMavenAppWithCustomGAV() throws IOException, MojoExecutionException { if (!Helper.detectPlay2()) { System.err.println("PLAY2_HOME missing, skipping tests"); return; } File baseDir = new File("target/tests/testPackagingOfMavenAppWithCustomGAV"); Helper.copyMavenApp(baseDir); Play2PackageMojo mojo = new Play2PackageMojo(); mojo.project = mock(MavenProject.class); mojo.projectHelper = mock(MavenProjectHelper.class); mojo.attachDist = true; mojo.buildDist = true; mojo.deleteDist = false; mojo.buildDirectory = new File(baseDir, "target"); mojo.setLog(new SystemStreamLog()); Build build = mock(Build.class); Artifact artifact = mock(Artifact.class); when(mojo.project.getBasedir()).thenReturn(baseDir); when(mojo.project.getBuild()).thenReturn(build); when(mojo.project.getArtifact()).thenReturn(artifact); when(build.getFinalName()).thenReturn("my-artifact-id-1.0.0"); when(mojo.project.getArtifactId()).thenReturn("my-artifact-id"); when(mojo.project.getGroupId()).thenReturn("my-group-id"); when(mojo.project.getVersion()).thenReturn("1.0.0"); mojo.execute(); // Verify attached file File target = new File(baseDir, "target"); File dist = new File(target, "my-artifact-id-1.0.0.zip"); File pack = new File(target, "my-artifact-id-1.0.0.jar"); assertThat(dist).exists(); assertThat(pack).exists(); verify(artifact).setFile(pack); verify(mojo.projectHelper).attachArtifact(mojo.project, "zip", null, dist); }