Package org.apache.maven.artifact

Examples of org.apache.maven.artifact.Artifact


     */
    private void buildContentsMap(final Model model, final RunMode runMode, final Map<String, File> contentsMap, final boolean isBoot)
    throws MojoExecutionException{
        for(final ArtifactGroup group : runMode.getArtifactGroups()) {
            for(final org.apache.sling.provisioning.model.Artifact a : group) {
                final Artifact artifact = ModelUtils.getArtifact(this.project, this.mavenSession, this.artifactHandlerManager, this.resolver, a.getGroupId(), a.getArtifactId(), a.getVersion(), a.getType(), a.getClassifier());
                final File artifactFile = artifact.getFile();
                contentsMap.put(getPathForArtifact(group.getStartLevel(), artifactFile.getName(), runMode, isBoot), artifactFile);
            }
        }

        final File rootConfDir = new File(this.getTmpDir(), "global-config");
View Full Code Here


     * Return the base artifact
     */
    private Artifact getBaseArtifact(final Model model, final String classifier, final String type) throws MojoExecutionException {
        final org.apache.sling.provisioning.model.Artifact baseArtifact = ModelUtils.getBaseArtifact(model);

        final Artifact a = ModelUtils.getArtifact(this.project,  this.mavenSession, this.artifactHandlerManager, this.resolver,
                baseArtifact.getGroupId(),
                baseArtifact.getArtifactId(),
                baseArtifact.getVersion(),
                type,
                classifier);
View Full Code Here

            type = BuildConstants.TYPE_JAR;
        } else {
            classifier = BuildConstants.CLASSIFIER_WEBAPP;
            type = BuildConstants.TYPE_WAR;
        }
        final Artifact artifact = this.getBaseArtifact(model, classifier, type);
        unpack(artifact.getFile(), outputDirectory);
    }
View Full Code Here

            final ArtifactResolver resolver,
            final MavenProject project,
            final MavenSession session,
            final Dependency d)
    throws MavenExecutionException {
        final Artifact prjArtifact = new DefaultArtifact(d.getGroupId(),
                d.getArtifactId(),
                VersionRange.createFromVersion(d.getVersion()),
                Artifact.SCOPE_PROVIDED,
                d.getType(),
                d.getClassifier(),
                artifactHandlerManager.getArtifactHandler(d.getType()));
        try {
            resolver.resolve(prjArtifact, project.getRemoteArtifactRepositories(), session.getLocalRepository());
        } catch (final ArtifactResolutionException e) {
            throw new MavenExecutionException("Unable to get artifact for " + d, e);
        } catch (final ArtifactNotFoundException e) {
            throw new MavenExecutionException("Unable to get artifact for " + d, e);
        }
        return prjArtifact.getFile();
    }
View Full Code Here

            }
        }
    }

    protected void copy(ArtifactDefinition additionalBundle, File outputDirectory) throws MojoExecutionException {
        Artifact artifact = getArtifact(additionalBundle);
        copy(artifact.getFile(), additionalBundle.getStartLevel(), additionalBundle.getRunModes(), outputDirectory);
    }
