From 3d78937d806e7f5bc2f7c7acfc3d40f09caa2055 Mon Sep 17 00:00:00 2001 From: rufushuang Date: Fri, 25 Nov 2016 09:48:02 +0800 Subject: [PATCH 01/10] Create LICENSE.md --- LICENSE.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE.md diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..77280be --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2016 rufushuang + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. From 3ddf9f80ac6af6bf2ce1b79f777f4b81bcbf78d5 Mon Sep 17 00:00:00 2001 From: Yoav Sternberg Date: Wed, 26 Jul 2017 20:04:06 +0300 Subject: [PATCH 02/10] Improve performance --- src/rufus/lzstring4java/LZString.java | 152 ++++++++++++-------------- 1 file changed, 67 insertions(+), 85 deletions(-) diff --git a/src/rufus/lzstring4java/LZString.java b/src/rufus/lzstring4java/LZString.java index 74b7322..925363e 100644 --- a/src/rufus/lzstring4java/LZString.java +++ b/src/rufus/lzstring4java/LZString.java @@ -9,20 +9,18 @@ package rufus.lzstring4java; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; +import java.util.*; public class LZString { private static char[] keyStrBase64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".toCharArray(); private static char[] keyStrUriSafe = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$".toCharArray(); - private static HashMap> baseReverseDic = new HashMap>(); + private static Map> baseReverseDic = new HashMap<>(); private static char getBaseValue(char[] alphabet, Character character) { - HashMap map = baseReverseDic.get(alphabet); + Map map = baseReverseDic.get(alphabet); if (map == null) { - map = new HashMap(); + map = new HashMap<>(); baseReverseDic.put(alphabet, map); for (int i = 0; i < alphabet.length; i++) { map.put(alphabet[i], i); @@ -36,7 +34,7 @@ public static String compressToBase64(String input) { return ""; String res = LZString._compress(input, 6, new CompressFunctionWrapper() { @Override - public Character doFunc(int a) { + public char doFunc(int a) { return keyStrBase64[a]; } }); @@ -56,15 +54,12 @@ public Character doFunc(int a) { public static String decompressFromBase64(String inputStr) { if (inputStr == null) return ""; - if (inputStr == "") + if (inputStr.equals("")) return null; - final char[] input = inputStr.toCharArray(); - // function(index) { return getBaseValue(keyStrBase64, - // input.charAt(index)); } - return LZString._decompress(input.length, 32, new DecompressFunctionWrapper() { + return LZString._decompress(inputStr.length(), 32, new DecompressFunctionWrapper() { @Override - public Character doFunc(int index) { - return getBaseValue(keyStrBase64, input[index]); + public char doFunc(int index) { + return getBaseValue(keyStrBase64, inputStr.charAt(index)); } }); } @@ -74,7 +69,7 @@ public static String compressToUTF16(String input) { return ""; return LZString._compress(input, 15, new CompressFunctionWrapper() { @Override - public Character doFunc(int a) { + public char doFunc(int a) { return fc(a + 32); } }) + " "; @@ -83,13 +78,12 @@ public Character doFunc(int a) { public static String decompressFromUTF16(String compressedStr) { if (compressedStr == null) return ""; - if (compressedStr == "") + if (compressedStr.isEmpty()) return null; - final char[] compressed = compressedStr.toCharArray(); - return LZString._decompress(compressed.length, 16384, new DecompressFunctionWrapper() { + return LZString._decompress(compressedStr.length(), 16384, new DecompressFunctionWrapper() { @Override - public Character doFunc(int index) { - return (char) (compressed[index] - 32); + public char doFunc(int index) { + return (char) (compressedStr.charAt(index) - 32); } }); } @@ -101,39 +95,32 @@ public static String compressToEncodedURIComponent(String input) { return ""; return LZString._compress(input, 6, new CompressFunctionWrapper() { @Override - public Character doFunc(int a) { + public char doFunc(int a) { return keyStrUriSafe[a]; } - }) + " "; + }); } public static String decompressFromEncodedURIComponent(String inputStr) { if (inputStr == null) return ""; - if (inputStr == "") return null; - inputStr = inputStr.replace(' ', '+'); - final char[] input = inputStr.toCharArray(); - return LZString._decompress(input.length, 32, new DecompressFunctionWrapper() { + if (inputStr.isEmpty()) return null; + String urlEncodedInputStr = inputStr.replace(' ', '+'); + return LZString._decompress(urlEncodedInputStr.length(), 32, new DecompressFunctionWrapper() { @Override - public Character doFunc(int index) { - return getBaseValue(keyStrUriSafe, input[index]); + public char doFunc(int index) { + return getBaseValue(keyStrUriSafe, urlEncodedInputStr.charAt(index)); } }); } - - protected static class Data { - int val; - int position; - StringBuffer string = new StringBuffer(); - } - + private static abstract class CompressFunctionWrapper { - public abstract Character doFunc(int i); + public abstract char doFunc(int i); } public static String compress(String uncompressed) { return LZString._compress(uncompressed, 16, new CompressFunctionWrapper() { @Override - public Character doFunc(int a) { + public char doFunc(int a) { return fc(a); } }); @@ -141,22 +128,21 @@ public Character doFunc(int a) { private static String _compress(String uncompressedStr, int bitsPerChar, CompressFunctionWrapper getCharFromInt) { if (uncompressedStr == null) return ""; int i, value; - HashMap context_dictionary = new HashMap(); - HashSet context_dictionaryToCreate = new HashSet(); + Map context_dictionary = new HashMap(); + Set context_dictionaryToCreate = new HashSet(); String context_c = ""; String context_wc = ""; String context_w = ""; - double context_enlargeIn = 2d; // Compensate for the first entry which should not count + int context_enlargeIn = 2; // Compensate for the first entry which should not count int context_dictSize = 3; int context_numBits = 2; - ArrayList context_data = new ArrayList(uncompressedStr.length() / 3); + StringBuilder context_data = new StringBuilder(uncompressedStr.length() / 3); int context_data_val = 0; int context_data_position = 0; int ii; - char[] uncompressed = uncompressedStr.toCharArray(); - for (ii = 0; ii < uncompressed.length; ii += 1) { - context_c = String.valueOf(uncompressed[ii]); + for (ii = 0; ii < uncompressedStr.length(); ii += 1) { + context_c = String.valueOf(uncompressedStr.charAt(ii)); if (!context_dictionary.containsKey(context_c)) { context_dictionary.put(context_c, context_dictSize++); context_dictionaryToCreate.add(context_c); @@ -172,7 +158,7 @@ private static String _compress(String uncompressedStr, int bitsPerChar, Compres context_data_val = (context_data_val << 1); if (context_data_position == bitsPerChar - 1) { context_data_position = 0; - context_data.add(getCharFromInt.doFunc(context_data_val)); + context_data.append(getCharFromInt.doFunc(context_data_val)); context_data_val = 0; } else { context_data_position++; @@ -183,7 +169,7 @@ private static String _compress(String uncompressedStr, int bitsPerChar, Compres context_data_val = (context_data_val << 1) | (value & 1); if (context_data_position == bitsPerChar - 1) { context_data_position = 0; - context_data.add(getCharFromInt.doFunc(context_data_val)); + context_data.append(getCharFromInt.doFunc(context_data_val)); context_data_val = 0; } else { context_data_position++; @@ -196,7 +182,7 @@ private static String _compress(String uncompressedStr, int bitsPerChar, Compres context_data_val = (context_data_val << 1) | value; if (context_data_position == bitsPerChar - 1) { context_data_position = 0; - context_data.add(getCharFromInt.doFunc(context_data_val)); + context_data.append(getCharFromInt.doFunc(context_data_val)); context_data_val = 0; } else { context_data_position++; @@ -208,7 +194,7 @@ private static String _compress(String uncompressedStr, int bitsPerChar, Compres context_data_val = (context_data_val << 1) | (value & 1); if (context_data_position == bitsPerChar - 1) { context_data_position = 0; - context_data.add(getCharFromInt.doFunc(context_data_val)); + context_data.append(getCharFromInt.doFunc(context_data_val)); context_data_val = 0; } else { context_data_position++; @@ -218,7 +204,7 @@ private static String _compress(String uncompressedStr, int bitsPerChar, Compres } context_enlargeIn--; if (context_enlargeIn == 0) { - context_enlargeIn = Math.pow(2, context_numBits); + context_enlargeIn = powerOf2(context_numBits); context_numBits++; } context_dictionaryToCreate.remove(context_w); @@ -228,7 +214,7 @@ private static String _compress(String uncompressedStr, int bitsPerChar, Compres context_data_val = (context_data_val << 1) | (value & 1); if (context_data_position == bitsPerChar - 1) { context_data_position = 0; - context_data.add(getCharFromInt.doFunc(context_data_val)); + context_data.append(getCharFromInt.doFunc(context_data_val)); context_data_val = 0; } else { context_data_position++; @@ -239,7 +225,7 @@ private static String _compress(String uncompressedStr, int bitsPerChar, Compres } context_enlargeIn--; if (context_enlargeIn == 0) { - context_enlargeIn = Math.pow(2, context_numBits); + context_enlargeIn = powerOf2(context_numBits); context_numBits++; } // Add wc to the dictionary. @@ -256,7 +242,7 @@ private static String _compress(String uncompressedStr, int bitsPerChar, Compres context_data_val = (context_data_val << 1); if (context_data_position == bitsPerChar - 1) { context_data_position = 0; - context_data.add(getCharFromInt.doFunc(context_data_val)); + context_data.append(getCharFromInt.doFunc(context_data_val)); context_data_val = 0; } else { context_data_position++; @@ -267,7 +253,7 @@ private static String _compress(String uncompressedStr, int bitsPerChar, Compres context_data_val = (context_data_val << 1) | (value & 1); if (context_data_position == bitsPerChar - 1) { context_data_position = 0; - context_data.add(getCharFromInt.doFunc(context_data_val)); + context_data.append(getCharFromInt.doFunc(context_data_val)); context_data_val = 0; } else { context_data_position++; @@ -280,7 +266,7 @@ private static String _compress(String uncompressedStr, int bitsPerChar, Compres context_data_val = (context_data_val << 1) | value; if (context_data_position == bitsPerChar - 1) { context_data_position = 0; - context_data.add(getCharFromInt.doFunc(context_data_val)); + context_data.append(getCharFromInt.doFunc(context_data_val)); context_data_val = 0; } else { context_data_position++; @@ -292,7 +278,7 @@ private static String _compress(String uncompressedStr, int bitsPerChar, Compres context_data_val = (context_data_val << 1) | (value & 1); if (context_data_position == bitsPerChar - 1) { context_data_position = 0; - context_data.add(getCharFromInt.doFunc(context_data_val)); + context_data.append(getCharFromInt.doFunc(context_data_val)); context_data_val = 0; } else { context_data_position++; @@ -302,7 +288,7 @@ private static String _compress(String uncompressedStr, int bitsPerChar, Compres } context_enlargeIn--; if (context_enlargeIn == 0) { - context_enlargeIn = Math.pow(2, context_numBits); + context_enlargeIn = powerOf2(context_numBits); context_numBits++; } context_dictionaryToCreate.remove(context_w); @@ -312,7 +298,7 @@ private static String _compress(String uncompressedStr, int bitsPerChar, Compres context_data_val = (context_data_val << 1) | (value & 1); if (context_data_position == bitsPerChar - 1) { context_data_position = 0; - context_data.add(getCharFromInt.doFunc(context_data_val)); + context_data.append(getCharFromInt.doFunc(context_data_val)); context_data_val = 0; } else { context_data_position++; @@ -323,7 +309,7 @@ private static String _compress(String uncompressedStr, int bitsPerChar, Compres } context_enlargeIn--; if (context_enlargeIn == 0) { - context_enlargeIn = Math.pow(2, context_numBits); + context_enlargeIn = powerOf2(context_numBits); context_numBits++; } } @@ -334,7 +320,7 @@ private static String _compress(String uncompressedStr, int bitsPerChar, Compres context_data_val = (context_data_val << 1) | (value & 1); if (context_data_position == bitsPerChar - 1) { context_data_position = 0; - context_data.add(getCharFromInt.doFunc(context_data_val)); + context_data.append(getCharFromInt.doFunc(context_data_val)); context_data_val = 0; } else { context_data_position++; @@ -346,20 +332,17 @@ private static String _compress(String uncompressedStr, int bitsPerChar, Compres while (true) { context_data_val = (context_data_val << 1); if (context_data_position == bitsPerChar - 1) { - context_data.add(getCharFromInt.doFunc(context_data_val)); + context_data.append(getCharFromInt.doFunc(context_data_val)); break; } else context_data_position++; } - StringBuffer sb = new StringBuffer(context_data.size()); - for (char c : context_data) - sb.append(c); - return sb.toString(); + return context_data.toString(); } private static abstract class DecompressFunctionWrapper { - public abstract Character doFunc(int i); + public abstract char doFunc(int i); } protected static class DecData { public char val; @@ -370,34 +353,32 @@ protected static class DecData { public static String f(int i) { return String.valueOf((char) i); } - public static Character fc(int i) { - return Character.valueOf((char) i); + public static char fc(int i) { + return (char) i; } public static String decompress(final String compressed) { if (compressed == null) return ""; - if (compressed == "") + if (compressed.isEmpty()) return null; return LZString._decompress(compressed.length(), 32768, new DecompressFunctionWrapper() { - char[] compChars = compressed.toCharArray(); - @Override - public Character doFunc(int i) { - return compChars[i]; + public char doFunc(int i) { + return compressed.charAt(i); } }); } private static String _decompress(int length, int resetValue, DecompressFunctionWrapper getNextValue) { - ArrayList dictionary = new ArrayList(); + List dictionary = new ArrayList<>(); // TODO: is next an unused variable in original lz-string? @SuppressWarnings("unused") int next; - double enlargeIn = 4d; + int enlargeIn = 4; int dictSize = 4; int numBits = 3; String entry = ""; - ArrayList result = new ArrayList(); + StringBuilder result = new StringBuilder(); String w; int bits, resb; int maxpower, power; String c = null; @@ -411,7 +392,7 @@ private static String _decompress(int length, int resetValue, DecompressFunction } bits = 0; - maxpower = (int) Math.pow(2, 2); + maxpower = (int) powerOf2(2); power = 1; while (power != maxpower) { resb = data.val & data.position; @@ -462,7 +443,7 @@ private static String _decompress(int length, int resetValue, DecompressFunction } dictionary.add(3, c); w = c; - result.add(w); + result.append(w); while (true) { if (data.index > length) { return ""; @@ -522,14 +503,11 @@ private static String _decompress(int length, int resetValue, DecompressFunction enlargeIn--; break; case 2: - StringBuffer sb = new StringBuffer(result.size()); - for (String s : result) - sb.append(s); - return sb.toString(); - } + return result.toString(); + } if (enlargeIn == 0) { - enlargeIn = Math.pow(2, numBits); + enlargeIn = powerOf2(numBits); numBits++; } @@ -542,7 +520,7 @@ private static String _decompress(int length, int resetValue, DecompressFunction return null; } } - result.add(entry); + result.append(entry); // Add w+entry[0] to the dictionary. dictionary.add(dictSize++, w + entry.charAt(0)); @@ -551,13 +529,17 @@ private static String _decompress(int length, int resetValue, DecompressFunction w = entry; if (enlargeIn == 0) { - enlargeIn = Math.pow(2, numBits); + enlargeIn = powerOf2(numBits); numBits++; } } } + + private static int powerOf2(int power) { + return 1 << power; + } public static void main(String[] args) { String input; From e5bacd35b9952ab87164e1d71402ee635ca8af23 Mon Sep 17 00:00:00 2001 From: Yoav Sternberg Date: Thu, 15 Mar 2018 19:03:27 +0200 Subject: [PATCH 03/10] Restore Java 6 support --- src/rufus/lzstring4java/LZString.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/rufus/lzstring4java/LZString.java b/src/rufus/lzstring4java/LZString.java index 925363e..2687f38 100644 --- a/src/rufus/lzstring4java/LZString.java +++ b/src/rufus/lzstring4java/LZString.java @@ -15,12 +15,12 @@ public class LZString { private static char[] keyStrBase64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".toCharArray(); private static char[] keyStrUriSafe = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$".toCharArray(); - private static Map> baseReverseDic = new HashMap<>(); + private static Map> baseReverseDic = new HashMap>(); private static char getBaseValue(char[] alphabet, Character character) { Map map = baseReverseDic.get(alphabet); if (map == null) { - map = new HashMap<>(); + map = new HashMap(); baseReverseDic.put(alphabet, map); for (int i = 0; i < alphabet.length; i++) { map.put(alphabet[i], i); @@ -51,7 +51,7 @@ public char doFunc(int a) { } } - public static String decompressFromBase64(String inputStr) { + public static String decompressFromBase64(final String inputStr) { if (inputStr == null) return ""; if (inputStr.equals("")) @@ -75,7 +75,7 @@ public char doFunc(int a) { }) + " "; } - public static String decompressFromUTF16(String compressedStr) { + public static String decompressFromUTF16(final String compressedStr) { if (compressedStr == null) return ""; if (compressedStr.isEmpty()) @@ -104,7 +104,7 @@ public char doFunc(int a) { public static String decompressFromEncodedURIComponent(String inputStr) { if (inputStr == null) return ""; if (inputStr.isEmpty()) return null; - String urlEncodedInputStr = inputStr.replace(' ', '+'); + final String urlEncodedInputStr = inputStr.replace(' ', '+'); return LZString._decompress(urlEncodedInputStr.length(), 32, new DecompressFunctionWrapper() { @Override public char doFunc(int index) { @@ -370,7 +370,7 @@ public char doFunc(int i) { }); } private static String _decompress(int length, int resetValue, DecompressFunctionWrapper getNextValue) { - List dictionary = new ArrayList<>(); + List dictionary = new ArrayList(); // TODO: is next an unused variable in original lz-string? @SuppressWarnings("unused") int next; From 8874a19d2a53d5f8a9347f17973df3876dd3655a Mon Sep 17 00:00:00 2001 From: Yoav Sternberg Date: Thu, 15 Mar 2018 21:52:51 +0200 Subject: [PATCH 04/10] Replace Math.pow with powerOf2 --- src/rufus/lzstring4java/LZString.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/rufus/lzstring4java/LZString.java b/src/rufus/lzstring4java/LZString.java index 2687f38..cdf66fe 100644 --- a/src/rufus/lzstring4java/LZString.java +++ b/src/rufus/lzstring4java/LZString.java @@ -408,7 +408,7 @@ private static String _decompress(int length, int resetValue, DecompressFunction switch (next = bits) { case 0: bits = 0; - maxpower = (int) Math.pow(2,8); + maxpower = (int) powerOf2(8); power=1; while (power != maxpower) { resb = data.val & data.position; @@ -424,7 +424,7 @@ private static String _decompress(int length, int resetValue, DecompressFunction break; case 1: bits = 0; - maxpower = (int) Math.pow(2,16); + maxpower = powerOf2(16); power=1; while (power!=maxpower) { resb = data.val & data.position; @@ -450,7 +450,7 @@ private static String _decompress(int length, int resetValue, DecompressFunction } bits = 0; - maxpower = (int) Math.pow(2,numBits); + maxpower = powerOf2(numBits); power=1; while (power!=maxpower) { resb = data.val & data.position; @@ -467,7 +467,7 @@ private static String _decompress(int length, int resetValue, DecompressFunction switch (cc = bits) { case 0: bits = 0; - maxpower = (int) Math.pow(2,8); + maxpower = powerOf2(8); power=1; while (power!=maxpower) { resb = data.val & data.position; @@ -486,7 +486,7 @@ private static String _decompress(int length, int resetValue, DecompressFunction break; case 1: bits = 0; - maxpower = (int) Math.pow(2,16); + maxpower = powerOf2(16); power=1; while (power!=maxpower) { resb = data.val & data.position; From 42f94841ec5ec3ad0099282b2eb8069cc0df702f Mon Sep 17 00:00:00 2001 From: Jean-Christophe Gay Date: Tue, 29 Sep 2020 15:30:41 +0200 Subject: [PATCH 05/10] Build within our CI --- .gitignore | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++-- Jenkinsfile | 45 ++++++++++++++++++++++++++++++++++++++++ pom.xml | 31 ++++++++++++++-------------- 3 files changed, 118 insertions(+), 17 deletions(-) create mode 100644 Jenkinsfile diff --git a/.gitignore b/.gitignore index e02e5e4..e93c5e2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,58 @@ -.idea/ + +# Created by https://www.toptal.com/developers/gitignore/api/maven,java,intellij +# Edit at https://www.toptal.com/developers/gitignore?templates=maven,java,intellij + +### Intellij ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +.idea *.iml -/bin +*.ipr + +# File-based project format +*.iws + +# IntelliJ +out/ + +### Java ### +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +### Maven ### +target/ +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +pom.xml.next +release.properties +dependency-reduced-pom.xml +buildNumber.properties +.mvn/timing.properties +# https://github.com/takari/maven-wrapper#usage-without-binary-jar +.mvn/wrapper/maven-wrapper.jar + +# End of https://www.toptal.com/developers/gitignore/api/maven,java,intellij + diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..a040cca --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,45 @@ +#!/usr/bin/env groovy +import com.vidal.jenkins.* + +pipeline { + agent { + docker { + image 'ci/mvn-chrome:2.0.0' + args "--volume /data/repository:/tmp/mvn-repo --name=lz-string4java-${BRANCH_NAME}-${env.BUILD_ID} -v /var/run/docker.sock:/var/run/docker.sock --group-add docker-slave" + } + } + options { + disableConcurrentBuilds() + buildDiscarder(logRotator(numToKeepStr: '10', artifactNumToKeepStr: '10')) + } + stages { + stage('Prepare') { + when { + expression { Branches.isPullRequest(BRANCH_NAME) } + } + steps { + cancelPreviousBuild() + } + } + + stage('Build and Tests') { + steps { + mvn 'clean verify' + junit '**/target/surefire-reports/TEST-*.xml' + } + } + + stage('Share (Nexus)') { + when { + anyOf { + branch 'master' + branch 'sprint-*' + } + expression { currentBuild.resultIsBetterOrEqualTo('SUCCESS') } + } + steps { + mvn 'deploy -DskipTests' + } + } + } +} \ No newline at end of file diff --git a/pom.xml b/pom.xml index 69905b0..592c070 100644 --- a/pom.xml +++ b/pom.xml @@ -3,9 +3,9 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 4.0.0 - com.github.wajda - lzstring4java - 0.1 + com.github.softwarevidal + lz-string4java + 1.0.0-SNAPSHOT jar LZ-String @@ -30,21 +30,22 @@ - scm:git:git@github.com:wajda/lz-string4java.git - scm:git:git@github.com:wajda/lz-string4java.git - https://github.com/wajda/lz-string4java.git + scm:git:git@github.com:softwarevidal/lz-string4java.git + scm:git:git@github.com:softwarevidal/lz-string4java.git + https://github.com/softwarevidal/lz-string4java - - ossrh - https://oss.sonatype.org/content/repositories/snapshots - - - ossrh - https://oss.sonatype.org/service/local/staging/deploy/maven2/ - - + + vidal-3rd-party-releases + http://nexus.vidal.net/content/repositories/vidal-3rd-party-releases/ + + + vidal-snapshots + true + http://nexus.vidal.net/content/repositories/vidal-snapshots/ + + From 5929aa6ccdf31b36b2d718b4658ac5d3aef99f85 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Gay Date: Tue, 29 Sep 2020 16:16:54 +0200 Subject: [PATCH 06/10] Skip Javadoc generation It is failing with Java 11. javadoc: error - The code being documented uses modules but the packages [...] --- pom.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pom.xml b/pom.xml index 592c070..4bc9cd2 100644 --- a/pom.xml +++ b/pom.xml @@ -102,6 +102,9 @@ org.apache.maven.plugins maven-javadoc-plugin 2.10.3 + + true + attach-javadocs From 48ad9bcefef7d4f5a9341abdf42983c17fa22746 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Gay Date: Tue, 29 Sep 2020 16:18:13 +0200 Subject: [PATCH 07/10] Build sources Jar without forking the build --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4bc9cd2..9f1b43e 100644 --- a/pom.xml +++ b/pom.xml @@ -93,7 +93,7 @@ attach-sources - jar + jar-no-fork From a659f1f2a5aa794b964fc171c6ee9df53b7083db Mon Sep 17 00:00:00 2001 From: Jean-Christophe Gay Date: Tue, 29 Sep 2020 16:21:47 +0200 Subject: [PATCH 08/10] [maven-release-plugin] prepare release lz-string4java-1.0.0 --- pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 9f1b43e..00043d3 100644 --- a/pom.xml +++ b/pom.xml @@ -1,11 +1,10 @@ - + 4.0.0 com.github.softwarevidal lz-string4java - 1.0.0-SNAPSHOT + 1.0.0 jar LZ-String @@ -33,7 +32,8 @@ scm:git:git@github.com:softwarevidal/lz-string4java.git scm:git:git@github.com:softwarevidal/lz-string4java.git https://github.com/softwarevidal/lz-string4java - + lz-string4java-1.0.0 + From 7856bb5efe0b5b5264797e27f90ae65c553f9621 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Gay Date: Tue, 29 Sep 2020 16:21:55 +0200 Subject: [PATCH 09/10] [maven-release-plugin] prepare for next development iteration --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 00043d3..84cd16e 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.github.softwarevidal lz-string4java - 1.0.0 + 1.0.1-SNAPSHOT jar LZ-String @@ -32,7 +32,7 @@ scm:git:git@github.com:softwarevidal/lz-string4java.git scm:git:git@github.com:softwarevidal/lz-string4java.git https://github.com/softwarevidal/lz-string4java - lz-string4java-1.0.0 + HEAD From 8456979ec545e4b473ad3ec7b43a78ca1031938c Mon Sep 17 00:00:00 2001 From: Jean-Christophe Gay Date: Tue, 29 Sep 2020 16:24:43 +0200 Subject: [PATCH 10/10] Do not deploy on ossrh --- pom.xml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/pom.xml b/pom.xml index 84cd16e..94d3cfa 100644 --- a/pom.xml +++ b/pom.xml @@ -114,17 +114,6 @@ - - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.7 - true - - ossrh - https://oss.sonatype.org/ - true - -