org.codehaus.mojo.webstart
Class AbstractBaseJnlpMojo

java.lang.Object
  extended by org.apache.maven.plugin.AbstractMojo
      extended by org.codehaus.mojo.webstart.AbstractBaseJnlpMojo
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo
Direct Known Subclasses:
AbstractJnlpMojo, JnlpDownloadServletMojo

public abstract class AbstractBaseJnlpMojo
extends org.apache.maven.plugin.AbstractMojo

The superclass for all JNLP generating MOJOs.

Since:
28 May 2007
Version:
$Revision: 6588 $
Author:
Kevin Stembridge, $LastChangedBy: bentmann $

Field Summary
protected  org.codehaus.plexus.archiver.manager.ArchiverManager archiverManager
          To look up Archiver/UnArchiver implementations
protected  String libPath
          The path where the libraries are placed within the jnlp structure.
 
Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
 
Constructor Summary
AbstractBaseJnlpMojo()
          Creates a new AbstractBaseJnlpMojo.
 
Method Summary
protected  boolean artifactContainsClass(org.apache.maven.artifact.Artifact artifact, String mainClass)
          TODO finish comment
protected  void checkPack200()
          Confirms that if Pack200 is enabled, the MOJO is being executed in at least a Java 1.5 JVM.
protected  boolean copyFileToDirectoryIfNecessary(File sourceFile, File targetDirectory)
          Conditionally copy the file into the target directory.
protected  boolean copyJarAsUnprocessedToDirectoryIfNecessary(File sourceFile, File targetDirectory)
          Conditionally copy the jar file into the target directory.
protected  void copyResources(File resourcesDir, File workDirectory)
           
protected  URL findDefaultJnlpTemplateURL()
           
protected  org.apache.maven.artifact.factory.ArtifactFactory getArtifactFactory()
          Returns the ArtifactFactory that can be used to create artifacts that need to be retrieved from maven artifact repositories.
protected  org.apache.maven.artifact.resolver.ArtifactResolver getArtifactResolver()
          Returns the ArtifactResolver that can be used to retrieve artifacts from maven artifact repositories.
protected  File getLibDirectory()
          Returns the library directory.
 String getLibPath()
          Returns the library path.
protected  org.apache.maven.artifact.repository.ArtifactRepository getLocalRepository()
          Returns the local artifact repository.
protected  List getModifiedJnlpArtifacts()
          Returns the collection of artifacts that have been modified since the last time this mojo was run.
abstract  org.apache.maven.project.MavenProject getProject()
           
protected  List getRemoteRepositories()
          Returns the collection of remote artifact repositories for the current Maven project.
protected  File getResourcesDirectory()
          Returns the location of the directory containing non-jar resources that are to be included in the JNLP bundle.
protected  SignConfig getSign()
          Returns jar signing configuration element.
protected  File getTemplateDirectory()
          Returns the file handle to the directory containing the Velocity templates for the JNLP files to be generated.
protected  URL getWebstartJarURL()
           
protected  String getWebstartJarURLForVelocity()
           
protected  File getWorkDirectory()
          Returns the working directory.
protected  boolean isExcludeTransitive()
          Returns the flag that indicates whether or not all transitive dependencies will be excluded from the generated JNLP bundle.
protected  boolean isGzip()
          Returns the flag that indicates whether or not a gzip should be created for each jar resource.
 boolean isPack200()
          Returns the flag that indicates whether or not jar resources will be compressed using pack200.
protected  boolean isVerbose()
          Returns the flag that indicates whether or not to provide verbose output.
protected  boolean isVerifyjar()
          Returns the flag that indicates whether or not jars should be verified after signing.
protected  void makeWorkingDirIfNecessary()
           
protected  void packJars()
          This is to try to workaround an issue with setting setLastModified.
protected  int removeExistingSignatures(File workDirectory, FileFilter updatedJarFileFilter)
          Removes the signature of the files in the specified directory which satisfy the specified filter.
protected  void signOrRenameJars()
          If sign is enabled, sign the jars, otherwise rename them into final jars
protected  boolean unsignAlreadySignedJars()
           
 
Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.maven.plugin.Mojo
execute
 

Field Detail

libPath

protected String libPath
The path where the libraries are placed within the jnlp structure.


archiverManager

protected org.codehaus.plexus.archiver.manager.ArchiverManager archiverManager
To look up Archiver/UnArchiver implementations

Constructor Detail

AbstractBaseJnlpMojo

public AbstractBaseJnlpMojo()
Creates a new AbstractBaseJnlpMojo.

Method Detail

makeWorkingDirIfNecessary

protected void makeWorkingDirIfNecessary()
                                  throws org.apache.maven.plugin.MojoExecutionException
Throws:
org.apache.maven.plugin.MojoExecutionException

getProject

public abstract org.apache.maven.project.MavenProject getProject()

getWorkDirectory

protected File getWorkDirectory()
Returns the working directory. This is the directory in which files and resources will be placed in order to be processed prior to packaging.

Returns:
Returns the value of the workDirectory field.

getLibDirectory

protected File getLibDirectory()
Returns the library directory. If not libPath is configured, the working directory is returned.

Returns:
Returns the value of the libraryDirectory field.

getLibPath

public String getLibPath()
Returns the library path. This is ths subpath within the working directory, where the libraries are placed. If the path is not configured it is null.

Returns:
the library path or null if not configured.

getResourcesDirectory

protected File getResourcesDirectory()
Returns the location of the directory containing non-jar resources that are to be included in the JNLP bundle.

