Bundle project as a Mac OS X application bundle.

@throws MojoExecutionException If an unexpected error occurs during packaging of the bundle.
503263
public void execute()
        throws MojoExecutionException
    {

        // Set up and create directories
        buildDirectory.mkdirs();

        File bundleDir = new File( buildDirectory, bundleName + ".app" );
        bundleDir.mkdirs();

        File contentsDir = new File( bundleDir, "Contents" );
        contentsDir.mkdirs();

        File resourcesDir = new File( contentsDir, "Resources" );
        resourcesDir.mkdirs();

        File javaDirectory = new File( resourcesDir, "Java" );
        javaDirectory.mkdirs();

        File macOSDirectory = new File( contentsDir, "MacOS" );
        macOSDirectory.mkdirs();

        // Copy in the native java application stub
        File stub = new File( macOSDirectory, javaApplicationStub.getName() );
        if(! javaApplicationStub.exists()) {
            String message = "Can't find JavaApplicationStub binary. File does not exist: " + javaApplicationStub;

            if(! isOsX() ) {
                message += "\nNOTICE: You are running the osxappbundle plugin on a non OS X platform. To make this work you need to copy the JavaApplicationStub binary into your source tree. Then configure it with the 'javaApplicationStub' configuration property.\nOn an OS X machine, the JavaApplicationStub is typically located under /System/Library/Frameworks/JavaVM.framework/Versions/Current/Resources/MacOS/JavaApplicationStub";
            }

            throw new MojoExecutionException( message);
            
        } else {
            try
            {
                FileUtils.copyFile( javaApplicationStub, stub );
            }
            catch ( IOException e )
            {
                throw new MojoExecutionException(
                    "Could not copy file " + javaApplicationStub + " to directory " + macOSDirectory, e );
            }
        }

        // Copy icon file to the bundle if specified
        if ( iconFile != null )
        {
            try
            {
                FileUtils.copyFileToDirectory( iconFile, resourcesDir );
            }
            catch ( IOException e )
            {
                throw new MojoExecutionException( "Error copying file " + iconFile + " to " + resourcesDir, e );
            }
        }

        // Resolve and copy in all dependecies from the pom
        List files = copyDependencies( javaDirectory );

        // Create and write the Info.plist file
        File infoPlist = new File( bundleDir, "Contents/Info.plist" );
        writeInfoPlist( infoPlist, files );

        // Copy specified additional resources into the top level directory
        if (additionalResources != null && !additionalResources.isEmpty())
        {
            copyResources( additionalResources );
        }

		if (copyElements != null && !copyElements.isEmpty())
			copyElements();
		
		if(createApplicationSymbolicLink!=null &&createApplicationSymbolicLink.equals(Boolean.TRUE) && isOsX())
			createApplicationSymbolicLink();
        
        if ( isOsX() )
        {
            // Make the stub executable
            Commandline chmod = new Commandline();
            try
            {
                chmod.setExecutable( "chmod" );
                chmod.createArgument().setValue( "755" );
                chmod.createArgument().setValue( stub.getAbsolutePath() );

                chmod.execute();
            }
            catch ( CommandLineException e )
            {
                throw new MojoExecutionException( "Error executing " + chmod + " ", e );
            }

            String setFileStr = null;
            for (String setFilePath : SET_FILE_PATH) {
            	setFileStr = setFilePath;
            	if (new File(setFileStr).exists())
            		break;
            }
            // This makes sure that the .app dir is actually registered as an application bundle
            if ( new File( setFileStr ).exists() )
            {
                Commandline setFile = new Commandline();
                try
                {
                    setFile.setExecutable(setFileStr);
                    setFile.createArgument().setValue( "-a B" );
                    setFile.createArgument().setValue( bundleDir.getAbsolutePath() );

                    setFile.execute();
                }
                catch ( CommandLineException e )
                {
                    throw new MojoExecutionException( "Error executing " + setFile, e );
                }
            }
            else
            {
                getLog().warn( "Could  not set 'Has Bundle' attribute. " +SET_FILE_PATH +" not found, is Developer Tools installed?" );
            }
            // Create a .dmg file of the app
            Commandline dmg = new Commandline();
            try
            {
                dmg.setExecutable( "hdiutil" );
                dmg.createArgument().setValue( "create" );
                dmg.createArgument().setValue( "-srcfolder" );
                dmg.createArgument().setValue( buildDirectory.getAbsolutePath() );
                dmg.createArgument().setValue( diskImageFile.getAbsolutePath() );
                try
                {
                    dmg.execute().waitFor();
                }
                catch ( InterruptedException e )
                {
                    throw new MojoExecutionException( "Thread was interrupted while creating DMG " + diskImageFile, e );
                }
            }
            catch ( CommandLineException e )
            {
                throw new MojoExecutionException( "Error creating disk image " + diskImageFile, e );
            }
            if(internetEnable) {
                try {

                    Commandline internetEnable = new Commandline();

                    internetEnable.setExecutable("hdiutil");
                    internetEnable.createArgument().setValue("internet-enable" );
                    internetEnable.createArgument().setValue("-yes");
                    internetEnable.createArgument().setValue(diskImageFile.getAbsolutePath());

                    internetEnable.execute();
                } catch (CommandLineException e) {
                    throw new MojoExecutionException("Error internet enabling disk image: " + diskImageFile, e);
                }
            }
            projectHelper.attachArtifact(project, "dmg", null, diskImageFile);
        }

		if (createApplicationSymbolicLink != null && createApplicationSymbolicLink.equals(Boolean.TRUE))
			removeApplicationLink();
        
        zipArchiver.setDestFile( zipFile );
        try
        {
            String[] stubPattern = {buildDirectory.getName() + "/" + bundleDir.getName() +"/Contents/MacOS/"
                                    + javaApplicationStub.getName()};
            

            zipArchiver.addDirectory( buildDirectory.getParentFile(), new String[]{buildDirectory.getName() + "/**"},
            		stubPattern);

            DirectoryScanner scanner = new DirectoryScanner();
            scanner.setBasedir( buildDirectory.getParentFile() );
            scanner.setIncludes(stubPattern);
            scanner.scan();

            String[] stubs = scanner.getIncludedFiles();
            for ( int i = 0; i < stubs.length; i++ )
            {
                String s = stubs[i];
                zipArchiver.addFile( new File( buildDirectory.getParentFile(), s ), s, 0755 );
            }

            zipArchiver.createArchive();
            projectHelper.attachArtifact(project, "zip", null, zipFile);
        }
        catch ( ArchiverException e )
        {
            throw new MojoExecutionException( "Could not create zip archive of application bundle in " + zipFile, e );
        }
        catch ( IOException e )
        {
            throw new MojoExecutionException( "IOException creating zip archive of application bundle in " + zipFile,
                                              e );
        }


    }
