Create the configuration of the SRE with the maven archive format.

@return the created manifest.
@throws MojoExecutionException if the mojo fails.
@throws MojoFailureException if the generation fails.
342628
protected Xpp3Dom createSREConfiguration() throws MojoExecutionException, MojoFailureException {
		final Xpp3Dom xmlConfiguration = new Xpp3Dom("configuration"); //$NON-NLS-1$
		final Xpp3Dom xmlArchive = new Xpp3Dom("archive"); //$NON-NLS-1$
		xmlConfiguration.addChild(xmlArchive);

		final String mainClass = getMainClass();
		if (mainClass.isEmpty()) {
			throw new MojoFailureException("the main class of the SRE is missed"); //$NON-NLS-1$
		}
		final Xpp3Dom xmlManifest = new Xpp3Dom("manifest"); //$NON-NLS-1$
		xmlArchive.addChild(xmlManifest);
		final Xpp3Dom xmlManifestMainClass = new Xpp3Dom("mainClass"); //$NON-NLS-1$
		xmlManifestMainClass.setValue(mainClass);
		xmlManifest.addChild(xmlManifestMainClass);

		final Xpp3Dom xmlSections = new Xpp3Dom("manifestSections"); //$NON-NLS-1$
		xmlArchive.addChild(xmlSections);
		final Xpp3Dom xmlSection = new Xpp3Dom("manifestSection"); //$NON-NLS-1$
		xmlSections.addChild(xmlSection);
		final Xpp3Dom xmlSectionName = new Xpp3Dom("name"); //$NON-NLS-1$
		xmlSectionName.setValue(SREConstants.MANIFEST_SECTION_SRE);
		xmlSection.addChild(xmlSectionName);
		final Xpp3Dom xmlManifestEntries = new Xpp3Dom("manifestEntries"); //$NON-NLS-1$
		xmlSection.addChild(xmlManifestEntries);

		ManifestUpdater updater = getManifestUpdater();
		if (updater == null) {
			updater = new ManifestUpdater() {

				@Override
				public void addSREAttribute(String name, String value) {
					assert name != null && !name.isEmpty();
					if (value != null && !value.isEmpty()) {
						getLog().debug("Adding to SRE manifest: " + name + " = " + value);  //$NON-NLS-1$//$NON-NLS-2$
						final Xpp3Dom xmlManifestEntry = new Xpp3Dom(name);
						xmlManifestEntry.setValue(value);
						xmlManifestEntries.addChild(xmlManifestEntry);
					}
				}

				@Override
				public void addMainAttribute(String name, String value) {
					//
				}

			};
		}

		buildManifest(updater, mainClass);

		return xmlConfiguration;
	}
219700
@Override
	protected void setup() throws MojoExecutionException {
		if (verbose) {
			getLog().info("Rox configuration is generated");
		}
		
		// Check if the ROX configuration is available
		if (roxActive && roxConfig != null) {
			// Check the ROX configuration file
			if (!roxConfig.exists() || !roxConfig.isFile() || !roxConfig.getAbsolutePath().endsWith(".yml")) {
				getLog().warn("The " + ROX_PROPERTIES_FILENAME + " configuration seems not to be a valid file or path is incorrect. Rox will be disabled.");
				roxActive = false;
			}
			else {
				try {
					// Prepare the resource to copy
					Resource r = new Resource();
					r.setFiltering(true);
					r.setDirectory(roxConfig.getParent());
					r.setIncludes(Arrays.asList(new String[] {roxConfig.getName()}));

					// Configure the resource filtering
					MavenResourcesExecution mre = new MavenResourcesExecution(
						Arrays.asList(new Resource[] {r}), getWorkingDirectory(), project, encoding, null, null, session
					);
					
					// Filter the resources
					mavenResourcesFiltering.filterResources(mre);
				}
				catch (MavenFilteringException mfe) {
					getLog().warn("Unable to filter the " + ROX_PROPERTIES_FILENAME + " file. Rox will be disabled.", mfe);
					roxActive = false;
				}
			}
		}
		else {
			getLog().info("No rox configuration to use");
			roxActive = false;
		}		
	}
