Package org.apache.maven.archiver

Examples of org.apache.maven.archiver.MavenArchiver


                        null,
                        ATTACHED_ARTIFACT_TYPE);

                File modelJar = new File(workDirectory, finalName + "." + ATTACHED_ARTIFACT_TYPE);

                final MavenArchiver modelJarArchiver = new MavenArchiver();

                modelJarArchiver.setArchiver(this.modelJarArchiver);
                modelJarArchiver.setOutputFile(modelJar);
                modelJarArchiver.getArchiver().addDirectory(
                    new File(this.outputDirectory),
                    JAR_INCLUDES,
                    JAR_EXCLUDES);

                // - create archive
                modelJarArchiver.createArchive(
                    project,
                    archive);

                // - set the artifact file as the modelJar so that we can install the model jar
                jarArtifact.setFile(modelJar);
View Full Code Here


                    }
                }
            }
            final File cartridgeFile = new File(buildDirectory, this.finalName + ".jar");
            final Artifact artifact = this.project.getArtifact();
            final MavenArchiver archiver = new MavenArchiver();
            archiver.setArchiver(this.jarArchiver);
            archiver.setOutputFile(cartridgeFile);
            archiver.getArchiver().addDirectory(
                outputDirectory,
                OUTPUT_INCLUDES,
                null);
            archiver.createArchive(
                this.project,
                this.archive);
            artifact.setFile(cartridgeFile);
        }
        catch (final Throwable throwable)
