code: public static void createDirectory(final File aDirectory, final boolean cleanBeforeCreate)
              throws MojoExecutionException {
  
          // Check sanity
          Validate.notNull(aDirectory, "aDirectory");
          validateFileOrDirectoryName(aDirectory);
  
          // Clean an existing directory?
          if (cleanBeforeCreate) {
              try {
                  FileUtils.deleteDirectory(aDirectory);
              } catch (IOException e) {
                  throw new MojoExecutionException("Could not clean directory [" + getCanonicalPath(aDirectory) + "]", e);
              }
          }
  
          // Now, make the required directory, if it does not already exist as a directory.
          final boolean existsAsFile = aDirectory.exists() && aDirectory.isFile();
          if (existsAsFile) {
              throw new MojoExecutionException("[" + getCanonicalPath(aDirectory) + "] exists and is a file. "
                      + "Cannot make directory");
          } else if (!aDirectory.exists() && !aDirectory.mkdirs()) {
              throw new MojoExecutionException("Could not create directory [" + getCanonicalPath(aDirectory) + "]");
          }
      }
docs: Convenience method to successfully create a directory - or throw an exception if failing to create it.
  
  @param aDirectory        The directory to create.
  @param cleanBeforeCreate if {@code true}, the directory and all its content will be deleted before being
  re-created. This will ensure that the created directory is really clean.
  @throws MojoExecutionException if the aDirectory could not be created (and/or cleaned).