1288061
protected void executeLicenseGoal(String goal) throws MojoExecutionException
    {
        // Find the license plugin (it's project's responsibility to make sure the License plugin is properly setup in
        // its <pluginManagement>, for most XWiki projects it just mean inherits from xwiki-commons-pom)
        Plugin licensePlugin =
            this.project.getPluginManagement().getPluginsAsMap().get("com.mycila:license-maven-plugin");

        if (licensePlugin == null) {
            throw new MojoExecutionException("License plugin could not be found in <pluginManagement>");
        }

        executeMojo(
            licensePlugin,
            goal(goal),
            configuration(
                element(name("header"), "license.txt"),
                element(name("strictCheck"), "true"),
                element(name("headerDefinitions"),
                    element(name("headerDefinition"), "license-xml-definition.xml")),
                element(name("includes"),
                    element(name("include"), "src/main/resources/**/*.xml"))
            ),
            executionEnvironment(
                this.project,
                this.mavenSession,
                this.pluginManager
            )
        );
    }
858273
void packageArtifacts(final File compileDir, final MavenProject project, final Set<String> bundles)
        throws IOException, XCodeException
  {

    File mainArtifact = createMainArtifactFile(project);

    attachBundle(compileDir, project, bundles, mainArtifact);

    final File mainArtifactFile = archiveMainArtifact(project, mainArtifact);
    setMainArtifact(project, mainArtifactFile);

  }
