private void addEjbModule( Element module )
    {
        String ejbVersion = getPluginSetting( "maven-ejb-plugin", "ejbVersion", "2.x" );

        module.addAttribute( "type", "J2EE_EJB_MODULE" );

        String explodedDir = executedProject.getBuild().getDirectory() + "/" + executedProject.getArtifactId();

        Element component = findComponent( module, "EjbModuleBuildComponent" );

        Element setting = findSetting( component, "EXPLODED_URL" );
        setting.addAttribute( "value", getModuleFileUrl( explodedDir ) );

        component = findComponent( module, "EjbModuleProperties" );
        Element deployDescElement =
            addDeploymentDescriptor( component, "ejb-jar.xml", ejbVersion, "src/main/resources/META-INF/ejb-jar.xml" );
        deployDescElement.addAttribute( "optional", ejbVersion.startsWith( "3" ) + "" );

        removeOldElements( component, "containerElement" );
        List artifacts = executedProject.getTestArtifacts();
        for ( Iterator i = artifacts.iterator(); i.hasNext(); )
        {
            Artifact artifact = (Artifact) i.next();

            Element containerElement = createElement( component, "containerElement" );

            if ( linkModules && isReactorProject( artifact.getGroupId(), artifact.getArtifactId() ) )
            {
                containerElement.addAttribute( "type", "module" );
                containerElement.addAttribute( "name", artifact.getArtifactId() );
                Element methodAttribute = createElement( containerElement, "attribute" );
                methodAttribute.addAttribute( "name", "method" );
                methodAttribute.addAttribute( "value", "6" );
                Element uriAttribute = createElement( containerElement, "attribute" );
                uriAttribute.addAttribute( "name", "URI" );
                uriAttribute.addAttribute( "value", "/lib/" + artifact.getArtifactId() + ".jar" );
            }
            else if ( artifact.getFile() != null )
            {
                containerElement.addAttribute( "type", "library" );
                containerElement.addAttribute( "level", "module" );

                //no longer needed in IntelliJ 6
                if ( StringUtils.isEmpty( ideaVersion ) || !ideaVersion.startsWith( "6" ) )
                {
                    containerElement.addAttribute( "name", artifact.getArtifactId() );
                }

                Element methodAttribute = createElement( containerElement, "attribute" );
                methodAttribute.addAttribute( "name", "method" );
                methodAttribute.addAttribute( "value", "2" );
                Element uriAttribute = createElement( containerElement, "attribute" );
                uriAttribute.addAttribute( "name", "URI" );
                uriAttribute.addAttribute( "value", "/lib/" + artifact.getFile().getName() );
                Element urlElement = createElement( containerElement, "url" );
                urlElement.setText( getLibraryUrl( artifact ) );
            }
        }
    }