You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ah...@apache.org on 2021/08/13 08:18:12 UTC

[commons-statistics] branch master updated: Avoid existing site checkout in all child modules

This is an automated email from the ASF dual-hosted git repository.

aherbert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-statistics.git


The following commit(s) were added to refs/heads/master by this push:
     new af23a8a  Avoid existing site checkout in all child modules
af23a8a is described below

commit af23a8a6e703e18d89d55d389e8be5e0b729dc34
Author: Alex Herbert <ah...@apache.org>
AuthorDate: Fri Aug 13 09:17:24 2021 +0100

    Avoid existing site checkout in all child modules
---
 pom.xml | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 79 insertions(+), 15 deletions(-)

diff --git a/pom.xml b/pom.xml
index 3865b88..574bc1d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -94,6 +94,7 @@
     <statistics.checkstyle.dep.version>8.20</statistics.checkstyle.dep.version>
     <statistics.clirr.version>2.8</statistics.clirr.version>
     <statistics.junit.bom.version>5.4.2</statistics.junit.bom.version>
+    <statistics.antrun.version>1.8</statistics.antrun.version>
     <!-- Workaround to avoid duplicating config files. -->
     <statistics.parent.dir>${basedir}</statistics.parent.dir>
 
@@ -486,10 +487,25 @@
       </build>
     </profile>
     <profile>
+      <!-- Override a parent property if the SVN site checkout should not be performed.
+           This should activate for child modules. -->
+      <id>is-child-module</id>
+      <activation>
+        <file>
+          <missing>${basedir}/CONTRIBUTING.md</missing>
+        </file>
+      </activation>
+      <properties>
+        <perform.site.checkout>false</perform.site.checkout>
+      </properties>
+    </profile>
+    <profile>
+      <!-- Runs if the SVN site checkout does not exist.
+           This is either obtained using svn (for the parent) or an empty directory is created. -->
       <id>setup-checkout</id>
       <activation>
         <file>
-          <missing>site-content</missing>
+          <missing>${commons.scmPubCheckoutDirectory}</missing>
         </file>
       </activation>
       <build>
@@ -497,7 +513,25 @@
           <plugin>
             <groupId>org.apache.maven.plugins</groupId>
             <artifactId>maven-antrun-plugin</artifactId>
+            <version>${statistics.antrun.version}</version>
             <executions>
+              <!-- For multi-module builds, only the parent directory requires a site checkout.
+                   This task will create an empty directory as the site checkout is missing. -->
+              <execution>
+                <id>empty-checkout</id>
+                <phase>pre-site</phase>
+                <goals>
+                  <goal>run</goal>
+                </goals>
+                <configuration>
+                  <target name="empty-checkout" unless="${perform.site.checkout}">
+                    <mkdir dir="${commons.scmPubCheckoutDirectory}"/>
+                    <echo file="${commons.scmPubCheckoutDirectory}${file.separator}README"
+                          message="The '${commons.scmPubCheckoutDirectory}' directory is empty in child modules."/>
+                  </target>
+                </configuration>
+              </execution>
+              <!-- Checkout the top-level directory of the site using SVN. -->
               <execution>
                 <id>prepare-checkout</id>
                 <phase>pre-site</phase>
@@ -505,22 +539,52 @@
                   <goal>run</goal>
                 </goals>
                 <configuration>
-                  <tasks>
-                    <exec executable="svn">
-                      <arg line="checkout --depth immediates ${commons.scmPubUrl} ${commons.scmPubCheckoutDirectory}"/>
-                    </exec>
-
-                    <exec executable="svn">
-                      <arg line="update --set-depth exclude ${commons.scmPubCheckoutDirectory}/javadocs"/>
+                  <target name="prepare-checkout" if="${perform.site.checkout}">
+                    <!-- Top level directory -->
+                    <exec executable="svn" failifexecutionfails="false">
+                      <arg line="checkout --depth immediates ${commons.scmPubUrl} ${commons.scmPubCheckoutDirectory}" />
                     </exec>
+                    <!-- Create the directory in the event that no svn exectuable is on the path -->
+                    <mkdir dir="${commons.scmPubCheckoutDirectory}"/>
 
-                    <pathconvert pathsep=" " property="dirs">
-                      <dirset dir="${commons.scmPubCheckoutDirectory}" includes="*"/>
-                    </pathconvert>
-                    <exec executable="svn">
-                      <arg line="update --set-depth infinity ${dirs}"/>
-                    </exec>
-                  </tasks>
+                    <echo file="${commons.scmPubCheckoutDirectory}.README">The '${commons.scmPubCheckoutDirectory}' directory is controlled by "subversion".
+Running "svn up" will download *all* the files of the live web site at
+    https://commons.apache.org/statistics
+This is avoided by creating an empty directory when svn is not available.
+                    </echo>
+                  </target>
+                </configuration>
+              </execution>
+            </executions>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+    <profile>
+      <!-- Allow the SVN site checkout to be removed in the clean phase. -->
+      <id>clean-checkout</id>
+      <activation>
+        <file>
+          <exists>${commons.scmPubCheckoutDirectory}</exists>
+        </file>
+      </activation>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-antrun-plugin</artifactId>
+            <version>${statistics.antrun.version}</version>
+            <executions>
+              <execution>
+                <id>remove-checkout</id>
+                <phase>clean</phase>
+                <goals>
+                  <goal>run</goal>
+                </goals>
+                <configuration>
+                  <target name="remove-checkout">
+                    <delete dir="${commons.scmPubCheckoutDirectory}" quiet="true"/>
+                  </target>
                 </configuration>
               </execution>
             </executions>