374214
public void execute()
        throws MojoExecutionException, MojoFailureException
    {
        File jarFile = new File( outputDirectory, finalName + ".jar" );
        File origJarFile = new File( outputDirectory, finalName + "-b4gwt.jar" );
        if ( origJarFile.exists() )
        {
            if ( !origJarFile.delete() )
            {
                throw new MojoExecutionException( "Error removing " + origJarFile );
            }
        }
        if ( !jarFile.renameTo( origJarFile ) )
        {
            throw new MojoExecutionException( "Error renaming " + jarFile + " to " + origJarFile );
        }

        MavenArchiver archiver = new MavenArchiver();

        archiver.setArchiver( jarArchiver );
        archiver.setOutputFile( jarFile );
        archive.setForced( false );
        // It is already created by maven-jar-plugin
        archive.setAddMavenDescriptor( false );

        Collection<ResourceFile> files = getAllResourceFiles();
        try
        {

            // Avoid annoying messages in log "com/package/Ccc.java already added, skipping"
            List<String> jarExcludes = new Vector<String>();

            // Add Sources first since they may already be present in jar from previous run and changed.
            for ( ResourceFile file : files )
            {
                jarArchiver.addFile( new File( file.basedir, file.fileRelativeName ), file.fileRelativeName );
                jarExcludes.add( file.fileRelativeName );
            }

            // Add the context of original jar excluding resources that we just added base on GWT descriptors
            jarArchiver.addArchivedFileSet( origJarFile, null, jarExcludes.toArray( new String[jarExcludes.size()] ) );

            archiver.createArchive( session , getProject(), archive );
        }
        catch ( Exception e )
        {
            throw new MojoExecutionException( "Error assembling JAR", e );
        }

    }
973315
public int execute() throws IOException
   {
      outputDir.mkdirs();

      // some archetypes might not use maven or use the maven source layout so lets remove
      // the pom.xml and src folder if its already been pre-created
      // as these will be created if necessary via the archetype jar's contents
      File pom = new File(outputDir, "pom.xml");
      if (pom.isFile() && pom.exists()) {
         pom.delete();
      }
      File src = new File(outputDir, "src");
      if (src.isDirectory() && src.exists()) {
         recursiveDelete(src);
      }

      if (packageName == null || packageName.length() == 0)
      {
         packageName = groupId + "." + artifactId;
      }

      String packageDir = packageName.replace('.', '/');

      info("Creating archetype using Maven groupId: " +
               groupId + ", artifactId: " + artifactId + ", version: " + version
               + " in directory: " + outputDir);

      Map<String, String> replaceProperties = new HashMap<String, String>();

      ZipInputStream zip = null;
      try
      {
         zip = new ZipInputStream(archetypeIn);
         boolean ok = true;
         while (ok)
         {
            ZipEntry entry = zip.getNextEntry();
            if (entry == null)
            {
               ok = false;
            }
            else
            {
               if (!entry.isDirectory())
               {
                  String fullName = entry.getName();
                  if (fullName != null && fullName.startsWith(zipEntryPrefix))
                  {
                     String name = replaceFileProperties(fullName.substring(zipEntryPrefix.length()), replaceProperties);
                     debug("Processing resource: " + name);

                     int idx = name.lastIndexOf('/');
                     Matcher matcher = sourcePathRegexPattern.matcher(name);
                     String dirName;
                     if (packageName.length() > 0 && idx > 0 && matcher.matches())
                     {
                        String prefix = matcher.group(1);
                        dirName = prefix + packageDir + "/" + name.substring(prefix.length());
                     }
                     else if (packageName.length() > 0 && name.startsWith(webInfResources))
                     {
                        dirName = "src/main/webapp/WEB-INF/" + packageDir + "/resources"
                                 + name.substring(webInfResources.length());
                     }
                     else
                     {
                        dirName = name;
                     }

                     // lets replace properties...
                     File file = new File(outputDir, dirName);
                     file.getParentFile().mkdirs();
                     FileOutputStream out = null;
                     try
                     {
                        out = new FileOutputStream(file);
                        boolean isBinary = false;
                        for (String suffix : binarySuffixes)
                        {
                           if (name.endsWith(suffix))
                           {
                              isBinary = true;
                              break;
                           }
                        }
                        if (isBinary)
                        {
                           // binary file? don't transform.
                           Streams.write(zip, out);
                        }
                        else
                        {
                           // text file...
                           ByteArrayOutputStream bos = new ByteArrayOutputStream();
                           Streams.write(zip, bos);
                           String text = new String(bos.toByteArray(), "UTF-8");
                           out.write(transformContents(text, replaceProperties).getBytes());
                        }
                     }
                     finally
                     {
                        if (out != null)
                        {
                           out.close();
                        }
                     }
                  }
                  else if (fullName != null && fullName.equals("META-INF/maven/archetype-metadata.xml"))
                  {
                     // we assume that this resource will be first in Archetype's ZIP
                     // this way we can find out what are the required properties before we will actually use them
                     parseReplaceProperties(zip, replaceProperties);
                     replaceProperties.putAll(overrideProperties);
                  }
               }
               zip.closeEntry();
            }
         }
      }
      catch (Exception e)
      {
         throw new IOException(e.getMessage(), e);
      }
      finally
      {
         if (zip != null)
         {
            zip.close();
         }
      }

      info("Using replace properties: " + replaceProperties);

      // now lets replace all the properties in the pom.xml
      if (!replaceProperties.isEmpty())
      {
         String text;
         try (FileInputStream fis = new FileInputStream(pom))
         {
            text = Streams.toString(fis);
         }
         for (Map.Entry<String, String> e : replaceProperties.entrySet())
         {
            text = replaceVariable(text, e.getKey(), e.getValue());
         }
         try (FileWriter writer = new FileWriter(pom))
         {
            writer.write(text);
            writer.flush();
         }
      }

      // now lets create the default directories
      if (createDefaultDirectories && pom.exists())
      {
         File srcDir = new File(outputDir, "src");
         File mainDir = new File(srcDir, "main");
         File testDir = new File(srcDir, "test");

         String srcDirName = "java";
         // Who needs Scala in 2014?
         // if (new File(mainDir, "scala").exists() || new File(textDir, "scala").exists()) {
         // srcDirName = "scala";
         // }

         for (File dir : new File[] { mainDir, testDir })
         {
            for (String name : new String[] { srcDirName + "/" + packageDir, "resources" })
            {
               new File(dir, name).mkdirs();
            }
         }
      }

      return 0;
   }
