MNG-853: added Javadoc and parameter's documentation.

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@280101 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Stephane Nicoll 2005-09-11 09:48:34 +00:00
parent d18e4b8a1b
commit 42718256a5
1 changed files with 94 additions and 8 deletions

View File

@ -51,11 +51,16 @@ public class WarMojo
public static final String WEB_INF = "WEB-INF"; public static final String WEB_INF = "WEB-INF";
/** /**
* The mode to use. Possible values are: war (default), inplace
* and exploded.
*
* @parameter * @parameter
*/ */
private String mode = "war"; private String mode = "war";
/** /**
* The maven project.
*
* @parameter expression="${project}" * @parameter expression="${project}"
* @required * @required
* @readonly * @readonly
@ -63,6 +68,8 @@ public class WarMojo
private MavenProject project; private MavenProject project;
/** /**
* The directory containing generated classes.
*
* @parameter expression="${project.build.outputDirectory}" * @parameter expression="${project.build.outputDirectory}"
* @required * @required
* @readonly * @readonly
@ -70,39 +77,54 @@ public class WarMojo
private File classesDirectory; private File classesDirectory;
/** /**
* The directory for the generated WAR.
*
* @parameter expression="${project.build.directory}" * @parameter expression="${project.build.directory}"
* @required * @required
*/ */
private String outputDirectory; private String outputDirectory;
/** /**
* The directory where the webapp is built.
*
* @parameter expression="${project.build.directory}/${project.build.finalName}" * @parameter expression="${project.build.directory}/${project.build.finalName}"
* @required * @required
*/ */
private File webappDirectory; private File webappDirectory;
/** /**
* Single directory for extra files to include in the WAR.
*
* @parameter expression="${basedir}/src/main/webapp" * @parameter expression="${basedir}/src/main/webapp"
* @required * @required
*/ */
private File warSourceDirectory; private File warSourceDirectory;
/** /**
* The comma separated list of tokens to include in the WAR.
* Default is '**'.
*
* @parameter alias="includes" * @parameter alias="includes"
*/ */
private String warSourceIncludes = "**"; private String warSourceIncludes = "**";
/** /**
* The comma separated list of tokens to exclude from the WAR.
*
* @parameter alias="excludes" * @parameter alias="excludes"
*/ */
private String warSourceExcludes; private String warSourceExcludes;
/** /**
* The path to the web.xml file to use.
*
* @parameter expression="${maven.war.webxml}" * @parameter expression="${maven.war.webxml}"
*/ */
private String webXml; private String webXml;
/** /**
* The name of the generated war.
*
* @parameter expression="${project.build.finalName}" * @parameter expression="${project.build.finalName}"
* @required * @required
* @deprecated "Please use the finalName element of build instead" * @deprecated "Please use the finalName element of build instead"
@ -110,12 +132,28 @@ public class WarMojo
private String warName; private String warName;
/** /**
* The maven archive configuration to use.
*
* @parameter * @parameter
*/ */
private MavenArchiveConfiguration archive = new MavenArchiveConfiguration(); private MavenArchiveConfiguration archive = new MavenArchiveConfiguration();
private static final String[] EMPTY_STRING_ARRAY = {}; private static final String[] EMPTY_STRING_ARRAY = {};
/**
* Copies webapp resources from the specified directory.
* <p/>
* Note that the <tt>webXml</tt> parameter could be null and may
* specify a file which is not named <tt>web.xml<tt>. If the file
* exists, it will be copied to the <tt>META-INF</tt> directory and
* renamed accordingly.
*
* @param sourceDirectory the source directory
* @param webappDirectory the target directory
* @param webXml the path to a custom web.xml
* @throws IOException if an error occured while copying resources
*/
public void copyResources( File sourceDirectory, File webappDirectory, String webXml ) public void copyResources( File sourceDirectory, File webappDirectory, String webXml )
throws IOException throws IOException
{ {
@ -126,9 +164,10 @@ public class WarMojo
if ( warSourceDirectory.exists() ) if ( warSourceDirectory.exists() )
{ {
String[] fileNames = getWarFiles( sourceDirectory ); String[] fileNames = getWarFiles( sourceDirectory );
for (int i = 0; i < fileNames.length; i++) for ( int i = 0; i < fileNames.length; i++ )
{ {
FileUtils.copyFile(new File( sourceDirectory, fileNames[i] ), new File( webappDirectory, fileNames[i] ) ); FileUtils.copyFile( new File( sourceDirectory, fileNames[i] ),
new File( webappDirectory, fileNames[i] ) );
} }
} }
@ -141,6 +180,15 @@ public class WarMojo
} }
} }
/**
* Builds the webapp for the specified project.
* <p/>
* Classes, libraries and tld files are copied to
* the <tt>webappDirectory</tt> during this phase.
*
* @param project the maven project
* @throws IOException if an error occured while building the webapp
*/
public void buildWebapp( MavenProject project ) public void buildWebapp( MavenProject project )
throws IOException throws IOException
{ {
@ -187,6 +235,14 @@ public class WarMojo
} }
} }
/**
* Generates and exploded webapp.
* <p/>
* This mode is invoked when the <tt>mode</tt> parameter has a value
* of <tt>exploded</tt>.
*
* @throws IOException if an error occured while building the webapp
*/
public void generateExplodedWebapp() public void generateExplodedWebapp()
throws IOException throws IOException
{ {
@ -201,6 +257,14 @@ public class WarMojo
buildWebapp( project ); buildWebapp( project );
} }
/**
* Generates the webapp in the source directory.
* <p/>
* This mode is invoked when the <tt>mode</tt> parameter has a value
* of <tt>inplace</tt>.
*
* @throws IOException if an error occured while building the webapp
*/
public void generateInPlaceWebapp() public void generateInPlaceWebapp()
throws IOException throws IOException
{ {
@ -209,6 +273,11 @@ public class WarMojo
generateExplodedWebapp(); generateExplodedWebapp();
} }
/**
* Executes the WarMojo on the current project.
*
* @throws MojoExecutionException if an error occured while building the webapp
*/
public void execute() public void execute()
throws MojoExecutionException throws MojoExecutionException
{ {
@ -225,6 +294,15 @@ public class WarMojo
} }
} }
/**
* Generates the webapp according to the <tt>mode</tt> attribute.
*
* @param warFile the target war file
* @throws IOException
* @throws ArchiverException
* @throws ManifestException
* @throws DependencyResolutionRequiredException
*/
private void performPackaging( File warFile ) private void performPackaging( File warFile )
throws IOException, ArchiverException, ManifestException, DependencyResolutionRequiredException throws IOException, ArchiverException, ManifestException, DependencyResolutionRequiredException
{ {
@ -262,6 +340,9 @@ public class WarMojo
} }
/** /**
* Returns the default exclude tokens.
*
* @return a list of <code>String</code> tokens
* @todo copied again. Next person to touch it puts it in the right place! :) * @todo copied again. Next person to touch it puts it in the right place! :)
*/ */
public List getDefaultExcludes() public List getDefaultExcludes()
@ -299,8 +380,8 @@ public class WarMojo
} }
/** /**
* Returns a list of filenames that should be copied over to the destination * Returns a list of filenames that should be copied
* directory * over to the destination directory.
* *
* @param sourceDir the directory to be scanned * @param sourceDir the directory to be scanned
* @return the array of filenames, relative to the sourceDir * @return the array of filenames, relative to the sourceDir
@ -320,7 +401,10 @@ public class WarMojo
} }
/** /**
* Returns an a string array of the excludes to be used when assembling/copy the war * Returns a string array of the excludes to be used
* when assembling/copying the war.
*
* @return an array of tokens to exclude
*/ */
private String[] getExcludes() private String[] getExcludes()
{ {
@ -340,11 +424,13 @@ public class WarMojo
} }
/** /**
* Returns an a string array of the includes to be used when assembling/copy the * Returns a string array of the includes to be used
* war * when assembling/copying the war.
*
* @return an array of tokens to include
*/ */
private String[] getIncludes() private String[] getIncludes()
{ {
return new String[] { warSourceIncludes }; return new String[]{warSourceIncludes};
} }
} }