EMMA Coverage Report (generated Thu Mar 10 11:16:09 GMT 2011)
[all classes][npanday.plugin.aspx]

COVERAGE SUMMARY FOR SOURCE FILE [AspxPackageMojo.java]

nameclass, %method, %block, %line, %
AspxPackageMojo.java0%   (0/1)0%   (0/3)0%   (0/129)0%   (0/24)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AspxPackageMojo0%   (0/1)0%   (0/3)0%   (0/129)0%   (0/24)
AspxPackageMojo (): void 0%   (0/1)0%   (0/3)0%   (0/1)
execute (): void 0%   (0/1)0%   (0/34)0%   (0/8)
performPackaging (File): void 0%   (0/1)0%   (0/92)0%   (0/15)

1package npanday.plugin.aspx;
2 
3/*
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements.  See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership.  The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License.  You may obtain a copy of the License at
11 *
12 *   http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied.  See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 */
21 
22import java.io.File;
23import java.io.IOException;
24 
25import org.apache.maven.plugin.AbstractMojo;
26import org.apache.maven.plugin.MojoExecutionException;
27import org.apache.maven.project.MavenProject;
28import org.codehaus.plexus.archiver.ArchiverException;
29import org.codehaus.plexus.archiver.zip.ZipArchiver;
30 
31/**
32 * Maven Mojo for packaging .Net Web applications
33 * 
34 * @goal package
35 * @phase package
36 * @description Maven Mojo for packaging .Net Web applications
37 */
38public class AspxPackageMojo
39    extends AbstractMojo
40{
41    /**
42     * The maven project.
43     * 
44     * @parameter expression="${project}"
45     * @required
46     */
47    private MavenProject project;
48 
49    /**
50     * The directory for the compilated web application
51     *
52     * @parameter  expression = "${outputDirectory}" default-value = "${project.build.directory}"
53     * @required
54     */
55    private File outputDirectory;
56 
57    /**
58     * The Zip archiver.
59     * 
60     * @parameter expression="${component.org.codehaus.plexus.archiver.Archiver#zip}"
61     * @required
62     */
63    private ZipArchiver archiver;
64 
65    public void execute()
66        throws MojoExecutionException
67    {
68 
69        long startTime = System.currentTimeMillis();
70 
71        File webappDir = new File( outputDirectory, project.getArtifactId() );
72 
73        if ( !webappDir.exists() )
74        {
75            return;
76        }
77 
78        performPackaging( webappDir );
79 
80        long endTime = System.currentTimeMillis();
81        getLog().info( "Mojo Execution Time = " + ( endTime - startTime ) );
82    }
83 
84    private void performPackaging( File webappDir )
85        throws MojoExecutionException
86    {
87        File destinationFile = new File( outputDirectory, project.getArtifactId() + ".zip" );
88        archiver.setDestFile( destinationFile );
89 
90        getLog().info( "Generating package " + destinationFile.getAbsolutePath() );
91 
92        try
93        {
94            archiver.addDirectory( webappDir );
95        }
96        catch ( ArchiverException e )
97        {
98            throw new MojoExecutionException( "Unable to package web application from " + webappDir.getAbsolutePath(),
99                                              e );
100        }
101 
102        // create archive
103        try
104        {
105            archiver.createArchive();
106        }
107        catch ( ArchiverException e )
108        {
109            throw new MojoExecutionException( "Unable to package web application in " +
110                destinationFile.getAbsolutePath(), e );
111        }
112        catch ( IOException e )
113        {
114            throw new MojoExecutionException( "Unable to package web application in " +
115                destinationFile.getAbsolutePath(), e );
116        }
117 
118        project.getArtifact().setFile( destinationFile );
119    }
120}

[all classes][npanday.plugin.aspx]
EMMA 2.0.5312 (C) Vladimir Roubtsov