852477
public void deploy() throws MojoExecutionException {
    stager.stage();

    DeployConfiguration config =
        configBuilder.buildDeployConfiguration(ImmutableList.of(deployMojo.getStagingDirectory()));

    try {
      deployMojo.getAppEngineFactory().deployment().deploy(config);
    } catch (AppEngineException ex) {
      throw new MojoExecutionException("App Engine application deployment failed", ex);
    }
  }
39204
public static EnterpriseArchive createEARDeployment() {

        final EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "scribble-test.ear");

        // use local maven repository mirror only
        final PomEquippedResolveStage pom = Maven.configureResolver().workOffline().loadPomFromFile("pom.xml");

        final File[] files = pom.importDependencies(ScopeType.COMPILE).resolve().withTransitivity().asFile();
        for (final File f : files) {
            if (f.getName().endsWith(".jar")) {
                LOG.debug("Adding lib {}", f);
                ear.addAsLibrary(f);
            }
        }
        return ear;
    }
1011577
public void execute() throws MojoFailureException, MojoExecutionException {
        // Validate
        validateArtifactInformation();

        Artifact artifact =
                artifactFactory.createArtifactWithClassifier( groupId, artifactId, version, packaging, classifier );

        File existingFile = getLocalRepoFile(artifact);
        if (existingFile != null && existingFile.exists()) {
            System.out.println("Using cached remapped artifact "+ existingFile.getPath()); // delete file to reinstall
            return; // success
        }

        // Remap
        File outJar = null;
        try {
            // load input jar(s), as one combined jar (for jarmods)
            List<File> files = new ArrayList<File>();
            for (String filename : inJars) {
                files.add(FileLocator.getFile(filename));
            }
            Jar inJar = Jar.init(files);

            // temporary output file
            outJar = File.createTempFile(groupId + "." + artifactId + "-" + version, "." + packaging);

            // mappings
            JarMapping mapping = new JarMapping();
            if (excludedPackages != null) {
                for (String packageName : excludedPackages) {
                    mapping.addExcludedPackage(packageName);
                }
            }
            mapping.loadMappings(srgIn, reverse, numeric, inShadeRelocation, outShadeRelocation);
            mapping.setFallbackInheritanceProvider(new JarProvider(inJar));


            // access transformers
            RemapperProcessor preprocessor = null;
            if (accessTransformers != null) {
                AccessMap accessMap = new AccessMap();

                for (String filename : accessTransformers) {
                    if (filename != null && filename.length() != 0) {
                        accessMap.loadAccessTransformer(filename);
                    }
                }

                preprocessor = new RemapperProcessor(null, null, accessMap);
            }

            // Do the remap
            JarRemapper remapper = new JarRemapper(preprocessor, mapping);
            remapper.setGenerateAPI(generateAPI);
            remapper.remapJar(inJar, outJar);
        } catch (Exception ex) {
            ex.printStackTrace();
            throw new MojoExecutionException("Error creating remapped jar at "+outJar+": " + ex.getMessage(), ex);
        }

        // Replace main artifact with this remapped artifact
        if (replaceMainArtifact) {
            getLog().info("Replacing original artifact with remapped artifact.");
            File originalArtifact = project.getArtifact().getFile();
            originalArtifact.delete();
            if (!outJar.renameTo(originalArtifact)) {
                throw new MojoExecutionException("Error replacing remapped jar at "+originalArtifact+" with "+outJar);
            }
        }

        // Attach output artifact to this project
        if (attachArtifact) {
            if (attachArtifactClassifier == null || attachArtifactClassifier.equals("")) {
                attachArtifactClassifier = null;
            }

            getLog().info("Attaching artifact " + outJar.getPath());
            projectHelper.attachArtifact(project, attachArtifactType, attachArtifactClassifier, outJar);
        }

        // Install output artifact to local repository
        if (installArtifact) {
            installArtifact(artifact, outJar);
        }
    }
