private Pom mavenizeModule(MavenizationContext mavCtx, ProjectModel projectModel, Pom containingModule)
    {
        LOG.info("Mavenizing submodule ProjectModel " + projectModel.toPrettyString());
        LOG.info("    Root file: " + projectModel.getRootFileModel().toPrettyString());
        LOG.info("    Containing module: " + containingModule);

        if (projectModel.getRootFileModel().getParseError() != null)
            return null;

        // Known library -> add as a dependency and skip.

        // SHA1 identified archive?
        if (projectModel.getRootFileModel() instanceof IdentifiedArchiveModel)
        {
            final IdentifiedArchiveModel idArch = (IdentifiedArchiveModel)projectModel.getRootFileModel();
            if (idArch == null)
                LOG.warning("Project's IdentifiedArchiveModel getRootFileModel() returned null.");
            else if (idArch.getCoordinate() == null)
                LOG.warning("Project's IdentifiedArchiveModel getRootFileModel().getCoordinate() returned null.");
            else if(containingModule == null)
                LOG.warning("containingModule is null."); // IllegalStateEx?
            else
                containingModule.dependencies.add(new SimpleDependency(Dependency.Role.LIBRARY, MavenCoord.from(idArch.getCoordinate())));

            LOG.info("Known library, skipping recursive mavenization: " + idArch.getCoordinate());
            return null;
        }

        // ArchiveModel's organizations contain a known org, like Apache.
        if (projectModel.getRootFileModel() instanceof ArchiveModel)
        {
            Set<String> skipOrganizations = new HashSet(Arrays.asList("Apache Sun Iona IBM Codehaus Spring Sonatype JBoss Oracle".toLowerCase().split("")));

            final ArchiveModel arch = (ArchiveModel)projectModel.getRootFileModel();
            for (OrganizationModel org : arch.getOrganizationModels())
            {
                if (skipOrganizations.contains(org.getName().toLowerCase()))
                {
                    LOG.info("Library from 3rd party vendor ("+org.getName()+"), skipping recursive mavenization: " + arch.getFilePath());
                    return null;
                }
            }
        }

        // A MavenProject.
        // TODO: This covers both app modules and libraries with pom.xml inside. Need to diferentiate - skip only libraries.
        // TODO: This should disappear after WINDUP-981
        if (false && projectModel instanceof MavenProjectModel)
        {
            final MavenProjectModel mvnProject = (MavenProjectModel)projectModel;
            if (mvnProject.getMavenIdentifier() == null)
                LOG.warning("MavenProject's getMavenIdentifier() returned null.");
            else if(containingModule == null)
                LOG.warning("containingModule is null."); // IllegalStateEx?
            else if (true /* isLibraryAndNotProjectModule() */)
                containingModule.dependencies.add(new SimpleDependency(Dependency.Role.LIBRARY, MavenCoord.fromGAVPC(mvnProject.getMavenIdentifier())));
            return null;
        }

        MavenCoord modulePomCoords = new MavenCoord();
        modulePomCoords.setGroupId(mavCtx.getUnifiedGroupId());
        modulePomCoords.setVersion(mavCtx.getUnifiedVersion());
        final String artifactId = deriveAppropriateArtifactId(projectModel);
        modulePomCoords.setArtifactId(artifactId);
        modulePomCoords.setPackaging(guessPackaging(projectModel));

        Pom modulePom = new Pom(modulePomCoords);
        modulePom.role = Pom.ModuleRole.NORMAL;
        modulePom.parent = mavCtx.getRootPom();
        mavCtx.getRootPom().submodules.put(artifactId, modulePom);
        mavCtx.getKnownSubmodules().add(modulePom);


        // Set up the dependency of the containing module on the contained module. E.g. EAR depends on WAR.
        if(containingModule != null)
            containingModule.dependencies.add(modulePom);

        // Nested archives
        // For now, only count with the modules of this app. There are likely more in the other apps.
        Set<ArchiveModel> nestedModules = new HashSet<>();
        for (FileModel file : projectModel.getFileModelsNoDirectories())
        {
            if(!(file instanceof ArchiveModel)) //  TODO: Query for ArchiveModel directly.
                continue;

            // Known library -> simple dependency.
            if(file instanceof IdentifiedArchiveModel){
                IdentifiedArchiveModel artifact = (IdentifiedArchiveModel) file;
                modulePom.dependencies.add(new SimpleDependency(Dependency.Role.LIBRARY, MavenCoord.from(artifact.getCoordinate())));
            }
            // Unknown archives -> nested modules? -> local dependencies.
            else {
                nestedModules.add((ArchiveModel) file);
            }
        }

        // Nested modules already identified as ProjectModel
        for (ProjectModel subProject : projectModel.getChildProjects())
        {
            Pom subModulePom = mavenizeModule(mavCtx, subProject, modulePom);
            if (subModulePom == null)
                continue;
            modulePom.dependencies.add(subModulePom);
        }

        // Nested module candidates.
        for (ArchiveModel nestedModule : nestedModules)
        {
            // TODO: Is it a submodule or a library? Does it appear in multiple applications?
            //Pom subModulePom = mavenizeModule(mavCtx, nestedModule, containingModule);
            //modulePom.dependencies.add(subModulePom.identification);
        }

        // TODO: MIGR-237 Determine and add the project internal dependencies (on other submodules, cross-app)
        // Queues? JNDI? CDI? REST + WS endpoints?
        // Needs to be done after initial mavenization of all apps to have their G:A:V.

        // TODO: Determine and add compile-time (API) dependencies (like, Java EE API's)
        // One big Java EE API vs. individual?

        // TODO: Remove the deps versions overriding the BOM.
        new FeatureBasedApiDependenciesDeducer(mavCtx).addAppropriateDependencies(projectModel, modulePom);

        return modulePom;
    }