View Full Code Here

                }
            }

            this.getLog().info("Bundled " + bundledFilesCount + " files");

            final MavenArchiver archiver = new MavenArchiver();
            archiver.setArchiver(this.binArchiver);
            archiver.setOutputFile(distribution);

            archiver.getArchiver().addDirectory(
                directory,
                new String[] {"**/*"},
                null);

            // - create archive
            archiver.createArchive(
                this.project,
                this.archive);
        }
        catch (final Throwable throwable)
        {
View Full Code Here

        File xarFile = new File(outputDirectory, xarName + ".xar");

        // generate xar file
        getLog().info("Generating XAR " + xarFile.getAbsolutePath());
        MavenArchiver archiver = new MavenArchiver();
        archiver.setArchiver(jarArchiver);
        archiver.setOutputFile(xarFile);
        try {
            buildArchive(jarArchiver);
        } catch (ArchiverException e) {
            throw new MojoExecutionException("Unable to build archive", e);
        }

        // create archive
        try {
            archiver.createArchive(project, archive);
        } catch (Exception e) {
            throw new MojoExecutionException("Unable to create archive", e);
        }

        if (classifier != null) {
View Full Code Here

    private File createArchive(List<Artifact> bundles) throws MojoExecutionException {
        ArtifactRepositoryLayout layout = new DefaultRepositoryLayout();
        File archiveFile = getArchiveFile(outputDirectory, finalName, null);

        MavenArchiver archiver = new MavenArchiver();
        MavenArchiveConfiguration configuration = new MavenArchiveConfiguration();
        archiver.setArchiver(jarArchiver);
        archiver.setOutputFile(archiveFile);

        try {
            // include the features XML file
            Artifact featureArtifact = factory.createArtifactWithClassifier(project.getGroupId(), project.getArtifactId(), project.getVersion(), "xml", KarArtifactInstaller.FEATURES_CLASSIFIER);
            jarArchiver.addFile(featuresFile, repositoryPath + layout.pathOf(featureArtifact));

            for (Artifact artifact : bundles) {
                resolver.resolve(artifact, remoteRepos, localRepo);
                File localFile = artifact.getFile();
                // TODO this may not be reasonable, but... resolved snapshot artifacts have timestamped versions
                // which do not work in startup.properties
                artifact.setVersion(artifact.getBaseVersion());
                String targetFileName = repositoryPath + layout.pathOf(artifact);
                jarArchiver.addFile(localFile, targetFileName);
            }

            if (resourcesDir.isDirectory()) {
                archiver.getArchiver().addDirectory(resourcesDir);
            }

            archiver.createArchive(project, configuration);

            return archiveFile;
        } catch (Exception e) {
            throw new MojoExecutionException("Failed to create kar archive", e);
        }
View Full Code Here

        {
            /*
             * Grab customized manifest entries from the maven-jar-plugin configuration
             */
            MavenArchiveConfiguration archiveConfig = JarPluginConfiguration.getArchiveConfiguration( currentProject );
            String mavenManifestText = new MavenArchiver().getManifest( currentProject, archiveConfig ).toString();
            addMavenDescriptor = addMavenDescriptor && archiveConfig.isAddMavenDescriptor();

            Manifest mavenManifest = new Manifest();

            // First grab the external manifest file (if specified and different to target location)
View Full Code Here

     * Generates the configuration archive.
     */
    private File createArchive() throws MojoExecutionException {
        File archiveFile = getArchiveFile(outputDirectory, finalName, null);

        MavenArchiver archiver = new MavenArchiver();
        archiver.setArchiver(jarArchiver);
        archiver.setOutputFile(archiveFile);

        try {
            // Incldue the generated artifact contents
            File artifactDirectory = getArtifactInRepositoryDir();
            if (artifactDirectory.exists()) {
                archiver.getArchiver().addDirectory(artifactDirectory);
            }

            // Include the optional classes.resources
            if (classesDirectory.isDirectory()) {
                archiver.getArchiver().addDirectory(classesDirectory);
            }

            if (resourcesDir.isDirectory()) {
                archiver.getArchiver().addDirectory(resourcesDir);
            }

            //
            // HACK: Include legal files here for sanity
            //

            //
            // NOTE: Would be nice to share this with the copy-legal-files mojo
            //
            String[] includes = {
                "LICENSE.txt",
                "LICENSE",
                "NOTICE.txt",
                "NOTICE",
                "DISCLAIMER.txt",
                "DISCLAIMER"
            };

            archiver.getArchiver().addDirectory(baseDirectory, "META-INF/", includes, new String[0]);

            if (classpath != null) {
                archive.addManifestEntry("Class-Path", getClassPath());
            }

            archiver.createArchive(project, archive);

            return archiveFile;
        }
        catch (Exception e) {
            throw new MojoExecutionException("Failed to create archive", e);
View Full Code Here

    public void execute()
        throws MojoExecutionException
    {
        File jarFile = new File( outputDirectory, finalName + "-it.jar" );

        MavenArchiver archiver = new MavenArchiver();

        archiver.setArchiver( new JarArchiver() );

        archiver.setOutputFile( jarFile );

        try
        {
            archiver.createArchive( project, new MavenArchiveConfiguration() );
        }
        catch ( Exception e )
        {
            // TODO: improve error handling
            throw new MojoExecutionException( "Error assembling JAR", e );
View Full Code Here

            // generate war file
            getLog().info(
                    "Generating shared library "
                            + installerFile.getAbsolutePath());
            MavenArchiver archiver = new MavenArchiver();
            archiver.setArchiver(jarArchiver);
            archiver.setOutputFile(installerFile);
            jarArchiver.addDirectory(workDirectory);
            if (jbiSourceDirectory.isDirectory()) {
                jarArchiver.addDirectory(jbiSourceDirectory, null,
                        DirectoryScanner.DEFAULTEXCLUDES);
            }
            // create archive
            archiver.createArchive(getProject(), archive);

        } catch (Exception e) {
            throw new JbiPluginException("Error creating shared library: "
                    + e.getMessage(), e);
        }
View Full Code Here

            // generate war file
            getLog().info(
                    "Generating service unit "
                            + installerFile.getAbsolutePath());
            MavenArchiver archiver = new MavenArchiver();
            archiver.setArchiver(jarArchiver);
            archiver.setOutputFile(installerFile);
            jarArchiver.addDirectory(workDirectory);

            // create archive
            archiver.createArchive(getProject(), archive);

        } catch (ArchiverException e) {
            throw new JbiPluginException("Error creating service unit: "
                    + e.getMessage(), e);
        } catch (ManifestException e) {
View Full Code Here

TOP

Related Classes of org.apache.maven.archiver.MavenArchiver

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.