Merge branch 'develop' of https://source.jalview.org/git/jalview.git into develop
[jalview.git] / utils / HelpLinksChecker.java
index 1ad5322..a0853a9 100644 (file)
@@ -34,6 +34,8 @@ public class HelpLinksChecker
 
   private int anchorRefCount = 0;
 
+  private int invalidAnchorRefCount = 0;
+
   private int externalHrefCount = 0;
 
   private int invalidMapUrlCount = 0;
@@ -83,7 +85,7 @@ public class HelpLinksChecker
   void checkLinks(String helpDirectoryPath) throws IOException
   {
     System.out.println("Checking help file links");
-    File helpFolder = new File(helpDirectoryPath);
+    File helpFolder = new File(helpDirectoryPath).getCanonicalFile();
     if (!helpFolder.exists())
     {
       System.out.println("Can't find " + helpDirectoryPath);
@@ -192,6 +194,8 @@ public class HelpLinksChecker
             internalHrefCount, anchorRefCount));
     System.out.println(invalidInternalHrefCount
             + " invalid internal href links");
+    System.out.println(invalidAnchorRefCount
+            + " invalid internal anchor links");
     System.out.println(externalHrefCount + " external href links");
     if (internetAvailable)
     {
@@ -203,7 +207,11 @@ public class HelpLinksChecker
       System.out
               .println("External links not verified as internet not available");
     }
-
+    if (invalidInternalHrefCount > 0 || invalidExternalHrefCount > 0
+            || invalidImageCount > 0 || invalidAnchorRefCount > 0)
+    {
+      System.exit(1);
+    }
   }
 
   /**
@@ -269,6 +277,7 @@ public class HelpLinksChecker
                 System.out.println(String.format(
                         "Invalid anchor: %s at line %d of %s", anchor,
                         lineNo, getPath(htmlFile)));
+                invalidAnchorRefCount++;
               }
             }
           }