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 2c043aa share common code in AbstractJobsReport
2c043aa is described below
commit 2c043aa6c5e7d0df525e601444789af0cfd8e16a
Author: Hervé Boutemy <[email protected]>
AuthorDate: Sun Jun 4 19:17:17 2023 +0200
share common code in AbstractJobsReport
---
.../maven/dist/tools/jobs/AbstractJobsReport.java | 78 ++++++++++++++++++++++
.../{ => jobs}/branches/ListBranchesReport.java | 49 ++------------
.../dist/tools/{ => jobs}/branches/Result.java | 2 +-
.../master}/ListMasterJobsReport.java | 60 ++---------------
.../tools/{masterjobs => jobs/master}/Result.java | 2 +-
5 files changed, 92 insertions(+), 99 deletions(-)
diff --git
a/src/main/java/org/apache/maven/dist/tools/jobs/AbstractJobsReport.java
b/src/main/java/org/apache/maven/dist/tools/jobs/AbstractJobsReport.java
new file mode 100644
index 0000000..924f0df
--- /dev/null
+++ b/src/main/java/org/apache/maven/dist/tools/jobs/AbstractJobsReport.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.maven.dist.tools.jobs;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import org.apache.maven.dist.tools.JsoupRetry;
+import org.apache.maven.reporting.AbstractMavenReport;
+import org.apache.maven.reporting.MavenReportException;
+import org.jsoup.nodes.Document;
+import org.jsoup.nodes.Element;
+import org.jsoup.select.Elements;
+
+public abstract class AbstractJobsReport extends AbstractMavenReport {
+ protected static final String GITBOX_URL =
"https://gitbox.apache.org/repos/asf";
+
+ protected static final String MAVENBOX_JOBS_BASE_URL =
"https://ci-maven.apache.org/job/Maven/job/maven-box/job/";
+
+ private static final Collection<String> EXCLUDED = Arrays.asList(
+ "maven-blog",
+ "maven-integration-testing", // runs with Maven core job
+ "maven-jenkins-env",
+ "maven-jenkins-lib",
+ "maven-sources",
+ "maven-studies",
+ "maven-mvnd",
+ "maven-metric-extension",
+ "maven-gh-actions-shared");
+
+ /**
+ * 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 java.io.IOException problem with reading repository index
+ */
+ protected Collection<String> repositoryNames() throws MavenReportException
{
+ try {
+ List<String> names = new ArrayList<>(100);
+ Document doc = JsoupRetry.get(GITBOX_URL);
+ // find Apache Maven table
+ Element apacheMavenTable =
+ doc.getElementsMatchingText("^Apache
Maven$").parents().get(0);
+
+ Elements gitRepo =
+ apacheMavenTable.select("tbody
tr").not("tr.disabled").select("td:first-child a");
+
+ for (Element element : gitRepo) {
+ names.add(element.text().split("\\.git")[0]);
+ }
+
+ return names.stream().filter(s ->
!EXCLUDED.contains(s)).collect(Collectors.toList());
+ } catch (IOException e) {
+ throw new MavenReportException("Failed to extract repositorynames
from Gitbox " + GITBOX_URL, e);
+ }
+ }
+}
diff --git
a/src/main/java/org/apache/maven/dist/tools/branches/ListBranchesReport.java
b/src/main/java/org/apache/maven/dist/tools/jobs/branches/ListBranchesReport.java
similarity index 92%
rename from
src/main/java/org/apache/maven/dist/tools/branches/ListBranchesReport.java
rename to
src/main/java/org/apache/maven/dist/tools/jobs/branches/ListBranchesReport.java
index 789d12f..7be549c 100644
--- a/src/main/java/org/apache/maven/dist/tools/branches/ListBranchesReport.java
+++
b/src/main/java/org/apache/maven/dist/tools/jobs/branches/ListBranchesReport.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.maven.dist.tools.branches;
+package org.apache.maven.dist.tools.jobs.branches;
import java.io.IOException;
import java.net.HttpURLConnection;
@@ -33,16 +33,14 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
import org.apache.maven.dist.tools.JsoupRetry;
-import org.apache.maven.dist.tools.masterjobs.ListMasterJobsReport;
+import org.apache.maven.dist.tools.jobs.AbstractJobsReport;
import org.apache.maven.doxia.sink.Sink;
import org.apache.maven.doxia.sink.SinkEventAttributes;
import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet;
import org.apache.maven.plugins.annotations.Mojo;
-import org.apache.maven.reporting.AbstractMavenReport;
import org.apache.maven.reporting.MavenReportException;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
-import org.jsoup.select.Elements;
/**
* Generate report with build status of the Jenkins job for the master branch
of every Git repository in
@@ -51,19 +49,13 @@ import org.jsoup.select.Elements;
* @author Robert Scholte
*/
@Mojo(name = "list-branches", requiresProject = false)
-public class ListBranchesReport extends AbstractMavenReport {
+public class ListBranchesReport extends AbstractJobsReport {
private static final String JIRA_BASE_URL =
"https://issues.apache.org/jira/projects/";
- private static final String GITBOX_URL =
"https://gitbox.apache.org/repos/asf";
-
- private static final String MAVENBOX_JOBS_BASE_URL =
"https://ci-maven.apache.org/job/Maven/job/maven-box/job/";
-
private static final String GITHUB_URL = "https://github.com/apache/";
private static final String DEPENDABOT_CONFIG = ".github/dependabot.yml";
- private static final Collection<String> EXCLUDED =
ListMasterJobsReport.EXCLUDED;
-
private static final Map<String, String> JIRAPROJECTS = new HashMap<>();
static {
@@ -188,19 +180,11 @@ public class ListBranchesReport extends
AbstractMavenReport {
/** {@inheritDoc} */
@Override
protected void executeReport(Locale locale) throws MavenReportException {
- Collection<String> repositoryNames;
- try {
- repositoryNames = repositoryNames();
- } catch (IOException e) {
- throw new MavenReportException("Failed to extract repositorynames
from Gitbox", e);
- }
+ Collection<String> repositoryNames = repositoryNames();
List<Result> repoStatus = new ArrayList<>(repositoryNames.size());
- Collection<String> included =
- repositoryNames.stream().filter(s ->
!EXCLUDED.contains(s)).collect(Collectors.toList());
-
- for (String repository : included) {
+ for (String repository : repositoryNames) {
final String gitboxHeadsUrl = getGitboxHeadsUrl(repository);
final String repositoryJobUrl = MAVENBOX_JOBS_BASE_URL +
repository;
@@ -509,29 +493,6 @@ public class ListBranchesReport extends
AbstractMavenReport {
sink.body_();
}
- /**
- * 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 java.io.IOException problem with reading repository index
- */
- protected Collection<String> repositoryNames() throws IOException {
- List<String> names = new ArrayList<>(100);
- Document doc = JsoupRetry.get(GITBOX_URL);
- // find Apache Maven table
- Element apacheMavenTable = doc.getElementById("maven");
-
- Elements gitRepo =
- apacheMavenTable.select("tbody
tr").not("tr.disabled").select("td:first-child a");
-
- for (Element element : gitRepo) {
- names.add(element.text().split("\\.git")[0]);
- }
-
- return names;
- }
-
/**
* <p>hasDependabotYml.</p>
*
diff --git a/src/main/java/org/apache/maven/dist/tools/branches/Result.java
b/src/main/java/org/apache/maven/dist/tools/jobs/branches/Result.java
similarity index 99%
rename from src/main/java/org/apache/maven/dist/tools/branches/Result.java
rename to src/main/java/org/apache/maven/dist/tools/jobs/branches/Result.java
index 35c62fa..7ad386f 100644
--- a/src/main/java/org/apache/maven/dist/tools/branches/Result.java
+++ b/src/main/java/org/apache/maven/dist/tools/jobs/branches/Result.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.maven.dist.tools.branches;
+package org.apache.maven.dist.tools.jobs.branches;
import java.util.Collection;
diff --git
a/src/main/java/org/apache/maven/dist/tools/masterjobs/ListMasterJobsReport.java
b/src/main/java/org/apache/maven/dist/tools/jobs/master/ListMasterJobsReport.java
similarity index 75%
rename from
src/main/java/org/apache/maven/dist/tools/masterjobs/ListMasterJobsReport.java
rename to
src/main/java/org/apache/maven/dist/tools/jobs/master/ListMasterJobsReport.java
index 6c5765d..6819d2a 100644
---
a/src/main/java/org/apache/maven/dist/tools/masterjobs/ListMasterJobsReport.java
+++
b/src/main/java/org/apache/maven/dist/tools/jobs/master/ListMasterJobsReport.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.maven.dist.tools.masterjobs;
+package org.apache.maven.dist.tools.jobs.master;
import java.io.IOException;
import java.time.ZonedDateTime;
@@ -31,13 +31,12 @@ import java.util.Map;
import java.util.stream.Collectors;
import org.apache.maven.dist.tools.JsoupRetry;
+import org.apache.maven.dist.tools.jobs.AbstractJobsReport;
import org.apache.maven.doxia.sink.Sink;
import org.apache.maven.plugins.annotations.Mojo;
-import org.apache.maven.reporting.AbstractMavenReport;
import org.apache.maven.reporting.MavenReportException;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
-import org.jsoup.select.Elements;
/**
* Generate report with build status of the Jenkins job for the master branch
of every Git repository in
@@ -46,20 +45,7 @@ import org.jsoup.select.Elements;
* @author Robert Scholte
*/
@Mojo(name = "list-master-jobs", requiresProject = false)
-public class ListMasterJobsReport extends AbstractMavenReport {
- private String gitboxUrl = "https://gitbox.apache.org/repos/asf";
- private String mavenboxJobsBaseUrl =
"https://ci-maven.apache.org/job/Maven/job/maven-box/";
-
- public static final Collection<String> EXCLUDED = Arrays.asList(
- "maven-blog",
- "maven-integration-testing", // runs with Maven core job
- "maven-jenkins-env",
- "maven-jenkins-lib",
- "maven-sources",
- "maven-studies",
- "maven-mvnd",
- "maven-metric-extension",
- "maven-gh-actions-shared");
+public class ListMasterJobsReport extends AbstractJobsReport {
/**
* <p>Constructor for DistCheckSiteReport.</p>
@@ -87,20 +73,12 @@ public class ListMasterJobsReport extends
AbstractMavenReport {
/** {@inheritDoc} */
@Override
protected void executeReport(Locale locale) throws MavenReportException {
- Collection<String> repositoryNames;
- try {
- repositoryNames = repositoryNames();
- } catch (IOException e) {
- throw new MavenReportException("Failed to extract repositorynames
from Gitbox", e);
- }
+ Collection<String> repositoryNames = repositoryNames();
List<Result> repoStatus = new ArrayList<>(repositoryNames.size());
- Collection<String> included =
- repositoryNames.stream().filter(s ->
!EXCLUDED.contains(s)).collect(Collectors.toList());
-
- for (String repository : included) {
- final String repositoryJobUrl = mavenboxJobsBaseUrl + "job/" +
repository;
+ for (String repository : repositoryNames) {
+ final String repositoryJobUrl = MAVENBOX_JOBS_BASE_URL + "job/" +
repository;
try {
Document doc = JsoupRetry.get(repositoryJobUrl);
@@ -109,7 +87,7 @@ public class ListMasterJobsReport extends
AbstractMavenReport {
Element masterRow = doc.getElementById("job_master");
if (masterRow == null) {
- getLog().warn(mavenboxJobsBaseUrl + repository + " is
missing id job_master");
+ getLog().warn(MAVENBOX_JOBS_BASE_URL + repository + " is
missing id job_master");
continue;
} else if (masterRow.hasClass("job-status-red") ||
masterRow.hasClass("job-status-red-anime")) {
result.setStatus("FAILURE");
@@ -216,28 +194,4 @@ public class ListMasterJobsReport extends
AbstractMavenReport {
return failure;
}
}
-
- /**
- * 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 java.io.IOException problem with reading repository index
- */
- protected Collection<String> repositoryNames() throws IOException {
- List<String> names = new ArrayList<>(100);
- Document doc = JsoupRetry.get(gitboxUrl);
- // find Apache Maven table
- Element apacheMavenTable =
- doc.getElementsMatchingText("^Apache Maven$").parents().get(0);
-
- Elements gitRepo =
- apacheMavenTable.select("tbody
tr").not("tr.disabled").select("td:first-child a");
-
- for (Element element : gitRepo) {
- names.add(element.text().split("\\.git")[0]);
- }
-
- return names;
- }
}
diff --git a/src/main/java/org/apache/maven/dist/tools/masterjobs/Result.java
b/src/main/java/org/apache/maven/dist/tools/jobs/master/Result.java
similarity index 98%
rename from src/main/java/org/apache/maven/dist/tools/masterjobs/Result.java
rename to src/main/java/org/apache/maven/dist/tools/jobs/master/Result.java
index 20f832e..3f24d2b 100644
--- a/src/main/java/org/apache/maven/dist/tools/masterjobs/Result.java
+++ b/src/main/java/org/apache/maven/dist/tools/jobs/master/Result.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.maven.dist.tools.masterjobs;
+package org.apache.maven.dist.tools.jobs.master;
import java.time.ZonedDateTime;