Examples of Artifact


Examples of org.apache.maven.artifact.Artifact

    protected List getProvidedClasspathElements()
    {
        final List classpathElements = new ArrayList();
        for (final Iterator iterator = this.project.getDependencies().iterator(); iterator.hasNext();)
        {
            final Artifact artifact = this.getArtifact(
                (Dependency)iterator.next(),
                Artifact.SCOPE_PROVIDED);
            if (artifact != null)
            {
                classpathElements.add(artifact.getFile().getAbsolutePath());
            }
        }
        return classpathElements;
    }
View Full Code Here

Examples of org.apache.maven.artifact.Artifact

     */
    private Artifact getArtifact(
        final Dependency dependency,
        final String scope)
    {
        Artifact artifact = null;
        final ArtifactRepository localRepository = this.localRepository;
        final MavenProject project = this.project;
        if (project != null && localRepository != null)
        {
            if (dependency != null)
            {
                artifact =
                    this.factory.createArtifact(
                        dependency.getGroupId(),
                        dependency.getArtifactId(),
                        dependency.getVersion(),
                        scope,
                        dependency.getType());
                final File file = new File(
                        localRepository.getBasedir(),
                        localRepository.pathOf(artifact));
                artifact.setFile(file);
            }
        }
        return artifact;
    }
View Full Code Here

