[maven-dist-tool] branch master updated: s/scmrepo/masterjobs/

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[maven-dist-tool] branch master updated: s/scmrepo/masterjobs/

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

hboutemy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-dist-tool.git


The following commit(s) were added to refs/heads/master by this push:
     new 3c647a5  s/scmrepo/masterjobs/
3c647a5 is described below

commit 3c647a598a7cb1c8c5d255b77d1148111d97b31b
Author: Hervé Boutemy <[hidden email]>
AuthorDate: Tue Mar 12 00:14:45 2019 +0100

    s/scmrepo/masterjobs/
---
 pom.xml                                            |  2 +-
 .../ListMasterJobsMojo.java}                       | 47 ++++++++++++++--------
 .../dist/tools/{scmrepo => masterjobs}/Result.java | 20 +++++----
 src/site/markdown/index.md                         |  7 +++-
 src/site/site.xml                                  |  4 +-
 5 files changed, 47 insertions(+), 33 deletions(-)

diff --git a/pom.xml b/pom.xml
index 4f71c01..e49054f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -249,7 +249,7 @@
               <report>check-index-page</report>
               <report>check-errors</report>
               <report>list-plugins-prerequisites</report>
-              <report>check-primary-branch</report>
+              <report>list-master-jobs</report>
             </reports>
           </reportSet>
           <reportSet>
diff --git a/src/main/java/org/apache/maven/dist/tools/scmrepo/CheckPrimaryBranchMojo.java b/src/main/java/org/apache/maven/dist/tools/masterjobs/ListMasterJobsMojo.java
similarity index 78%
rename from src/main/java/org/apache/maven/dist/tools/scmrepo/CheckPrimaryBranchMojo.java
rename to src/main/java/org/apache/maven/dist/tools/masterjobs/ListMasterJobsMojo.java
index 73dae09..753f370 100644
--- a/src/main/java/org/apache/maven/dist/tools/scmrepo/CheckPrimaryBranchMojo.java
+++ b/src/main/java/org/apache/maven/dist/tools/masterjobs/ListMasterJobsMojo.java
@@ -1,4 +1,4 @@
-package org.apache.maven.dist.tools.scmrepo;
+package org.apache.maven.dist.tools.masterjobs;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -39,14 +39,16 @@ import org.jsoup.nodes.Element;
 import org.jsoup.select.Elements;
 
 /**
- * Generate report with build status of the master for every repository
+ * Generate report with build status of the Jenkins job for the master branch of every Git repository in
+ * <a href="https://builds.apache.org/job/maven-box/">{@code maven-box} Apache Hosted Git Folder job</a>.
+ *
  * @author Robert Scholte
  */