View Full Code Here

            }
        }
    }

    private void copyBaseArtifact() throws MojoExecutionException {
        Artifact artifact = getBaseArtifact();
        if (artifact == null) {
            throw new MojoExecutionException(
                    String.format("Project doesn't have a base dependency of groupId %s and artifactId %s",
                                    base.getGroupId(), base.getArtifactId()));
        }
        File destinationDir = new File(getOutputDirectory(), baseDestination);
        File destinationFile = new File(destinationDir, artifact
                .getArtifactId()
                + "." + artifact.getArtifactHandler().getExtension());

        // check if custom sling.properties file or bootstrap command exists
        final Properties additionalProps = this.getSlingProperties(JAR.equals(this.packaging));
        final String bootstrapCmd = this.getSlingBootstrap(JAR.equals(this.packaging));
        if ( additionalProps != null || bootstrapCmd != null ) {
            // unpack to a temp destination
            final File dest = new File(this.tempDirectory, "basejar");
            try {
                unpack(artifact.getFile(), dest);

                // patch sling properties
                if ( additionalProps != null ) {
                    this.patchSlingProperties(dest, additionalProps);
                }

                // patch bootstrap command
                if  ( bootstrapCmd != null ) {
                    this.patchSlingBootstrap(dest, bootstrapCmd);
                }

                // and repack again
                pack(dest, destinationFile);
            } finally {
                this.tempDirectory.delete();
            }
        } else {
            // we can just copy
            if (shouldCopy(artifact.getFile(), destinationFile)) {
                try {
                    getLog().info(
                            String.format("Copying base artifact from %s to %s.",
                                    artifact.getFile(), destinationFile));
                    FileUtils.copyFile(artifact.getFile(), destinationFile);
                } catch (IOException e) {
                    throw new MojoExecutionException(
                            "Unable to copy base artifact.", e);
                }
            } else {
                getLog().debug(
                        String.format("Skipping copy of base artifact from %s.",
                                artifact.getFile()));
            }
        }
    }
View Full Code Here

            }
        }
    }

    private Artifact getBaseArtifact() throws MojoExecutionException {
        Artifact baseDependency = getBaseDependency();
        if (baseDependency == null) {
            return null;
        }

        return getArtifact(base.getGroupId(), base.getArtifactId(),
                baseDependency.getVersion(), base.getType(), base
                        .getClassifier());

    }
View Full Code Here

        }
        return buildOutputDirectory;
    }

    protected void unpackBaseArtifact() throws MojoExecutionException {
        Artifact artifact = getBaseDependency();
        if (artifact == null) {
            throw new MojoExecutionException(
                    String
                            .format(
                                    "Project doesn't have a base dependency of groupId %s and artifactId %s",
                                    base.getGroupId(), base.getArtifactId()));
        }
        unpack(artifact.getFile(), buildOutputDirectory);
    }
View Full Code Here

    private void addBundles() throws MojoExecutionException {
        BundleList bundles = getInitializedBundleList();

        for (StartLevel level : bundles.getStartLevels()) {
            for (Bundle bundle : level.getBundles()) {
                Artifact artifact = getArtifact(new ArtifactDefinition(bundle,
                        level.getStartLevel()));
                final String destFileName = getPathForArtifact(level.getStartLevel(), bundle.getRunModes(), artifact.getFile().getName());
                try {
                    jarArchiver.addFile(artifact.getFile(), destFileName);
                } catch (ArchiverException e) {
                    throw new MojoExecutionException(
                            "Unable to add file to bundle jar file: "
                                    + artifact.getFile().getAbsolutePath(), e);
                }
            }
        }
    }
View Full Code Here

            if (tokens.length >= 4)
                packaging = tokens[3];
            if (tokens.length == 5)
                classifier = tokens[4];
        }
        Artifact packageArtifact = artifactFactory.createArtifactWithClassifier(groupId, artifactId, version, packaging, classifier);

        if (pomRemoteRepositories == null) {
            pomRemoteRepositories = new ArrayList();
        }

        List repoList = new ArrayList(pomRemoteRepositories);

        if (repositoryUrl != null) {
            ArtifactRepositoryPolicy policy =
                new ArtifactRepositoryPolicy( true, ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS,
                                              ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN );
            ArtifactRepository remoteRepo = artifactRepositoryFactory.createArtifactRepository(repositoryId, repositoryUrl,
                    repositoryLayout, policy, policy);

            repoList.add(remoteRepo);
        }

        try {
            artifactResolver.resolve(packageArtifact, repoList, localRepository);
            getLog().info("Resolved artifact to " + packageArtifact.getFile().getAbsolutePath());
        } catch (AbstractArtifactResolutionException e) {
            throw new MojoExecutionException("Couldn't download artifact: " + e.getMessage(), e);
        }

        return packageArtifact.getFile().getAbsolutePath();
    }
View Full Code Here

TOP

Related Classes of org.apache.maven.artifact.Artifact

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.