From 89aad504cbbf5ce5e5fd91e10176bb79b341eaf8 Mon Sep 17 00:00:00 2001 From: Andrew Woods Date: Sat, 14 May 2016 08:23:29 -0400 Subject: [PATCH 1/2] Allow building site in batches of commits - instead of one potentially large commit --- .../com/github/maven/plugins/site/SiteMojo.java | 15 +++++++++++++++ pom.xml | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/github-site-plugin/src/main/java/com/github/maven/plugins/site/SiteMojo.java b/github-site-plugin/src/main/java/com/github/maven/plugins/site/SiteMojo.java index f09080ca..64174547 100644 --- a/github-site-plugin/src/main/java/com/github/maven/plugins/site/SiteMojo.java +++ b/github-site-plugin/src/main/java/com/github/maven/plugins/site/SiteMojo.java @@ -22,6 +22,7 @@ package com.github.maven.plugins.site; import static java.lang.Integer.MAX_VALUE; +import static java.lang.Integer.min; import static org.eclipse.egit.github.core.Blob.ENCODING_BASE64; import static org.eclipse.egit.github.core.TreeEntry.MODE_BLOB; import static org.eclipse.egit.github.core.TreeEntry.TYPE_BLOB; @@ -327,6 +328,20 @@ public void execute() throws MojoExecutionException { debug(MessageFormat.format("Scanned files to include: {0}", Arrays.toString(paths))); + // Push updates in multiple passes + final int CAPACITY = 500; + int start = 0; + int end = min(CAPACITY, paths.length); + while (start < paths.length) { + info("Sending batch: [" + start + " - " + end + ")"); + String[] subpaths = Arrays.copyOfRange(paths, start, end); + doExecute(repository, subpaths); + start = end; + end = (end + CAPACITY < paths.length ? end + CAPACITY : paths.length ); + } + } + + private void doExecute(RepositoryId repository, String[] paths) throws MojoExecutionException { DataService service = new DataService(createClient(host, userName, password, oauth2Token, server, settings, session)); diff --git a/pom.xml b/pom.xml index ba36f1b3..2417e6e8 100644 --- a/pom.xml +++ b/pom.xml @@ -113,8 +113,8 @@ maven-compiler-plugin 2.3.2 - 1.5 - 1.5 + 1.8 + 1.8 From ac06e53467e55204b92298d43d5c13f0f2474635 Mon Sep 17 00:00:00 2001 From: Andrew Woods Date: Thu, 17 Nov 2016 18:42:37 -0500 Subject: [PATCH 2/2] Revert to Java5 style syntax --- .../com/github/maven/plugins/site/SiteMojo.java | 16 +++++++++++++--- pom.xml | 4 ++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/github-site-plugin/src/main/java/com/github/maven/plugins/site/SiteMojo.java b/github-site-plugin/src/main/java/com/github/maven/plugins/site/SiteMojo.java index 64174547..2205e51d 100644 --- a/github-site-plugin/src/main/java/com/github/maven/plugins/site/SiteMojo.java +++ b/github-site-plugin/src/main/java/com/github/maven/plugins/site/SiteMojo.java @@ -22,7 +22,6 @@ package com.github.maven.plugins.site; import static java.lang.Integer.MAX_VALUE; -import static java.lang.Integer.min; import static org.eclipse.egit.github.core.Blob.ENCODING_BASE64; import static org.eclipse.egit.github.core.TreeEntry.MODE_BLOB; import static org.eclipse.egit.github.core.TreeEntry.TYPE_BLOB; @@ -331,16 +330,27 @@ public void execute() throws MojoExecutionException { // Push updates in multiple passes final int CAPACITY = 500; int start = 0; - int end = min(CAPACITY, paths.length); + int end = Math.min(CAPACITY, paths.length); while (start < paths.length) { info("Sending batch: [" + start + " - " + end + ")"); - String[] subpaths = Arrays.copyOfRange(paths, start, end); + String[] subpaths = copyOfRange(paths, start, end); doExecute(repository, subpaths); start = end; end = (end + CAPACITY < paths.length ? end + CAPACITY : paths.length ); } } + private String[] copyOfRange(String[] original, int from, int to) { + int newLength = to - from; + if (newLength < 0) { + throw new IllegalArgumentException(from + " > " + to); + } + + String[] copy = new String[newLength]; + System.arraycopy(original, from, copy, 0, Math.min(original.length - from, newLength)); + return copy; + } + private void doExecute(RepositoryId repository, String[] paths) throws MojoExecutionException { DataService service = new DataService(createClient(host, userName, password, oauth2Token, server, settings, session)); diff --git a/pom.xml b/pom.xml index 2417e6e8..ba36f1b3 100644 --- a/pom.xml +++ b/pom.xml @@ -113,8 +113,8 @@ maven-compiler-plugin 2.3.2 - 1.8 - 1.8 + 1.5 + 1.5