773530
protected String getExecutableJar() throws IOException {
        Manifest manifest = new Manifest();
        manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
        manifest.getMainAttributes().put(Attributes.Name.MAIN_CLASS, MAIN);
        manifest.getMainAttributes().put(Attributes.Name.CLASS_PATH, getClasspath());

        Path jar = createTempDirectory("exec").resolve("generate.jar");
        try (JarOutputStream output = new JarOutputStream(Files.newOutputStream(jar), manifest)) {
            output.putNextEntry(new JarEntry("allure.properties"));
            Path allureConfig = PROPERTIES.getAllureConfig();
            if (Files.exists(allureConfig)) {
                byte[] bytes = Files.readAllBytes(allureConfig);
                output.write(bytes);
            }
            output.closeEntry();
        }

        return jar.toAbsolutePath().toString();
    }
136755
protected function createManifestFile()
    {
        $manifestXmlFileContents = <<<EOD
<?xml version="1.0" encoding="UTF-8"?>
<manifest:manifest xmlns:manifest="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0" manifest:version="1.2">
    <manifest:file-entry manifest:full-path="/" manifest:media-type="application/vnd.oasis.opendocument.spreadsheet"/>
    <manifest:file-entry manifest:full-path="styles.xml" manifest:media-type="text/xml"/>
    <manifest:file-entry manifest:full-path="content.xml" manifest:media-type="text/xml"/>
    <manifest:file-entry manifest:full-path="meta.xml" manifest:media-type="text/xml"/>
</manifest:manifest>
EOD;

        $this->createFileWithContents($this->metaInfFolder, self::MANIFEST_XML_FILE_NAME, $manifestXmlFileContents);

        return $this;
    }
1330759
public void execute() throws MojoExecutionException, MojoFailureException {
        try {
            removeFromResources(blocksDir);
            removeFromResources(resourcesDir);
            File targetDir = new File(outputDir);
            boolean jar = "jar".equalsIgnoreCase(mavenProject.getPackaging());
            if (jar) {
                JarBuilder builder = new JarBuilder(blocksDir, resourcesDir, targetDir, mavenProject, mavenSession, getLog());
                builder.generate();
            } else {
                WarBuilder builder = new WarBuilder(blocksDir, resourcesDir, targetDir, mavenProject, mavenSession, getLog());
                builder.generate();
            }
        } catch (Exception e) {
            throw new MojoFailureException("Source generator error", e);
        }
    }
893318
public final Artifact resolveArtifact(Artifact mavenArtifact) throws MojoExecutionException {
		final org.eclipse.aether.artifact.Artifact aetherArtifact = createArtifact(mavenArtifact);
		final ArtifactRequest request = new ArtifactRequest();
		request.setArtifact(aetherArtifact);
		request.setRepositories(getRemoteRepositoryList());
		final ArtifactResult result;
		try {
			result = getRepositorySystem().resolveArtifact(getRepositorySystemSession(), request);
		} catch (ArtifactResolutionException e) {
			throw new MojoExecutionException(e.getMessage(), e);
		}
		return createArtifact(result.getArtifact());
	}
1298775
private List copyDependencies( File javaDirectory )
        throws MojoExecutionException
    {

        ArtifactRepositoryLayout layout = new DefaultRepositoryLayout();

        List list = new ArrayList();

        File repoDirectory = new File(javaDirectory, "repo");
        repoDirectory.mkdirs();

        // First, copy the project's own artifact
        File artifactFile = project.getArtifact().getFile();
        list.add( repoDirectory.getName() +"/" +layout.pathOf(project.getArtifact()));

        try
        {
            FileUtils.copyFile( artifactFile, new File(repoDirectory, layout.pathOf(project.getArtifact())) );
        }
        catch ( IOException e )
        {
            throw new MojoExecutionException( "Could not copy artifact file " + artifactFile + " to " + javaDirectory );
        }

        Set artifacts = project.getArtifacts();

        Iterator i = artifacts.iterator();

        while ( i.hasNext() )
        {
            Artifact artifact = (Artifact) i.next();

            File file = artifact.getFile();
            File dest = new File(repoDirectory, layout.pathOf(artifact));

            getLog().debug( "Adding " + file );

            try
            {
                FileUtils.copyFile( file, dest);
            }
            catch ( IOException e )
            {
                throw new MojoExecutionException( "Error copying file " + file + " into " + javaDirectory, e );
            }

            list.add( repoDirectory.getName() +"/" + layout.pathOf(artifact) );
        }

        return list;

    }
