Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   /*
    *  Licensed to the Apache Software Foundation (ASF) under one
    *  or more contributor license agreements.  See the NOTICE file
    *  distributed with this work for additional information
    *  regarding copyright ownership.  The ASF licenses this file
    *  to you under the Apache License, Version 2.0 (the
    *  "License"); you may not use this file except in compliance
    *  with the License.  You may obtain a copy of the License at
    *
   *  http://www.apache.org/licenses/LICENSE-2.0
   *
   *  Unless required by applicable law or agreed to in writing,
   *  software distributed under the License is distributed on an
   *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   *  KIND, either express or implied.  See the License for the
   *  specific language governing permissions and limitations
   *  under the License.
   */
  
  package org.apache.myfaces.trinidadbuild.plugin.jdeveloper;
  
  import java.io.File;
  import java.io.Reader;
  
  import java.net.URL;
  
  import java.util.Arrays;
  import java.util.List;
  import java.util.Map;
  import java.util.Set;
  import java.util.TreeMap;
  
  
  
  
  
    /*
     * Important informational note:
     *
     * The following XML code is similar to what would be seen in a pom file
     * under the maven-jdev-plugin tag if Libraries (e.g. JSP Runtime
     * and JSF 1.2) and Distributed Tag Libraries wanted to be added to the .jpr
     * project.
     *
     * What you see below are the defaults that are put in a project's .jpr
     * automatically without specifying anything.  See replaceLibraries(),
     * replaceTagLibraries() and replaceDefaultTagLibraries().
     *
     * Also note that by setting the property "jdev.plugin.add.libraries" to
     * false in a project's pom.xml file, no libraries will be added, default
     * or otherwise.  In kind, setting the property "jdev.plugin.add.taglibs"
     * to false will result in no tag libraries of any kind being added.
     *
     * As you would expect, the default for both of these properties is "true".
     *
     *   <plugin>
          <groupId>org.apache.myfaces.trinidadbuild</groupId>
          <artifactId>maven-jdev-plugin</artifactId>
          <version>1.2.4-SNAPSHOT</version>
          <inherited>true</inherited>
          <configuration>
            <libraries>
              <library>JSP Runtime</library>
              <library>JSF 1.2</library>
            </libraries>
            <distributedTagLibraries>
              <distributedTagLibrary>
                <property>
                  <name>name</name>
                  <value>JSF HTML</value>
               </property>
               <property>
                 <name>version</name>
                 <value>1.2</value>
               </property>
               <property>
                 <name>jspVersion</name>
                 <value>2.1</value>
               </property>
               <property>
                 <name>tld</name>
                 <value>html_basic.tld</value>
               </property>
               <property>
                 <name>URI</name>
                 <value>http://java.sun.com/jsf/html</value>
               </property>
             </distributedTagLibrary>
             <distributedTagLibrary>
               <property>
                 <name>name</name>
                 <value>JSF Core</value>
               </property>
               <property>
                 <name>version</name>
                 <value>1.2</value>
               </property>
               <property>
                 <name>jspVersion</name>
                 <value>2.1</value>
               </property>
               <property>
                 <name>tld</name>
                 <value>jsf_core.tld</value>
               </property>
               <property>
                 <name>URI</name>
                 <value>http://java.sun.com/jsf/core</value>
               </property>
             </distributedTagLibrary>
           </distributedTagLibraries>
         </configuration>
       </plugin>
  */

Generates the JDeveloper Workspace and Projects from a maven development environment.