1323662
@Override
	public void processBundles(GlobalPostProcessingContext ctx, List<JoinableResourceBundle> bundles) {

		if (ctx.hasBundleToBeProcessed()) {
			String workingDir = ctx.getRsReaderHandler().getWorkingDirectory();

			if (srcDir == null || destDir == null || tempDir == null || srcZipDir == null || destZipDir == null) {
				srcDir = ctx.getBundleHandler().getBundleTextDirPath();
				srcZipDir = ctx.getBundleHandler().getBundleZipDirPath();
				destDir = workingDir + GOOGLE_CLOSURE_RESULT_TEXT_DIR;
				destZipDir = workingDir + GOOGLE_CLOSURE_RESULT_ZIP_DIR;
				tempDir = workingDir + GOOGLE_CLOSURE_TEMP_DIR;
			}

			// Create result directory
			File dir = new File(destDir);
			if (!dir.exists() && !dir.mkdirs()) {
				throw new BundlingProcessException("Impossible to create temporary directory :" + destDir);
			}

			// Create result directory
			dir = new File(destZipDir);
			if (!dir.exists() && !dir.mkdirs()) {
				throw new BundlingProcessException("Impossible to create temporary directory :" + destZipDir);
			}

			// Create temporary directory
			dir = new File(tempDir);
			if (!dir.exists() && !dir.mkdirs()) {
				throw new BundlingProcessException("Impossible to create temporary directory :" + tempDir);
			}

			// Copy the bundle files in a temp directory
			try {
				FileUtils.copyDirectory(new File(srcDir), new File(tempDir));

				Map<String, String> resultBundleMapping = new HashMap<>();
				JawrClosureCommandLineRunner cmdRunner = new JawrClosureCommandLineRunner(ctx, bundles,
						resultBundleMapping);
				cmdRunner.doRun();
				// Copy compiled bundles
				FileUtils.copyDirectory(new File(destDir), new File(srcDir));

				// Copy zipped compiled bundles
				FileUtils.copyDirectory(new File(destZipDir), new File(srcZipDir));

			} catch (Exception e) {

				throw new BundlingProcessException(e);
			}
		}
	}
639143
public void start(BundleContext context)
            throws Exception
    {
        String library = System.mapLibraryName(LIBRARY_NAME);
        if (library.toLowerCase().endsWith(".dylib")) {
            // some MacOS JDK7+ vendors map to dylib instead of jnilib
            library = library.replace(".dylib", ".jnilib");
        }
        System.loadLibrary(library);
        SnappyLoader.setSnappyApi(new SnappyNative());
    }
786253
public void execute()
        throws MojoExecutionException, MojoFailureException
    {
        Collection<ResourceFile> files = getAllResourceFiles();
        for ( ResourceFile file : files )
        {
            File f = new File( file.basedir, file.fileRelativeName );
            File target = new File( outputDirectory, file.fileRelativeName );
            try
            {
                getLog().debug( "copy " + f + " to outputDirectory" );
                if ( !target.getParentFile().exists() )
                {
                    if ( !target.getParentFile().mkdirs() )
                    {
                        throw new MojoExecutionException( "Failed to create destination directory "
                            + target.getParentFile() );
                    }
                }
                FileUtils.copyFile( f, target );
            }
            catch ( IOException e )
            {
                throw new MojoExecutionException( "Failed to copy GWT source " + f, e );
            }
        }
    }
