@Override
  public void execute() throws MojoExecutionException, MojoFailureException {
    File outputFile = null, outputAlignedFile = null, destFile = null, destAlignedFile = null;
    String techId;
    if (baseDir.getPath().endsWith("source")
        || baseDir.getPath().endsWith("unit")
        || baseDir.getPath().endsWith("functional")
        || baseDir.getPath().endsWith("performance")) {
      try {
        if (baseDir.getPath().endsWith("source")) {
          rootPomFile =
              new File(
                  baseDir.getParentFile().getPath() + File.separator + PluginConstants.POM_XML);
        } else {
          String rootDir = baseDir.getParentFile().getParentFile().getParentFile().getPath();
          SplitedSourceDirName = rootDir.substring(rootDir.lastIndexOf(File.separator) + 1);
          rootPomFile =
              new File(
                  baseDir.getParentFile().getParentFile().getParentFile().getPath()
                      + File.separator
                      + SplitedSourceDirName
                      + File.separator
                      + PluginConstants.POM_XML);
        }
        try {

          if (rootPomFile.exists()) {
            rootPomProcessor = new PomProcessor(rootPomFile);
            if (StringUtils.isNotEmpty(
                rootPomProcessor.getProperty(Constants.POM_PROP_KEY_SPLIT_PHRESCO_DIR))) {
              dotPhrescoDirName =
                  rootPomProcessor.getProperty(Constants.POM_PROP_KEY_SPLIT_PHRESCO_DIR);
              testDirName = rootPomProcessor.getProperty(Constants.POM_PROP_KEY_SPLIT_TEST_DIR);
            }
          }
        } catch (PhrescoPomException e) {
          e.printStackTrace();
        }
        buildInfoList = new ArrayList<BuildInfo>(); // initialization
        if (baseDir.getPath().endsWith("source") && dotPhrescoDirName == null) {
          buildDir = new File(baseDir.getParentFile().getPath() + buildDirectory);
          packageInfoFile =
              new File(
                  baseDir.getParentFile().getPath()
                      + File.separator
                      + ".phresco"
                      + File.separator
                      + "phresco-package-info.xml");

        } else if (baseDir.getPath().endsWith("source") && dotPhrescoDirName != null) {
          // code for new archetype changes starts
          dotPhrescoDir =
              baseDir.getParentFile().getParentFile().getPath()
                  + File.separator
                  + dotPhrescoDirName;
          File projectDir = new File(baseDir.getParentFile().getParentFile().getPath());
          File[] filesInDir = projectDir.listFiles();
          fileProcessor(filesInDir);
          // code for new archetype changes ends
          buildDir = new File(finalBuildDir + File.separator + buildDirectory);
          packageInfoFile =
              new File(
                  dotPhrescoDir
                      + File.separator
                      + ".phresco"
                      + File.separator
                      + "phresco-package-info.xml");

        } else if (dotPhrescoDirName != null) {
          dotPhrescoDir =
              baseDir.getParentFile().getParentFile().getParentFile().getPath()
                  + File.separator
                  + dotPhrescoDirName;
          buildDir = new File(baseDir.getPath() + buildDirectory);

        } else {
          buildDir = new File(baseDir.getPath() + buildDirectory);
        }

        if (!buildDir.exists()) {
          buildDir.mkdir();
        }
        buildInfoFile = new File(buildDir.getPath() + "/build.info");

        if ((baseDir.getPath().endsWith("unit")
                || baseDir.getPath().endsWith("functional")
                || baseDir.getPath().endsWith("performance"))
            && dotPhrescoDir != null) {
          packageInfoFile =
              new File(
                  dotPhrescoDir
                      + File.separator
                      + ".phresco"
                      + File.separator
                      + "phresco-package-info.xml");
        } else if (baseDir.getPath().endsWith("unit")
            || baseDir.getPath().endsWith("functional")
            || baseDir.getPath().endsWith("performance")) {
          packageInfoFile =
              new File(
                  baseDir.getParentFile().getParentFile()
                      + File.separator
                      + ".phresco"
                      + File.separator
                      + "phresco-package-info.xml");
          buildDir = baseDir.getParentFile().getParentFile();
          buildInfoFile = new File(baseDir.getPath() + buildDirectory + "/build.info");
        }

        MojoProcessor processor = new MojoProcessor(packageInfoFile);
        Configuration configuration = processor.getConfiguration("package");
        Map<String, String> configs = MojoUtil.getAllValues(configuration);
        techId = configs.get("techId");
        if (StringUtils.isNotEmpty(techId)) {

          outputFile =
              new File(
                  project.getBuild().getDirectory(),
                  project.getBuild().getFinalName() + '.' + APKLIB);

        } else {

          outputFile =
              new File(
                  project.getBuild().getDirectory(), project.getBuild().getFinalName() + '.' + APK);
          outputAlignedFile =
              new File(
                  project.getBuild().getDirectory(),
                  project.getBuild().getFinalName() + "-aligned." + APK);
        }

        nextBuildNo = generateNextBuildNo();

        currentDate = Calendar.getInstance().getTime();
      } catch (IOException e) {
        throw new MojoFailureException("APK could not initialize " + e.getLocalizedMessage());
      } catch (PhrescoException e) {
        throw new MojoFailureException("APK could not initialize " + e.getLocalizedMessage());
      }

      if (outputFile.exists()) {
        try {
          if (StringUtils.isNotEmpty(techId)) {
            getLog().info("APKLib created.. Copying to Build directory.....");
          } else {
            getLog().info("APK created.. Copying to Build directory.....");
          }
          String buildNameLocal =
              project.getBuild().getFinalName() + '_' + getTimeStampForBuildName(currentDate);

          if (baseDir.getPath().endsWith("unit")
              || baseDir.getPath().endsWith("functional")
              || baseDir.getPath().endsWith("performance")) {
            buildDir = new File(baseDir.getPath() + buildDirectory);
          }
          if (buildName != null) {
            if (StringUtils.isNotEmpty(techId)) {
              destFile = new File(buildDir, buildName + '.' + APKLIB);

            } else {

              destFile = new File(buildDir, buildName + '.' + APK);
              // Creating the file in build folder for copying the aligned APK - Created by Hari -
              // 20-May-2013
              destAlignedFile = new File(buildDir, buildName + "-aligned." + APK);
            }

            FileUtils.copyFile(outputFile, destFile);
            getLog().info("copied to..." + destFile.getName());

            /* If outputAlignedFile exists in target folder,
             * Then we are copying it to destinationFile in build folder
             * Added By - Hari - May, 20 , 2013
             */

            if (outputAlignedFile != null && outputAlignedFile.exists()) {

              FileUtils.copyFile(outputAlignedFile, destAlignedFile);
            }
            apkFileName = destFile.getName();

            getLog().info("Creating deliverables.....");

            ZipArchiver zipArchiver = new ZipArchiver();
            File tmpFile = new File(buildDir, buildName);

            if (!tmpFile.exists()) {

              tmpFile.mkdirs();
            }
            FileUtils.copyFileToDirectory(destFile, tmpFile);

            /*To Copy the aligned apk into zip file in build folder,
             *It is for downloading the aligned apk from build Tab
             * Added by - Hari -May, 20 ,2013
             */
            if (destAlignedFile != null && destAlignedFile.exists()) {

              FileUtils.copyFileToDirectory(destAlignedFile, tmpFile);
            }
            if (!packageInfoFile.exists()) {
              PluginUtils.createBuildResources(packageInfoFile, baseDir, tmpFile);
            }
            File inputFile = new File(apkFileName);
            zipArchiver.addDirectory(tmpFile);
            File deliverableZip = new File(buildDir, buildName + ".zip");
            zipArchiver.setDestFile(deliverableZip);
            zipArchiver.createArchive();

            deliverable = deliverableZip.getPath();
            getLog().info("Deliverables available at " + deliverableZip.getName());
            if (tmpFile.exists()) {
              FileUtil.delete(tmpFile);
            }
            writeBuildInfo(true);
          } else {
            if (StringUtils.isNotEmpty(techId)) {
              destFile = new File(buildDir, buildNameLocal + '.' + APKLIB);

            } else {

              destFile = new File(buildDir, buildNameLocal + '.' + APK);
              // Creating the file in build folder for copying the aligned APK - Created by Hari -
              // 20-May-2013
              destAlignedFile = new File(buildDir, buildNameLocal + "-aligned." + APK);
            }

            FileUtils.copyFile(outputFile, destFile);
            getLog().info("copied to..." + destFile.getName());

            /* If outputAlignedFile exists in target folder,
             * Then we are copying it to destinationFile in build folder
             * Added By - Hari - May, 20 , 2013
             */

            if (outputAlignedFile != null && outputAlignedFile.exists()) {

              FileUtils.copyFile(outputAlignedFile, destAlignedFile);
            }
            apkFileName = destFile.getName();

            getLog().info("Creating deliverables.....");

            ZipArchiver zipArchiver = new ZipArchiver();
            File tmpFile = new File(buildDir, buildNameLocal);

            if (!tmpFile.exists()) {

              tmpFile.mkdirs();
            }
            FileUtils.copyFileToDirectory(destFile, tmpFile);

            /*To Copy the aligned apk into zip file in build folder,
             *It is for downloading the aligned apk from build Tab
             * Added by - Hari -May, 20 ,2013
             */
            if (destAlignedFile != null && destAlignedFile.exists()) {

              FileUtils.copyFileToDirectory(destAlignedFile, tmpFile);
            }
            if (!packageInfoFile.exists()) {
              PluginUtils.createBuildResources(packageInfoFile, baseDir, tmpFile);
            }
            File inputFile = new File(apkFileName);
            zipArchiver.addDirectory(tmpFile);
            File deliverableZip = new File(buildDir, buildNameLocal + ".zip");
            zipArchiver.setDestFile(deliverableZip);
            zipArchiver.createArchive();

            deliverable = deliverableZip.getPath();
            getLog().info("Deliverables available at " + deliverableZip.getName());
            if (tmpFile.exists()) {
              FileUtil.delete(tmpFile);
            }
            writeBuildInfo(true);
          }

        } catch (IOException e) {
          throw new MojoExecutionException("Error in writing output...");
        }
      }
    } else {
      getLog().info("It is a component ");
    }
  }
  @Override
  public void execute() throws MojoExecutionException, MojoFailureException {
    File outputFile = null, destFile = null, projectHome = null;
    String techId;
    try {
      getLog().info("Base Dir === " + baseDir.getAbsolutePath());

      buildInfoList = new ArrayList<BuildInfo>(); // initialization
      //			srcDir = new File(baseDir.getPath() + File.separator + sourceDirectory);
      buildDir = new File(baseDir.getPath() + buildDirectory);
      if (!buildDir.exists()) {
        buildDir.mkdir();
        getLog().info("Build directory created..." + buildDir.getPath());
      }
      buildInfoFile = new File(buildDir.getPath() + "/build.info");
      if (baseDir.getPath().endsWith("unit")
          || baseDir.getPath().endsWith("functional")
          || baseDir.getPath().endsWith("performance")) {
        projectHome =
            new File(
                baseDir.getParentFile().getParentFile()
                    + File.separator
                    + ".phresco"
                    + File.separator
                    + "phresco-package-info.xml");
      } else {
        projectHome =
            new File(
                baseDir.getPath()
                    + File.separator
                    + ".phresco"
                    + File.separator
                    + "phresco-package-info.xml");
      }
      MojoProcessor processor = new MojoProcessor(projectHome);
      Configuration configuration = processor.getConfiguration("package");
      Map<String, String> configs = MojoUtil.getAllValues(configuration);
      if (baseDir.getPath().endsWith("unit")
          || baseDir.getPath().endsWith("functional")
          || baseDir.getPath().endsWith("performance")) {
        buildDir = baseDir.getParentFile().getParentFile();
        buildInfoFile = new File(baseDir.getPath() + buildDirectory + "/build.info");
      }

      techId = configs.get("techId");
      if (StringUtils.isNotEmpty(techId)) {
        outputFile =
            new File(
                project.getBuild().getDirectory(),
                project.getBuild().getFinalName() + '.' + APKLIB);
      } else {
        outputFile =
            new File(
                project.getBuild().getDirectory(), project.getBuild().getFinalName() + '.' + APK);
      }

      nextBuildNo = generateNextBuildNo();

      currentDate = Calendar.getInstance().getTime();
    } catch (IOException e) {
      throw new MojoFailureException("APK could not initialize " + e.getLocalizedMessage());
    } catch (PhrescoException e) {
      throw new MojoFailureException("APK could not initialize " + e.getLocalizedMessage());
    }

    if (outputFile.exists()) {
      try {
        getLog().info("APK created.. Copying to Build directory.....");
        String buildName =
            project.getBuild().getFinalName() + '_' + getTimeStampForBuildName(currentDate);

        if (baseDir.getPath().endsWith("unit")
            || baseDir.getPath().endsWith("functional")
            || baseDir.getPath().endsWith("performance")) {
          buildDir = new File(baseDir.getPath() + buildDirectory);
        }

        if (StringUtils.isNotEmpty(techId)) {
          destFile = new File(buildDir, buildName + '.' + APKLIB);
        } else {
          destFile = new File(buildDir, buildName + '.' + APK);
        }

        FileUtils.copyFile(outputFile, destFile);
        getLog().info("copied to..." + destFile.getName());
        apkFileName = destFile.getName();
        getLog().info("Creating deliverables.....");
        File packageInfoFile =
            new File(
                baseDir.getPath()
                    + File.separator
                    + ".phresco"
                    + File.separator
                    + PluginConstants.PHRESCO_PACKAGE_FILE);
        ZipArchiver zipArchiver = new ZipArchiver();
        File tmpFile = new File(buildDir, buildName);
        if (!tmpFile.exists()) {
          tmpFile.mkdirs();
        }
        FileUtils.copyFileToDirectory(destFile, tmpFile);
        if (packageInfoFile.exists()) {
          PluginUtils.createBuildResources(packageInfoFile, baseDir, tmpFile);
        }
        File inputFile = new File(apkFileName);
        zipArchiver.addDirectory(tmpFile);
        File deliverableZip = new File(buildDir, buildName + ".zip");
        zipArchiver.setDestFile(deliverableZip);
        zipArchiver.createArchive();

        deliverable = deliverableZip.getPath();
        getLog().info("Deliverables available at " + deliverableZip.getName());
        writeBuildInfo(true);
        if (!tmpFile.exists()) {
          FileUtil.delete(tmpFile);
        }
      } catch (IOException e) {
        throw new MojoExecutionException("Error in writing output...");
      }
    }
  }