-@Mojo( name = "check-primary-branch", requiresProject = false )
-public class CheckPrimaryBranchMojo extends AbstractMavenReport
+@Mojo( name = "list-master-jobs", requiresProject = false )
+public class ListMasterJobsMojo extends AbstractMavenReport
 {
     private String gitboxUrl = "https://gitbox.apache.org/repos/asf";
-    private String baseUrl = "https://builds.apache.org/job/maven-box/job/";
+    private String mavenboxJobsBaseUrl = "https://builds.apache.org/job/maven-box/job/";
     
     private Collection<String> excluded = Arrays.asList( "maven-integration-testing", // runs with maven
                                                          "maven-jenkins-env",
@@ -57,19 +59,19 @@ public class CheckPrimaryBranchMojo extends AbstractMavenReport
     @Override
     public String getOutputName()
     {
-        return "check-primary-branch";
+        return "dist-tool-master-jobs";
     }
 
     @Override
     public String getName( Locale locale )
     {
-        return "Check Primary Branch";
+        return "Dist Tool> List Master Jobs";
     }
 
     @Override
     public String getDescription( Locale locale )
     {
-        return "Shows the statuses of all Maven repositories on one page";
+        return "Shows the status of Jenkins job for the master branch of every Git repository on one page";
     }
 
     @Override
@@ -83,7 +85,7 @@ public class CheckPrimaryBranchMojo extends AbstractMavenReport
         }
         catch ( IOException e )
         {
-            throw new MavenReportException( "Failed to extract repositorynames", e );
+            throw new MavenReportException( "Failed to extract repositorynames from Gitbox", e );
         }
         
         List<Result> repoStatus = new ArrayList<>( repositoryNames.size() );
@@ -94,18 +96,18 @@ public class CheckPrimaryBranchMojo extends AbstractMavenReport
         
         for ( String repository : included )
         {
-            Document doc;
+            final String repositoryJobUrl = mavenboxJobsBaseUrl + repository;
+
             try
             {
-                final String buildUrl = baseUrl + repository;
-                doc = JsoupRetry.get( buildUrl );
+                Document doc = JsoupRetry.get( repositoryJobUrl );
                 
-                Result result = new Result( repository, buildUrl );
+                Result result = new Result( repository, repositoryJobUrl );
                 
                 Element masterRow = doc.getElementById( "job_master" );
                 if ( masterRow == null )
                 {
-                    getLog().warn( baseUrl + repository + " is missing id job_master" );
+                    getLog().warn( mavenboxJobsBaseUrl + repository + " is missing id job_master" );
                 }
                 else if ( masterRow.hasClass( "job-status-red" ) )
                 {
@@ -129,7 +131,7 @@ public class CheckPrimaryBranchMojo extends AbstractMavenReport
             }
             catch ( IOException e )
             {
-                getLog().warn( "Failed to read status for " + repository  );
+                getLog().warn( "Failed to read status for " + repository + " Jenkins job " + repositoryJobUrl  );
             }
         }
         
@@ -150,9 +152,12 @@ public class CheckPrimaryBranchMojo extends AbstractMavenReport
         Map<String, List<Result>> groupedResults = repoStatus.stream()
                                                              .collect( Collectors.groupingBy( Result::getStatus ) );
         
-        groupedResults.entrySet().stream().sorted( Map.Entry.comparingByKey( resultComparator() ) ).forEach( e ->
+        groupedResults.entrySet()
+                      .stream()
+                      .sorted( Map.Entry.comparingByKey( resultComparator() ) )
+                      .forEach( e ->
             {
-                sink.text( "Repository " + e.getKey() );
+                sink.text( "Jenkins jobs for master branch with status " + e.getKey() );
                 sink.list();
                 e.getValue().forEach( r ->
                 {
@@ -180,6 +185,13 @@ public class CheckPrimaryBranchMojo extends AbstractMavenReport
             };
     }
 
+    /**
+     * Extract Git repository names for Apache Maven from
+     * <a href="https://gitbox.apache.org/repos/asf">Gitbox main page</a>.
+     *
+     * @return the list of repository names (without ".git")
+     * @throws IOException
+     */
     protected Collection<String> repositoryNames()
         throws IOException
     {
@@ -194,6 +206,7 @@ public class CheckPrimaryBranchMojo extends AbstractMavenReport
         {
             names.add( element.text().split( "\\.git" )[0] );
         }
+
         return names;
     }
 }
diff --git a/src/main/java/org/apache/maven/dist/tools/scmrepo/Result.java b/src/main/java/org/apache/maven/dist/tools/masterjobs/Result.java
similarity index 92%
rename from src/main/java/org/apache/maven/dist/tools/scmrepo/Result.java
rename to src/main/java/org/apache/maven/dist/tools/masterjobs/Result.java
index afa5a39..3281863 100644
--- a/src/main/java/org/apache/maven/dist/tools/scmrepo/Result.java
+++ b/src/main/java/org/apache/maven/dist/tools/masterjobs/Result.java
@@ -1,4 +1,4 @@
-package org.apache.maven.dist.tools.scmrepo;
+package org.apache.maven.dist.tools.masterjobs;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -19,21 +19,19 @@ package org.apache.maven.dist.tools.scmrepo;
  * under the License.
  */
 
-
 /**
- * Represent build result of a repository  
+ * Represent build result of a Jenkins job for a Git master branch.
  *
  * @author Robert Scholte
- *
  */
 public class Result
 {
     private String repositoryName;
-    
+
     private String status;
-    
+
     private String buildUrl;
-    
+
     private String icon;
 
     public Result( String repositoryName, String buildUrl )
@@ -51,22 +49,22 @@ public class Result
     {
         this.icon = icon;
     }
-    
+
     public String getRepositoryName()
     {
         return repositoryName;
     }
-    
+
     public String getStatus()
     {
         return status;
     }
-    
+
     public String getBuildUrl()
     {
         return buildUrl;
     }
-    
+
     public String getIcon()
     {
         return icon;
diff --git a/src/site/markdown/index.md b/src/site/markdown/index.md
index 38b03ac..41ba33b 100644
--- a/src/site/markdown/index.md
+++ b/src/site/markdown/index.md
@@ -34,7 +34,11 @@ Results are displayed in 4 reports:
 
 In addition, dist-tool-plugin provides report for some interesting information about Maven artifacts:
 
-* [List Plugins Prerequisites][7] report, displaying plugins' Maven and JDK version prerequisites.
+* [List Plugins Prerequisites][7] report, displaying plugins' Maven and JDK version prerequisites,
+
+or [MavenBox Jenkins Jobs](https://builds.apache.org/job/maven-box/):
+
+* [List Master Jobs][9] report, displaying the status of Jenkins jobs for the master branch of every Git repository on one page.
 
 Notice that this plugin is actually intended for Maven itself only: if interest is expressed to use it
 in other context, it would require more configurations.
@@ -47,3 +51,4 @@ in other context, it would require more configurations.
 [6]: http://maven.apache.org/developers/release/releasing.html
 [7]: ./dist-tool-prerequisites.html
 [8]: ./dist-tool-check-errors.html
+[9]: ./dist-tool-master-jobs.html
diff --git a/src/site/site.xml b/src/site/site.xml
index 861af59..64aaca1 100644
--- a/src/site/site.xml
+++ b/src/site/site.xml
@@ -36,9 +36,7 @@ under the License.
         </menu>
         <menu name="Dist Tool Informations">
             <item name="List Plugins Prerequisites" href="dist-tool-prerequisites.html" />
-        </menu>
-        <menu name="Build Information">
-            <item name="Primary Branch" href="check-primary-branch.html" />
+            <item name="List Master Jobs" href="dist-tool-master-jobs.html" />
         </menu>
         <menu name="for dev">
             <item name="TODO" href="todo.html" />