521998
@Override
    public void execute()
            throws MojoExecutionException, MojoFailureException
        {
        boolean fExplicit = this.script != null;
        String  script    = fExplicit
                            ? this.script
                            : execution.getLifecyclePhase();

        String SCRIPT_NOT_FOUND = "Script '" + script + "' is not defined in package.json";

        Package pkg = getPackage();
        if (fExplicit && !pkg.hasScript(script))
            {
            getLog().error(SCRIPT_NOT_FOUND);
            throw new MojoFailureException(SCRIPT_NOT_FOUND);
            }
        else if (pkg.hasScript(script))
            {
            if (!fExplicit && script.endsWith("test") && skipTests)
                {
                getLog().info("Tests are skipped.");
                }
            else
                {
                CommandLine cmdLine = getNpmCommand();
                addCommand(cmdLine);
                cmdLine.addArgument(script);
                addArguments(cmdLine);

                execute(cmdLine);
                }
            }
        else
            {
            getLog().info(SCRIPT_NOT_FOUND);
            }
        }
543353
protected void buildShareWar() throws MojoExecutionException {
        buildCustomWarInDir(SHARE_WAR_PREFIX_NAME, shareModules,
                alfrescoGroupId, alfrescoShareWarArtifactId, alfrescoShareVersion);

        copyShareLog4jConfig();
        copyShareConfigCustom();
        copyHotswapAgentProperties(SHARE_WAR_PREFIX_NAME);


        String shareWarArtifactId = packageAndInstallCustomWar(SHARE_WAR_PREFIX_NAME);

        // Set up the custom share war to be run by Tomcat plugin
        runnerAlfrescoGroupId = "${project.groupId}";
        runnerAlfrescoShareWarArtifactId = shareWarArtifactId;
        runnerAlfrescoShareVersion = "${project.version}";
    }
1007740
@Override
  public void execute() throws MojoExecutionException, MojoFailureException {
    if (isSkip()) {
      return;
    }

    PackageDownloader downloader = new PackageDownloader(getPackageManagerProperties(), getLoggerWrapper());

    File outputFileObject = downloader.downloadFile(getPackageFile(), this.outputFile);
    if (this.unpack) {
      unpackFile(outputFileObject);
    }
  }
476080
public static Bundle addBundle(final CFMLEngineFactory factory, final BundleContext context, final File bundle, final Log log) throws IOException, BundleException {

	return addBundle(factory, context, bundle.getAbsolutePath(), new FileInputStream(bundle), true, log);
    }
122968
private void addScoverageDependenciesToClasspath( Artifact scalaScoveragePluginArtifact )
        throws MojoExecutionException
    {
        @SuppressWarnings( "unchecked" )
        Set<Artifact> set = new LinkedHashSet<Artifact>( project.getDependencyArtifacts() );
        set.add( scalaScoveragePluginArtifact );
        project.setDependencyArtifacts( set );
    }
225144
@Override
  public final void narExecute() throws MojoExecutionException, MojoFailureException {
    // let the layout decide which (additional) nars to attach
    getLayout().prepareNarInfo(getTargetDirectory(), getMavenProject(), getNarInfo(), this);
    getNarInfo().writeToDirectory(this.classesDirectory);

    final String artifactIdVersion = getMavenProject().getArtifactId() + "-" + getMavenProject().getVersion();

    // Scan target directory to identify project classifier directories, skipping noarch
    File[] files = getTargetDirectory().listFiles(new FileFilter() {
      @Override
      public boolean accept(File file) {
        return file.getName().startsWith(artifactIdVersion) && (!file.getName().endsWith(NarConstants.NAR_NO_ARCH));
      }
    });

    // Write nar info to project classifier directories
    getNarInfo().writeToDirectory(files);
  }