Returns:
Returns the value of the resourcesDirectory field, never null.

getTemplateDirectory

protected File getTemplateDirectory()
Returns the file handle to the directory containing the Velocity templates for the JNLP files to be generated.

Returns:
Returns the value of the templateDirectory field.

getArtifactFactory

protected org.apache.maven.artifact.factory.ArtifactFactory getArtifactFactory()
Returns the ArtifactFactory that can be used to create artifacts that need to be retrieved from maven artifact repositories.

Returns:
Returns the value of the artifactFactory field.

getArtifactResolver

protected org.apache.maven.artifact.resolver.ArtifactResolver getArtifactResolver()
Returns the ArtifactResolver that can be used to retrieve artifacts from maven artifact repositories.

Returns:
Returns the value of the artifactResolver field.

getLocalRepository

protected org.apache.maven.artifact.repository.ArtifactRepository getLocalRepository()
Returns the local artifact repository.

Returns:
Returns the value of the localRepository field.

getRemoteRepositories

protected List getRemoteRepositories()
Returns the collection of remote artifact repositories for the current Maven project.

Returns:
Returns the value of the remoteRepositories field.

isPack200

public boolean isPack200()
Returns the flag that indicates whether or not jar resources will be compressed using pack200.

Returns:
Returns the value of the pack200 field.

getSign

protected SignConfig getSign()
Returns jar signing configuration element.

Returns:
Returns the value of the sign field.

isGzip

protected boolean isGzip()
Returns the flag that indicates whether or not a gzip should be created for each jar resource.

Returns:
Returns the value of the gzip field.

isVerbose

protected boolean isVerbose()
Returns the flag that indicates whether or not to provide verbose output.

Returns:
Returns the value of the verbose field.

isVerifyjar

protected boolean isVerifyjar()
Returns the flag that indicates whether or not jars should be verified after signing.

Returns:
Returns the value of the verifyjar field.

isExcludeTransitive

protected boolean isExcludeTransitive()
Returns the flag that indicates whether or not all transitive dependencies will be excluded from the generated JNLP bundle.

Returns:
Returns the value of the excludeTransitive field.

getModifiedJnlpArtifacts

protected List getModifiedJnlpArtifacts()
Returns the collection of artifacts that have been modified since the last time this mojo was run.

Returns:
Returns the value of the modifiedJnlpArtifacts field.

checkPack200

protected void checkPack200()
                     throws org.apache.maven.plugin.MojoExecutionException
Confirms that if Pack200 is enabled, the MOJO is being executed in at least a Java 1.5 JVM.

Throws:
org.apache.maven.plugin.MojoExecutionException

copyResources

protected void copyResources(File resourcesDir,
                             File workDirectory)
                      throws IOException
Throws:
IOException

copyFileToDirectoryIfNecessary

protected boolean copyFileToDirectoryIfNecessary(File sourceFile,
                                                 File targetDirectory)
                                          throws IOException
Conditionally copy the file into the target directory. The operation is not performed when the target file exists and is up to date. The target file name is taken from the sourceFile name.

Returns:
true when the file was copied, false otherwise.
Throws:
IllegalArgumentException - if sourceFile is null or sourceFile.getName() is null
IOException - if an error occurs attempting to copy the file.

copyJarAsUnprocessedToDirectoryIfNecessary

protected boolean copyJarAsUnprocessedToDirectoryIfNecessary(File sourceFile,
                                                             File targetDirectory)
                                                      throws IOException
Conditionally copy the jar file into the target directory. The operation is not performed when a signed target file exists and is up to date. The signed target file name is taken from the sourceFile name.E The unsigned target file name is taken from the sourceFile name prefixed with UNPROCESSED_PREFIX. TODO this is confusing if the sourceFile is already signed. By unsigned we really mean 'unsignedbyus'

Returns:
true when the file was copied, false otherwise.
Throws:
IllegalArgumentException - if sourceFile is null or sourceFile.getName() is null
IOException - if an error occurs attempting to copy the file.

signOrRenameJars

protected void signOrRenameJars()
                         throws org.apache.maven.plugin.MojoExecutionException,
                                org.apache.maven.plugin.MojoFailureException
If sign is enabled, sign the jars, otherwise rename them into final jars

Throws:
org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoFailureException

findDefaultJnlpTemplateURL

protected URL findDefaultJnlpTemplateURL()

getWebstartJarURL

protected URL getWebstartJarURL()

getWebstartJarURLForVelocity

protected String getWebstartJarURLForVelocity()
Returns:
something of the form jar:file:..../webstart-maven-plugin-.....jar!/

removeExistingSignatures

protected int removeExistingSignatures(File workDirectory,
                                       FileFilter updatedJarFileFilter)
                                throws org.apache.maven.plugin.MojoExecutionException
Removes the signature of the files in the specified directory which satisfy the specified filter.

Returns:
the number of unsigned jars
Throws:
org.apache.maven.plugin.MojoExecutionException

packJars

protected void packJars()
This is to try to workaround an issue with setting setLastModified. See MWEBSTART-28. May be removed later on if that doesn't help.


artifactContainsClass

protected boolean artifactContainsClass(org.apache.maven.artifact.Artifact artifact,
                                        String mainClass)
                                 throws MalformedURLException
TODO finish comment

Parameters:
artifact -
mainClass -
Returns:
Throws:
MalformedURLException

unsignAlreadySignedJars

protected boolean unsignAlreadySignedJars()
Returns:
true if already signed jars should be unsigned prior to signing with own key.


Copyright © 2005-2011 Codehaus. All Rights Reserved.