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.t11; 20 21 import java.io.File; 22 23 import org.apache.maven.project.MavenProject; 24 import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase; 25 26 /** 27 * Verifies scope of root project is preserved regardless of parent dependency management. 28 * 29 * @author <a href="mailto:pschneider@gmail.com">Patrick Schneider</a> 30 * @see <a href="https://issues.apache.org/jira/browse/MNG-2919">MNG-2919</a> 31 */ 32 public class ProjectInheritanceTest extends AbstractProjectInheritanceTestCase { 33 // ---------------------------------------------------------------------- 34 // 35 // p1 inherits from p0 36 // p0 inherits from super model 37 // 38 // or we can show it graphically as: 39 // 40 // p1 ---> p0 --> super model 41 // 42 // ---------------------------------------------------------------------- 43 44 public void testDependencyManagementDoesNotOverrideScopeOfCurrentArtifact() throws Exception { 45 File localRepo = getLocalRepositoryPath(); 46 47 File pom0 = new File(localRepo, "p0/pom.xml"); 48 File pom0Basedir = pom0.getParentFile(); 49 File pom1 = new File(pom0Basedir, "p1/pom.xml"); 50 51 // load the child project, which inherits from p0... 52 MavenProject project0 = getProjectWithDependencies(pom0); 53 MavenProject project1 = getProjectWithDependencies(pom1); 54 55 assertEquals(pom0Basedir, project1.getParent().getBasedir()); 56 assertNull( 57 "dependencyManagement has overwritten the scope of the currently building child project", 58 project1.getArtifact().getScope()); 59 } 60 }