307276
protected void internalExecute()
        throws MojoExecutionException, MojoFailureException
    {
        List<String> compileSourceRoots = getCompileSourceRoots();

        if ( compileSourceRoots.isEmpty() )// ?
        {
            getLog().info( "No sources to compile" );

            return;
        }

        List<File> sourceRootDirs = new ArrayList<File>( compileSourceRoots.size() );
        for ( String compileSourceRoot : compileSourceRoots )
        {
            sourceRootDirs.add( new File( compileSourceRoot ) );
        }

        List<File> sourceFiles = getSourceFiles( sourceRootDirs );
        if ( sourceFiles.isEmpty() )
        {
            getLog().info( "No sources to compile" );

            return;
        }

        try
        {
            Compiler sbtCompiler = getSbtCompiler();
            
            String resolvedScalaVersion = getScalaVersion( sbtCompiler );

            Artifact scalaLibraryArtifact =
                getResolvedArtifact( SCALA_GROUPID, SCALA_LIBRARY_ARTIFACTID, resolvedScalaVersion );
            if ( scalaLibraryArtifact == null )
            {
                throw new MojoExecutionException( String.format( "Required %s:%s:%s:jar artifact not found",
                                                                 SCALA_GROUPID, SCALA_LIBRARY_ARTIFACTID,
                                                                 resolvedScalaVersion ) );
            }

            Artifact scalaCompilerArtifact =
                getResolvedArtifact( SCALA_GROUPID, SCALA_COMPILER_ARTIFACTID, resolvedScalaVersion );
            if ( scalaCompilerArtifact == null )
            {
                throw new MojoExecutionException( String.format( "Required %s:%s:%s:jar artifact not found",
                                                                 SCALA_GROUPID, SCALA_COMPILER_ARTIFACTID,
                                                                 resolvedScalaVersion ) );
            }

            List<File> scalaExtraJars = getCompilerDependencies( scalaCompilerArtifact, scalaLibraryArtifact );

            String resolvedSbtVersion = sbtCompiler.getDefaultSbtVersion();

            Artifact xsbtiArtifact = getResolvedArtifact( SBT_GROUP_ID, XSBTI_ARTIFACT_ID, resolvedSbtVersion );
            if ( xsbtiArtifact == null )
            {
                throw new MojoExecutionException( String.format( "Required %s:%s:%s:jar dependency not found",
                                                                 SBT_GROUP_ID, XSBTI_ARTIFACT_ID, resolvedSbtVersion ) );
            }

            Artifact compilerInterfaceSrc =
                getResolvedArtifact( SBT_GROUP_ID, COMPILER_INTERFACE_ARTIFACT_ID, resolvedSbtVersion,
                                     COMPILER_INTERFACE_CLASSIFIER );
            if ( compilerInterfaceSrc == null )
            {
                throw new MojoExecutionException( String.format( "Required %s:%s:%s:%s:jar dependency not found",
                                                                 SBT_GROUP_ID, COMPILER_INTERFACE_ARTIFACT_ID,
                                                                 resolvedSbtVersion, COMPILER_INTERFACE_CLASSIFIER ) );
            }

            List<String> classpathElements = getClasspathElements();
            classpathElements.remove( getOutputDirectory().getAbsolutePath() );
            List<File> classpathFiles = new ArrayList<File>( classpathElements.size() );
            for ( String path : classpathElements )
            {
                classpathFiles.add( new File( path ) );
            }

            String resolvedScalacOptions = scalacOptions.trim();
            if ( _scalacOptions != null && _scalacOptions.length() > 0 )
            {
                resolvedScalacOptions = resolvedScalacOptions + ' ' + _scalacOptions;
            }

            if ( ( scalacPlugins != null && scalacPlugins.trim().length() > 0 )
                || ( _scalacPlugins != null && _scalacPlugins.trim().length() > 0 ) )
            {
                List<Artifact> resolvedScalaCompilerPluginArtifacts = new ArrayList<Artifact>();
                resolveArtifacts( resolvedScalaCompilerPluginArtifacts, scalacPlugins );
                resolveArtifacts( resolvedScalaCompilerPluginArtifacts, _scalacPlugins );
                for ( Artifact artifact: resolvedScalaCompilerPluginArtifacts )
                {
                    String arg = "-Xplugin:" + artifact.getFile().getAbsolutePath();
                    if ( arg.indexOf( ' ' ) >= 0 )
                    {
                        arg = '\"' + arg + '\"';
                    }
                    resolvedScalacOptions = resolvedScalacOptions + ' ' + arg;
                }
            }

            SourcePositionMapper sourcePositionMapper = null;
            if ( sbtCompiler.supportsSourcePositionMappers() )
            {
                if ( ( sourcePositionMappers != null && sourcePositionMappers.trim().length() > 0 )
                    || ( _sourcePositionMappers != null && _sourcePositionMappers.trim().length() > 0 ) )
                {
                    List<Artifact> resolvedSourcePositionMapperArtifacts = new ArrayList<Artifact>();
                    resolveArtifacts( resolvedSourcePositionMapperArtifacts, sourcePositionMappers );
                    resolveArtifacts( resolvedSourcePositionMapperArtifacts, _sourcePositionMappers );
                    if ( !resolvedSourcePositionMapperArtifacts.isEmpty() )
                    {
                        Set<Artifact> resolvedSourcePositionMapperArtifactSet =
                            getAllDependencies( new HashSet<Artifact>( resolvedSourcePositionMapperArtifacts ), null /* filter */ );
                        List<SourcePositionMapper> resolvedSourcePositionMappers =
                            resolveSourcePositionMappers( resolvedSourcePositionMapperArtifactSet );
                        if ( resolvedSourcePositionMappers != null )
                        {
                            sourcePositionMapper = new SourcePositionMapperCollection( resolvedSourcePositionMappers );
                            sourcePositionMapper.setCharsetName( sourceEncoding );
                        }
                    }
                }
            }

            CompilerConfiguration configuration = new CompilerConfiguration();
            configuration.setSourceFiles( sourceFiles );
            configuration.setScalaLibraryFile( scalaLibraryArtifact.getFile() );
            configuration.setScalaCompilerFile( scalaCompilerArtifact.getFile() );
            configuration.setScalaExtraJarFiles( scalaExtraJars );
            configuration.setXsbtiFile( xsbtiArtifact.getFile() );
            configuration.setCompilerInterfaceSrcFile( compilerInterfaceSrc.getFile() );
            configuration.setClasspathFiles( classpathFiles );
            configuration.setLogger( new MavenCompilerLogger( getLog() ) );
            configuration.setOutputDirectory( getOutputDirectory() );
            configuration.setSourceEncoding( sourceEncoding );
            configuration.setJavacOptions( javacOptions );
            configuration.setScalacOptions( resolvedScalacOptions );
            configuration.setAnalysisCacheFile( getAnalysisCacheFile() );
            configuration.setAnalysisCacheMap( getAnalysisCacheMap() );
            configuration.setSourcePositionMapper( sourcePositionMapper );

            sbtCompiler.performCompile( configuration );
        }
        catch ( CompilerException e )
        {
            throw new MojoFailureException( "Scala compilation failed", e );
        }
        catch ( ArtifactNotFoundException e )
        {
            throw new MojoExecutionException( "Scala compilation failed", e );
        }
        catch ( ArtifactResolutionException e )
        {
            throw new MojoExecutionException( "Scala compilation failed", e );
        }
        catch ( MalformedURLException e )
        {
            throw new MojoExecutionException( "Scala compilation failed", e );
        }
    }
