Logo Search packages:      
Sourcecode: maven2 version File versions  Download package

MavenProject org::apache::maven::project::DefaultMavenProjectBuilder::processProjectLogic ( String  pomLocation,
MavenProject  project,
ProfileManager  profileMgr,
File  projectDir,
boolean  strict 
) throws ProjectBuildingException, ModelInterpolationException, InvalidRepositoryException [inline, private]

Todo:
can this take in a model instead of a project and still be successful?
Todo:
In fact, does project REALLY need a MavenProject as a parent? Couldn't it have just a wrapper around a model that supported parents which were also the wrapper so that inheritence was assembled. We don't really need the resolved source roots, etc for the parent - that occurs for the parent when it is constructed independently and projects are not cached or reused

Definition at line 897 of file DefaultMavenProjectBuilder.java.

References org::apache::maven::project::MavenProject::getArtifactId(), org::apache::maven::project::MavenProject::getGroupId(), org::apache::maven::project::validation::ModelValidationResult::getMessageCount(), org::apache::maven::project::MavenProject::getModel(), org::apache::maven::project::MavenProject::getVersion(), org::apache::maven::project::injection::ModelDefaultsInjector::injectDefaults(), org::apache::maven::project::interpolation::ModelInterpolator::interpolate(), and org::apache::maven::project::validation::ModelValidator::validate().

    {
        Model model = project.getModel();

        List activeProfiles = project.getActiveProfiles();

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

        List injectedProfiles = injectActiveProfiles( profileMgr, model );

        activeProfiles.addAll( injectedProfiles );

        // TODO: Clean this up...we're using this to 'jump' the interpolation step for model properties not expressed in XML.
        //  [BP] - Can this above comment be explained?
        // We don't need all the project methods that are added over those in the model, but we do need basedir
        Map context = new HashMap( System.getProperties() );

        if ( projectDir != null )
        {
            context.put( "basedir", projectDir.getAbsolutePath() );
        }

        // TODO: this is a hack to ensure MNG-2124 can be satisfied without triggering MNG-1927
        //  MNG-1927 relies on the false assumption that ${project.build.*} evaluates to null, which occurs before
        //  MNG-2124 is fixed. The null value would leave it uninterpolated, to be handled after path translation.
        //  Until these steps are correctly sequenced, we guarantee these fields remain uninterpolated.
        context.put( "build.directory", null );
        context.put( "build.outputDirectory", null );
        context.put( "build.testOutputDirectory", null );
        context.put( "build.sourceDirectory", null );
        context.put( "build.testSourceDirectory", null );

        model = modelInterpolator.interpolate( model, context, strict );

        // interpolation is before injection, because interpolation is off-limits in the injected variables
        modelDefaultsInjector.injectDefaults( model );

        MavenProject parentProject = project.getParent();

        Model originalModel = project.getOriginalModel();

        // We will return a different project object using the new model (hence the need to return a project, not just modify the parameter)
        project = new MavenProject( model );

        project.setOriginalModel( originalModel );

        project.setActiveProfiles( activeProfiles );

        // TODO: maybe not strictly correct, while we should enfore that packaging has a type handler of the same id, we don't
        Artifact projectArtifact = artifactFactory.createBuildArtifact( project.getGroupId(), project.getArtifactId(),
                                                                        project.getVersion(), project.getPackaging() );

        project.setArtifact( projectArtifact );

        project.setPluginArtifactRepositories( ProjectUtils.buildArtifactRepositories( model.getPluginRepositories(),
                                                                                       artifactRepositoryFactory,
                                                                                       container ) );

        DistributionManagement dm = model.getDistributionManagement();
        if ( dm != null )
        {
            ArtifactRepository repo = ProjectUtils.buildDeploymentArtifactRepository( dm.getRepository(),
                                                                                      artifactRepositoryFactory,
                                                                                      container );
            project.setReleaseArtifactRepository( repo );

            if ( dm.getSnapshotRepository() != null )
            {
                repo = ProjectUtils.buildDeploymentArtifactRepository( dm.getSnapshotRepository(),
                                                                       artifactRepositoryFactory, container );
                project.setSnapshotArtifactRepository( repo );
            }
        }

        project.setParent( parentProject );

        if ( parentProject != null )
        {
            Artifact parentArtifact = artifactFactory.createParentArtifact( parentProject.getGroupId(),
                                                                            parentProject.getArtifactId(),
                                                                            parentProject.getVersion() );
            project.setParentArtifact( parentArtifact );
        }

        // Must validate before artifact construction to make sure dependencies are good
        ModelValidationResult validationResult = validator.validate( model );

        String projectId = safeVersionlessKey( model.getGroupId(), model.getArtifactId() );

        if ( validationResult.getMessageCount() > 0 )
        {
            throw new InvalidProjectModelException( projectId, pomLocation, "Failed to validate POM",
                                                    validationResult );
        }

        project.setRemoteArtifactRepositories(
            ProjectUtils.buildArtifactRepositories( model.getRepositories(), artifactRepositoryFactory, container ) );

        // TODO: these aren't taking active project artifacts into consideration in the reactor
        project.setPluginArtifacts( createPluginArtifacts( projectId, project.getBuildPlugins() ) );

        project.setReportArtifacts( createReportArtifacts( projectId, project.getReportPlugins() ) );

        project.setExtensionArtifacts( createExtensionArtifacts( projectId, project.getBuildExtensions() ) );

        return project;
    }


Generated by  Doxygen 1.6.0   Back to index