Coverage Report - org.apache.maven.plugin.eclipse.writers.EclipseClasspathWriter
 
Classes in this File Line Coverage Branch Coverage Complexity
EclipseClasspathWriter
69%
128/186
40%
55/136
18.333
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one
 3  
  * or more contributor license agreements.  See the NOTICE file
 4  
  * distributed with this work for additional information
 5  
  * regarding copyright ownership.  The ASF licenses this file
 6  
  * to you under the Apache License, Version 2.0 (the
 7  
  * "License"); you may not use this file except in compliance
 8  
  * with the License.  You may obtain a copy of the License at
 9  
  *
 10  
  *   http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing,
 13  
  * software distributed under the License is distributed on an
 14  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 15  
  * KIND, either express or implied.  See the License for the
 16  
  * specific language governing permissions and limitations
 17  
  * under the License.
 18  
  */
 19  
 package org.apache.maven.plugin.eclipse.writers;
 20  
 
 21  
 import java.io.File;
 22  
 import java.io.FileOutputStream;
 23  
 import java.io.IOException;
 24  
 import java.io.OutputStreamWriter;
 25  
 import java.io.Writer;
 26  
 import java.util.ArrayList;
 27  
 import java.util.HashMap;
 28  
 import java.util.HashSet;
 29  
 import java.util.Iterator;
 30  
 import java.util.List;
 31  
 import java.util.Map;
 32  
 import java.util.Set;
 33  
 
 34  
 import org.apache.maven.plugin.MojoExecutionException;
 35  
 import org.apache.maven.plugin.eclipse.BuildCommand;
 36  
 import org.apache.maven.plugin.eclipse.Constants;
 37  
 import org.apache.maven.plugin.eclipse.EclipseSourceDir;
 38  
 import org.apache.maven.plugin.eclipse.Messages;
 39  
 import org.apache.maven.plugin.ide.IdeDependency;
 40  
 import org.apache.maven.plugin.ide.IdeUtils;
 41  
 import org.codehaus.plexus.util.IOUtil;
 42  
 import org.codehaus.plexus.util.StringUtils;
 43  
 import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter;
 44  
 import org.codehaus.plexus.util.xml.XMLWriter;
 45  
 
 46  
 /**
 47  
  * Writes eclipse .classpath file.
 48  
  * 
 49  
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
 50  
  * @author <a href="mailto:kenney@neonics.com">Kenney Westerhof</a>
 51  
  * @author <a href="mailto:fgiust@apache.org">Fabrizio Giustina</a>
 52  
  * @version $Id: EclipseClasspathWriter.java 750073 2009-03-04 16:55:01Z aheritier $
 53  
  */
 54  8
 public class EclipseClasspathWriter
 55  
     extends AbstractEclipseWriter
 56  
 {
 57  
 
 58  
     /**
 59  
      * 
 60  
      */
 61  
     private static final String ORG_ECLIPSE_AJDT_INPATH = "org.eclipse.ajdt.inpath";
 62  
 
 63  
     /**
 64  
      * 
 65  
      */
 66  
     private static final String ORG_ECLIPSE_AJDT_ASPECTPATH = "org.eclipse.ajdt.aspectpath";
 67  
 
 68  
     /**
 69  
      * 
 70  
      */
 71  
     private static final String NAME = "name";
 72  
 
 73  
     /**
 74  
      * 
 75  
      */
 76  
     private static final String VALUE = "value";
 77  
 
 78  
     /**
 79  
      * 
 80  
      */
 81  
     private static final String ATTRIBUTE = "attribute";
 82  
 
 83  
     /**
 84  
      * 
 85  
      */
 86  
     private static final String ATTRIBUTES = "attributes";
 87  
 
 88  
     /**
 89  
      * Eclipse build path variable M2_REPO
 90  
      */
 91  
     protected static final String M2_REPO = "M2_REPO"; //$NON-NLS-1$
 92  
 
 93  
     /**
 94  
      * Attribute for sourcepath.
 95  
      */
 96  
     private static final String ATTR_SOURCEPATH = "sourcepath"; //$NON-NLS-1$
 97  
 
 98  
     /**
 99  
      * Attribute for output.
 100  
      */
 101  
     private static final String ATTR_OUTPUT = "output"; //$NON-NLS-1$
 102  
 
 103  
     /**
 104  
      * Attribute for path.
 105  
      */
 106  
     private static final String ATTR_PATH = "path"; //$NON-NLS-1$
 107  
 
 108  
     /**
 109  
      * Attribute for kind - Container (con), Variable (var)..etc.
 110  
      */
 111  
     private static final String ATTR_KIND = "kind"; //$NON-NLS-1$
 112  
 
 113  
     /**
 114  
      * Attribute value for kind: var
 115  
      */
 116  
     private static final String ATTR_VAR = "var"; //$NON-NLS-1$
 117  
 
 118  
     /**
 119  
      * Attribute value for kind: lib
 120  
      */
 121  
     private static final String ATTR_LIB = "lib"; //$NON-NLS-1$
 122  
 
 123  
     /**
 124  
      * Attribute value for kind: src
 125  
      */
 126  
     private static final String ATTR_SRC = "src"; //$NON-NLS-1$
 127  
 
 128  
     /**
 129  
      * Attribute name for source file includes in a path.
 130  
      */
 131  
     private static final String ATTR_INCLUDING = "including";
 132  
 
 133  
     /**
 134  
      * Attribute name for source file excludes in a path.
 135  
      */
 136  
     private static final String ATTR_EXCLUDING = "excluding";
 137  
 
 138  
     /**
 139  
      * Element for classpathentry.
 140  
      */
 141  
     private static final String ELT_CLASSPATHENTRY = "classpathentry"; //$NON-NLS-1$
 142  
 
 143  
     /**
 144  
      * Element for classpath.
 145  
      */
 146  
     private static final String ELT_CLASSPATH = "classpath"; //$NON-NLS-1$
 147  
 
 148  
     /**
 149  
      * File name that stores project classpath settings.
 150  
      */
 151  
     private static final String FILE_DOT_CLASSPATH = ".classpath"; //$NON-NLS-1$
 152  
 
 153  
     /**
 154  
      * @see org.apache.maven.plugin.eclipse.writers.EclipseWriter#write()
 155  
      */
 156  
     public void write()
 157  
         throws MojoExecutionException
 158  
     {
 159  
 
 160  
         Writer w;
 161  
 
 162  
         try
 163  
         {
 164  8
             w =
 165  
                 new OutputStreamWriter( new FileOutputStream( new File( config.getEclipseProjectDirectory(),
 166  
                                                                         FILE_DOT_CLASSPATH ) ), "UTF-8" );
 167  
         }
 168  0
         catch ( IOException ex )
 169  
         {
 170  0
             throw new MojoExecutionException( Messages.getString( "EclipsePlugin.erroropeningfile" ), ex ); //$NON-NLS-1$
 171  8
         }
 172  
 
 173  8
         XMLWriter writer = new PrettyPrintXMLWriter( w );
 174  
 
 175  8
         writer.startElement( ELT_CLASSPATH );
 176  
 
 177  8
         String defaultOutput =
 178  
             IdeUtils.toRelativeAndFixSeparator( config.getProjectBaseDir(), config.getBuildOutputDirectory(), false );
 179  
 
 180  
         // ----------------------------------------------------------------------
 181  
         // Source roots and resources
 182  
         // ----------------------------------------------------------------------
 183  
 
 184  
         // List<EclipseSourceDir>
 185  8
         List specialSources = new ArrayList();
 186  
 
 187  
         // Map<String,List<EclipseSourceDir>>
 188  8
         Map byOutputDir = new HashMap();
 189  
 
 190  16
         for ( int j = 0; j < config.getSourceDirs().length; j++ )
 191  
         {
 192  8
             EclipseSourceDir dir = config.getSourceDirs()[j];
 193  
 
 194  
             // List<EclipseSourceDir>
 195  8
             List byOutputDirs = (List) byOutputDir.get( dir.getOutput() );
 196  8
             if ( byOutputDirs == null )
 197  
             {
 198  
                 // ArrayList<EclipseSourceDir>
 199  8
                 byOutputDir.put( dir.getOutput() == null ? defaultOutput : dir.getOutput(), byOutputDirs =
 200  
                     new ArrayList() );
 201  
             }
 202  8
             byOutputDirs.add( dir );
 203  
         }
 204  
 
 205  16
         for ( int j = 0; j < config.getSourceDirs().length; j++ )
 206  
         {
 207  8
             EclipseSourceDir dir = config.getSourceDirs()[j];
 208  
 
 209  8
             log.debug( "Processing " + ( dir.isResource() ? "re" : "" ) + "source " + dir.getPath() + ": output="
 210  
                 + dir.getOutput() + "; default output=" + defaultOutput );
 211  
 
 212  8
             boolean isSpecial = false;
 213  
 
 214  
             // handle resource with nested output folders
 215  8
             if ( dir.isResource() )
 216  
             {
 217  
                 // Check if the output is a subdirectory of the default output,
 218  
                 // and if the default output has any sources that copy there.
 219  
 
 220  8
                 if ( dir.getOutput() != null // resource output dir is set
 221  
                     && !dir.getOutput().equals( defaultOutput ) // output dir is not default target/classes
 222  
                     && dir.getOutput().startsWith( defaultOutput ) // ... but is nested
 223  
                     && byOutputDir.get( defaultOutput ) != null // ???
 224  
                     && !( (List) byOutputDir.get( defaultOutput ) ).isEmpty() // ???
 225  
                 )
 226  
                 {
 227  
                     // do not specify as source since the output will be nested. Instead, mark
 228  
                     // it as a todo, and handle it with a custom build.xml file later.
 229  
 
 230  4
                     log.debug( "Marking as special to prevent output folder nesting: " + dir.getPath() + " (output="
 231  
                         + dir.getOutput() + ")" );
 232  
 
 233  4
                     isSpecial = true;
 234  4
                     specialSources.add( dir );
 235  
                 }
 236  
             }
 237  
 
 238  8
             writer.startElement( ELT_CLASSPATHENTRY );
 239  
 
 240  8
             writer.addAttribute( ATTR_KIND, "src" ); //$NON-NLS-1$
 241  8
             writer.addAttribute( ATTR_PATH, dir.getPath() );
 242  
 
 243  8
             if ( !isSpecial && dir.getOutput() != null && !defaultOutput.equals( dir.getOutput() ) )
 244  
             {
 245  0
                 writer.addAttribute( ATTR_OUTPUT, dir.getOutput() );
 246  
             }
 247  
 
 248  8
             String includes = dir.getInclude();
 249  
 
 250  8
             if ( !dir.isResource() )
 251  
             {
 252  
                 // automatically include java files only: eclipse doesn't have the concept of a source only directory so it 
 253  
                 // will try to include non-java files found in maven source dirs
 254  0
                 includes = StringUtils.isEmpty( includes ) ? "**/*.java" : includes + "|**/*.java";
 255  
             }
 256  
             
 257  8
             if ( StringUtils.isNotEmpty( includes ) )
 258  
             {
 259  0
                 writer.addAttribute( ATTR_INCLUDING, includes );
 260  
             }
 261  
 
 262  8
             String excludes = dir.getExclude();
 263  
 
 264  8
             if ( dir.isResource() )
 265  
             {
 266  
                 // automatically exclude java files: eclipse doesn't have the concept of resource directory so it will
 267  
                 // try to compile any java file found in maven resource dirs
 268  8
                 excludes = StringUtils.isEmpty( excludes ) ? "**/*.java" : excludes + "|**/*.java";
 269  
             }
 270  
 
 271  8
             if ( StringUtils.isNotEmpty( excludes ) )
 272  
             {
 273  8
                 writer.addAttribute( ATTR_EXCLUDING, excludes );
 274  
             }
 275  
 
 276  8
             writer.endElement();
 277  
 
 278  
         }
 279  
 
 280  
         // handle the special sources.
 281  8
         if ( !specialSources.isEmpty() )
 282  
         {
 283  4
             log.info( "Creating maven-eclipse.xml Ant file to handle resources" );
 284  
 
 285  
             try
 286  
             {
 287  4
                 Writer buildXmlWriter =
 288  
                     new OutputStreamWriter( new FileOutputStream( new File( config.getEclipseProjectDirectory(),
 289  
                                                                             "maven-eclipse.xml" ) ), "UTF-8" );
 290  4
                 PrettyPrintXMLWriter buildXmlPrinter = new PrettyPrintXMLWriter( buildXmlWriter );
 291  
 
 292  4
                 buildXmlPrinter.startElement( "project" );
 293  4
                 buildXmlPrinter.addAttribute( "default", "copy-resources" );
 294  
 
 295  4
                 buildXmlPrinter.startElement( "target" );
 296  4
                 buildXmlPrinter.addAttribute( NAME, "init" );
 297  
                 // initialize filtering tokens here
 298  4
                 buildXmlPrinter.endElement();
 299  
 
 300  4
                 buildXmlPrinter.startElement( "target" );
 301  4
                 buildXmlPrinter.addAttribute( NAME, "copy-resources" );
 302  4
                 buildXmlPrinter.addAttribute( "depends", "init" );
 303  
 
 304  4
                 for ( Iterator it = specialSources.iterator(); it.hasNext(); )
 305  
                 {
 306  
                     // TODO: merge source dirs on output path+filtering to reduce
 307  
                     // <copy> tags for speed.
 308  4
                     EclipseSourceDir dir = (EclipseSourceDir) it.next();
 309  4
                     buildXmlPrinter.startElement( "copy" );
 310  4
                     buildXmlPrinter.addAttribute( "todir", dir.getOutput() );
 311  4
                     buildXmlPrinter.addAttribute( "filtering", "" + dir.isFiltering() );
 312  
 
 313  4
                     buildXmlPrinter.startElement( "fileset" );
 314  4
                     buildXmlPrinter.addAttribute( "dir", dir.getPath() );
 315  4
                     if ( dir.getInclude() != null )
 316  
                     {
 317  0
                         buildXmlPrinter.addAttribute( "includes", dir.getInclude() );
 318  
                     }
 319  4
                     if ( dir.getExclude() != null )
 320  
                     {
 321  0
                         buildXmlPrinter.addAttribute( "excludes", dir.getExclude() );
 322  
                     }
 323  4
                     buildXmlPrinter.endElement();
 324  
 
 325  4
                     buildXmlPrinter.endElement();
 326  
                 }
 327  
 
 328  4
                 buildXmlPrinter.endElement();
 329  
 
 330  4
                 buildXmlPrinter.endElement();
 331  
 
 332  4
                 IOUtil.close( buildXmlWriter );
 333  
             }
 334  0
             catch ( IOException e )
 335  
             {
 336  0
                 throw new MojoExecutionException( "Cannot create " + config.getEclipseProjectDirectory()
 337  
                     + "/maven-eclipse.xml", e );
 338  4
             }
 339  
 
 340  4
             log.info( "Creating external launcher file" );
 341  
             // now create the launcher
 342  4
             new EclipseAntExternalLaunchConfigurationWriter().init( log, config, "Maven_Ant_Builder.launch",
 343  
                                                                     "maven-eclipse.xml" ).write();
 344  
 
 345  
             // finally add it to the project writer.
 346  
 
 347  4
             config.getBuildCommands().add(
 348  
                                            new BuildCommand(
 349  
                                                              "org.eclipse.ui.externaltools.ExternalToolBuilder",
 350  
                                                              "LaunchConfigHandle",
 351  
                                                              "<project>/"
 352  
                                                                  + EclipseLaunchConfigurationWriter.FILE_DOT_EXTERNAL_TOOL_BUILDERS
 353  
                                                                  + "Maven_Ant_Builder.launch" ) );
 354  
         }
 355  
 
 356  
         // ----------------------------------------------------------------------
 357  
         // The default output
 358  
         // ----------------------------------------------------------------------
 359  
 
 360  8
         writer.startElement( ELT_CLASSPATHENTRY );
 361  8
         writer.addAttribute( ATTR_KIND, ATTR_OUTPUT );
 362  8
         writer.addAttribute( ATTR_PATH, defaultOutput );
 363  8
         writer.endElement();
 364  
 
 365  8
         Set addedDependencies = new HashSet();
 366  
         // TODO if (..magic property equals orderDependencies..)
 367  
 
 368  
         // ----------------------------------------------------------------------
 369  
         // Java API dependencies that may complete the classpath container so must
 370  
         // be declared BEFORE so that container access rules don't fail
 371  
         // ----------------------------------------------------------------------
 372  8
         IdeDependency[] depsToWrite = config.getDepsOrdered();
 373  12
         for ( int j = 0; j < depsToWrite.length; j++ )
 374  
         {
 375  4
             IdeDependency dep = depsToWrite[j];
 376  4
             if ( dep.isJavaApi() )
 377  
             {
 378  0
                 String depId = getDependencyId( dep );
 379  0
                 if ( !addedDependencies.contains( depId ) )
 380  
                 {
 381  0
                     addDependency( writer, dep );
 382  0
                     addedDependencies.add( depId );
 383  
                 }
 384  
             }
 385  
         }
 386  
 
 387  
         // ----------------------------------------------------------------------
 388  
         // The dependencies
 389  
         // ----------------------------------------------------------------------
 390  12
         for ( int j = 0; j < depsToWrite.length; j++ )
 391  
         {
 392  4
             IdeDependency dep = depsToWrite[j];
 393  
 
 394  4
             if ( dep.isAddedToClasspath() )
 395  
             {
 396  4
                 String depId = getDependencyId( dep );
 397  
                 /* avoid duplicates in the classpath for artifacts with different types (like ejbs or test-jars) */
 398  4
                 if ( !addedDependencies.contains( depId ) )
 399  
                 {
 400  4
                     addDependency( writer, dep );
 401  4
                     addedDependencies.add( depId );
 402  
                 }
 403  
             }
 404  
         }
 405  
 
 406  
         // ----------------------------------------------------------------------
 407  
         // Container classpath entries
 408  
         // ----------------------------------------------------------------------
 409  
 
 410  8
         for ( Iterator it = config.getClasspathContainers().iterator(); it.hasNext(); )
 411  
         {
 412  0
             writer.startElement( ELT_CLASSPATHENTRY );
 413  0
             writer.addAttribute( ATTR_KIND, "con" ); //$NON-NLS-1$
 414  0
             writer.addAttribute( ATTR_PATH, (String) it.next() );
 415  0
             writer.endElement(); // name
 416  
         }
 417  
         
 418  8
         writer.endElement();
 419  
 
 420  8
         IOUtil.close( w );
 421  
 
 422  8
     }
 423  
 
 424  
     private String getDependencyId( IdeDependency dep )
 425  
     {
 426  4
         String depId =
 427  
             dep.getGroupId() + ":" + dep.getArtifactId() + ":" + dep.getClassifier() + ":" + dep.getVersion();
 428  
 
 429  4
         if ( dep.isReferencedProject() )
 430  
         {
 431  
             // This dependency will be refered as an eclipse project
 432  0
             depId = dep.getEclipseProjectName();
 433  
         }
 434  4
         return depId;
 435  
     }
 436  
 
 437  
     protected void addDependency( XMLWriter writer, IdeDependency dep )
 438  
         throws MojoExecutionException
 439  
     {
 440  
 
 441  
         String path;
 442  
         String kind;
 443  4
         String sourcepath = null;
 444  4
         String javadocpath = null;
 445  
 
 446  4
         if ( dep.isReferencedProject() && !config.isPde() )
 447  
         {
 448  0
             path = "/" + dep.getEclipseProjectName(); //$NON-NLS-1$
 449  0
             kind = ATTR_SRC;
 450  
         }
 451  4
         else if ( dep.isReferencedProject() && config.isPde() )
 452  
         {
 453  
             // don't do anything, referenced projects are automatically handled by eclipse in PDE builds
 454  0
             return;
 455  
         }
 456  
         else
 457  
         {
 458  4
             File artifactPath = dep.getFile();
 459  
 
 460  4
             if ( artifactPath == null )
 461  
             {
 462  0
                 log.error( Messages.getString( "EclipsePlugin.artifactpathisnull", dep.getId() ) ); //$NON-NLS-1$
 463  0
                 return;
 464  
             }
 465  
 
 466  4
             if ( dep.isSystemScoped() )
 467  
             {
 468  0
                 path = IdeUtils.toRelativeAndFixSeparator( config.getEclipseProjectDirectory(), artifactPath, false );
 469  
 
 470  0
                 if ( log.isDebugEnabled() )
 471  
                 {
 472  0
                     log.debug( Messages.getString( "EclipsePlugin.artifactissystemscoped", //$NON-NLS-1$
 473  
                                                    new Object[] { dep.getArtifactId(), path } ) );
 474  
                 }
 475  
 
 476  0
                 kind = ATTR_LIB;
 477  
             }
 478  
             else
 479  
             {
 480  4
                 File localRepositoryFile = new File( config.getLocalRepository().getBasedir() );
 481  
 
 482  
                 // if the dependency is not provided and the plugin runs in "pde mode", the dependency is
 483  
                 // added to the Bundle-Classpath:
 484  4
                 if ( config.isPde() && ( dep.isProvided() || dep.isOsgiBundle() ) )
 485  
                 {
 486  0
                     return;
 487  
                 }
 488  4
                 else if ( config.isPde() && !dep.isProvided() && !dep.isTestDependency() )
 489  
                 {
 490  
                     // path for link created in .project, not to the actual file
 491  0
                     path = dep.getFile().getName();
 492  
 
 493  0
                     kind = ATTR_LIB;
 494  
                 }
 495  
                 // running in PDE mode and the dependency is provided means, that it is provided by
 496  
                 // the target platform. This case is covered by adding the plugin container
 497  
                 else
 498  
                 {
 499  4
                     String fullPath = artifactPath.getPath();
 500  4
                     String relativePath =
 501  
                         IdeUtils.toRelativeAndFixSeparator( localRepositoryFile, new File( fullPath ), false );
 502  
 
 503  4
                     if ( !new File( relativePath ).isAbsolute() )
 504  
                     {
 505  4
                         path = M2_REPO + "/" //$NON-NLS-1$
 506  
                             + relativePath;
 507  4
                         kind = ATTR_VAR; //$NON-NLS-1$
 508  
                     }
 509  
                     else
 510  
                     {
 511  0
                         path = relativePath;
 512  0
                         kind = ATTR_LIB;
 513  
                     }
 514  
                 }
 515  
 
 516  4
                 if ( dep.getSourceAttachment() != null )
 517  
                 {
 518  0
                     if ( ATTR_VAR.equals( kind ) )
 519  
                     {
 520  0
                         sourcepath =
 521  
                             M2_REPO
 522  
                                 + "/" //$NON-NLS-1$
 523  
                                 + IdeUtils.toRelativeAndFixSeparator( localRepositoryFile, dep.getSourceAttachment(),
 524  
                                                                       false );
 525  
                     }
 526  
                     else
 527  
                     {
 528  
                         // source archive must be referenced with the full path, we can't mix a lib with a variable
 529  0
                         sourcepath = IdeUtils.getCanonicalPath( dep.getSourceAttachment() );
 530  
                     }
 531  
                 }
 532  
 
 533  4
                 if ( dep.getJavadocAttachment() != null )
 534  
                 {
 535  
                     // NB eclipse (3.1) doesn't support variables in javadoc paths, so we need to add the
 536  
                     // full path for the maven repo
 537  4
                     javadocpath =
 538  
                         StringUtils.replace( IdeUtils.getCanonicalPath( dep.getJavadocAttachment() ), "\\", "/" ); //$NON-NLS-1$ //$NON-NLS-2$
 539  
                 }
 540  
 
 541  
             }
 542  
 
 543  
         }
 544  
 
 545  
         // Skip aspectj libraries since they are in the container.
 546  4
         if ( ( config.getAjdtVersion() != 0 ) && dep.getArtifactId().toLowerCase().startsWith( "aspectj" ) )
 547  
         {
 548  0
             return;
 549  
         }
 550  
 
 551  4
         writer.startElement( ELT_CLASSPATHENTRY );
 552  4
         writer.addAttribute( ATTR_KIND, kind );
 553  4
         writer.addAttribute( ATTR_PATH, path );
 554  
 
 555  4
         if ( sourcepath != null )
 556  
         {
 557  0
             writer.addAttribute( ATTR_SOURCEPATH, sourcepath );
 558  
         }
 559  
 
 560  4
         boolean attributeElemOpen = false;
 561  
 
 562  4
         if ( javadocpath != null )
 563  
         {
 564  4
             if ( !attributeElemOpen )
 565  
             {
 566  4
                 writer.startElement( ATTRIBUTES ); //$NON-NLS-1$
 567  4
                 attributeElemOpen = true;
 568  
             }
 569  
 
 570  4
             writer.startElement( ATTRIBUTE ); //$NON-NLS-1$
 571  4
             writer.addAttribute( VALUE, "jar:" + new File( javadocpath ).toURI() + "!/" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
 572  4
             writer.addAttribute( NAME, "javadoc_location" ); //$NON-NLS-1$ //$NON-NLS-2$
 573  4
             writer.endElement();
 574  
 
 575  
         }
 576  
 
 577  4
         if ( Constants.PROJECT_PACKAGING_WAR.equals( this.config.getPackaging() ) && config.getWtpapplicationxml()
 578  
             && kind.equals( ATTR_VAR ) && !dep.isTestDependency() && !dep.isProvided()
 579  
             && !dep.isSystemScopedOutsideProject( this.config.getProject() ) )
 580  
         {
 581  0
             if ( !attributeElemOpen )
 582  
             {
 583  0
                 writer.startElement( ATTRIBUTES ); //$NON-NLS-1$
 584  0
                 attributeElemOpen = true;
 585  
             }
 586  
 
 587  0
             writer.startElement( ATTRIBUTE ); //$NON-NLS-1$
 588  0
             writer.addAttribute( VALUE, "/WEB-INF/lib" ); //$NON-NLS-1$ //$NON-NLS-2$
 589  0
             writer.addAttribute( NAME, "org.eclipse.jst.component.dependency" ); //$NON-NLS-1$ //$NON-NLS-2$
 590  0
             writer.endElement();
 591  
 
 592  
         }
 593  
 
 594  4
         if ( dep.isAjdtDependency() && ( config.getAjdtVersion() >= 1.5 ) )
 595  
         {
 596  0
             if ( !attributeElemOpen )
 597  
             {
 598  0
                 writer.startElement( ATTRIBUTES ); //$NON-NLS-1$
 599  0
                 attributeElemOpen = true;
 600  
             }
 601  
 
 602  0
             writer.startElement( ATTRIBUTE ); //$NON-NLS-1$
 603  0
             writer.addAttribute( NAME, ORG_ECLIPSE_AJDT_ASPECTPATH ); //$NON-NLS-1$ //$NON-NLS-2$
 604  0
             writer.addAttribute( VALUE, Boolean.TRUE.toString() ); //$NON-NLS-1$ //$NON-NLS-2$
 605  0
             writer.endElement();
 606  
 
 607  
         }
 608  
 
 609  4
         if ( dep.isAjdtWeaveDependency() && ( config.getAjdtVersion() >= 1.5 ) )
 610  
         {
 611  0
             if ( !attributeElemOpen )
 612  
             {
 613  0
                 writer.startElement( ATTRIBUTES ); //$NON-NLS-1$
 614  0
                 attributeElemOpen = true;
 615  
             }
 616  
 
 617  0
             writer.startElement( ATTRIBUTE ); //$NON-NLS-1$
 618  0
             writer.addAttribute( NAME, ORG_ECLIPSE_AJDT_INPATH ); //$NON-NLS-1$ //$NON-NLS-2$
 619  0
             writer.addAttribute( VALUE, Boolean.TRUE.toString() ); //$NON-NLS-1$ //$NON-NLS-2$
 620  0
             writer.endElement();
 621  
 
 622  
         }
 623  
 
 624  4
         if ( attributeElemOpen )
 625  
         {
 626  4
             writer.endElement();
 627  
         }
 628  4
         writer.endElement();
 629  
 
 630  4
     }
 631  
 }