View Javadoc
1   package org.apache.maven.plugin.coreit;
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 org.apache.maven.artifact.manager.WagonManager;
23  import org.apache.maven.plugin.AbstractMojo;
24  import org.apache.maven.plugin.MojoExecutionException;
25  import org.apache.maven.wagon.Wagon;
26  import org.apache.maven.wagon.providers.file.FileWagon;
27  import org.apache.maven.wagon.providers.ssh.jsch.ScpWagon;
28  
29  /**
30   * @goal use-wagon
31   * @phase validate
32   */
33  public class UsesWagonMojo
34      extends AbstractMojo
35  {
36  
37      /**
38       * @component
39       */
40      private WagonManager wagonManager;
41  
42      public void execute()
43          throws MojoExecutionException
44      {
45          Wagon fileWagon;
46          try
47          {
48              getLog().info( "[MAVEN-CORE-IT-LOG] Looking up wagon for protocol file" );
49              fileWagon = wagonManager.getWagon( "file" );
50          }
51          catch ( Exception e )
52          {
53              throw new MojoExecutionException( e.getMessage(), e );
54          }
55          try
56          {
57              FileWagon theWagon = (FileWagon) fileWagon;
58          }
59          catch ( ClassCastException e )
60          {
61              getLog().error( "", e );
62              getLog().error( "Plugin Class Loaded by " + FileWagon.class.getClassLoader() );
63              getLog().error( "Wagon Class Loaded by " + fileWagon.getClass().getClassLoader() );
64  
65              throw e;
66          }
67  
68          Wagon scpWagon;
69          try
70          {
71              getLog().info( "[MAVEN-CORE-IT-LOG] Looking up wagon for protocol scp" );
72              scpWagon = wagonManager.getWagon( "scp" );
73          }
74          catch ( Exception e )
75          {
76              throw new MojoExecutionException( e.getMessage(), e );
77          }
78          try
79          {
80              ScpWagon theWagon = (ScpWagon) scpWagon;
81          }
82          catch ( ClassCastException e )
83          {
84              getLog().error( "", e );
85              getLog().error( "Plugin Class Loaded by " + ScpWagon.class.getClassLoader() );
86              getLog().error( "Wagon Class Loaded by " + scpWagon.getClass().getClassLoader() );
87  
88              throw e;
89          }
90      }
91  
92  }