org.apache.maven.plugin.eclipse.writers
Class AbstractEclipseManifestWriter

java.lang.Object
  extended by org.apache.maven.plugin.eclipse.writers.AbstractEclipseWriter
      extended by org.apache.maven.plugin.eclipse.writers.AbstractEclipseManifestWriter
All Implemented Interfaces:
EclipseWriter
Direct Known Subclasses:
EclipseManifestWriter, RadManifestWriter

public abstract class AbstractEclipseManifestWriter
extends AbstractEclipseWriter

Common behaviours for creating or adapting the manifest files for eclipse environments.

Author:
Richard van Nieuwenhoven

Field Summary
protected static String MANIFEST_MF_FILENAME
           
protected static String META_INF_DIRECTORY
           
 
Fields inherited from class org.apache.maven.plugin.eclipse.writers.AbstractEclipseWriter
config, log
 
Constructor Summary
AbstractEclipseManifestWriter()
           
 
Method Summary
protected  void addDependencyToClassPath(StringBuilder classpath, IdeDependency dependency)
          Add one dependency to the blank separated classpath StringBuilder.
protected  boolean areManifestsEqual(Manifest manifest, Manifest existingManifest)
          Check if the two manifests are equal.
protected  String constructManifestClasspath()
          Convert all dependencies in a blank seperated list of jars and projects representing the classpath.
protected  Manifest createNewManifest()
          Create a manifest contaigning the required classpath.
protected abstract  String getMetaInfBaseDirectory(MavenProject project)
          Search the project for the existing META-INF directory where the manifest should be located.
protected  String orderClasspath(String newValue)
          Aphabeticaly sort the classpath.
protected  Manifest readExistingManifest(File manifestFile)
          Read and parse the existing manifest file.
protected  boolean shouldNewManifestFileBeWritten(Manifest manifest, File manifestFile)
          Verify is the manifest sould be overwritten this sould take in account that the manifest should only be written if the contents of the classpath was changed not the order.
 void write()
          If the existing manifest file located in getMetaInfBaseDirectory() already has a correct MANIFEST_VERSION and CLASS_PATH value then do nothing.
 
Methods inherited from class org.apache.maven.plugin.eclipse.writers.AbstractEclipseWriter
init
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MANIFEST_MF_FILENAME

protected static final String MANIFEST_MF_FILENAME
See Also:
Constant Field Values

META_INF_DIRECTORY

protected static final String META_INF_DIRECTORY
See Also:
Constant Field Values
Constructor Detail

AbstractEclipseManifestWriter

public AbstractEclipseManifestWriter()
Method Detail

orderClasspath

protected String orderClasspath(String newValue)
Aphabeticaly sort the classpath. Do this by splitting it up, sort the entries and gleue them together again.

Parameters:
newValue - classpath to sort
Returns:
the sorted classpath

readExistingManifest

protected Manifest readExistingManifest(File manifestFile)
                                 throws IOException
Read and parse the existing manifest file.

Parameters:
manifestFile - file
Returns:
the read manifest
Throws:
IOException - if the file could not be read

addDependencyToClassPath

protected void addDependencyToClassPath(StringBuilder classpath,
                                        IdeDependency dependency)
Add one dependency to the blank separated classpath StringBuilder. When the project is available in the reactor (current build) then the project is used else the jar representing the artifact. System dependencies will only be included if they are in this project.

Parameters:
classpath - existing classpath to append
dependency - dependency to append as jar or as project

areManifestsEqual

protected boolean areManifestsEqual(Manifest manifest,
                                    Manifest existingManifest)
Check if the two manifests are equal. Manifest.equal can not be used because of the special case the Classpath entr, witch must be comaired sorted so that a different oder in the classpath does not result in "not equal". This not not realy correct but in this case it is more important to reduce the number of version-controll files.

Parameters:
manifest - the new manifest
existingManifest - to compaire the new one with
Returns:
are the manifests equal

constructManifestClasspath

protected String constructManifestClasspath()
Convert all dependencies in a blank seperated list of jars and projects representing the classpath.

Returns:
the blank separeted classpath string

createNewManifest

protected Manifest createNewManifest()
Create a manifest contaigning the required classpath.

Returns:
the newly created manifest

shouldNewManifestFileBeWritten

protected boolean shouldNewManifestFileBeWritten(Manifest manifest,
                                                 File manifestFile)
                                          throws MojoExecutionException
Verify is the manifest sould be overwritten this sould take in account that the manifest should only be written if the contents of the classpath was changed not the order. The classpath sorting oder should be ignored.

Parameters:
manifest - the newly created classpath
manifestFile - the file where the manifest
Returns:
if the new manifest file must be written
Throws:
MojoExecutionException

getMetaInfBaseDirectory

protected abstract String getMetaInfBaseDirectory(MavenProject project)
                                           throws MojoExecutionException
Search the project for the existing META-INF directory where the manifest should be located.

Returns:
the absolute path to the META-INF directory
Throws:
MojoExecutionException

write

public void write()
           throws MojoExecutionException
If the existing manifest file located in getMetaInfBaseDirectory() already has a correct MANIFEST_VERSION and CLASS_PATH value then do nothing.

Otherwise generate a NEW (i.e the old one is overwritten) which only contains values for MANIFEST_VERSION and CLASS_PATH, all other previous entries are not kept.

Parameters:
sourceDirs - all eclipse source directorys
localRepository - the local reposetory
buildOutputDirectory - build output directory (target)
Throws:
MojoExecutionException - when writing the config files was not possible
See Also:
AbstractWtpResourceWriter#write(EclipseSourceDir[], ArtifactRepository, File)


Copyright © 2002–2015 The Apache Software Foundation. All rights reserved.