Package org.apache.maven.project

Examples of org.apache.maven.project.MavenProject


    private MavenProject getRootProject()
        throws MojoExecutionException
    {
        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);
                     this.rootProject.getParent() != null;
View Full Code Here


     */
    private MavenProject getProject(final File pom)
        throws MojoExecutionException
    {
        // - first attempt to get the existing project from the session
        MavenProject project = this.getProjectFromSession(pom);
        if (project == null)
        {
            // - if we didn't find it in the session, create it
            try
            {
                project =
                    this.projectBuilder.build(
                        pom,
                        this.session.getLocalRepository(),
                        new DefaultProfileManager(this.session.getContainer()));
            }
            catch (Exception exception)
            {
                try
                {
                    // - if we failed, try to build from the repository
                    project =
                        this.projectBuilder.buildFromRepository(
                            this.buildArtifact(pom),
                            this.project.getRemoteArtifactRepositories(),
                            this.localRepository);
                }
                catch (final Throwable throwable)
                {
                    throw new MojoExecutionException("Project could not be built from pom file " + pom, exception);
                }
            }
        }
        if (this.getLog().isDebugEnabled())
        {
            this.getLog().debug("Processing project " + project.getId());
        }
        return project;
    }
View Full Code Here

     * @param pom the POM to find.
     * @return the maven project with the matching POM.
     */
    private MavenProject getProjectFromSession(final File pom)
    {
        MavenProject foundProject = null;
        for (final Iterator projectIterator = this.session.getSortedProjects().iterator(); projectIterator.hasNext();)
        {
            final MavenProject project = (MavenProject)projectIterator.next();
            final File projectPom = new File(
                    project.getBasedir(),
                    POM_FILE);
            if (projectPom.equals(pom))
            {
                foundProject = project;
            }
View Full Code Here

        final Set projects = new LinkedHashSet();
        final List poms = this.getPoms();
        for (ListIterator iterator = poms.listIterator(); iterator.hasNext();)
        {
            final File pom = (File)iterator.next();
            final MavenProject project = this.getProject(pom);
            if (project != null)
            {
                projects.add(project);
            }
        }
View Full Code Here

        writer.startElement("classpath");

        final Set projectArtifactIds = new LinkedHashSet();
        for (final Iterator iterator = projects.iterator(); iterator.hasNext();)
        {
            final MavenProject project = (MavenProject)iterator.next();
            final Artifact projectArtifact =
                artifactFactory.createArtifact(
                    project.getGroupId(),
                    project.getArtifactId(),
                    project.getVersion(),
                    null,
                    project.getPackaging());
            projectArtifactIds.add(projectArtifact.getId());
        }

        // - write the source roots for the root project (if they are any)
        this.writeSourceRoots(this.project, rootDirectory, writer);

        final Set allArtifacts = new LinkedHashSet(this.project.createArtifacts(
            artifactFactory,
            null,
            null));
        for (final Iterator iterator = projects.iterator(); iterator.hasNext();)
        {
            final MavenProject project = (MavenProject)iterator.next();
            this.writeSourceRoots(project, rootDirectory, writer);
            final Set artifacts = project.createArtifacts(
                    artifactFactory,
                    null,
                    null);

            // - get the direct dependencies
            for (final Iterator artifactIterator = artifacts.iterator(); artifactIterator.hasNext();)
            {
                final Artifact artifact = (Artifact)artifactIterator.next();

                // - don't attempt to resolve the artifact if its part of the project (we
                //   infer this if it has the same id has one of the projects or is in
                //   the same groupId).
                if (!projectArtifactIds.contains(artifact.getId()) &&
                    !project.getGroupId().equals(artifact.getGroupId()))
                {
                    artifactResolver.resolve(
                        artifact,
                        project.getRemoteArtifactRepositories(),
                        localRepository);
                    allArtifacts.add(artifact);
                }
                else
                {
                    allArtifacts.add(artifact);
                }
            }
        }

        // - 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 = allArtifacts.iterator(); artifactIterator.hasNext();)
                {
                    final Artifact artifact = (Artifact)artifactIterator.next();
View Full Code Here

        if (synapseCore == null) {
            throw new MojoExecutionException("Could not locate dependency on synapse-core");
        }
       
        log.debug("Loading project data for " + synapseCore + " ...");
        MavenProject synapseCoreProject;
        try {
            synapseCoreProject = projectBuilder.buildFromRepository(synapseCore,
                    remoteArtifactRepositories, localRepository);
        } catch (ProjectBuildingException e) {
            throw new MojoExecutionException("Unable to retrieve project information for "
                    + synapseCore, e);
        }
        Set<Artifact> synapseRuntimeDeps;
        try {
            synapseRuntimeDeps = synapseCoreProject.createArtifacts(artifactFactory,
                    Artifact.SCOPE_RUNTIME, new TypeArtifactFilter("jar"));
        } catch (InvalidDependencyVersionException e) {
            throw new MojoExecutionException("Unable to get project dependencies for "
                    + synapseCore, e);
        }
        log.debug("Direct runtime dependencies for " + synapseCore + " :");
        logArtifacts(synapseRuntimeDeps);
       
        log.debug("Resolving transitive dependencies for " + synapseCore + " ...");
        try {
            synapseRuntimeDeps = artifactCollector.collect(synapseRuntimeDeps,
                    synapseCoreProject.getArtifact(), synapseCoreProject.getManagedVersionMap(),
                    localRepository, remoteArtifactRepositories, artifactMetadataSource, null,
                    Collections.singletonList(new DebugResolutionListener(logger))).getArtifacts();
        } catch (ArtifactResolutionException e) {
            throw new MojoExecutionException("Unable to resolve transitive dependencies for "
                    + synapseCore);
View Full Code Here

        // We have no POM file.
        //
        if ( request.getPom() == null )
        {
            ModelSource modelSource = new UrlModelSource( DefaultMaven.class.getResource( "project/standalone.xml" ) );
            MavenProject project =
                projectBuilder.build( modelSource, request.getProjectBuildingRequest() ).getProject();
            project.setExecutionRoot( true );
            projects.add( project );
            request.setProjectPresent( false );
            return projects;
        }
       
View Full Code Here

        for ( MavenProject project : projects )
        {
            String projectId = ArtifactUtils.key( project.getGroupId(), project.getArtifactId(), project.getVersion() );

            MavenProject collision = index.get( projectId );

            if ( collision == null )
            {
                index.put( projectId, project );
            }
            else
            {
                List<File> pomFiles = collisions.get( projectId );

                if ( pomFiles == null )
                {
                    pomFiles = new ArrayList<File>( Arrays.asList( collision.getFile(), project.getFile() ) );
                    collisions.put( projectId, pomFiles );
                }
                else
                {
                    pomFiles.add( project.getFile() );
View Full Code Here

            Collection<MavenProject> selectedProjects = new LinkedHashSet<MavenProject>( projects.size() );

            for ( String selector : request.getSelectedProjects() )
            {
                MavenProject selectedProject = null;

                for ( MavenProject project : projects )
                {
                    if ( isMatchingProject( project, selector, reactorDirectory ) )
                    {
View Full Code Here

                                         ProjectSegment projectBuild, DependencyContext dependencyContext,
                                         PhaseRecorder phaseRecorder )
        throws LifecycleExecutionException
    {

        MavenProject currentProject = projectBuild.getProject();

        long buildStartTime = System.currentTimeMillis();

        CurrentPhaseForThread.setPhasenode.getLifecyclePhase() );
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.