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.t12scm;
20  
21  import java.io.File;
22  
23  import org.apache.maven.project.MavenProject;
24  import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase;
25  import org.junit.jupiter.api.Test;
26  
27  import static org.junit.jupiter.api.Assertions.assertEquals;
28  
29  /**
30   * Verifies SCM inheritance uses modules statement from parent.
31   *
32   */
33  @Deprecated
34  class ProjectInheritanceTest extends AbstractProjectInheritanceTestCase {
35      // ----------------------------------------------------------------------
36      //
37      // p1 inherits from p0
38      // p0 inherits from super model
39      //
40      // or we can show it graphically as:
41      //
42      // p1 ---> p0 --> super model
43      //
44      // ----------------------------------------------------------------------
45  
46      @Test
47      void testScmInfoCalculatedCorrectlyOnParentAndChildRead() throws Exception {
48          File localRepo = getLocalRepositoryPath();
49  
50          File pom0 = new File(localRepo, "p0/pom.xml");
51          File pom0Basedir = pom0.getParentFile();
52          File pom1 = new File(pom0Basedir, "modules/p1/pom.xml");
53  
54          // load the child project, which inherits from p0...
55          MavenProject project0 = getProject(pom0);
56          MavenProject project1 = getProject(pom1);
57  
58          System.out.println("\n\n");
59          System.out.println("Parent SCM URL is: " + project0.getScm().getUrl());
60          System.out.println("Child SCM URL is: " + project1.getScm().getUrl());
61          System.out.println();
62          System.out.println("Parent SCM connection is: " + project0.getScm().getConnection());
63          System.out.println("Child SCM connection is: " + project1.getScm().getConnection());
64          System.out.println();
65          System.out.println(
66                  "Parent SCM developer connection is: " + project0.getScm().getDeveloperConnection());
67          System.out.println(
68                  "Child SCM developer connection is: " + project1.getScm().getDeveloperConnection());
69  
70          assertEquals(project1.getScm().getUrl(), project0.getScm().getUrl() + "/modules/p1");
71          assertEquals(project1.getScm().getConnection(), project0.getScm().getConnection() + "/modules/p1");
72          assertEquals(
73                  project1.getScm().getDeveloperConnection(), project0.getScm().getDeveloperConnection() + "/modules/p1");
74      }
75  
76      @Test
77      void testScmInfoCalculatedCorrectlyOnChildOnlyRead() throws Exception {
78          File localRepo = getLocalRepositoryPath();
79  
80          File pom1 = new File(localRepo, "p0/modules/p1/pom.xml");
81  
82          // load the child project, which inherits from p0...
83          MavenProject project1 = getProject(pom1);
84  
85          System.out.println("\n\n");
86          System.out.println("Child SCM URL is: " + project1.getScm().getUrl());
87          System.out.println("Child SCM connection is: " + project1.getScm().getConnection());
88          System.out.println(
89                  "Child SCM developer connection is: " + project1.getScm().getDeveloperConnection());
90  
91          assertEquals("http://host/viewer?path=/p0/modules/p1", project1.getScm().getUrl());
92          assertEquals("scm:svn:http://host/p0/modules/p1", project1.getScm().getConnection());
93          assertEquals("scm:svn:https://host/p0/modules/p1", project1.getScm().getDeveloperConnection());
94      }
95  
96      //    public void testScmInfoCalculatedCorrectlyOnChildReadFromLocalRepository()
97      //        throws Exception
98      //    {
99      //        File localRepo = getLocalRepositoryPath();
100     //
101     //        ArtifactFactory factory = (ArtifactFactory) lookup( ArtifactFactory.class );
102     //        Artifact artifact = factory.createProjectArtifact( "maven", "p1", "1.0" );
103     //
104     //        ArtifactRepositoryFactory repoFactory = (ArtifactRepositoryFactory) lookup(
105     // ArtifactRepositoryFactory.class );
106     //        ArtifactRepository localArtifactRepo = repoFactory.createLocalRepository( localRepo );
107     //
108     //        MavenProject project1 = getProjectBuilder().buildFromRepository( artifact, Collections.EMPTY_LIST,
109     // localArtifactRepo );
110     //
111     //        System.out.println( "\n\n" );
112     //        System.out.println( "Child SCM URL is: " + project1.getScm().getUrl() );
113     //        System.out.println( "Child SCM connection is: " + project1.getScm().getConnection() );
114     //        System.out.println( "Child SCM developer connection is: "
115     //                            + project1.getScm().getDeveloperConnection() );
116     //
117     //        assertEquals( project1.getScm().getUrl(), "http://host/viewer?path=/p0/modules/p1" );
118     //        assertEquals( project1.getScm().getConnection(), "scm:svn:http://host/p0/modules/p1" );
119     //        assertEquals( project1.getScm().getDeveloperConnection(),
120     //                      "scm:svn:https://host/p0/modules/p1" );
121     //    }
122 
123 }