744917
public void execute() throws MojoExecutionException {
        getLog().debug("starting packaging");
        
        AbstractConfiguration[] configurations= (AbstractConfiguration[]) getPluginContext().get(ConfiguratorMojo.GENERATED_CONFIGURATIONS_KEY);
        
        try {
            for(AbstractConfiguration configuration : configurations) {
                if(!(configuration instanceof NodeConfiguration)) {
                    continue;
                }
                
                String classifier= configuration.className.substring(configuration.className.lastIndexOf('.') + 1);
                File jarFile= checkJarFile(classifier);
                JavaApplicationDescriptor descriptor= getDescriptor();
                descriptor.setNodeConfiguration(configuration.className);
                descriptor.setJarFile(jarFile);
                File jadFile= getJadFile(classifier);
                getDescriptor().writeDescriptor(jadFile);
                getProjectHelper().attachArtifact(getProject(), "jad", classifier, jadFile);
            }
        } catch (IOException ioe) {
            throw new MojoExecutionException("could not create .jad file", ioe);
        } catch (RuntimeException e) {
            throw new MojoExecutionException("could not create .jad file", e);
        }
        getLog().debug("finished packaging");
    }
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);
    }
  }
308826
URLClassLoader createUrlClassLoader(
            final List<String> classpathElements,
            final ClassLoader contextClassLoader)
            throws MojoExecutionException {
        try {
            final URL[] urls = new URL[classpathElements.size()];
            int i = 0;
            for (final String classpathElement : classpathElements) {
                urls[i++] = new File(classpathElement).toURI().toURL();
            }
            return URLClassLoader.newInstance(urls, contextClassLoader);
        } catch (final MalformedURLException e) {
            throw new MojoExecutionException("Unable to instantiate class loader", e);
        }
    }
