### Question:
ExportPackageMojo extends TakariLifecycleMojo { @Override protected void executeMojo() throws MojoExecutionException { try { classesDirectory = classesDirectory.getCanonicalFile(); generateOutput(); } catch (IOException e) { throw new MojoExecutionException("Could not generate export-package file", e); } }   static final String PATH_EXPORT_PACKAGE; static final char EOL; }### Answer:
@Test public void testBasic() throws Exception { File basedir = resources.getBasedir("exportpackage/basic"); mkfile(basedir, "target/classes/exported/Exported.class"); mkfile(basedir, "target/classes/internal/Internal.class"); mojos.executeMojo(basedir, "export-package"); mojos.assertBuildOutputs(basedir, "target/classes/" + ExportPackageMojo.PATH_EXPORT_PACKAGE); assertExportedPackages(basedir, "exported"); mojos.executeMojo(basedir, "export-package"); mojos.assertCarriedOverOutputs(basedir, "target/classes/" + ExportPackageMojo.PATH_EXPORT_PACKAGE); assertExportedPackages(basedir, "exported"); touch(basedir, "target/classes/exported/Exported.class"); touch(basedir, "target/classes/internal/Internal.class"); mojos.executeMojo(basedir, "export-package"); mojos.assertCarriedOverOutputs(basedir, "target/classes/" + ExportPackageMojo.PATH_EXPORT_PACKAGE); assertExportedPackages(basedir, "exported"); rm(basedir, "target/classes/internal/Internal.class"); mojos.executeMojo(basedir, "export-package"); mojos.assertCarriedOverOutputs(basedir, "target/classes/" + ExportPackageMojo.PATH_EXPORT_PACKAGE); assertExportedPackages(basedir, "exported"); mkfile(basedir, "target/classes/exported/another/Exported.class"); mojos.executeMojo(basedir, "export-package"); mojos.assertBuildOutputs(basedir, "target/classes/" + ExportPackageMojo.PATH_EXPORT_PACKAGE); assertExportedPackages(basedir, "exported", "exported.another"); rm(basedir, "target/classes/exported/another/Exported.class"); mojos.executeMojo(basedir, "export-package"); mojos.assertBuildOutputs(basedir, "target/classes/" + ExportPackageMojo.PATH_EXPORT_PACKAGE); assertExportedPackages(basedir, "exported"); rm(basedir, "target/classes/exported/Exported.class"); mojos.executeMojo(basedir, "export-package"); mojos.assertBuildOutputs(basedir, "target/classes/" + ExportPackageMojo.PATH_EXPORT_PACKAGE); assertExportedPackages(basedir, new String[0]); }
@Test public void testNoClassesDirectory() throws Exception { File basedir = resources.getBasedir("exportpackage/basic"); mojos.executeMojo(basedir, "export-package"); mojos.assertBuildOutputs(basedir, "target/classes/" + ExportPackageMojo.PATH_EXPORT_PACKAGE); assertExportedPackages(basedir, new String[0]); }
@Test public void testBasic_symlinked() throws Exception { Assume.assumeTrue(Os.isFamily(Os.FAMILY_UNIX)); File basedir = resources.getBasedir(); File orig = new File(basedir, "orig"); create(orig, "target/classes/exported/Class.class"); File symlink = java.nio.file.Files.createSymbolicLink(new File(basedir, "symlink").toPath(), orig.toPath()).toFile(); mojos.executeMojo(symlink, "export-package"); assertExportedPackages(symlink, "exported"); }