Examples of org.apache.maven.artifact.Artifact

            final File earDirectory =
                new File(this.project.getBuild().getDirectory() + '/' + project.getBuild().getFinalName());
            final Map artifacts = new LinkedHashMap();
            for (final Iterator iterator = this.getExplodedModuleArtifacts().iterator(); iterator.hasNext();)
            {
                final Artifact artifact = (Artifact)iterator.next();
                artifacts.put(
                    artifact.getFile().toString().replaceAll(
                        ".*(\\\\|//)",
                        ""),
                    artifact);
            }

            if (earDirectory.exists() && earDirectory.isDirectory())
            {
                String linkCommand;
                if (isWindows)
                {
                    linkCommand = LN_WINDOWS;
                    final File executableFile =
                        new File(System.getProperty("java.io.tmpdir") + '/' + System.getProperty("user.name"),
                            LN_WINDOWS);
                    if (!executableFile.exists())
                    {
                        final URL resource =
                            Thread.currentThread().getContextClassLoader().getResource(LN_WINDOWS);
                        FileUtils.copyURLToFile(
                            resource,
                            executableFile);
                    }
                    linkCommand = executableFile.toString();
                }
                else
                {
                    linkCommand = LN_UNIX;
                }
                final File[] files = earDirectory.listFiles();
                final File explodedEarDirectory = new File(earDirectory + "-exploded");
                explodedEarDirectory.mkdirs();
                for (int ctr = 0; ctr < files.length; ctr++)
                {
                    final File file = files[ctr];
                    final String fileName = file.toString().replaceAll(
                            ".*(\\\\|//)",
                            "");
                    final Artifact artifact = (Artifact)artifacts.get(fileName);
                    if (artifact == null)
                    {
                        if (file.isFile())
                        {
                            FileUtils.copyFileToDirectory(
                                file,
                                explodedEarDirectory);
                        }
                        else
                        {
                            final File targetDirectory = new File(explodedEarDirectory,
                                    file.getName());
                            targetDirectory.mkdir();
                            FileUtils.copyDirectory(
                                file,
                                targetDirectory);
                        }
                    }
                    else
                    {
                        final File targetFile = new File(explodedEarDirectory, fileName);
                        final File explodedArtifactDirectory =
                            new File(artifact.getFile().toString().replaceAll(
                                    "\\." + artifact.getType(),
                                    ""));

                        final String command;
                        if (!isWindows)
                        {
View Full Code Here

Examples of org.apache.maven.artifact.Artifact

            for (Parent parent = model.getParent(); version == null && model.getParent() != null;
                parent = model.getParent())
            {
                version = parent.getVersion();
            }
            final Artifact artifact =
                this.artifactFactory.createArtifact(
                    groupId,
                    model.getArtifactId(),
                    version,
                    null,
                    model.getPackaging());
            final File pomParent = pom.getParentFile();
            final String finalName = model.getArtifactId() + "-" + version;
            final File explodedDirectory = new File(pomParent, "target/" + finalName);
            final File artifactFile = new File(explodedDirectory + "." + model.getPackaging());
            if (explodedDirectory.isDirectory() && artifactFile.exists() &&
                !finalName.equals(this.project.getBuild().getFinalName()))
            {
                artifacts.add(artifact);
                artifact.setFile(artifactFile);
            }
        }
        return artifacts;
    }
View Full Code Here

Examples of org.apache.maven.artifact.Artifact

                final File installDirectory = new File(this.installDirectory);
                if (!installDirectory.exists() || !installDirectory.isDirectory())
                {
                    throw new MojoExecutionException("'" + installDirectory + "' is not a valid install directory");
                }
                Artifact artifact = this.project.getArtifact();

                final String path = this.replaceExtension(
                        artifact,
                        JAR_EXTENSION);
                final String localRepositoryDirectory = this.localRepository.getBasedir();
                final File existingFile = new File(localRepositoryDirectory, path);
                final String bootstrapGroupId = this.getBootstrapGroupId(artifact);
                final String bootstrapPath = bootstrapGroupId.replace(
                        '.',
                        '/') + '/' + artifact.getArtifactId();
                final File bootstrapFile = new File(installDirectory, bootstrapPath + '.' + JAR_EXTENSION);
                this.getLog().info("Installing bootstrap artifact: " + bootstrapFile);
                FileUtils.copyFile(
                    existingFile,
                    bootstrapFile);
View Full Code Here

Examples of org.apache.maven.artifact.Artifact

            // - remove the parent
            final Parent parent = model.getParent();
            final List dependencies = new ArrayList(model.getDependencies());
            final String groupId = model.getGroupId();
            final Artifact artifact = this.project.getArtifact();
            final Build build = this.project.getBuild();
            final List developers = new ArrayList(model.getDevelopers());
            final List contributors = new ArrayList(model.getContributors());
            model.setGroupId(this.getBootstrapGroupId(artifact));
            model.setParent(null);
View Full Code Here

Examples of org.apache.maven.artifact.Artifact

                projects.add(this.getRootProject());
                final Set artifacts = new LinkedHashSet();
                for (final Iterator iterator = projects.iterator(); iterator.hasNext();)
                {
                    final MavenProject project = (MavenProject)iterator.next();
                    final Artifact artifact =
                        this.artifactFactory.createArtifact(
                            project.getGroupId(),
                            project.getArtifactId(),
                            project.getVersion(),
                            null,
                            project.getPackaging());
                    final String artifactPath = this.localRepository.pathOf(artifact);
                    final String artifactFileName = artifactPath.replaceAll(
                            ".*(\\\\|/+)",
                            "");
                    final String repositoryDirectoryPath =
                        artifactPath.substring(
                            0,
                            artifactPath.indexOf(artifactFileName));
                    final Build build = project.getBuild();
                    final File workDirectory = new File(build.getDirectory());
                    final File distributionDirectory =
                        new File(new File(
                                directory,
                                this.artifactDirectory), repositoryDirectoryPath);
                    if (workDirectory.exists())
                    {
                        final String finalName = build.getFinalName();
                        final String[] names = workDirectory.list();
                        if (names != null)
                        {
                            final int numberOfArtifacts = names.length;
                            for (int ctr = 0; ctr < numberOfArtifacts; ctr++)
                            {
                                final String name = names[ctr];
                                if (name.indexOf(finalName) != -1 && !name.equals(finalName))
                                {
                                    final File distributionFile = new File(distributionDirectory, name);
                                    this.bundleFile(
                                        artifact,
                                        new File(
                                            workDirectory,
                                            name),
                                        distributionFile);
                                }
                            }
                        }
                    }
                    else
                    {
                        this.artifactResolver.resolve(
                            artifact,
                            this.project.getRemoteArtifactRepositories(),
                            this.localRepository);
                    }

                    // - bundle the POM
                    final File repositoryPom =
                        this.constructPom(
                            new File(
                                this.localRepository.getBasedir(),
                                repositoryDirectoryPath),
                            artifact);
                    final File distributionPom = this.constructPom(
                            distributionDirectory,
                            artifact);
                    this.bundleFile(
                        artifact,
                        repositoryPom,
                        distributionPom);
                    artifacts.addAll(project.createArtifacts(
                            artifactFactory,
                            null,
                            null));
                }

                final ArtifactResolutionResult result =
                    this.artifactResolver.resolveTransitively(
                        artifacts,
                        this.project.getArtifact(),
                        this.project.getRemoteArtifactRepositories(),
                        this.localRepository,
                        this.artifactMetadataSource);

                artifacts.addAll(result.getArtifacts());

                // - remove the project artifacts
                for (final Iterator iterator = projects.iterator(); iterator.hasNext();)
                {
                    final MavenProject project = (MavenProject)iterator.next();
                    final Artifact projectArtifact = project.getArtifact();
                    if (projectArtifact != null)
                    {
                        for (final Iterator artifactIterator = artifacts.iterator(); artifactIterator.hasNext();)
                        {
                            final Artifact artifact = (Artifact)artifactIterator.next();
                            final String projectId = projectArtifact.getArtifactId();
                            final String projectGroupId = projectArtifact.getGroupId();
                            final String artifactId = artifact.getArtifactId();
                            final String groupId = artifact.getGroupId();
                            if (artifactId.equals(projectId) && groupId.equals(projectGroupId))
                            {
                                artifactIterator.remove();
                            }
                        }
                    }
                }

                // - bundle the dependant artifacts
                for (final Iterator iterator = artifacts.iterator(); iterator.hasNext();)
                {
                    final Artifact artifact = (Artifact)iterator.next();
                    this.bundleArtifact(
                        new File(
                            directory,
                            this.dependencyDirectory),
                        artifact);
View Full Code Here

Examples of org.apache.maven.artifact.Artifact

        final MavenProject project = this.getProject();
        if (project != null && localRepository != null)
        {
            if (dependency != null)
            {
                final Artifact artifact =
                    this.getFactory().createArtifact(
                        dependency.getGroupId(),
                        dependency.getArtifactId(),
                        dependency.getVersion(),
                        scope,
                        dependency.getType());
                final File file = new File(
                        localRepository.getBasedir(),
                        localRepository.pathOf(artifact));
                artifact.setFile(file);
                project.getDependencies().add(dependency);
                project.getArtifacts().add(artifact);
            }
        }
    }
View Full Code Here

Examples of org.apache.maven.artifact.Artifact

        public int compare(
            final Object objectA,
            final Object objectB)
        {
            final Artifact a = (Artifact)objectA;
            final Artifact b = (Artifact)objectB;
            return collator.compare(
                a.getId(),
                b.getId());
        }
View Full Code Here

Examples of org.apache.maven.artifact.Artifact

        //   so we explicity load them
        if (this.pluginArtifacts != null)
        {
            for (final Iterator iterator = this.pluginArtifacts.iterator(); iterator.hasNext();)
            {
                final Artifact artifact = (Artifact)iterator.next();
                final File artifactFile = artifact.getFile();
                if (artifactFile != null)
                {
                    classpathFiles.add(artifactFile.toString());
                }
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.