370029
public static function bundle(string $root = "", string $ignore = ""): void
    {
        echo "Bundling...\n";

        $root = realpath($root ?: self::rootPath());
        $ignore = realpath($ignore ?: self::rootPath()."/.zipignore");

        $archive_name = basename($root);
        $archive_path = $root."/zip/";

        echo "$archive_path => $archive_name.zip\n";

        $directory = new \RecursiveDirectoryIterator($archive_path);
        $file_info = new \RecursiveIteratorIterator($directory);

        $files = [];
        foreach ($file_info as $info)
        {
            $real_path = $info->getPathname();
            $file_name = $info->getFilename();

            // Skip /. and /..
            if($file_name === "." || $file_name === "..")
                continue;

            $path = str_replace($root, "", $real_path); // Remove base path from the path string.
            $path = str_replace("\\", "/", $path); // Match .zipignore format
            $path = substr($path, 1, strlen($path) - 1);

            if (!self::inIgnoreFile($path, $ignore))
            {
                $files[] = $path;
                echo "ADDED  : $path\n";
            }
            else
                echo "IGNORED: $path\n";
        }

        $zip = new \ZipArchive();
        $file_name = $root."/$archive_name.zip";

        if ($zip->open($file_name, \ZipArchive::CREATE | \ZipArchive::OVERWRITE) !== true) {
            exit("Unable to create $file_name!\n");
        }

        // Save the current working directory and move to the root of the project for the next steps!
        $old_dir = getcwd();
        chdir($root);

        // Loop through each file in the list...
        foreach ($files as $file) {
            // Ensure .zipignore directory separators are converted to OS separators.
            //$path = str_replace("/", DIRECTORY_SEPARATOR, $file);
            $path = $file;

            // Remove the leading folder, as we do not want that structure in the ZIP archive.
            $local = str_replace("zip/", "", $path);

            // Add the file to the archive.
            $zip->addFile($path, $local);
        }

        $total_files = $zip->numFiles;
        $status = $zip->status !== 0 ? $zip->getStatusString() : "SUCCESS!";

        echo "FILES  : $total_files\n";
        echo "STATUS : $status\n";

        // Close the archive, we're all finished!
        $zip->close();

        // Return to the previous working directory.
        chdir($old_dir);
    }
546526
public void execute() throws MojoExecutionException, MojoFailureException {
		try {
			createBundles();
		} catch (Exception ex) {
			Logger logger = Logger.getLogger(JawrMojo.class.getName());
			if(ex instanceof ServletException){
				logger.log(Level.SEVERE, null, ((ServletException)ex).getRootCause());
			}else{
				logger.log(Level.SEVERE, null, ex);
			}
			throw new MojoFailureException("JAWR Maven plugin failed: " + ex.getLocalizedMessage());
		}
	}
1241652
public void deployCron() throws MojoExecutionException {
    stager.stage();
    try {
      deployMojo
          .getAppEngineFactory()
          .deployment()
          .deployCron(
              configBuilder.buildDeployProjectConfigurationConfiguration(appengineDirectory));
    } catch (AppEngineException ex) {
      throw new MojoExecutionException("Failed to deploy", ex);
    }
  }
1300957
public void execute() throws MojoExecutionException {
		
		
		getLog().info("Start, BS: " + System.getProperty("os.name"));
		if (System.getProperty("os.name").contains("indows")){
			CPPATHSEPERATOR = ";";
			PATHSEPERATOR="\\";
		}else{
			CPPATHSEPERATOR=":";
			PATHSEPERATOR="/";
		}
		System.out.println("Execute: " + standardoutput);
		tests = 0;
		failure = 0;
		error = 0;
		
		if (standardoutput != null){
			File output = new File(standardoutput);
			try {
				bw = new BufferedWriter( new FileWriter(output));
			} catch (IOException e1) {
				// TODO Automatisch generierter Erfassungsblock
				e1.printStackTrace();
			}
		}
		else{
			File output = new File("stdout.txt");
			try {
				bw = new BufferedWriter( new FileWriter(output));
			} catch (IOException e1) {
				// TODO Automatisch generierter Erfassungsblock
				e1.printStackTrace();
			}
		}
		
		File dir = new File("src/test/java/");
		FileFilter fileFilter = new RegexFileFilter("[A-z/]*.java$");

		project = project.getExecutionProject();
		runTestFile(dir, fileFilter);

		getLog().info("Tests: " + tests + " Fehlschläge: " + failure
				+ " Fehler: " + error);

	}
1234449
@Override
	public void processBundles(T ctx, List<JoinableResourceBundle> bundles) {
		globalPreprocessor.processBundles(ctx, bundles);
	}