class PublishPackage extends AbstractCommand {

  @Override
  public void execute() throws Exception {
    logger.trace("Starting {}...", this);

    final ProjectFile rootProject = readProject();
    final String buildTarget = rootProject.getTarget();
    assertNotNull(buildTarget, bind(NL_0));

    if (!exists(Paths.get(buildTarget))) {
      new BuildProject().execute();
    }

    final String publishRepository = append(System.getProperty("user.home"), MODULES_BASE);
    final Path publishPath = Paths.get(append(publishRepository, rootProject.getName()));
    if (exists(publishPath)) {
      deleteRecursively(publishPath, ALLOW_INSECURE);
    }
    createDirectories(publishPath);
    FileSet.from(Paths.get(".")).copyTo(publishPath);
    printer.println(NL_1, rootProject.getName());
    printer.println(NL_2, publishPath);
  }

}