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: 15187 $
Author:
Kevin Stembridge, $LastChangedBy: tchemit $

Field Summary
static String JAR_SUFFIX
           
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)
          Tests if the given fully qualified name exists in the given artifact.
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 findDefaultJnlpExtensionTemplateURL()
           
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  String getCodebase()
          Returns the code base to inject in the generated jnlp.
 String getEncoding()
           
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.
protected  Pack200Tool getPack200Tool()
           
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 isAttachArchive()
          Returns the flag indicates whether or not archive must be deployed.
protected  boolean isCanUnsign()
           
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.
protected  boolean isJarSigned(File jarFile)
           
protected  boolean isMakeArchive()
          Returns the flag indicates whether or not archive must be build.
 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()
           
protected  void signOrRenameJars()
          If sign is enabled, sign the jars, otherwise rename them into final jars
protected  boolean unsignAlreadySignedJars()
           
protected  void verboseLog(String msg)
          Log as info when verbose or info is enabled, as debug otherwise.
 
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

JAR_SUFFIX

public static final String JAR_SUFFIX
See Also:
Constant Field Values

libPath

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

Is defined by:
default-value:
Constructor Detail

AbstractBaseJnlpMojo

public AbstractBaseJnlpMojo()
Creates a new AbstractBaseJnlpMojo.

Method Detail

getProject

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

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.

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.

makeWorkingDirIfNecessary

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

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.

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.

getSign

protected SignConfig getSign()
Returns jar signing configuration element.

Returns:
Returns the value of the sign field.

getCodebase

protected String getCodebase()
Returns the code base to inject in the generated jnlp.

Returns:
Returns the value of codebase 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.

isMakeArchive

protected boolean isMakeArchive()
Returns the flag indicates whether or not archive must be build.

Returns:
Returns the value of the makeArchive field.

isAttachArchive

protected boolean isAttachArchive()
Returns the flag indicates whether or not archive must be deployed.

Returns:
Returns the value of the attachArchive field.

isCanUnsign

protected boolean isCanUnsign()

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.

getEncoding

public String getEncoding()
Returns:
the mojo encoding to use to write files.

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 - if can not foind pack200 tool or jdk is before 5.0

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.

Parameters:
sourceFile - source file to copy
targetDirectory - location of the target directory where to copy file
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'

Parameters:
sourceFile - source file to copy
targetDirectory - location of the target directory where to copy file
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
If sign is enabled, sign the jars, otherwise rename them into final jars

Throws:
org.apache.maven.plugin.MojoExecutionException - if can not sign or rename jars

findDefaultJnlpTemplateURL

protected URL findDefaultJnlpTemplateURL()

findDefaultJnlpExtensionTemplateURL

protected URL findDefaultJnlpExtensionTemplateURL()

getWebstartJarURL

protected URL getWebstartJarURL()

getWebstartJarURLForVelocity

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

isJarSigned

protected boolean isJarSigned(File jarFile)
                       throws org.apache.maven.plugin.MojoExecutionException
Throws:
org.apache.maven.plugin.MojoExecutionException

packJars

protected void packJars()

artifactContainsClass

protected boolean artifactContainsClass(org.apache.maven.artifact.Artifact artifact,
                                        String mainClass)
                                 throws MalformedURLException
Tests if the given fully qualified name exists in the given artifact.

Parameters:
artifact - artifact to test
mainClass - the fully qualified name to find in artifact
Returns:
true if given artifact contains the given fqn, false otherwise
Throws:
MalformedURLException - if artifact file url is mal formed

unsignAlreadySignedJars

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

getPack200Tool

protected Pack200Tool getPack200Tool()

verboseLog

protected void verboseLog(String msg)
Log as info when verbose or info is enabled, as debug otherwise.

Parameters:
msg - the message to display


Copyright © 2005-2012 Codehaus. All Rights Reserved.