private Pom mavenizeModule ( MavenizationContext mavCtx , ProjectModel projectModel , Pom containingModule ) { LOG . info ( "Mavenizing submodule ProjectModel " + projectModel . toPrettyString ( ) ) ; LOG . info ( "    Root file: " + projectModel . getRootFileModel ( ) . toPrettyString ( ) ) ; LOG . info ( "    Containing module: " + containingModule ) ; if ( projectModel . getRootFileModel ( ) . getParseError ( ) != null ) return null ; if ( projectModel . getRootFileModel ( ) instanceof IdentifiedArchiveModel ) { final IdentifiedArchiveModel idArch = ( IdentifiedArchiveModel ) projectModel . getRootFileModel ( ) ; if ( idArch == null ) LOG . warning ( "Project's IdentifiedArchiveModel getRootFileModel() returned null." ) ; else if ( idArch . getCoordinate ( ) == null ) LOG . warning ( "Project's IdentifiedArchiveModel getRootFileModel().getCoordinate() returned null." ) ; else if ( containingModule == null ) LOG . warning ( "containingModule is null." ) ; else containingModule . dependencies . add ( new SimpleDependency ( Dependency . Role . LIBRARY , MavenCoord . from ( idArch . getCoordinate ( ) ) ) ) ; LOG . info ( "Known library, skipping recursive mavenization: " + idArch . getCoordinate ( ) ) ; return null ; } if ( projectModel . getRootFileModel ( ) instanceof ArchiveModel ) { Set < String > skipOrganizations = new HashSet ( Arrays . asList ( "Apache Sun Iona IBM Codehaus Spring Sonatype JBoss Oracle" . toLowerCase ( ) . split ( "" ) ) ) ; final ArchiveModel arch = ( ArchiveModel ) projectModel . getRootFileModel ( ) ; for ( OrganizationModel org : arch . getOrganizationModels ( ) ) { if ( skipOrganizations . contains ( org . getName ( ) . toLowerCase ( ) ) ) { LOG . info ( "Library from 3rd party vendor (" + org . getName ( ) + "), skipping recursive mavenization: " + arch . getFilePath ( ) ) ; return null ; } } } if ( false && projectModel instanceof MavenProjectModel ) { final MavenProjectModel mvnProject = ( MavenProjectModel ) projectModel ; if ( mvnProject . getMavenIdentifier ( ) == null ) LOG . warning ( "MavenProject's getMavenIdentifier() returned null." ) ; else if ( containingModule == null ) LOG . warning ( "containingModule is null." ) ; else if ( true ) containingModule . dependencies . add ( new SimpleDependency ( Dependency . Role . LIBRARY , MavenCoord . fromGAVPC ( mvnProject . getMavenIdentifier ( ) ) ) ) ; return null ; } MavenCoord modulePomCoords = new MavenCoord ( ) ; modulePomCoords . setGroupId ( mavCtx . getUnifiedGroupId ( ) ) ; modulePomCoords . setVersion ( mavCtx . getUnifiedVersion ( ) ) ; final String artifactId = deriveAppropriateArtifactId ( projectModel ) ; modulePomCoords . setArtifactId ( artifactId ) ; modulePomCoords . setPackaging ( guessPackaging ( projectModel ) ) ; Pom modulePom = new Pom ( modulePomCoords ) ; modulePom . role = Pom . ModuleRole . NORMAL ; modulePom . parent = mavCtx . getRootPom ( ) ; mavCtx . getRootPom ( ) . submodules . put ( artifactId , modulePom ) ; mavCtx . getKnownSubmodules ( ) . add ( modulePom ) ; if ( containingModule != null ) containingModule . dependencies . add ( modulePom ) ; Set < ArchiveModel > nestedModules = new HashSet < > ( ) ; for ( FileModel file : projectModel . getFileModelsNoDirectories ( ) ) { if ( ! ( file instanceof ArchiveModel ) ) continue ; if ( file instanceof IdentifiedArchiveModel ) { IdentifiedArchiveModel artifact = ( IdentifiedArchiveModel ) file ; modulePom . dependencies . add ( new SimpleDependency ( Dependency . Role . LIBRARY , MavenCoord . from ( artifact . getCoordinate ( ) ) ) ) ; } else { nestedModules . add ( ( ArchiveModel ) file ) ; } } for ( ProjectModel subProject : projectModel . getChildProjects ( ) ) { Pom subModulePom = mavenizeModule ( mavCtx , subProject , modulePom ) ; if ( subModulePom == null ) continue ; modulePom . dependencies . add ( subModulePom ) ; } for ( ArchiveModel nestedModule : nestedModules ) { } new FeatureBasedApiDependenciesDeducer ( mavCtx ) . addAppropriateDependencies ( projectModel , modulePom ) ; return modulePom ; }
Mavenizes the particular project module, i.e. single pom.xml.
Then continues recursively to submodules.

@return null if the project can't be processed for some reason, e.g. is from an unparsable jar.