Version:
$Id$
Goal:
jdev
Execute:
phase=process-resources
RequiresDependencyResolution:
test
Description:
Goal which generates the JDeveloper Workspace and Projects from a maven development environment.
 
 public class JDeveloperMojo
   extends AbstractMojo
 {
  
Libraries to include in Classpath.

Parameter:
 
   private String[] libraries;

  
List of source root directories

Parameter:
 
   private File[] sourceRoots;

  
Does project have tests? Used to determine if the maven-jdev-plugin needs to create a <project name>-test.jpr

Parameter:
expression="${jdev.project.has.tests}" default-value="false"
 
   private boolean projectHasTests;
  
  
List of source root directories for the test project

Parameter:
 
   private File[] testSourceRoots;

  
List of resource root directories

Parameter:
 
   private File[] resourceRoots;

  
List of resource root directories for the test project

Parameter:
 
   private File[] testResourceRoots;

  
Force the Mojo to use the default project.xml or workspace.xml file to be used in creation of the workspace file (.jws) or project file (.jpr). Otherwise, if a .jws or .jpr exists, it will be used instead.

Parameter:
expression="${force}" default-value=false
 
   private boolean force;

  
Compiler to be used by JDeveloper. "Ojc" is the default. If this parameter is absent or anything other than "Javac", "Ojc" will be used.

Parameter:
expression="${jdev.compiler}" default-value="Ojc"
 
   private String compiler;

  
Make the entire project before each run. Running anything in the project will automatically trigger a make of the entire project followed by the run.

Parameter:
expression="${jdev.make.project}" default-value="false"
 
   private boolean makeProject;

  
Default file to be run when JDeveloper project is run.

Parameter:
expression="${jdev.run.target}"
 
   private String runTarget;

  
Create JDeveloper Workspace and Project Files that correspond to the format used

Parameter:
expression="${jdev.release}" default-value="10.1.3.0.4"
 
   private String release;

  
Name of the Maven Project

Parameter:
expression="${project}"
Required:
Readonly:
 
   private MavenProject project;

  
List of reactorProjects

Parameter:
expression="${reactorProjects}"
Required:
Readonly:
 
   private List reactorProjects;

  
Tag library directory used by each distributed jsf tag library

Parameter:
expression="${jdev.tag.lib.dir}"
 
   private String tagLibDirectory;

  
Tag libraries and their properties.

Parameter:
 
   private Properties[] distributedTagLibraries;

  
JVM javaOptions found under Project Properties->Run/Debug/Profile->Launch Settings->Java Options in JDeveloper. "-ea" is the default for "enableAssertions".

Parameter:
expression="${jdev.jvm.java.options}" default-value="-ea"
 
   private String javaOptions;

  
Execute the Mojo.
 
   public void execute()
     throws MojoExecutionException
   {
     _parseRelease();
 
     if ( >= 11)
     {
        = 
         "@oracle.home@/modules/oracle.jsf_1.2.9/glassfish.jsf_1.2.9.0.jar!/META-INF";
     }
     else
     {
        =
         "@oracle.home@lib/java/shared/oracle.jsf/1.2/jsf-ri.jar!/META-INF";
     }
     
     try
     {
       generateWorkspace();
       generateProject();
       generateTestProject();
     }
     catch (IOException e)
     {
       throw new MojoExecutionException(e.getMessage());
     }
   }
 
   private void generateWorkspace()
   {
     {
       getLog().info("Generating JDeveloper " +  + " workspace: " +
                     .getArtifactId());
 
       File workspaceFile = getJWorkspaceFile();
 
       try
       {
         Xpp3Dom workspaceDOM = readWorkspaceDOM(workspaceFile);
         replaceProjects(workspaceFile.getParentFile(), workspaceDOM);
         writeDOM(workspaceFileworkspaceDOM);
       }
       catch (XmlPullParserException e)
       {
         throw new MojoExecutionException("Error generating workspace"e);
       }
     }
   }
 
   private void generateProject()
   {
     if (!"pom".equals(.getPackaging()))
     {
       File projectFile = getJProjectFile();
 
       // Get Project Properties to tell Mojo whether or not to add
       // library refs and taglibs to the project.
       Properties props = .getProperties();
       String addLibs = (String)props.get();
       String addTagLibs = (String)props.get();
        = (addLibs == null)
         ? true : (new Boolean(addLibs)).booleanValue();
          = (addTagLibs == null)
         ? true : (new Boolean(addTagLibs)).booleanValue();
 
       // TODO: read configuration for war:war goal
       File webappDir = new File(.getBasedir(), "src/main/webapp");
       // TODO: read configuration for compiler:complie goal
       File outputDir =
         new File(.getBuild().getDirectory(), "classes");
 
       MavenProject executionProject = .getExecutionProject();
       List compileSourceRoots = executionProject.getCompileSourceRoots();
       if ( != null)
       {
         for (int i = 0; i < .i++)
         {
           compileSourceRoots.add([i].getAbsolutePath());
         }
       }
 
       List compileResourceRoots = executionProject.getResources();
       if ( != null)
       {
         for (int i = 0; i < .i++)
         {
           Resource resource = new Resource();
           resource.setDirectory([i].getAbsolutePath());
           compileResourceRoots.add(resource);
         }
       }
 
       getLog().info("Generating JDeveloper " +  + " Project " +
                     .getArtifactId());
 
       Set pluginArtifacts = new LinkedHashSet();
       pluginArtifacts.addAll(.getPluginArtifacts());
 
       // Note: include "compile", "provided", "system" and "runtime" scopes
       Set compileArtifacts = new LinkedHashSet();
       compileArtifacts.addAll(.getCompileArtifacts());
       compileArtifacts.addAll(.getRuntimeArtifacts());
 
       // Note: separate "runtime" vs. "compile" dependencies in JDeveloper?
       generateProject(projectFile.getArtifactId(),
                       .getPackaging(), .getDependencies(),
                       new ArrayList(compileArtifacts), compileSourceRoots,
                       compileResourceRoots,
                       Collections.singletonList(webappDir.getPath()),
                       outputDir);
     }
   }
 
   private void generateTestProject()
   {
     if (!"pom".equals(.getPackaging()) && )
     {
       File projectFile = getJProjectTestFile();
 
       // Get Project Properties to tell Mojo whether or not to add
       // library refs and taglibs to the project.
       Properties props = .getProperties();
       String addLibs = (String)props.get();
       String addTagLibs = (String)props.get();
        = (addLibs == null)
         ? true : (new Boolean(addLibs)).booleanValue();
          = (addTagLibs == null)
         ? true : (new Boolean(addTagLibs)).booleanValue();
       File webappDir = new File(.getBasedir(), "src/test/webapp");
       // TODO: read configuration for compiler:testCompile goal
       File outputDir =
         new File(.getBuild().getDirectory(), "test-classes");
 
       // self dependency needed for test project
       List testDependencies = new ArrayList(.getTestDependencies());
       Dependency selfDependency = new Dependency();
       selfDependency.setArtifactId(.getArtifactId());
       selfDependency.setGroupId(.getGroupId());
       selfDependency.setType(.getPackaging());
       testDependencies.add(selfDependency);
 
       MavenProject executionProject = .getExecutionProject();
       List compileSourceRoots =
         executionProject.getTestCompileSourceRoots();
 
       for (int i = 0; i < .i++)
       {
         compileSourceRoots.add([i].getAbsolutePath());
       }
 
       List compileResourceRoots = executionProject.getTestResources();
       if ( != null)
       {
         for (int i = 0; i < .i++)
         {
           Resource resource = new Resource();
           resource.setDirectory([i].getAbsolutePath());
           compileResourceRoots.add(resource);
         }
       }
 
       getLog().info("Generating JDeveloper " +  + " Project " +
                     .getArtifactId() + "-test");
 
       // Note: all artifacts implicitly included in "test" scope
       generateProject(projectFile.getArtifactId() + "-test",
                       .getPackaging(), testDependencies,
                       .getTestArtifacts(), compileSourceRoots,
                       compileResourceRoots,
                       Collections.singletonList(webappDir.getPath()),
                       outputDir);
     }
   }
 
   private void generateProject(File projectFileString projectName,
                                String packagingList dependencies,
                                List artifactsList sourceRoots,
                                List resourceRootsList webSourceRoots,
                                File outputDir)
   {
     try
     {
       File projectDir = projectFile.getParentFile();
       Xpp3Dom projectDOM = readProjectDOM(projectFile);
       replaceWebappInfo(projectNameprojectDOM);
       replaceSourcePaths(projectDirsourceRootsresourceRoots,
                          projectDOM);
       //replaceResourcePaths(projectDir, resourceRoots, projectDOM);
       replaceWebSourcePaths(projectDirwebSourceRootsprojectDOM);
       replaceDependencies(projectDirdependenciesprojectDOM);
       replaceLibraries(projectDirartifactsprojectDOM);
       replaceTagLibraries(projectDOM);
       replaceOutputDirectory(projectDiroutputDirprojectDOM);
       replaceParameters(projectNameprojectDOM);
       writeDOM(projectFileprojectDOM);
 
       /* Not needed in release 11 where .tld files are obtained
       ** From jar's META-INF dir, not in WEB-INF dir as in v10
       */
       if ( ( < 11) && ("war".equals(packaging)) )
         copyTagLibraries(projectDirdependenciesartifacts);
 
     }
     catch (XmlPullParserException e)
     {
       throw new MojoExecutionException("Error generating project"e);
     }
   }
 
   private void replaceProjects(File workspaceDirXpp3Dom workspaceDOM)
     throws XmlPullParserException
   {
     // /jws:workspace
     //   /list[@n="listOfChildren"]
     Xpp3Dom sourceDOM = workspaceDOM.getChild("list");
 
     // <hash>
     //   <value n="nodeClass" v="oracle.jdeveloper.model.JProject"/>
     //   <url n="URL" path="[workspace-relative-path-to-project.jpr]"/>
     // </hash>
     Xpp3Dom targetDOM = new Xpp3Dom("list");
 
     for (Iterator i = .getCollectedProjects().iterator(); i.hasNext(); )
     {
       MavenProject collectedProject = (MavenProjecti.next();
       boolean projHasTests = false;
 
       // Added in V11
       if ( >= 11)
       {
         Properties props = collectedProject.getProperties();
         String hasTests = (String)props.get();
         projHasTests = "true".equalsIgnoreCase(hasTests);
       }
 
       getLog().info("projHasTests is " + Boolean.valueOf(projHasTests).toString());
 
       // if a child project is also a workspace, then don't 
       // put it in the .jws file.  It will have its own .jws
       // file.
       if (!"pom".equals(collectedProject.getPackaging()))
       {
         File projectFile = getJProjectFile(collectedProject);
         
         targetDOM.addChild(createProjectReferenceDOM(workspaceDir,
                                                      projectFile));
   
         File testProjectFile = getJProjectTestFile(collectedProject);
 
         /*
         ** In V11, we don't create a <projname>-test.jpr if 
         ** a project does not have any tests.
         */
         if ( >= 11)
         {
           if (projHasTests)
           {
             targetDOM.addChild(createProjectReferenceDOM(workspaceDir
                                                          testProjectFile));
           }
         }
         else
         {
           targetDOM.addChild(createProjectReferenceDOM(workspaceDir
                                                        testProjectFile));
         }      
       }
     }
 
     // TODO: use a better merge algorithm
     removeChildren(sourceDOM);
 
     // make sure to pass Boolean.FALSE to allow
     // multiple child elements with the same name
     Xpp3Dom.mergeXpp3Dom(sourceDOMtargetDOM.);
   }
 
   private void replaceWebSourcePaths(File projectDirList sourceRoots,
                                      Xpp3Dom projectDOM)
     throws XmlPullParserException
   {
     // /jpr:project
     //   /hash[@n="oracle.jdeveloper.model.J2eeSettings"]
     //     /hash[@n="webContentSet"]
     //       /list[@n="url-path"]
     Xpp3Dom pathsDOM =
       findNamedChild(projectDOM"hash""oracle.jdeveloper.model.J2eeSettings");
     Xpp3Dom contentSetDOM =
       findNamedChild(pathsDOM"hash""webContentSet");
     Xpp3Dom sourceDOM = findNamedChild(contentSetDOM"list""url-path");
 
     //
     // <url path="[relative-path-to-source-root]" />
     //
     Xpp3Dom targetDOM = new Xpp3Dom("list");
     for (Iterator i = sourceRoots.iterator(); i.hasNext(); )
     {
       File sourceRoot = new File((Stringi.next());
       String relativeRoot = getRelativeDir(projectDirsourceRoot);
       Xpp3Dom urlDOM = new Xpp3Dom("url");
       urlDOM.setAttribute("path"relativeRoot);
       targetDOM.addChild(urlDOM);
     }
 
     // TODO: use a better merge algorithm
     removeChildren(sourceDOM);
 
     // make sure to pass Boolean.FALSE to allow
     // multiple child elements with the same name
     Xpp3Dom.mergeXpp3Dom(sourceDOMtargetDOM.);
   }
 
   private void replaceWebappInfo(String projectNameXpp3Dom projectDOM)
     throws XmlPullParserException
   {
     // /jpr:project
     //   /hash[@n="oracle.jdeveloper.model.J2eeSettings"]
     //     /value[@n="j2eeWebAppName" v="maven-generated-webapp"]
     //     /value[@n="j2eeWebContextRoot" v="maven-generated-context-root"]
     Xpp3Dom settingsDOM =
       findNamedChild(projectDOM"hash""oracle.jdeveloper.model.J2eeSettings");
     Xpp3Dom webappNameDOM =
       findNamedChild(settingsDOM"value""j2eeWebAppName");
     Xpp3Dom webappContextDOM =
       findNamedChild(settingsDOM"value""j2eeWebContextRoot");
 
     // update the webapp name
     webappNameDOM.setAttribute("v"projectName + "-webapp");
 
     // update the webapp context root
     webappContextDOM.setAttribute("v"projectName + "-context-root");
   }
 
   private void replaceSourcePaths(File projectDirList sourceRoots,
                                   List resourceRootsXpp3Dom projectDOM)
     throws XmlPullParserException
   {
     // /jpr:project
     //   /hash[@n="oracle.jdeveloper.model.PathsConfiguration"]
     //     /hash[@n="javaContentSet"]
     //       /list[@n="url-path"]
     Xpp3Dom pathsDOM =
       findNamedChild(projectDOM"hash""oracle.jdeveloper.model.PathsConfiguration");
     Xpp3Dom contentSetDOM =
       findNamedChild(pathsDOM"hash""javaContentSet");
     Xpp3Dom sourceDOM = findNamedChild(contentSetDOM"list""constituent-sets");
 
     //
     // <url path="[relative-path-to-source-root]" />
     //
     Xpp3Dom targetDOM = new Xpp3Dom("list");
 
     Collections.sort(sourceRoots);
     for (Iterator i = sourceRoots.iterator(); i.hasNext(); )
     {
       File sourceRoot = new File((Stringi.next());
       Xpp3Dom hashDOM = new Xpp3Dom("hash");
 
       Xpp3Dom listDOM = new Xpp3Dom("list");
       listDOM.setAttribute("n""pattern-filters");
       hashDOM.addChild(listDOM);
 
       Xpp3Dom stringDOM = new Xpp3Dom("string");
       stringDOM.setAttribute("v""+**");
       listDOM.addChild(stringDOM);
 
       listDOM = new Xpp3Dom("list");
       listDOM.setAttribute("n""url-path");
       hashDOM.addChild(listDOM);
 
       String relativeRoot = getRelativeDir(projectDirsourceRoot);
       Xpp3Dom urlDOM = new Xpp3Dom("url");
       urlDOM.setAttribute("path"relativeRoot);
       listDOM.addChild(urlDOM);
 
       targetDOM.addChild(hashDOM);
     }
 
     // TODO: get bug fixed in 10.1.3 for copying resources
     Collections.sort(resourceRootsnew Comparator()
         {
           public int compare(Object aObject b)
           {
             Resource ra = (Resourcea;
             Resource rb = (Resourceb;
             return ra.getDirectory().compareTo(rb.getDirectory());
           }
 
         });
 
     for (Iterator i = resourceRoots.iterator(); i.hasNext(); )
     {
       Resource resource = (Resourcei.next();
       File resourceRoot = new File(resource.getDirectory());
       String relativeRoot = getRelativeDir(projectDirresourceRoot);
 
       Xpp3Dom hashDOM = new Xpp3Dom("hash");
 
       Xpp3Dom listDOM = new Xpp3Dom("list");
       listDOM.setAttribute("n""pattern-filters");
       hashDOM.addChild(listDOM);
 
       Xpp3Dom stringDOM = null;
       // TODO: This is a Hack for excluding the golden files,
       // which are not really xml files.  We need a way, in
       // the pom file to specify excludes.
       if (relativeRoot.startsWith("src/test/resources"))
       {
         stringDOM = new Xpp3Dom("string");
         stringDOM.setAttribute("v",
                             "-oracle/adfinternal/view/faces/renderkit/golden/");
         listDOM.addChild(stringDOM);
       }
 
       stringDOM = new Xpp3Dom("string");
       stringDOM.setAttribute("v""+**");
       listDOM.addChild(stringDOM);
 
       listDOM = new Xpp3Dom("list");
       listDOM.setAttribute("n""url-path");
       hashDOM.addChild(listDOM);
 
       Xpp3Dom urlDOM = new Xpp3Dom("url");
       urlDOM.setAttribute("path"relativeRoot);
       listDOM.addChild(urlDOM);
 
       targetDOM.addChild(hashDOM);
     }
 
     // TODO: use a better merge algorithm
     removeChildren(sourceDOM);
 
     // make sure to pass Boolean.FALSE to allow
     // multiple child elements with the same name
     Xpp3Dom.mergeXpp3Dom(sourceDOMtargetDOM.);
   }
 
   private void replaceResourcePaths(File projectDirList resourceRoots,
                                     Xpp3Dom projectDOM)
     throws XmlPullParserException
   {
     // /jpr:project
     //   /hash[@n="oracle.ide.model.ResourcePaths"]
     //     /hash[@n="resourcesContentSet"]
     //       /list[@n="url-path"]
 
     Xpp3Dom pathsDOM =
       findNamedChild(projectDOM"hash""oracle.ide.model.ResourcePaths");
     Xpp3Dom contentSetDOM =
       findNamedChild(pathsDOM"hash""resourcesContentSet");
     Xpp3Dom sourceDOM = findNamedChild(contentSetDOM"list""url-path");
 
     //
     // <url path="[relative-path-to-source-root]" />
     //
     Xpp3Dom targetDOM = new Xpp3Dom("list");
     for (Iterator i = resourceRoots.iterator(); i.hasNext(); )
     {
       Resource resource = (Resourcei.next();
       File resourceRoot = new File(resource.getDirectory());
       String relativeRoot = getRelativeDir(projectDirresourceRoot);
       Xpp3Dom urlDOM = new Xpp3Dom("url");
       urlDOM.setAttribute("path"relativeRoot);
       targetDOM.addChild(urlDOM);
     }
 
     // TODO: use a better merge algorithm
     removeChildren(sourceDOM);
 
     // make sure to pass Boolean.FALSE to allow
     // multiple child elements with the same name
     Xpp3Dom.mergeXpp3Dom(sourceDOMtargetDOM.);
   }
 
   private void replaceDependencies(File projectDirList dependencies,
                                    Xpp3Dom projectDOM)
     throws XmlPullParserException
   {
     // /jpr:project
     //   /hash[@n="oracle.ide.model.DependencyConfiguration"]
     //     /list[@n="dependencyList"]
     Xpp3Dom configDOM =
       findNamedChild(projectDOM"hash""oracle.ide.model.DependencyConfiguration");
     Xpp3Dom sourceDOM =
       findNamedChild(configDOM"list""dependencyList");
 
     Xpp3Dom targetDOM = new Xpp3Dom("list");
     for (Iterator i = dependencies.iterator(); i.hasNext(); )
     {
       Dependency dependency = (Dependencyi.next();
       MavenProject dependentProject =
         findDependentProject(dependency.getManagementKey());
       if (dependentProject != null)
       {
         File dependentProjectFile = getJProjectFile(dependentProject);
         String relativePath =
           getRelativeFile(projectDirdependentProjectFile);
 
         Xpp3Dom hashDOM = new Xpp3Dom("hash");
         Xpp3Dom valueDOM = new Xpp3Dom("value");
         valueDOM.setAttribute("n""class");
         valueDOM.setAttribute("v",
                               "oracle.jdeveloper.library.ProjectLibrary");
         Xpp3Dom srcOwnValDOM = new Xpp3Dom("value");
         srcOwnValDOM.setAttribute("n""sourceOwnerURL");
         Xpp3Dom urlDOM = new Xpp3Dom("url");
         urlDOM.setAttribute("n""sourceURL");
         urlDOM.setAttribute("path"relativePath);
         hashDOM.addChild(valueDOM);
         hashDOM.addChild(srcOwnValDOM);
         hashDOM.addChild(urlDOM);
         targetDOM.addChild(hashDOM);
       }
     }
 
     // TODO: use a better merge algorithm
     removeChildren(sourceDOM);
 
     // make sure to pass Boolean.FALSE to allow
     // multiple child elements with the same name
     Xpp3Dom.mergeXpp3Dom(sourceDOMtargetDOM.);
   }
 
   private void replaceLibraries(File projectDirList artifacts,
                                 Xpp3Dom projectDOM)
     throws XmlPullParserException
   {
     // /jpr:project
     //   /hash[@n="oracle.jdevimpl.config.JProjectLibraries"]
     //     /hash[@n="internalDefinitions"]
     //       /list[@n="libraryDefinitions"]
     Xpp3Dom projectLibsDOM =
       findNamedChild(projectDOM"hash""oracle.jdevimpl.config.JProjectLibraries");
     Xpp3Dom internalDefsDOM =
       findNamedChild(projectLibsDOM"hash""internalDefinitions");
     Xpp3Dom sourceDefsDOM =
       findNamedChild(internalDefsDOM"list""libraryDefinitions");
 
     // /jpr:project
     //   /hash[@n="oracle.jdevimpl.config.JProjectLibraries"]
     //     /list[@n="libraryReferences"]
     Xpp3Dom sourceRefsDOM =
       findNamedChild(projectLibsDOM"list""libraryReferences");
 
     Xpp3Dom targetDefsDOM = new Xpp3Dom("list");
     Xpp3Dom targetRefsDOM = new Xpp3Dom("list");
 
     //
     // libraryDefinitions
     //
     // <hash>
     //   <list n="classPath">
     //     <url path="[path-to-artifact]" jar-entry="" />
     //   </list>
     //   <value n="deployedByDefault" v="true"/>
     //   <value n="description" v="[artifact.id]"/>
     //   <value n="id" v="[artifact.id]"/>
     // </hash>
     //
 
     // sort the artifacts
     Collections.sort(artifactsnew Comparator()
         {
           public int compare(Object aObject b)
           {
             Artifact arta = (Artifacta;
             Artifact artb = (Artifactb;
             return arta.getId().compareTo(artb.getId());
           }
 
         });
 
     List libraryRefs = new LinkedList();
     for (Iterator i = artifacts.iterator(); i.hasNext(); )
     {
       Artifact artifact = (Artifacti.next();
 
       if (!isDependentProject(artifact.getDependencyConflictId()))
       {
         String id = artifact.getId();
         String path = getRelativeFile(projectDirartifact.getFile());
 
         // libraryDefinitions entry
         Xpp3Dom hashDOM = new Xpp3Dom("hash");
         Xpp3Dom listDOM = new Xpp3Dom("list");
         listDOM.setAttribute("n""classPath");
 
         Xpp3Dom urlDOM = new Xpp3Dom("url");
         urlDOM.setAttribute("path"path);
         urlDOM.setAttribute("jar-entry""");
         listDOM.addChild(urlDOM);
         hashDOM.addChild(listDOM);
 
         Xpp3Dom valueDOM = new Xpp3Dom("value");
         valueDOM.setAttribute("n""deployedByDefault");
         valueDOM.setAttribute("v""true");
         hashDOM.addChild(valueDOM);
 
         valueDOM = new Xpp3Dom("value");
         valueDOM.setAttribute("n""description");
         valueDOM.setAttribute("v"id);
         hashDOM.addChild(valueDOM);
 
         valueDOM = new Xpp3Dom("value");
         valueDOM.setAttribute("n""id");
         valueDOM.setAttribute("v"id);
         hashDOM.addChild(valueDOM);
         targetDefsDOM.addChild(hashDOM);
 
         libraryRefs.add(id);
       }
     }
 
     // This boolean is set by specifying the jdev.plugin.add.libraries
     // property at the top of a project's pom file.  There are projects
     // that don't need these libraries in their .jpr files to compile and this
     // property allows them to be excluded.
     //
     // IMPORTANT NOTE: if this property is set in a project,
     // then libraries will NOT be added, even though they
     // may be specified under the maven-jdev-plugin.
     if ()
     {
       // Add libraries.  The default libraries can be
       // overridden in the trunk/toplevel pom file.
       if ( >= 11)
       {
         // Add the default libraries
         libraryRefs.add(0,"JSF 1.2");
         libraryRefs.add(0,"JSP Runtime");
       }
 
       // Add the libraries
       if ( != null)
       {
         for (int i = 0; i < .i++)
         {
           // Default libraries for release 11 were already
           // added above.
           if (   ( >= 11)
               && (   ("JSF 1.2".equalsIgnoreCase([i]))
                   || ("JSP Runtime".equalsIgnoreCase([i]))
                  )
              )
           {
             continue;
           }
           // Add the library
           libraryRefs.add(0, [i]);
         }
       }
     }
 
     //
     // libraryReferences
     //
     // <hash>
     //   <value n="id" v="[artifact.id]"/>
     //   <value n="isJDK" v="false"/>
     // </hash>
     //
     Collections.sort(libraryRefs);
 
     for (Iterator i = libraryRefs.iterator(); i.hasNext(); )
     {
       String id = (Stringi.next();
 
       // libraryReferences entry
       Xpp3Dom hashDOM = new Xpp3Dom("hash");
       Xpp3Dom valueDOM = new Xpp3Dom("value");
       valueDOM.setAttribute("n""id");
       valueDOM.setAttribute("v"id);
       hashDOM.addChild(valueDOM);
 
       valueDOM = new Xpp3Dom("value");
       valueDOM.setAttribute("n""isJDK");
       valueDOM.setAttribute("v""false");
       hashDOM.addChild(valueDOM);
       targetRefsDOM.addChild(hashDOM);
     }
 
     // First, add JSP Runtime dependency if src/main/webapp exists
     // TODO: use a better merge algorithm
     removeChildren(sourceDefsDOM);
     removeChildren(sourceRefsDOM);
 
     // make sure to pass Boolean.FALSE to allow
     // multiple child elements with the same name
     Xpp3Dom.mergeXpp3Dom(sourceDefsDOMtargetDefsDOM.);
     Xpp3Dom.mergeXpp3Dom(sourceRefsDOMtargetRefsDOM.);
   }
 
   private void replaceLocalTagLibraries(Xpp3Dom targetLibsDOM)
     throws XmlPullParserException
   {
     TldContentHandler tldHandler = new TldContentHandler();
     String path = null;
 
     // Loop through all the .tld files in the WEB-INF dir
     // Parse each and get the values needed for the TagLibraries
     // hash in the .jpr file.
     try
     {
       File webInfDir =
         new File(.getBasedir(), "src/main/webapp/WEB-INF");
       if (webInfDir == null)
         return;
 
       File[] files = webInfDir.listFiles();
       if (files == null)
         return;
 
       Xpp3Dom hashDOM = null;
       Xpp3Dom valueDOM = null;
       for (int i = 0; i < files.lengthi++)
       {
         path = files[i].getPath();
         if (path.endsWith(".tld"))
         {
           hashDOM = new Xpp3Dom("hash");
           // we have a tag library.  Parse it and
          // get the values needed for the .jpr file
          // Parse
          tldHandler.parseTld(files[i]);
          // call gettors to get the values
          valueDOM = new Xpp3Dom("value");
          valueDOM.setAttribute("n""jspVersion");
          valueDOM.setAttribute("v"tldHandler.getJspVersion());
          hashDOM.addChild(valueDOM);
          valueDOM = new Xpp3Dom("value");
          valueDOM.setAttribute("n""name");
          valueDOM.setAttribute("v"tldHandler.getName());
          hashDOM.addChild(valueDOM);
          valueDOM = new Xpp3Dom("value");
          valueDOM.setAttribute("n""prefix");
          valueDOM.setAttribute("v"tldHandler.getPrefix());
          hashDOM.addChild(valueDOM);
          valueDOM = new Xpp3Dom("value");
          valueDOM.setAttribute("n""tldURL");
          valueDOM.setAttribute("v",
            "WEB-INF/" + path.substring(path.indexOf("WEB-INF") +  8));
          hashDOM.addChild(valueDOM);
          valueDOM = new Xpp3Dom("value");
          valueDOM.setAttribute("n""URI");
          valueDOM.setAttribute("v"tldHandler.getURI());
          hashDOM.addChild(valueDOM);
          valueDOM = new Xpp3Dom("value");
          valueDOM.setAttribute("n""version");
          valueDOM.setAttribute("v"tldHandler.getVersion());
          hashDOM.addChild(valueDOM);
          // Add each file's hash to the tag-libraries "list"
          targetLibsDOM.addChild(hashDOM);
        } // endif
      } // endfor
      return;
    }
    catch (SAXException saxex)
    {
      getLog().info("SAX Parse Exception parsing " + path + ": " +
                    saxex.getMessage(), saxex);
    }
    catch (IOException ioe)
    {
      getLog().info("Unable to open an InputStream to " + pathioe);
    }
    catch (ParserConfigurationException pce)
    {
      getLog().info("Unable to create SAX parser for " + pathpce);
    }
  }
  private void replaceTagLibraries(Xpp3Dom projectDOM)
  {
    // This boolean is set by specifying the jdev.plugin.add.taglibs
    // property at the top of a project's pom file.  There are projects
    // that don't need taglibs in their .jpr files to compile and this
    // allows them to be excluded.
    if (!)
      return;
    // /jpr:project
    //   /hash[@n="oracle.jdevimpl.webapp.jsp.libraries.model.ProjectTagLibraries"]
    //       /list[@n="tag-libaries"]
    Xpp3Dom projectTagsDOM =
      findNamedChild(projectDOM"hash""oracle.jdevimpl.webapp.jsp.libraries.model.ProjectTagLibraries");
    Xpp3Dom tagLibsDOM =
      findNamedChild(projectTagsDOM"list""tag-libraries");
    Xpp3Dom targetLibsDOM = new Xpp3Dom("list");
    //
    // tagLibraryDefinitions
    //
    //<hash>
    //  <hash n="baseLibrary">
    //    <value n="name" v="JSF HTML"></value>
    //    <value n="version" v="1.2"></value>
    //  </hash>
    //  <value n="jspVersion" v="2.1"></value>
    //  <value n="name" v="JSF HTML"></value>
    //
    //  <value n="tldURL" v="@oracle.home@/jdeveloper/modules/oracle.jsf_1.2.9/glassfish.jsf_1.2.9.0.jar!/META-INF"></value>        
    //  <value n="URI" v="http://java.sun.com/jsf/html"></value>
    //  <value n="version" v="1.2"></value>
    //</hash>
    //
    // Parent "hash"
    Xpp3Dom hashDOM = null;
    // <value...
    Xpp3Dom valueDOM = null;
    if ( != null &&
        . > 0)
    {
      // Process each distributed Tag Library
      for (int i = 0; i < .i++)
      {
        Properties disTagLib = [i];
        String nameName = null;
        String nameValue = null;
        String versionName = null;
        String versionValue = null;
        // Create parent hash for each taglib
        hashDOM = new Xpp3Dom("hash");
        // baseLibrary "hash" for each taglib
        Xpp3Dom hashBaseDOM = new Xpp3Dom("hash");
        hashBaseDOM.setAttribute("n""baseLibrary");
        // Add baseLibrary hash to parent hash
        hashDOM.addChild(hashBaseDOM);
        // Process each property of the taglib
        for (Enumeration keys = disTagLib.propertyNames();
             keys.hasMoreElements(); )
        {
          // Get the name value pair
          String name = (Stringkeys.nextElement();
          String value = (StringdisTagLib.get(name);
          // Put the name and version values
          // inside the baseLibrary hash.
          // This only happens once per taglib
          if ("name".equals(name))
          {
            nameName = name;
            nameValue = value;
            // n="name, v=<name of taglib> in baseLibrary
            valueDOM = new Xpp3Dom("value");
            valueDOM.setAttribute("n"name);
            valueDOM.setAttribute("v"value);
            hashBaseDOM.addChild(valueDOM);
            // Duplicate the "name"  <value...
            // outside of the baseLibrary
            // n="name, v=<name of taglib> in parent hash
            valueDOM = new Xpp3Dom("value");
            valueDOM.setAttribute("n"nameName);
            valueDOM.setAttribute("v"nameValue);
            hashDOM.addChild(valueDOM);
          }
          else if ("version".equals(name))
          {
            versionName = name;
            versionValue = value;
            // n="version" v=<taglib version> in baseLibrary
            valueDOM = new Xpp3Dom("value");
            valueDOM.setAttribute("n"name);
            valueDOM.setAttribute("v"value);
            hashBaseDOM.addChild(valueDOM);
            // Duplicate the "version" <value...
            // outside of the baseLibrary
            // n="version" v=<taglib version> in parent hash
            valueDOM = new Xpp3Dom("value");
            valueDOM.setAttribute("n"versionName);
            valueDOM.setAttribute("v"versionValue);
            hashDOM.addChild(valueDOM);
          }
          else
          {
            if ("tld".equals(name))
            {
              // Did not want to have a URL in the pom file.
              // I just wanted the user to specify the name
              // of the tld file.  So we fix it for JDev
              // here.
              name += "URL";
              value =  + "/" + value;
            }
            valueDOM = new Xpp3Dom("value");
            valueDOM.setAttribute("n"name);
            valueDOM.setAttribute("v"value);
            hashDOM.addChild(valueDOM);
          }
        } //endfor processing each property
        // We are done with this disTagLib