View Javadoc

1   /*
2    *  jDTAUS Core Container Mojo
3    *  Copyright (C) 2005 Christian Schulte
4    *  <cs@schulte.it>
5    *
6    *  This library is free software; you can redistribute it and/or
7    *  modify it under the terms of the GNU Lesser General Public
8    *  License as published by the Free Software Foundation; either
9    *  version 2.1 of the License, or any later version.
10   *
11   *  This library is distributed in the hope that it will be useful,
12   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14   *  Lesser General Public License for more details.
15   *
16   *  You should have received a copy of the GNU Lesser General Public
17   *  License along with this library; if not, write to the Free Software
18   *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19   *
20   */
21  package org.jdtaus.core.container.mojo;
22  
23  import java.io.File;
24  import java.net.URL;
25  import java.util.Locale;
26  import org.apache.maven.plugin.MojoExecutionException;
27  import org.apache.maven.plugin.MojoFailureException;
28  
29  /**
30   * Mojo to validate a set of modules from a single jar file.
31   *
32   * @author <a href="mailto:cs@schulte.it">Christian Schulte</a>
33   * @version $JDTAUS: VerifyJarMojo.java 8743 2012-10-07 03:06:20Z schulte $
34   * @goal verify-jar
35   * @phase verify
36   * @requiresDependencyResolution test
37   */
38  public class VerifyJarMojo extends VerifyModelMojo
39  {
40  
41      /**
42       * @parameter expression="${jarFile}" default-value="${project.build.directory}/${project.build.finalName}.jar"
43       * @optional
44       */
45      private File jarFile;
46  
47      /** Creates a new {@code VerifyJarMojo} instance. */
48      public VerifyJarMojo()
49      {
50          super();
51      }
52  
53      public void execute() throws MojoExecutionException, MojoFailureException
54      {
55          this.getLog().info( VerifyJarMojoBundle.getInstance().
56              getJarFileMessage( Locale.getDefault(),
57                                 this.jarFile.getAbsolutePath() ) );
58  
59          super.execute();
60      }
61  
62      protected ClassLoader getClassLoader( final ClassLoader parent )
63          throws Exception
64      {
65          final ClassLoader projectClassloader = super.getClassLoader( parent );
66          final URL[] urls = new URL[]
67          {
68              this.jarFile.toURI().toURL()
69          };
70  
71          return new ResourceLoader( urls, projectClassloader );
72      }
73  
74  }