Coverage Report - org.apache.maven.plugin.eclipse.writers.EclipseWriterConfig
 
Classes in this File Line Coverage Branch Coverage Complexity
EclipseWriterConfig
46%
33/72
50%
1/2
1.182
EclipseWriterConfig$1
8%
1/13
0%
0/10
1.182
 
 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.util.Arrays;
 23  
 import java.util.Comparator;
 24  
 import java.util.List;
 25  
 import java.util.Map;
 26  
 
 27  
 import org.apache.maven.artifact.repository.ArtifactRepository;
 28  
 import org.apache.maven.plugin.eclipse.EclipsePlugin;
 29  
 import org.apache.maven.plugin.eclipse.EclipseSourceDir;
 30  
 import org.apache.maven.plugin.eclipse.WorkspaceConfiguration;
 31  
 import org.apache.maven.plugin.ide.IdeDependency;
 32  
 import org.apache.maven.project.MavenProject;
 33  
 
 34  
 /**
 35  
  * @author Fabrizio Giustina
 36  
  * @version $Id: EclipseWriterConfig.java 616816 2008-01-30 17:23:08Z aheritier $
 37  
  */
 38  6
 public class EclipseWriterConfig
 39  
 {
 40  
     /**
 41  
      * The maven project.
 42  
      */
 43  
     private MavenProject project;
 44  
 
 45  
     /**
 46  
      * The maven project packaging.
 47  
      */
 48  
     private String packaging;
 49  
 
 50  
     /**
 51  
      * Eclipse project dir.
 52  
      */
 53  
     private File eclipseProjectDirectory;
 54  
 
 55  
     /**
 56  
      * The name of the project in eclipse.
 57  
      */
 58  
     private String eclipseProjectName;
 59  
 
 60  
     /**
 61  
      * Base project dir.
 62  
      */
 63  
     private File projectBaseDir;
 64  
 
 65  
     /**
 66  
      * List of IDE dependencies.
 67  
      */
 68  6
     private IdeDependency[] deps = new IdeDependency[0];
 69  
 
 70  
     /**
 71  
      * List of IDE dependencies ordered.
 72  
      */
 73  6
     private IdeDependency[] orderedDeps = new IdeDependency[0];
 74  
 
 75  
     /**
 76  
      * Source directories.
 77  
      */
 78  
     private EclipseSourceDir[] sourceDirs;
 79  
 
 80  
     /**
 81  
      * Local maven repo.
 82  
      */
 83  
     private ArtifactRepository localRepository;
 84  
 
 85  
     /**
 86  
      * Build output directory for eclipse.
 87  
      */
 88  
     private File buildOutputDirectory;
 89  
 
 90  
     /**
 91  
      * Manifest file.
 92  
      */
 93  
     private File manifestFile;
 94  
 
 95  
     /**
 96  
      * PDE mode.
 97  
      */
 98  
     private boolean pde;
 99  
 
 100  
     /**
 101  
      * Project natures.
 102  
      */
 103  
     private List projectnatures;
 104  
 
 105  
     /**
 106  
      * Project facets.
 107  
      */
 108  
     private Map projectFacets;
 109  
 
 110  
     /**
 111  
      * Build commands. List<BuildCommand>
 112  
      */
 113  
     private List buildCommands;
 114  
 
 115  
     /**
 116  
      * Classpath containers.
 117  
      */
 118  
     private List classpathContainers;
 119  
 
 120  
     /**
 121  
      * Appends the version number to the project name if <tt>true</tt>.
 122  
      * 
 123  
      * @deprecated use {@link #projectNameTemplate}
 124  
      */
 125  
     private boolean addVersionToProjectName;
 126  
 
 127  
     /**
 128  
      * @see EclipsePlugin#getProjectNameTemplate()
 129  
      */
 130  
     private String projectNameTemplate;
 131  
 
 132  
     /**
 133  
      * @see EclipsePlugin#deployName()
 134  
      */
 135  
 
 136  
     private String contextName;
 137  
 
 138  
     /**
 139  
      * @see EclipsePlugin#wtpapplicationxml()
 140  
      */
 141  
     private boolean wtpapplicationxml;
 142  
 
 143  
     /**
 144  
      * @see EclipsePlugin#getWtpversion()
 145  
      */
 146  
     private float wtpVersion;
 147  
 
 148  
     private WorkspaceConfiguration workspaceConfiguration;
 149  
 
 150  
     public WorkspaceConfiguration getWorkspaceConfiguration()
 151  
     {
 152  0
         return workspaceConfiguration;
 153  
     }
 154  
 
 155  
     public void setWorkspaceConfiguration( WorkspaceConfiguration workspaceConfiguration )
 156  
     {
 157  0
         this.workspaceConfiguration = workspaceConfiguration;
 158  0
     }
 159  
 
 160  
     /**
 161  
      * Getter for <code>deps</code>.
 162  
      * 
 163  
      * @return Returns the deps.
 164  
      */
 165  
     public IdeDependency[] getDeps()
 166  
     {
 167  0
         return deps;
 168  
     }
 169  
 
 170  
     /**
 171  
      * Setter for <code>deps</code>.
 172  
      * 
 173  
      * @param deps The deps to set.
 174  
      */
 175  
     public void setDeps( IdeDependency[] deps )
 176  
     {
 177  2
         this.deps = deps;
 178  2
         if ( deps != null )
 179  
         {
 180  
             // TODO get the right comparator depending on orderDependencies={name,nearness..};
 181  
             // if none specified it could use a NullComparator to reduce the number of
 182  
             // conditions that have to be checked
 183  2
             Comparator depsByArtifactId = new Comparator()
 184  
             {
 185  2
                 public int compare( Object o1, Object o2 )
 186  
                 {
 187  0
                     int result =
 188  
                         ( (IdeDependency) o1 ).getArtifactId().compareToIgnoreCase(
 189  
                                                                                     ( (IdeDependency) o2 ).getArtifactId() );
 190  0
                     if ( result != 0 )
 191  
                     {
 192  0
                         return result;
 193  
                     }
 194  0
                     if ( ( (IdeDependency) o1 ).getClassifier() != null &&
 195  
                         ( (IdeDependency) o2 ).getClassifier() != null )
 196  
                     {
 197  0
                         result =
 198  
                             ( (IdeDependency) o1 ).getClassifier().compareToIgnoreCase(
 199  
                                                                                         ( (IdeDependency) o2 ).getClassifier() );
 200  0
                         if ( result != 0 )
 201  
                         {
 202  0
                             return result;
 203  
                         }
 204  
                     }
 205  0
                     result = ( (IdeDependency) o1 ).getType().compareToIgnoreCase( ( (IdeDependency) o2 ).getType() );
 206  0
                     if ( result != 0 )
 207  
                     {
 208  0
                         return result;
 209  
                     }
 210  0
                     result =
 211  
                         ( (IdeDependency) o1 ).getGroupId().compareToIgnoreCase( ( (IdeDependency) o2 ).getGroupId() );
 212  0
                     return result;
 213  
                 }
 214  
             };
 215  
 
 216  2
             orderedDeps = new IdeDependency[deps.length];
 217  2
             System.arraycopy( deps, 0, orderedDeps, 0, deps.length );
 218  2
             Arrays.sort( orderedDeps, depsByArtifactId );
 219  
         }
 220  2
     }
 221  
 
 222  
     /**
 223  
      * Getter for <code>eclipseProjectDir</code>.
 224  
      * 
 225  
      * @return Returns the eclipseProjectDir.
 226  
      */
 227  
     public File getEclipseProjectDirectory()
 228  
     {
 229  8
         return eclipseProjectDirectory;
 230  
     }
 231  
 
 232  
     /**
 233  
      * Setter for <code>eclipseProjectDir</code>.
 234  
      * 
 235  
      * @param eclipseProjectDir The eclipseProjectDir to set.
 236  
      */
 237  
     public void setEclipseProjectDirectory( File eclipseProjectDir )
 238  
     {
 239  4
         eclipseProjectDirectory = eclipseProjectDir;
 240  4
     }
 241  
 
 242  
     /**
 243  
      * Getter for <code>eclipseProjectName</code>.
 244  
      * 
 245  
      * @return Returns the project name used in eclipse.
 246  
      */
 247  
     public String getEclipseProjectName()
 248  
     {
 249  6
         return eclipseProjectName;
 250  
     }
 251  
 
 252  
     /**
 253  
      * Setter for <code>eclipseProjectName</code>.
 254  
      * 
 255  
      * @param eclipseProjectName the project name used in eclipse.
 256  
      */
 257  
     public void setEclipseProjectName( String eclipseProjectName )
 258  
     {
 259  4
         this.eclipseProjectName = eclipseProjectName;
 260  4
     }
 261  
 
 262  
     /**
 263  
      * Getter for <code>project</code>.
 264  
      * 
 265  
      * @return Returns the project.
 266  
      */
 267  
     public MavenProject getProject()
 268  
     {
 269  0
         return project;
 270  
     }
 271  
 
 272  
     /**
 273  
      * Setter for <code>project</code>.
 274  
      * 
 275  
      * @param project The project to set.
 276  
      */
 277  
     public void setProject( MavenProject project )
 278  
     {
 279  0
         this.project = project;
 280  0
     }
 281  
 
 282  
     /**
 283  
      * Getter for <code>sourceDirs</code>.
 284  
      * 
 285  
      * @return Returns the sourceDirs.
 286  
      */
 287  
     public EclipseSourceDir[] getSourceDirs()
 288  
     {
 289  24
         return sourceDirs;
 290  
     }
 291  
 
 292  
     /**
 293  
      * Setter for <code>sourceDirs</code>.
 294  
      * 
 295  
      * @param sourceDirs The sourceDirs to set.
 296  
      */
 297  
     public void setSourceDirs( EclipseSourceDir[] sourceDirs )
 298  
     {
 299  2
         this.sourceDirs = sourceDirs;
 300  2
     }
 301  
 
 302  
     /**
 303  
      * Getter for <code>buildOutputDirectory</code>.
 304  
      * 
 305  
      * @return Returns the buildOutputDirectory.
 306  
      */
 307  
     public File getBuildOutputDirectory()
 308  
     {
 309  4
         return buildOutputDirectory;
 310  
     }
 311  
 
 312  
     /**
 313  
      * Setter for <code>buildOutputDirectory</code>.
 314  
      * 
 315  
      * @param buildOutputDirectory The buildOutputDirectory to set.
 316  
      */
 317  
     public void setBuildOutputDirectory( File buildOutputDirectory )
 318  
     {
 319  4
         this.buildOutputDirectory = buildOutputDirectory;
 320  4
     }
 321  
 
 322  
     /**
 323  
      * Getter for <code>localRepository</code>.
 324  
      * 
 325  
      * @return Returns the localRepository.
 326  
      */
 327  
     public ArtifactRepository getLocalRepository()
 328  
     {
 329  2
         return localRepository;
 330  
     }
 331  
 
 332  
     /**
 333  
      * Setter for <code>localRepository</code>.
 334  
      * 
 335  
      * @param localRepository The localRepository to set.
 336  
      */
 337  
     public void setLocalRepository( ArtifactRepository localRepository )
 338  
     {
 339  2
         this.localRepository = localRepository;
 340  2
     }
 341  
 
 342  
     /**
 343  
      * Getter for <code>manifestFile</code>.
 344  
      * 
 345  
      * @return Returns the manifestFile.
 346  
      */
 347  
     public File getManifestFile()
 348  
     {
 349  0
         return manifestFile;
 350  
     }
 351  
 
 352  
     /**
 353  
      * Setter for <code>manifestFile</code>.
 354  
      * 
 355  
      * @param manifestFile The manifestFile to set.
 356  
      */
 357  
     public void setManifestFile( File manifestFile )
 358  
     {
 359  0
         this.manifestFile = manifestFile;
 360  0
     }
 361  
 
 362  
     /**
 363  
      * Getter for <code>classpathContainers</code>.
 364  
      * 
 365  
      * @return Returns the classpathContainers.
 366  
      */
 367  
     public List getClasspathContainers()
 368  
     {
 369  4
         return classpathContainers;
 370  
     }
 371  
 
 372  
     /**
 373  
      * Setter for <code>classpathContainers</code>.
 374  
      * 
 375  
      * @param classpathContainers The classpathContainers to set.
 376  
      */
 377  
     public void setClasspathContainers( List classpathContainers )
 378  
     {
 379  0
         this.classpathContainers = classpathContainers;
 380  0
     }
 381  
 
 382  
     /**
 383  
      * Getter for <code>pde</code>.
 384  
      * 
 385  
      * @return Returns the pde.
 386  
      */
 387  
     public boolean isPde()
 388  
     {
 389  4
         return pde;
 390  
     }
 391  
 
 392  
     /**
 393  
      * Setter for <code>pde</code>.
 394  
      * 
 395  
      * @param pde The pde to set.
 396  
      */
 397  
     public void setPde( boolean pde )
 398  
     {
 399  0
         this.pde = pde;
 400  0
     }
 401  
 
 402  
     /**
 403  
      * Getter for <code>buildCommands</code>.
 404  
      * 
 405  
      * @return Returns the buildCommands.
 406  
      */
 407  
     public List getBuildCommands()
 408  
     {
 409  2
         return buildCommands;
 410  
     }
 411  
 
 412  
     /**
 413  
      * Setter for <code>buildCommands</code>.
 414  
      * 
 415  
      * @param buildCommands The buildCommands to set.
 416  
      */
 417  
     public void setBuildCommands( List buildCommands )
 418  
     {
 419  0
         this.buildCommands = buildCommands;
 420  0
     }
 421  
 
 422  
     /**
 423  
      * Getter for <code>projectnatures</code>.
 424  
      * 
 425  
      * @return Returns the projectnatures.
 426  
      */
 427  
     public List getProjectnatures()
 428  
     {
 429  0
         return projectnatures;
 430  
     }
 431  
 
 432  
     /**
 433  
      * Setter for <code>projectnatures</code>.
 434  
      * 
 435  
      * @param projectnatures The projectnatures to set.
 436  
      */
 437  
     public void setProjectnatures( List projectnatures )
 438  
     {
 439  0
         this.projectnatures = projectnatures;
 440  0
     }
 441  
 
 442  
     /**
 443  
      * Getter for <code>projectFacets</code>.
 444  
      * 
 445  
      * @return Returns the projectFacets
 446  
      */
 447  
     public Map getProjectFacets()
 448  
     {
 449  0
         return projectFacets;
 450  
     }
 451  
 
 452  
     /**
 453  
      * Setter for <code>projectFacets</code>
 454  
      * 
 455  
      * @param projectFacets The projectFacets to set.
 456  
      */
 457  
     public void setProjectFacets( Map projectFacets )
 458  
     {
 459  0
         this.projectFacets = projectFacets;
 460  0
     }
 461  
 
 462  
     /**
 463  
      * Getter for <code>projectBaseDir</code>.
 464  
      * 
 465  
      * @return Returns the projectBaseDir.
 466  
      */
 467  
     public File getProjectBaseDir()
 468  
     {
 469  4
         return projectBaseDir;
 470  
     }
 471  
 
 472  
     /**
 473  
      * Setter for <code>projectBaseDir</code>.
 474  
      * 
 475  
      * @param projectBaseDir The projectBaseDir to set.
 476  
      */
 477  
     public void setProjectBaseDir( File projectBaseDir )
 478  
     {
 479  4
         this.projectBaseDir = projectBaseDir;
 480  4
     }
 481  
 
 482  
     /**
 483  
      * Getter for <code>addVersionToProjectName</code>.
 484  
      * 
 485  
      * @deprecated use {@link #getProjectNameTemplate()}
 486  
      */
 487  
     public boolean isAddVersionToProjectName()
 488  
     {
 489  0
         return addVersionToProjectName;
 490  
     }
 491  
 
 492  
     /**
 493  
      * Setter for <code>addVersionToProjectName</code>.
 494  
      * 
 495  
      * @deprecated use {@link #setProjectNameTemplate(String)}
 496  
      */
 497  
     public void setAddVersionToProjectName( boolean addVersionToProjectName )
 498  
     {
 499  0
         this.addVersionToProjectName = addVersionToProjectName;
 500  0
     }
 501  
 
 502  
     public void setProjectNameTemplate( String projectNameTemplate )
 503  
     {
 504  0
         this.projectNameTemplate = projectNameTemplate;
 505  0
     }
 506  
 
 507  
     public String getProjectNameTemplate()
 508  
     {
 509  0
         return projectNameTemplate;
 510  
     }
 511  
 
 512  
     public String getContextName()
 513  
     {
 514  0
         return contextName;
 515  
     }
 516  
 
 517  
     public void setContextName( String deployName )
 518  
     {
 519  0
         contextName = deployName;
 520  0
     }
 521  
 
 522  
     /**
 523  
      * @return the packaging
 524  
      */
 525  
     public String getPackaging()
 526  
     {
 527  2
         return packaging;
 528  
     }
 529  
 
 530  
     /**
 531  
      * @param packaging the packaging to set
 532  
      */
 533  
     public void setPackaging( String packaging )
 534  
     {
 535  0
         this.packaging = packaging;
 536  0
     }
 537  
 
 538  
     /**
 539  
      * Getter for <code>wtpapplicationxml</code>.
 540  
      * 
 541  
      * @return Returns the wtpapplicationxml.
 542  
      */
 543  
     public boolean getWtpapplicationxml()
 544  
     {
 545  0
         return wtpapplicationxml;
 546  
     }
 547  
 
 548  
     /**
 549  
      * Setter for <code>buildCommands</code>.
 550  
      * 
 551  
      * @param buildCommands The buildCommands to set.
 552  
      */
 553  
     public void setWtpapplicationxml( boolean wtpapplicationxml )
 554  
     {
 555  0
         this.wtpapplicationxml = wtpapplicationxml;
 556  0
     }
 557  
 
 558  
     /**
 559  
      * Getter for <code>wtpVersion</code>.
 560  
      * 
 561  
      * @return Returns the wtpVersion.
 562  
      */
 563  
     public float getWtpVersion()
 564  
     {
 565  0
         return wtpVersion;
 566  
     }
 567  
 
 568  
     /**
 569  
      * Setter for <code>wtpVersion</code>.
 570  
      * 
 571  
      * @param wtpVersion The wtpVersion to set.
 572  
      */
 573  
     public void setWtpVersion( float wtpVersion )
 574  
     {
 575  0
         this.wtpVersion = wtpVersion;
 576  0
     }
 577  
 
 578  
     /**
 579  
      * @return an ordered list of dependencies
 580  
      */
 581  
     public IdeDependency[] getDepsOrdered()
 582  
     {
 583  4
         return orderedDeps;
 584  
     }
 585  
 
 586  
 }