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  
24  import org.apache.maven.it.util.ResourceExtractor;
25  
26  /**
27   * This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-2926">MNG-2926</a>
28   *
29   * @author Brian Fox
30   *
31   */
32  public class MavenITmng2926PluginPrefixOrderTest
33      extends AbstractMavenIntegrationTestCase
34  {
35  
36      public MavenITmng2926PluginPrefixOrderTest()
37      {
38          super( "(2.0.6,)" );
39      }
40  
41      /**
42       * Verify that when resolving plugin prefixes the group org.apache.maven.plugins is searched before
43       * org.codehaus.mojo and that custom groups from the settings are searched before these standard ones.
44       *
45       * @throws Exception in case of failure
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.addCliOption( "--settings" );
72          verifier.addCliOption( "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.addCliOption( "--settings" );
83          verifier.addCliOption( "settings-custom.xml" );
84          verifier.executeGoal( "mng-2926:custom" );
85          verifier.verifyErrorFreeLog();
86          verifier.resetStreams();
87      }
88  
89  }