View Javadoc

1   package org.apache.maven.it;
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.util.ArrayList;
24  
25  import org.apache.maven.it.Verifier;
26  import org.apache.maven.it.util.ResourceExtractor;
27  
28  /**
29   * This is a test set for <a href="http://jira.codehaus.org/browse/MNG-2926">MNG-2926</a>
30   * 
31   * @author Brian Fox
32   * @version $Id: MavenITmng2926PluginPrefixOrderTest.java 1050435 2010-12-17 16:06:59Z bentmann $
33   */
34  public class MavenITmng2926PluginPrefixOrderTest
35      extends AbstractMavenIntegrationTestCase
36  {
37  
38      public MavenITmng2926PluginPrefixOrderTest()
39      {
40          super( "(2.0.6,)" );
41      }
42  
43      /**
44       * Verify that when resolving plugin prefixes the group org.apache.maven.plugins is searched before
45       * org.codehaus.mojo and that custom groups from the settings are searched before these standard ones.
46       */
47      public void testitMNG2926()
48          throws Exception
49      {
50          File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-2926" );
51  
52          Verifier verifier;
53  
54          verifier = newVerifier( testDir.getAbsolutePath() );
55          verifier.deleteArtifacts( "org.apache.maven.its.mng2926" );
56          verifier.deleteArtifacts( "org.apache.maven.plugins", "mng-2926", "0.1" );
57          verifier.deleteArtifacts( "org.apache.maven.plugins", "mng-2926", "0.1" );
58          new File( verifier.getArtifactMetadataPath( "org.apache.maven.plugins", null, null, "maven-metadata-maven-core-it.xml" ) ).delete();
59          new File( verifier.getArtifactMetadataPath( "org.apache.maven.plugins", null, null, "resolver-status.properties" ) ).delete();
60          verifier.deleteArtifacts( "org.codehaus.mojo", "mng-2926", "0.1" );
61          verifier.deleteArtifacts( "org.codehaus.mojo", "mng-2926", "0.1" );
62          new File( verifier.getArtifactMetadataPath( "org.codehaus.mojo", null, null, "maven-metadata-maven-core-it.xml" ) ).delete();
63          new File( verifier.getArtifactMetadataPath( "org.codehaus.mojo", null, null, "resolver-status.properties" ) ).delete();
64          verifier.resetStreams();
65  
66          verifier = newVerifier( testDir.getAbsolutePath() );
67          verifier.setAutoclean( false );
68          verifier.setLogFileName( "log-default.txt" );
69          verifier.filterFile( "settings-default-template.xml", "settings-default.xml", "UTF-8", 
70              verifier.newDefaultFilterProperties() );
71          verifier.getCliOptions().add( "--settings" );
72          verifier.getCliOptions().add( "settings-default.xml" );
73          verifier.executeGoal( "mng-2926:apache" );
74          verifier.verifyErrorFreeLog();
75          verifier.resetStreams();
76  
77          verifier = newVerifier( testDir.getAbsolutePath() );
78          verifier.setAutoclean( false );
79          verifier.setLogFileName( "log-custom.txt" );
80          verifier.filterFile( "settings-custom-template.xml", "settings-custom.xml", "UTF-8", 
81              verifier.newDefaultFilterProperties() );
82          verifier.getCliOptions().add( "--settings" );
83          verifier.getCliOptions().add( "settings-custom.xml" );
84          verifier.executeGoal( "mng-2926:custom" );
85          verifier.verifyErrorFreeLog();
86          verifier.resetStreams();
87      }
88  
89  }