View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.project.inheritance.t12;
20  
21  import java.io.File;
22  import java.util.Map;
23  
24  import org.apache.maven.model.Plugin;
25  import org.apache.maven.project.MavenProject;
26  import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase;
27  import org.junit.jupiter.api.Test;
28  
29  import static org.junit.jupiter.api.Assertions.assertNotNull;
30  import static org.junit.jupiter.api.Assertions.assertNull;
31  
32  /**
33   * Verifies that plugin execution sections in the parent POM that have
34   * inherit == false are not inherited to the child POM.
35   */
36  @Deprecated
37  class ProjectInheritanceTest extends AbstractProjectInheritanceTestCase {
38      // ----------------------------------------------------------------------
39      //
40      // p1 inherits from p0
41      // p0 inherits from super model
42      //
43      // or we can show it graphically as:
44      //
45      // p1 ---> p0 --> super model
46      //
47      // ----------------------------------------------------------------------
48  
49      @Test
50      void testFalsePluginExecutionInheritValue() throws Exception {
51          File localRepo = getLocalRepositoryPath();
52  
53          File pom0 = new File(localRepo, "p0/pom.xml");
54          File pom0Basedir = pom0.getParentFile();
55          File pom1 = new File(pom0Basedir, "p1/pom.xml");
56  
57          getProjectWithDependencies(pom0);
58          MavenProject project1 = getProjectWithDependencies(pom1);
59  
60          Map pluginMap = project1.getBuild().getPluginsAsMap();
61          Plugin compilerPlugin = (Plugin) pluginMap.get("org.apache.maven.plugins:maven-compiler-plugin");
62  
63          assertNotNull(compilerPlugin);
64  
65          Map executionMap = compilerPlugin.getExecutionsAsMap();
66          assertNull(
67                  executionMap.get("test"),
68                  "Plugin execution: 'test' should NOT exist in the compiler plugin specification for the child project!");
69      }
70  }