View Javadoc
1   package org.apache.maven.plugins.jmod;
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  
22  import java.io.File;
23  import java.io.IOException;
24  import java.util.List;
25  
26  import org.apache.maven.plugin.MojoExecutionException;
27  import org.apache.maven.plugin.MojoFailureException;
28  import org.apache.maven.plugins.annotations.LifecyclePhase;
29  import org.apache.maven.plugins.annotations.Mojo;
30  import org.apache.maven.plugins.annotations.Parameter;
31  import org.apache.maven.plugins.annotations.ResolutionScope;
32  import org.codehaus.plexus.util.cli.Commandline;
33  
34  /**
35   * <pre>
36   * jmod hash ...
37   * </pre>
38   * 
39   * @author Karl Heinz Marbaise <a href="mailto:khmarbaise@apache.org">khmarbaise@apache.org</a>
40   */
41  // TODO: Reconsider resolution scope, phase ?
42  @Mojo( name = "hash", requiresDependencyResolution = ResolutionScope.COMPILE, defaultPhase = LifecyclePhase.PACKAGE )
43  public class JModHashMojo
44      extends AbstractJModMojo
45  {
46  
47      /**
48       * <code>--class-path &lt;path&gt;</code> Application jar files|dir containing classes.
49       */
50      @Parameter
51      private List<String> classPath;
52  
53      /**
54       * <code>--class-path &lt;path&gt;</code> Application jar files|dir containing classes.
55       */
56      @Parameter
57      private List<String> cmds;
58  
59      /**
60       * <code>--config &lt;path&gt;</code> Location of user-editable config files.
61       */
62      @Parameter
63      private File config;
64  
65      @Parameter
66      private boolean dryRun;
67  
68      @Parameter
69      private List<String> excludes;
70  
71      @Parameter
72      private String mainClass;
73  
74      @Parameter
75      private List<File> libs;
76  
77      @Parameter
78      private String moduleVersion;
79  
80      /**
81       * Define the modulepath for the <code>jmod</code> call. <code>--module-path &lt;path&gt;</code>
82       * Must be a directory.
83       */
84      @Parameter( required = true )
85      private File modulePath;
86  
87      public void execute()
88          throws MojoExecutionException, MojoFailureException
89      {
90  
91          String jModExecutable;
92          try
93          {
94              jModExecutable = getJModExecutable();
95          }
96          catch ( IOException e )
97          {
98              throw new MojoFailureException( "Unable to find jmod command: " + e.getMessage(), e );
99          }
100 
101         Commandline cmd = createJModHashCommandLine();
102         cmd.setExecutable( jModExecutable );
103 
104         // executeCommand( cmd, outputDirectory );
105 
106     }
107 
108     private Commandline createJModHashCommandLine()
109     {
110         Commandline cmd = new Commandline();
111 
112         cmd.createArg().setValue( "hash" );
113 
114         if ( dryRun )
115         {
116             cmd.createArg().setValue( "--dry-run" );
117         }
118 
119         return cmd;
120     }
121 
122 }