953872
private void createVcProjFile(final Project antProject, final Library library)
      throws MojoExecutionException, MojoFailureException {

    // configure task
    final CCTask task = new CCTask();
    task.setProject(antProject);
    task.setDebug(true);

    // subsystem (console)
    final SubsystemEnum subSystem = new SubsystemEnum();
    subSystem.setValue(library.getSubSystem());
    task.setSubsystem(subSystem);

    // outtype
    final OutputTypeEnum outTypeEnum = new OutputTypeEnum();
    final String type = library.getType();
    outTypeEnum.setValue(type);
    task.setOuttype(outTypeEnum);

    // stdc++
    task.setLinkCPP(library.linkCPP());

    // TODO: this should match the standard NAR location defined by layout
    // similar to Nar Compile
    // outDir
    File outDir = new File(getTargetDirectory(), "bin");
    outDir = new File(outDir, getAOL().toString());
    outDir.mkdirs();

    // outFile
    final File outFile = new File(outDir, getOutput(getAOL(), type));

    getLog().debug("NAR - output: '" + outFile + "'");
    task.setOutfile(outFile);

    // object directory
    File objDir = new File(getTargetDirectory(), "obj");
    objDir = new File(objDir, getAOL().toString());
    objDir.mkdirs();
    task.setObjdir(objDir);

    // failOnError, libtool
    task.setFailonerror(failOnError(getAOL()));
    task.setLibtool(useLibtool(getAOL()));

    // runtime
    final RuntimeType runtimeType = new RuntimeType();
    runtimeType.setValue(getRuntime(getAOL()));
    task.setRuntime(runtimeType);

    // add C++ compiler
    final CompilerDef cpp = getCpp().getCompiler(Compiler.MAIN, null);
    if (cpp != null) {
      task.addConfiguredCompiler(cpp);
    }

    // add VCPROJ_MOJO def (see UnitTestDriverImpl.cpp generated by Krusoe
    // plugin)
    final DefineSet defineSet = new DefineSet();
    final DefineArgument defineArgument = new DefineArgument();
    defineArgument.setName("VCPROJ_MOJO");
    defineSet.addDefine(defineArgument);
    cpp.addConfiguredDefineset(defineSet);

    // add javah include path
    final File jniDirectory = getJavah().getJniDirectory();
    if (jniDirectory.exists()) {
      task.createIncludePath().setPath(jniDirectory.getPath());
    }

    // add java include paths
    getJava().addIncludePaths(task, Library.EXECUTABLE);

    getMsvc().configureCCTask(task);

    final List<NarArtifact> dependencies = getNarArtifacts();
    // add dependency include paths
    for (final Object element : dependencies) {
      // FIXME, handle multiple includes from one NAR
      final NarArtifact narDependency = (NarArtifact) element;
      final String binding = narDependency.getNarInfo().getBinding(getAOL(), Library.STATIC);
      getLog().debug("Looking for " + narDependency + " found binding " + binding);
      if (!binding.equals(Library.JNI)) {
        final File unpackDirectory = getUnpackDirectory();
        final File include = getLayout().getIncludeDirectory(unpackDirectory, narDependency.getArtifactId(),
            narDependency.getBaseVersion());
        getLog().debug("Looking for directory: " + include);
        if (include.exists()) {
          task.createIncludePath().setPath(include.getPath());
        } else {
          getLog().warn(String.format("Unable to locate %1$s lib include path '%2$s'", binding, include));
        }
      }
    }

    // add linker
    final LinkerDef linkerDefinition = getLinker().getLinker(this, task, getOS(), getAOL().getKey() + ".linker.",
        type, null);
    task.addConfiguredLinker(linkerDefinition);

    // add dependency libraries
    // FIXME: what about PLUGIN and STATIC, depending on STATIC, should we
    // not add all libraries, see NARPLUGIN-96
    if (type.equals(Library.SHARED) || type.equals(Library.JNI) || type.equals(Library.EXECUTABLE)) {

      final List depLibOrder = getDependencyLibOrder();
      List depLibs = dependencies;

      // reorder the libraries that come from the nar dependencies
      // to comply with the order specified by the user
      if (depLibOrder != null && !depLibOrder.isEmpty()) {

        final List tmp = new LinkedList();

        for (final Object aDepLibOrder : depLibOrder) {

          final String depToOrderName = (String) aDepLibOrder;

          for (final Iterator j = depLibs.iterator(); j.hasNext(); ) {

            final NarArtifact dep = (NarArtifact) j.next();
            final String depName = dep.getGroupId() + ":" + dep.getArtifactId();

            if (depName.equals(depToOrderName)) {

              tmp.add(dep);
              j.remove();
            }
          }
        }

        tmp.addAll(depLibs);
        depLibs = tmp;
      }

      for (final Object depLib : depLibs) {

        final NarArtifact dependency = (NarArtifact) depLib;

        // FIXME no handling of "local"

        // FIXME, no way to override this at this stage
        final String binding = dependency.getNarInfo().getBinding(getAOL(), Library.STATIC);
        getLog().debug("Using Binding: " + binding);
        AOL aol = getAOL();
        aol = dependency.getNarInfo().getAOL(getAOL());
        getLog().debug("Using Library AOL: " + aol.toString());

        if (!binding.equals(Library.JNI) && !binding.equals(Library.NONE) && !binding.equals(Library.EXECUTABLE)) {
          final File unpackDirectory = getUnpackDirectory();
          final File dir = getLayout()
              .getLibDirectory(unpackDirectory, dependency.getArtifactId(), dependency.getBaseVersion(), aol.toString(),
                  binding);
          getLog().debug("Looking for Library Directory: " + dir);
          if (dir.exists()) {
            final LibrarySet libSet = new LibrarySet();
            libSet.setProject(antProject);

            // FIXME, no way to override
            final String libs = dependency.getNarInfo().getLibs(getAOL());
            if (libs != null && !libs.equals("")) {
              getLog().debug("Using LIBS = " + libs);
              libSet.setLibs(new CUtil.StringArrayBuilder(libs));
              libSet.setDir(dir);
              task.addLibset(libSet);
            }
          } else {
            getLog().debug("Library Directory " + dir + " does NOT exist.");
          }

          // FIXME, look again at this, for multiple dependencies we
          // may need to remove duplicates
          final String options = dependency.getNarInfo().getOptions(getAOL());
          if (options != null && !options.equals("")) {
            getLog().debug("Using OPTIONS = " + options);
            final LinkerArgument arg = new LinkerArgument();
            arg.setValue(options);
            linkerDefinition.addConfiguredLinkerArg(arg);
          }

          final String sysLibs = dependency.getNarInfo().getSysLibs(getAOL());

          if (sysLibs != null && !sysLibs.equals("")) {
            getLog().debug("Using SYSLIBS = " + sysLibs);
            final SystemLibrarySet sysLibSet = new SystemLibrarySet();
            sysLibSet.setProject(antProject);

            sysLibSet.setLibs(new CUtil.StringArrayBuilder(sysLibs));

            task.addSyslibset(sysLibSet);
          }
        }
      }

      // Add JVM to linker
      getJava().addRuntime(task, getJavaHome(getAOL()), getOS(), getAOL().getKey() + "java.");

      // DS: generate project file
      getLog().debug("NAR: Writing project file...");
      final ProjectWriterEnum projectWriterEnum = new ProjectWriterEnum();
      projectWriterEnum.setValue("msvc8");
      final ProjectDef projectDef = new ProjectDef();
      projectDef.setType(projectWriterEnum);
      String filename = null;
      try {
        final File outputDir = new File(getTargetDirectory(), "vcproj");
        if (!outputDir.exists()) {
          final boolean succeeded = outputDir.mkdir();
          if (!succeeded) {
            throw new MojoExecutionException("Unable to create directory: " + outputDir);
          }
        }
        filename = outputDir + "/" + getMavenProject().getArtifactId();
        final File projFile = new File(filename);
        projectDef.setOutfile(projFile.getCanonicalFile());
      } catch (final IOException e) {
        throw new MojoExecutionException("Unable to create file: " + filename, e);
      }
      task.addProject(projectDef);
      task.setProjectsOnly(true);

      // we always want an EXE for debugging
      task.setOuttype(new OutputTypeEnum());

      // execute
      try {
        task.execute();
        getLog().info("Wrote project file: " + filename + ".vcproj");
      } catch (final BuildException e) {
        throw new MojoExecutionException("NAR: Compile failed", e);
      }
    }
  }