Package org.apache.maven.project

Examples of org.apache.maven.project.MavenProject


        {
            if (!sortProjects)
            {
                for (final Iterator iterator = projects.keySet().iterator(); iterator.hasNext();)
                {
                    final MavenProject project = (MavenProject)iterator.next();
                    List projectGoals;
                    if (goals == null)
                    {
                        projectGoals = (List)projects.get(project);
                        if (projectGoals.isEmpty())
View Full Code Here


                this.getLog().info("Reactor build order:");
            }
            final ReactorManager reactorManager = new ReactorManager(new ArrayList(projects));
            for (final Iterator iterator = reactorManager.getSortedProjects().iterator(); iterator.hasNext();)
            {
                final MavenProject project = (MavenProject)iterator.next();
                this.getLog().info("  " + project.getName());
            }

            final MavenSession projectSession =
                new MavenSession(
                    this.session.getContainer(),
View Full Code Here

            for (final Iterator iterator = poms.keySet().iterator(); iterator.hasNext();)
            {
                final File pom = (File)iterator.next();
                try
                {
                    final MavenProject project = ProjectUtils.getProject(
                            this.projectBuilder,
                            this.session,
                            pom,
                            this.getLog());
                    if (project != null)
                    {
                        if (this.getLog().isDebugEnabled())
                        {
                            this.getLog().debug("Adding project " + project.getId());
                        }
                        projects.put(
                            project,
                            poms.get(pom));
                    }
View Full Code Here

    public void execute()
        throws MojoExecutionException
    {
        try
        {
            final MavenProject rootProject = this.getRootProject();
            final ProjectWriter projectWriter = new ProjectWriter(rootProject,
                    this.getLog());
            projectWriter.write();
            final Map originalCompileSourceRoots = this.collectProjectCompileSourceRoots();
            final List projects = this.collectProjects();
            this.processCompileSourceRoots(projects);
            final ClasspathWriter classpathWriter = new ClasspathWriter(rootProject,
                    this.getLog());
            classpathWriter.write(
                projects,
                this.repositoryVariableName,
                this.artifactFactory,
                this.artifactResolver,
                this.localRepository,
                this.artifactMetadataSource,
                this.classpathArtifactTypes,
                this.project.getRemoteArtifactRepositories(),
                this.resolveTransitiveDependencies,
                this.classpathMerge);
            // - reset to the original source roots
            for (final Iterator iterator = projects.iterator(); iterator.hasNext();)
            {
                final MavenProject project = (MavenProject)iterator.next();
                project.getCompileSourceRoots().clear();
                project.getCompileSourceRoots().addAll((List)originalCompileSourceRoots.get(project));
            }
        }
        catch (Throwable throwable)
        {
            throw new MojoExecutionException("Error creating eclipse configuration", throwable);
View Full Code Here

        throws Exception
    {
        final Map sourceRoots = new LinkedHashMap();
        for (final Iterator iterator = this.collectProjects().iterator(); iterator.hasNext();)
        {
            final MavenProject project = (MavenProject)iterator.next();
            sourceRoots.put(project, new ArrayList(project.getCompileSourceRoots()));
        }
        return sourceRoots;
    }
View Full Code Here

            {
                final File pom = (File)iterator.next();
                try
                {
                    // - first attempt to get the existing project from the session
                    final MavenProject project = ProjectUtils.getProject(this.projectBuilder, this.session, pom, this.getLog());
                    if (project != null)
                    {
                        this.getLog().info("found project " + project.getId());
                        projects.add(project);
                    }
                    else
                    {
                        if (this.getLog().isWarnEnabled())
View Full Code Here

    private void processCompileSourceRoots(final List projects)
        throws Exception
    {
        for (final Iterator iterator = projects.iterator(); iterator.hasNext();)
        {
            final MavenProject project = (MavenProject)iterator.next();
            final Set compileSourceRoots = new LinkedHashSet(project.getCompileSourceRoots());
            compileSourceRoots.addAll(this.getExtraSourceDirectories(project));
            final String testSourceDirectory = project.getBuild().getTestSourceDirectory();
            if (testSourceDirectory != null && testSourceDirectory.trim().length() > 0)
            {
                compileSourceRoots.add(testSourceDirectory);
            }
            project.getCompileSourceRoots().clear();
            project.getCompileSourceRoots().addAll(compileSourceRoots);
        }
    }
View Full Code Here

    private MavenProject getRootProject()
        throws MojoExecutionException, ArtifactResolutionException, ArtifactNotFoundException
    {
        if (this.rootProject == null)
        {
            final MavenProject firstParent = this.project.getParent();
            File rootFile = this.project.getFile();
            if (firstParent != null)
            {
                for (this.rootProject = firstParent, rootFile = new File(rootFile.getParentFile().getParentFile(), POM_FILE_NAME);
                     this.rootProject.getParent() != null && this.rootProject.getParent().getFile() != null;
View Full Code Here

    private void addDependency(
        final Dependency dependency,
        final String scope)
    {
        final ArtifactRepository localRepository = this.getLocalRepository();
        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

            {
                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();
View Full Code Here

TOP

Related Classes of org.apache.maven.project.MavenProject

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.