From 1b06bccda047bc942dd00d9e83de4f20c9988568 Mon Sep 17 00:00:00 2001 From: jantje Date: Sat, 25 Nov 2023 05:08:23 +0100 Subject: [PATCH 1/4] the build no longer worked #1593 This has mostly to do with apache other plugins which now are somewhere else. --- io.sloeber.core.nl1/META-INF/MANIFEST.MF | 2 +- io.sloeber.core/.classpath | 22 +- io.sloeber.core/.gitignore | 1 + .../.settings/org.eclipse.jdt.core.prefs | 11 - io.sloeber.core/META-INF/MANIFEST.MF | 13 +- .../src/io/sloeber/core/Activator.java | 7 +- .../io/sloeber/core/api/CodeDescription.java | 5 +- .../src/io/sloeber/core/api/Defaults.java | 6 +- .../sloeber/core/api/LaunchConfiguration.java | 3 +- .../src/io/sloeber/core/common/Common.java | 26 ++- .../io/sloeber/core/common/IndexHelper.java | 5 +- .../ArduinoGnuMakefileGenerator.java | 7 +- .../io/sloeber/core/tools/FileModifiers.java | 165 +++++++------- .../src/io/sloeber/core/tools/Libraries.java | 11 +- .../io/sloeber/core/tools/PackageManager.java | 4 +- .../sloeber/core/tools/PdePreprocessor.java | 7 +- .../src/io/sloeber/core/txt/WorkAround.java | 31 +-- io.sloeber.parent/pom.xml | 7 +- io.sloeber.product/sloeber.target | 207 ++++-------------- io.sloeber.tests/.classpath | 16 +- io.sloeber.tests/.gitignore | 3 +- .../.settings/org.eclipse.jdt.core.prefs | 10 - io.sloeber.tests/META-INF/MANIFEST.MF | 7 +- ...teAndCompileDefaultInoOnAllBoardsTest.java | 12 +- .../src/io/sloeber/core/Shared.java | 62 ++++-- .../junit/TxtWorkAroundRegression.java | 29 ++- io.sloeber.ui.nl1/META-INF/MANIFEST.MF | 2 +- io.sloeber.ui/META-INF/MANIFEST.MF | 5 +- .../sloeber/ui/core/launchconfig/MainTab.java | 3 +- 29 files changed, 318 insertions(+), 371 deletions(-) delete mode 100644 io.sloeber.core/.settings/org.eclipse.jdt.core.prefs delete mode 100644 io.sloeber.tests/.settings/org.eclipse.jdt.core.prefs diff --git a/io.sloeber.core.nl1/META-INF/MANIFEST.MF b/io.sloeber.core.nl1/META-INF/MANIFEST.MF index 44e99ac94..3ae33eb1c 100644 --- a/io.sloeber.core.nl1/META-INF/MANIFEST.MF +++ b/io.sloeber.core.nl1/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Sloeber core language pack Bundle-SymbolicName: io.sloeber.core.nl1;singleton:=true -Bundle-RequiredExecutionEnvironment: JavaSE-11 +Bundle-RequiredExecutionEnvironment: JavaSE-17 Bundle-Version: 4.4.1.qualifier Fragment-Host: io.sloeber.core Bundle-Vendor: Sloeber.io diff --git a/io.sloeber.core/.classpath b/io.sloeber.core/.classpath index a81ce7f72..50f33be30 100644 --- a/io.sloeber.core/.classpath +++ b/io.sloeber.core/.classpath @@ -1,14 +1,24 @@ - - + - + - - - + + + + + + + + + + + + + + diff --git a/io.sloeber.core/.gitignore b/io.sloeber.core/.gitignore index 09e3bc9b2..bfa4cce0d 100644 --- a/io.sloeber.core/.gitignore +++ b/io.sloeber.core/.gitignore @@ -1,2 +1,3 @@ /bin/ /target/ +.settings/* \ No newline at end of file diff --git a/io.sloeber.core/.settings/org.eclipse.jdt.core.prefs b/io.sloeber.core/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index cc714748f..000000000 --- a/io.sloeber.core/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,11 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.codeComplete.argumentPrefixes= -org.eclipse.jdt.core.codeComplete.argumentSuffixes= -org.eclipse.jdt.core.codeComplete.fieldPrefixes= -org.eclipse.jdt.core.codeComplete.fieldSuffixes= -org.eclipse.jdt.core.codeComplete.localPrefixes= -org.eclipse.jdt.core.codeComplete.localSuffixes= -org.eclipse.jdt.core.codeComplete.staticFieldPrefixes= -org.eclipse.jdt.core.codeComplete.staticFieldSuffixes= -org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes= -org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes= diff --git a/io.sloeber.core/META-INF/MANIFEST.MF b/io.sloeber.core/META-INF/MANIFEST.MF index 44da93310..a9204be91 100644 --- a/io.sloeber.core/META-INF/MANIFEST.MF +++ b/io.sloeber.core/META-INF/MANIFEST.MF @@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: Arduino eclipse plugin Bundle-SymbolicName: io.sloeber.core;singleton:=true Bundle-Version: 4.4.1.qualifier -Bundle-RequiredExecutionEnvironment: JavaSE-11 +Bundle-RequiredExecutionEnvironment: JavaSE-17 Bundle-Vendor: Sloeber.io Bundle-ActivationPolicy: lazy Bundle-Activator: io.sloeber.core.Activator @@ -13,17 +13,16 @@ Bundle-ClassPath: ., lib/jmdns-3.5.7.jar Require-Bundle: org.eclipse.cdt.managedbuilder.core, org.eclipse.core.filesystem, - org.eclipse.cdt.core;bundle-version="7.0.0", - org.apache.commons.compress, - org.apache.commons.lang, + org.eclipse.cdt.core, com.google.gson, org.eclipse.equinox.security, org.eclipse.core.runtime, - org.apache.commons.io;bundle-version="2.0.0", - org.eclipse.ui;bundle-version="3.117.0", + org.eclipse.ui, org.eclipse.ui.console, org.eclipse.debug.core, - org.eclipse.core.variables + org.eclipse.core.variables, + org.apache.commons.io, + org.apache.commons.compress Export-Package: cc.arduino.packages;x-internal:=true, cc.arduino.packages.discoverers;x-internal:=true, cc.arduino.packages.ssh;x-internal:=true, diff --git a/io.sloeber.core/src/io/sloeber/core/Activator.java b/io.sloeber.core/src/io/sloeber/core/Activator.java index 0bed083fb..821629203 100644 --- a/io.sloeber.core/src/io/sloeber/core/Activator.java +++ b/io.sloeber.core/src/io/sloeber/core/Activator.java @@ -1,5 +1,6 @@ package io.sloeber.core; +import static io.sloeber.core.common.Common.*; import static io.sloeber.core.common.Const.*; import static org.eclipse.core.resources.IResource.*; @@ -10,8 +11,6 @@ import java.net.MalformedURLException; import java.net.URL; -import org.apache.commons.io.FileUtils; -import org.apache.commons.lang.SystemUtils; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.settings.model.CProjectDescriptionEvent; @@ -402,13 +401,13 @@ private static void installOtherStuff() { String AWK_URL = "https://github.com/Sloeber/arduino-eclipse-plugin/files/7102568/awk_GNU_64_bit_V4_2_1.zip"; // On Windows install make and awk - if (SystemUtils.IS_OS_WINDOWS) { + if (isWindows) { // Install make if needed IPath localMakePath = ConfigurationPreferences.getMakePath(); if (localMakePath.append(MAKE_EXE).toFile().exists()) { if (!localMakePath.append(SH_EXE).toFile().exists()) { try { - FileUtils.deleteDirectory(new File(localMakePath.toString())); + deleteDirectory(localMakePath); } catch (IOException e) { // should not happen e.printStackTrace(); diff --git a/io.sloeber.core/src/io/sloeber/core/api/CodeDescription.java b/io.sloeber.core/src/io/sloeber/core/api/CodeDescription.java index 4890e10b0..22b72d842 100644 --- a/io.sloeber.core/src/io/sloeber/core/api/CodeDescription.java +++ b/io.sloeber.core/src/io/sloeber/core/api/CodeDescription.java @@ -9,9 +9,9 @@ import java.util.ArrayList; import java.util.Map; import java.util.TreeMap; +import java.util.stream.Collectors; import org.apache.commons.io.FileUtils; -import org.apache.commons.lang.StringUtils; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; @@ -205,6 +205,7 @@ Map createFiles(IProject project, IProgressMonitor monitor) throw if (myMakeLinks) { Helpers.linkDirectory(project, curPath, new Path("/")); //$NON-NLS-1$ } else { + // Files.copy(curPath.toPath(), project.getLocation().toPath()); FileUtils.copyDirectory(curPath.toFile(), project.getLocation().toFile()); FileModifiers.addPragmaOnce(curPath); } @@ -237,7 +238,7 @@ public ArrayList getExamples() { private void saveLastUsedExamples() { if (myExamples != null) { - String toStore = StringUtils.join(myExamples, "\n"); //$NON-NLS-1$ + String toStore = myExamples.stream().map(Object::toString).collect(Collectors.joining("\n")); //$NON-NLS-1$ InstancePreferences.setGlobalValue(KEY_LAST_USED_EXAMPLES, toStore); } else { InstancePreferences.setGlobalValue(KEY_LAST_USED_EXAMPLES, new String()); diff --git a/io.sloeber.core/src/io/sloeber/core/api/Defaults.java b/io.sloeber.core/src/io/sloeber/core/api/Defaults.java index 2d45a67a0..fb44deaa7 100644 --- a/io.sloeber.core/src/io/sloeber/core/api/Defaults.java +++ b/io.sloeber.core/src/io/sloeber/core/api/Defaults.java @@ -1,8 +1,8 @@ package io.sloeber.core.api; +import static io.sloeber.core.common.Common.*; import static io.sloeber.core.common.Const.*; -import org.apache.commons.lang.SystemUtils; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; @@ -32,7 +32,7 @@ public class Defaults { */ public static String getPrivateLibraryPath() { IPath homPath = new Path(System.getProperty("user.home")); - if (SystemUtils.IS_OS_MAC || SystemUtils.IS_OS_WINDOWS) { + if (isMac || isWindows) { homPath = homPath.append("Documents"); } return homPath.append("Arduino").append(LIBRARY_PATH_SUFFIX).toString(); @@ -40,7 +40,7 @@ public static String getPrivateLibraryPath() { public static String getPrivateHardwarePath() { IPath homPath = new Path(System.getProperty("user.home")); - if (SystemUtils.IS_OS_MAC || SystemUtils.IS_OS_WINDOWS) { + if (isMac || isWindows) { homPath = homPath.append("Documents"); } return homPath.append("Arduino").append(ARDUINO_HARDWARE_FOLDER_NAME).toString(); diff --git a/io.sloeber.core/src/io/sloeber/core/api/LaunchConfiguration.java b/io.sloeber.core/src/io/sloeber/core/api/LaunchConfiguration.java index fad35f861..56eeb5645 100644 --- a/io.sloeber.core/src/io/sloeber/core/api/LaunchConfiguration.java +++ b/io.sloeber.core/src/io/sloeber/core/api/LaunchConfiguration.java @@ -1,6 +1,5 @@ package io.sloeber.core.api; -import org.apache.commons.lang.StringUtils; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; @@ -82,7 +81,7 @@ private void loadSettingsFromConfiguration() { * @return the project handle if a project was found */ public static IProject findProject(String name) { - if (StringUtils.isNotBlank(name) && new Path(name).isValidPath(name)) { + if ((!name.isBlank()) && new Path(name).isValidPath(name)) { IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject(name); if (p.getLocation() != null) return p; diff --git a/io.sloeber.core/src/io/sloeber/core/common/Common.java b/io.sloeber.core/src/io/sloeber/core/common/Common.java index 149d6f0ab..f708fa057 100644 --- a/io.sloeber.core/src/io/sloeber/core/common/Common.java +++ b/io.sloeber.core/src/io/sloeber/core/common/Common.java @@ -3,10 +3,14 @@ import static io.sloeber.core.common.Const.*; import java.io.File; +import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Path; import java.nio.file.Paths; +import java.util.Comparator; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.envvar.IEnvironmentVariableManager; @@ -18,7 +22,6 @@ import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; import org.eclipse.ui.statushandlers.StatusManager; @@ -28,7 +31,7 @@ public class Common { public final static String sloeberHome = getSloeberHome(); - public final static IPath sloeberHomePath = new Path(sloeberHome); + public final static IPath sloeberHomePath = new org.eclipse.core.runtime.Path(sloeberHome); public final static String sloeberHomePathToString = sloeberHomePath.toString(); private static String getSloeberHome() { @@ -239,7 +242,7 @@ public static String makePathEnvironmentString(IPath path) { } public static String makePathVersionString(File file) { - return new Path(file.getPath()).toString().replace(sloeberHomePathToString, SLOEBER_HOME_VAR); + return file.getPath().replace(sloeberHomePathToString, SLOEBER_HOME_VAR); } /** @@ -278,4 +281,21 @@ static public String getOldWayEnvVar(ICConfigurationDescription confDesc, String getBuildEnvironmentVariable(confDesc, envName.toUpperCase(), EMPTY, false), false); } + public static void deleteDirectory(org.eclipse.core.runtime.IPath directory) throws IOException { + deleteDirectory(Path.of(directory.toOSString())); + } + + public static void deleteDirectory(Path directory) throws IOException { + Files.walk(directory).sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete); + } + + /** + * this is some code to work around issue + * https://github.com/eclipse-cdt/cdt/issues/539 + * + */ + public static String getFileExtension(String fileName) { + int dotPosition = fileName.lastIndexOf('.'); + return (dotPosition == -1 || dotPosition == fileName.length() - 1) ? "" : fileName.substring(dotPosition + 1); //$NON-NLS-1$ + } } diff --git a/io.sloeber.core/src/io/sloeber/core/common/IndexHelper.java b/io.sloeber.core/src/io/sloeber/core/common/IndexHelper.java index 3d5f856b3..0deba6229 100644 --- a/io.sloeber.core/src/io/sloeber/core/common/IndexHelper.java +++ b/io.sloeber.core/src/io/sloeber/core/common/IndexHelper.java @@ -3,8 +3,9 @@ import java.io.File; import java.io.IOException; import java.nio.charset.Charset; +import java.nio.file.Files; +import java.nio.file.Path; -import org.apache.commons.io.FileUtils; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction; import org.eclipse.cdt.core.index.IIndex; @@ -35,7 +36,7 @@ private static String findParameterInFunction(IIndexName[] names, String functio String codeFileName = name.getFileLocation().getFileName(); String rawCodeFileContent; try { - rawCodeFileContent = FileUtils.readFileToString(new File(codeFileName), Charset.defaultCharset()); + rawCodeFileContent = Files.readString(Path.of(codeFileName), Charset.defaultCharset()); } catch (IOException e) { return defaultValue; } diff --git a/io.sloeber.core/src/io/sloeber/core/toolchain/ArduinoGnuMakefileGenerator.java b/io.sloeber.core/src/io/sloeber/core/toolchain/ArduinoGnuMakefileGenerator.java index 942d81d78..7a2b6591c 100644 --- a/io.sloeber.core/src/io/sloeber/core/toolchain/ArduinoGnuMakefileGenerator.java +++ b/io.sloeber.core/src/io/sloeber/core/toolchain/ArduinoGnuMakefileGenerator.java @@ -32,6 +32,8 @@ import java.io.InputStreamReader; import java.io.Reader; import java.nio.charset.Charset; +import java.nio.file.Files; +import java.nio.file.StandardOpenOption; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -46,7 +48,6 @@ import java.util.Set; import java.util.Vector; -import org.apache.commons.io.FileUtils; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.settings.model.CSourceEntry; @@ -923,7 +924,9 @@ public MultiStatus regenerateMakefiles() throws CoreException { awkContent += "\"}"; try { - FileUtils.write(sizeAwkFile, awkContent, Charset.defaultCharset()); + Files.write(sizeAwkFile.toPath(), awkContent.getBytes(), StandardOpenOption.TRUNCATE_EXISTING, + StandardOpenOption.CREATE); + } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); diff --git a/io.sloeber.core/src/io/sloeber/core/tools/FileModifiers.java b/io.sloeber.core/src/io/sloeber/core/tools/FileModifiers.java index f01d4369a..e71d1e0cc 100644 --- a/io.sloeber.core/src/io/sloeber/core/tools/FileModifiers.java +++ b/io.sloeber.core/src/io/sloeber/core/tools/FileModifiers.java @@ -5,11 +5,12 @@ import java.nio.charset.Charset; import java.nio.file.FileVisitResult; import java.nio.file.Files; +import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.SimpleFileVisitor; +import java.nio.file.StandardOpenOption; import java.nio.file.attribute.BasicFileAttributes; -import org.apache.commons.io.FileUtils; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; @@ -19,95 +20,99 @@ import io.sloeber.core.common.InstancePreferences; public class FileModifiers { - static final String PRAGMA_ONCE = System.lineSeparator() +"//Added by Sloeber \n#pragma once"+System.lineSeparator() ; //$NON-NLS-1$ + static final String PRAGMA_ONCE = System.lineSeparator() + "//Added by Sloeber \n#pragma once" //$NON-NLS-1$ + + System.lineSeparator(); - /** - * method to add at the top of a file copied from - * http://stackoverflow.com/questions/6127648/writing-in-the-beginning-of-a-text-file-java - * - * @param input - * @param addString - * @throws IOException - */ - public static void appendString(File input, String addString) throws IOException { - String fileString = FileUtils.readFileToString(input, Charset.defaultCharset()) +addString; - FileUtils.write(input, fileString, Charset.defaultCharset()); - } + /** + * method to add at the top of a file copied from + * http://stackoverflow.com/questions/6127648/writing-in-the-beginning-of-a-text-file-java + * + * @param input + * @param addString + * @throws IOException + */ + public static void appendString(File input, String addString) throws IOException { + Path pathFile = Path.of(input.toString()); + String fileString = Files.readString(pathFile, Charset.defaultCharset()) + addString; + Files.write(pathFile, fileString.getBytes(), StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.CREATE); + } - /** - * Add pragma once to all .h files from this path recursively if the option - * is set - */ - public static void addPragmaOnce(IPath startingDir) { - if (!InstancePreferences.getPragmaOnceHeaders()) { - return; - } - class Finder extends SimpleFileVisitor { + /** + * Add pragma once to all .h files from this path recursively if the option + * is set + */ + public static void addPragmaOnce(IPath startingDir) { + if (!InstancePreferences.getPragmaOnceHeaders()) { + return; + } + class Finder extends SimpleFileVisitor { - // Compares the glob pattern against - // the file or directory name. - void find(java.nio.file.Path file) { - java.nio.file.Path fileNamePath = file.getFileName(); - if (fileNamePath != null) { - String fileName=fileNamePath.toString(); - if (fileName.length() > 2) { - if (fileName.endsWith(".h")) { //$NON-NLS-1$ - try { - appendString(file.toFile(), PRAGMA_ONCE ); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - } - } + // Compares the glob pattern against + // the file or directory name. + void find(java.nio.file.Path file) { + java.nio.file.Path fileNamePath = file.getFileName(); + if (fileNamePath != null) { + String fileName = fileNamePath.toString(); + if (fileName.length() > 2) { + if (fileName.endsWith(".h")) { //$NON-NLS-1$ + try { + appendString(file.toFile(), PRAGMA_ONCE); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + } - // Invoke the pattern matching - // method on each file. - @Override - public FileVisitResult visitFile(java.nio.file.Path file, BasicFileAttributes attrs) { - find(file); - return FileVisitResult.CONTINUE; - } + // Invoke the pattern matching + // method on each file. + @Override + public FileVisitResult visitFile(java.nio.file.Path file, BasicFileAttributes attrs) { + find(file); + return FileVisitResult.CONTINUE; + } - // Invoke the pattern matching - // method on each directory. - @Override - public FileVisitResult preVisitDirectory(java.nio.file.Path dir, BasicFileAttributes attrs) { - find(dir); - return FileVisitResult.CONTINUE; - } + // Invoke the pattern matching + // method on each directory. + @Override + public FileVisitResult preVisitDirectory(java.nio.file.Path dir, BasicFileAttributes attrs) { + find(dir); + return FileVisitResult.CONTINUE; + } - @Override - public FileVisitResult visitFileFailed(java.nio.file.Path file, IOException exc) { - System.err.println(exc); - return FileVisitResult.CONTINUE; - } - } + @Override + public FileVisitResult visitFileFailed(java.nio.file.Path file, IOException exc) { + System.err.println(exc); + return FileVisitResult.CONTINUE; + } + } - Finder finder = new Finder(); - try { + Finder finder = new Finder(); + try { Files.walkFileTree(Paths.get(startingDir.toString()), finder); - } catch (IOException e) { - e.printStackTrace(); - } + } catch (IOException e) { + e.printStackTrace(); + } - } + } - public static void replaceInFile(File file, boolean regex, String find, String replace) { - try { - String textFromFile = FileUtils.readFileToString(file, Charset.defaultCharset()); + public static void replaceInFile(File file, boolean regex, String find, String replace) { + try { + Path pathFile = Path.of(file.toString()); + String textFromFile = Files.readString(pathFile, Charset.defaultCharset()); - if (regex) { - textFromFile = textFromFile.replaceAll(find, replace); - } else { - textFromFile = textFromFile.replace(find, replace); - } - FileUtils.write(file, textFromFile, Charset.defaultCharset()); - } catch (IOException e) { - Common.log(new Status(IStatus.WARNING, Activator.getId(), - "Failed to replace "+find+" with "+replace+" in file "+file.toString(), e)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - } - } + if (regex) { + textFromFile = textFromFile.replaceAll(find, replace); + } else { + textFromFile = textFromFile.replace(find, replace); + } + Files.write(pathFile, textFromFile.getBytes(), StandardOpenOption.TRUNCATE_EXISTING, + StandardOpenOption.CREATE); + } catch (IOException e) { + Common.log(new Status(IStatus.WARNING, Activator.getId(), + "Failed to replace " + find + " with " + replace + " in file " + file.toString(), e)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + } + } } diff --git a/io.sloeber.core/src/io/sloeber/core/tools/Libraries.java b/io.sloeber.core/src/io/sloeber/core/tools/Libraries.java index ca93bae88..fa78bc2c4 100644 --- a/io.sloeber.core/src/io/sloeber/core/tools/Libraries.java +++ b/io.sloeber.core/src/io/sloeber/core/tools/Libraries.java @@ -5,6 +5,7 @@ import java.io.File; import java.io.FilenameFilter; +import java.util.Arrays; import java.util.HashMap; import java.util.LinkedList; import java.util.List; @@ -14,7 +15,6 @@ import java.util.TreeMap; import java.util.TreeSet; -import org.apache.commons.lang.ArrayUtils; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.index.IIndex; import org.eclipse.cdt.core.index.IIndexFile; @@ -69,9 +69,9 @@ private static Map findAllSubFolders(IPath ipath) { // if the folder contains any of the following it is considered a // library itself // src library.properties or examples - if (ArrayUtils.contains(children, "src") //$NON-NLS-1$ - || ArrayUtils.contains(children, "library.properties") //$NON-NLS-1$ - || ArrayUtils.contains(children, "examples")) { //$NON-NLS-1$ + if (Arrays.stream(children).anyMatch("src"::equals) + || Arrays.stream(children).anyMatch("library.properties"::equals) + || Arrays.stream(children).anyMatch("examples"::equals)) { ret.put(ipath.lastSegment(), ipath); return ret; } @@ -526,7 +526,8 @@ public boolean accept(File dir, String name) { return name.toLowerCase().endsWith(".h"); //$NON-NLS-1$ } }); - if (ArrayUtils.contains(allHeaderFiles, new File(curLibName + ".h"))) { //$NON-NLS-1$ + if (Arrays.stream(allHeaderFiles).anyMatch(new File(curLibName + ".h")::equals)) { //$NON-NLS-1$ + //if (ArrayUtils.contains(allHeaderFiles, new File(curLibName + ".h"))) { //$NON-NLS // We found a one to one match make sure others do not // overrule doubleHeaders.add(curLibName); diff --git a/io.sloeber.core/src/io/sloeber/core/tools/PackageManager.java b/io.sloeber.core/src/io/sloeber/core/tools/PackageManager.java index 2dea2d212..e21067662 100644 --- a/io.sloeber.core/src/io/sloeber/core/tools/PackageManager.java +++ b/io.sloeber.core/src/io/sloeber/core/tools/PackageManager.java @@ -1,6 +1,7 @@ package io.sloeber.core.tools; import static java.nio.file.StandardCopyOption.*; +import static io.sloeber.core.common.Common.*; import java.io.File; import java.io.FileInputStream; @@ -21,7 +22,6 @@ import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream; import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream; import org.apache.commons.io.FileUtils; -import org.apache.commons.lang.SystemUtils; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; @@ -311,7 +311,7 @@ private static void symlink(String from, File to) throws IOException, Interrupte @SuppressWarnings("nls") private static void link(File actualFile, File linkName) throws IOException, InterruptedException { String[] command = new String[] { "ln", actualFile.getAbsolutePath(), linkName.getAbsolutePath() }; - if (SystemUtils.IS_OS_WINDOWS) { + if (isWindows) { command = new String[] { "cmd", "/c", "mklink", "/H", linkName.getAbsolutePath(), actualFile.getAbsolutePath() }; } diff --git a/io.sloeber.core/src/io/sloeber/core/tools/PdePreprocessor.java b/io.sloeber.core/src/io/sloeber/core/tools/PdePreprocessor.java index 7bd7e8dd9..9a1e2e6f5 100644 --- a/io.sloeber.core/src/io/sloeber/core/tools/PdePreprocessor.java +++ b/io.sloeber.core/src/io/sloeber/core/tools/PdePreprocessor.java @@ -22,6 +22,7 @@ import java.io.ByteArrayInputStream; import java.io.IOException; import java.nio.charset.Charset; +import java.nio.file.Files; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; @@ -29,7 +30,6 @@ import java.util.HashMap; import java.util.List; -import org.apache.commons.io.FileUtils; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.ast.IASTDeclaration; import org.eclipse.cdt.core.dom.ast.IASTNode; @@ -214,8 +214,9 @@ private static void writeTheGeneratedFile(IProject iProject, String content) thr String newFileContent = "#ifdef " + DEFINE_IN_ECLIPSE + NEWLINE + content + NEWLINE + "#endif" + NEWLINE; String currentFileContent = null; try { - currentFileContent = FileUtils.readFileToString( - iProject.getFile(new Path(generatedFile)).getLocation().toFile(), Charset.defaultCharset()); + currentFileContent = Files.readString( + java.nio.file.Path.of(iProject.getFile(new Path(generatedFile)).getLocation().toOSString()), + Charset.defaultCharset()); } catch (IOException e) { // This happens when the generated file does not yet exist } diff --git a/io.sloeber.core/src/io/sloeber/core/txt/WorkAround.java b/io.sloeber.core/src/io/sloeber/core/txt/WorkAround.java index 8d05b3853..d5f28c1ae 100644 --- a/io.sloeber.core/src/io/sloeber/core/txt/WorkAround.java +++ b/io.sloeber.core/src/io/sloeber/core/txt/WorkAround.java @@ -1,10 +1,14 @@ package io.sloeber.core.txt; +import static io.sloeber.core.common.Common.*; + import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.nio.charset.Charset; +import java.nio.file.Files; +import java.nio.file.StandardOpenOption; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -13,8 +17,6 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.apache.commons.io.FileUtils; -import org.apache.commons.lang.SystemUtils; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Status; @@ -114,12 +116,13 @@ static File MakeBoardsSloeberTxt(File requestedFileToWorkAround) { // generate the workaround file try { - String boardsTXT = FileUtils.readFileToString(requestedFileToWorkAround, Charset.defaultCharset()); + String boardsTXT = Files.readString(requestedFileToWorkAround.toPath(), Charset.defaultCharset()); boardsTXT = boardsApplyWorkArounds(boardsTXT); boardsTXT = FIRST_SLOEBER_WORKAROUND_LINE + "\n" + boardsTXT; - FileUtils.write(boardsSloeberTXT, boardsTXT, Charset.defaultCharset()); + Files.write(boardsSloeberTXT.toPath(), boardsTXT.getBytes(), StandardOpenOption.TRUNCATE_EXISTING, + StandardOpenOption.CREATE); } catch (IOException e) { Common.log(new Status(IStatus.WARNING, Activator.getId(), "Failed to apply work arounds to " + requestedFileToWorkAround.toString(), e)); @@ -199,12 +202,13 @@ static File MakePlatformSloeberTXT(File requestedFileToWorkAround) { // generate the workaround file try { - String platformTXT = FileUtils.readFileToString(requestedFileToWorkAround, Charset.defaultCharset()); + String platformTXT = Files.readString(requestedFileToWorkAround.toPath(), Charset.defaultCharset()); platformTXT = platformApplyWorkArounds(platformTXT, requestedFileToWorkAround); platformTXT = FIRST_SLOEBER_WORKAROUND_LINE + "\n" + platformTXT; - FileUtils.write(platformSloeberTXT, platformTXT, Charset.defaultCharset()); + Files.write(platformSloeberTXT.toPath(), platformTXT.getBytes(), StandardOpenOption.TRUNCATE_EXISTING, + StandardOpenOption.CREATE); } catch (IOException e) { Common.log(new Status(IStatus.WARNING, Activator.getId(), "Failed to apply work arounds to " + requestedFileToWorkAround.toString(), e)); @@ -512,15 +516,15 @@ private static String solveOSStuff(String inpuText) { String thisOSKey = null; // do not use platform as I run this in plain junit tests - if (SystemUtils.IS_OS_WINDOWS) { + if (isWindows) { thisOSKey = WINDOWSKEY; Otherosses.add(LINUXKEY); Otherosses.add(MACKEY); - } else if (SystemUtils.IS_OS_LINUX) { + } else if (isLinux) { thisOSKey = LINUXKEY; Otherosses.add(WINDOWSKEY); Otherosses.add(MACKEY); - } else if (SystemUtils.IS_OS_MAC_OSX) { + } else if (isMac) { thisOSKey = MACKEY; Otherosses.add(WINDOWSKEY); Otherosses.add(LINUXKEY); @@ -596,11 +600,12 @@ public static File MakeProgrammersSloeberTXT(File requestedFileToWorkAround) { // generate the workaround file try { - String programmersTXT = FileUtils.readFileToString(requestedFileToWorkAround, Charset.defaultCharset()); + String programmersTXT = Files.readString(requestedFileToWorkAround.toPath(), Charset.defaultCharset()); programmersTXT = programmersApplyWorkArounds(programmersTXT); programmersTXT = FIRST_SLOEBER_WORKAROUND_LINE + "\n" + programmersTXT; - FileUtils.write(actualProgrammersTXT, programmersTXT, Charset.defaultCharset()); + Files.write(actualProgrammersTXT.toPath(), programmersTXT.getBytes(), StandardOpenOption.TRUNCATE_EXISTING, + StandardOpenOption.CREATE); } catch (IOException e) { Common.log(new Status(IStatus.WARNING, Activator.getId(), "Failed to apply work arounds to " + requestedFileToWorkAround.toString(), e)); @@ -630,11 +635,11 @@ private static void deleteIfOutdated(File actualProgrammersTXT) { // delete if outdated String firstLine = null; try (BufferedReader Buff = new BufferedReader(new FileReader(actualProgrammersTXT));) { - firstLine = Buff.readLine(); + firstLine = Buff.readLine().trim(); } catch (Exception e) { // ignore and delete the file } - if (!FIRST_SLOEBER_WORKAROUND_LINE.trim().equals(firstLine.trim())) { + if (!FIRST_SLOEBER_WORKAROUND_LINE.trim().equals(firstLine)) { actualProgrammersTXT.delete(); } } diff --git a/io.sloeber.parent/pom.xml b/io.sloeber.parent/pom.xml index 16b322a83..d289dd3de 100644 --- a/io.sloeber.parent/pom.xml +++ b/io.sloeber.parent/pom.xml @@ -377,7 +377,7 @@ nebula p2 - https://download.eclipse.org/nebula/releases/2.7.2/ + https://download.eclipse.org/nebula/releases/latest/ @@ -386,11 +386,6 @@ https://download.eclipse.org/justj/jres/17/updates/release/latest/ - - gnumcu - p2 - http://gnu-mcu-eclipse.netlify.com/v4-neon-updates/ - diff --git a/io.sloeber.product/sloeber.target b/io.sloeber.product/sloeber.target index c22066aa7..eae14e186 100644 --- a/io.sloeber.product/sloeber.target +++ b/io.sloeber.product/sloeber.target @@ -3,37 +3,54 @@ - - - - - - - - + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + com.google.code.gson + gson + 2.10.1 + jar + + + org.apache.commons + commons-compress + 1.23.0 + jar + + + commons-io + commons-io + 2.13.0 + jar + + @@ -41,139 +58,5 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + \ No newline at end of file diff --git a/io.sloeber.tests/.classpath b/io.sloeber.tests/.classpath index a262c2276..29a6cc206 100644 --- a/io.sloeber.tests/.classpath +++ b/io.sloeber.tests/.classpath @@ -1,15 +1,21 @@ - + - + - + + - + + + + + + + - diff --git a/io.sloeber.tests/.gitignore b/io.sloeber.tests/.gitignore index a3b472d48..6c1b445a5 100644 --- a/io.sloeber.tests/.gitignore +++ b/io.sloeber.tests/.gitignore @@ -1,3 +1,4 @@ /bin/ /target/ -.* \ No newline at end of file +.settings/* +.externalToolBuilders diff --git a/io.sloeber.tests/.settings/org.eclipse.jdt.core.prefs b/io.sloeber.tests/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 11265a345..000000000 --- a/io.sloeber.tests/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,10 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 -org.eclipse.jdt.core.compiler.compliance=11 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning -org.eclipse.jdt.core.compiler.release=enabled -org.eclipse.jdt.core.compiler.source=11 diff --git a/io.sloeber.tests/META-INF/MANIFEST.MF b/io.sloeber.tests/META-INF/MANIFEST.MF index ce22d97f1..3be4718d8 100644 --- a/io.sloeber.tests/META-INF/MANIFEST.MF +++ b/io.sloeber.tests/META-INF/MANIFEST.MF @@ -3,21 +3,20 @@ Bundle-ManifestVersion: 2 Bundle-Name: Sloeber Tests Bundle-SymbolicName: io.sloeber.tests Bundle-Version: 4.4.1.qualifier -Bundle-RequiredExecutionEnvironment: JavaSE-11 +Bundle-RequiredExecutionEnvironment: JavaSE-17 Bundle-Vendor: Sloeber.io Require-Bundle: io.sloeber.core, org.eclipse.cdt.core, org.eclipse.core.runtime, org.eclipse.core.resources, org.junit, - org.apache.commons.lang, io.sloeber.ui, org.eclipse.swt, - org.eclipse.cdt.managedbuilder.core;bundle-version="9.0.0" + org.eclipse.cdt.managedbuilder.core Bundle-ActivationPolicy: lazy Import-Package: io.sloeber.ui, io.sloeber.ui.monitor, - org.apache.commons.io;version="2.6.0" + org.apache.commons.io Automatic-Module-Name: io.sloeber.tests Export-Package: io.sloeber.core;x-internal:=true, io.sloeber.junit;x-internal:=true, diff --git a/io.sloeber.tests/src/io/sloeber/core/CreateAndCompileDefaultInoOnAllBoardsTest.java b/io.sloeber.tests/src/io/sloeber/core/CreateAndCompileDefaultInoOnAllBoardsTest.java index 836839a28..98ff55502 100644 --- a/io.sloeber.tests/src/io/sloeber/core/CreateAndCompileDefaultInoOnAllBoardsTest.java +++ b/io.sloeber.tests/src/io/sloeber/core/CreateAndCompileDefaultInoOnAllBoardsTest.java @@ -1,6 +1,7 @@ package io.sloeber.core; import static org.junit.Assert.*; +import static io.sloeber.core.common.Common.*; import java.io.File; import java.util.ArrayList; @@ -9,7 +10,6 @@ import java.util.HashSet; import java.util.List; -import org.apache.commons.lang.SystemUtils; import org.eclipse.core.runtime.IPath; import org.junit.Assume; import org.junit.Test; @@ -278,10 +278,10 @@ public static Collection boards() { HashSet boardsToIgnoreList = new HashSet<>(Arrays.asList(boardsToIgnoreOnAllOses)); - if (SystemUtils.IS_OS_LINUX) { + if (isLinux) { boardsToIgnoreList.addAll(Arrays.asList(boardsToIgnoreOnLinux)); } - if (SystemUtils.IS_OS_WINDOWS) { + if (isWindows) { boardsToIgnoreList.addAll(Arrays.asList(boardsToIgnoreOnWindows)); } List ignoreBoards = new ArrayList<>(); @@ -312,13 +312,13 @@ public static void installAdditionalBoards() { HashSet toAddList = new HashSet<>(Arrays.asList(packageUrlsFromThirthPartyWebPage)); toAddList.addAll(Arrays.asList(BoardsManager.getJsonURLList())); toAddList.removeAll(Arrays.asList(packageUrlsToIgnoreonAllOSes)); - if (SystemUtils.IS_OS_WINDOWS) { + if (isWindows) { toAddList.removeAll(Arrays.asList(packageUrlsToIgnoreonWindows)); } - if (SystemUtils.IS_OS_LINUX) { + if (isLinux) { toAddList.removeAll(Arrays.asList(packageUrlsToIgnoreOnLinux)); } - if (SystemUtils.IS_OS_MAC) { + if (isMac) { toAddList.removeAll(Arrays.asList(packageUrlsToIgnoreOnMac)); } BoardsManager.setPackageURLs(toAddList, true); diff --git a/io.sloeber.tests/src/io/sloeber/core/Shared.java b/io.sloeber.tests/src/io/sloeber/core/Shared.java index 9f7474623..b54adb8d4 100644 --- a/io.sloeber.tests/src/io/sloeber/core/Shared.java +++ b/io.sloeber.tests/src/io/sloeber/core/Shared.java @@ -10,10 +10,11 @@ import java.net.URL; import java.nio.file.Files; import java.nio.file.Paths; +import java.util.HashMap; +import java.util.Map; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; -import org.apache.commons.lang.SystemUtils; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.model.ICModelMarker; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; @@ -36,6 +37,7 @@ import io.sloeber.core.api.BoardDescription; import io.sloeber.core.api.CodeDescription; +import io.sloeber.core.common.Common; import io.sloeber.core.api.CompileDescription; import io.sloeber.core.api.BoardsManager; import io.sloeber.core.api.SloeberProject; @@ -75,15 +77,16 @@ public static boolean hasBuildErrors(IProject project) throws CoreException { ICConfigurationDescription activeConfig = prjCDesc.getActiveConfiguration(); IFolder buildFolder = project.getFolder(activeConfig.getName()); - String projName=project.getName() ; - String[] validOutputss= {projName+".elf",projName+".bin",projName+".hex",projName+".exe","application.axf"}; - for(String validOutput:validOutputss) { - IFile validFile = buildFolder.getFile( validOutput); + String projName = project.getName(); + String[] validOutputss = { projName + ".elf", projName + ".bin", projName + ".hex", projName + ".exe", + "application.axf" }; + for (String validOutput : validOutputss) { + IFile validFile = buildFolder.getFile(validOutput); if (validFile.exists()) { return false; } } - + return true; } @@ -104,11 +107,11 @@ public static void waitForAllJobsToFinish() { } public static IPath getTemplateFolder(String templateName) throws Exception { - Bundle bundle = Platform.getBundle("io.sloeber.tests"); - Path path = new Path("src/templates/" + templateName); - URL fileURL = FileLocator.find(bundle, path, null); - URL resolvedFileURL = FileLocator.toFileURL(fileURL); - return new Path(resolvedFileURL.toURI().getPath()); + Bundle bundle = Platform.getBundle("io.sloeber.tests"); + Path path = new Path("src/templates/" + templateName); + URL fileURL = FileLocator.find(bundle, path, null); + URL resolvedFileURL = FileLocator.toFileURL(fileURL); + return new Path(resolvedFileURL.toURI().getPath()); } public static IPath getprojectZip(String zipFileName) throws Exception { @@ -174,8 +177,8 @@ public static boolean BuildAndVerify(String projectName, BoardDescription boardD try { compileOptions.setEnableParallelBuild(true); - theTestProject = SloeberProject.createArduinoProject(projectName, null, boardDescriptor, - codeDescriptor, compileOptions, monitor); + theTestProject = SloeberProject.createArduinoProject(projectName, null, boardDescriptor, codeDescriptor, + compileOptions, monitor); waitForAllJobsToFinish(); // for the indexer } catch (Exception e) { e.printStackTrace(); @@ -231,7 +234,7 @@ public static void applyKnownWorkArounds() { * move the file * */ - if (SystemUtils.IS_OS_LINUX) { + if (Common.isLinux) { java.nio.file.Path esptool2root = packageRoot.resolve("digistump").resolve("tools").resolve("esptool2") .resolve("0.9.1"); java.nio.file.Path esptool2wrong = esptool2root.resolve("0.9.1").resolve("esptool2"); @@ -248,7 +251,7 @@ public static void applyKnownWorkArounds() { * Elector heeft core Platino maar de directory noemt platino. In windows geen * probleem maar in case sensitive linux dus wel */ - if (SystemUtils.IS_OS_LINUX) { + if (Common.isLinux) { java.nio.file.Path cores = packageRoot.resolve("Elektor").resolve("hardware").resolve("avr") .resolve("1.0.0").resolve("cores"); java.nio.file.Path coreWrong = cores.resolve("platino"); @@ -340,4 +343,33 @@ private static void extractFile(ZipInputStream zipIn, String filePath) throws IO // } // end copy from // https://www.codejava.net/java-se/file-io/programmatically-extract-a-zip-file-using-java + + //copied from https://stackoverflow.com/questions/18344721/extract-the-difference-between-two-strings-in-java + /** + * Returns an array of size 2. The entries contain a minimal set of characters + * that have to be removed from the corresponding input strings in order to + * make the strings equal. + */ + public static String[] difference(String a, String b) { + return diffHelper(a, b, new HashMap<>()); + } + + @SuppressWarnings("boxing") + private static String[] diffHelper(String a, String b, Map lookup) { + return lookup.computeIfAbsent(((long) a.length()) << 32 | b.length(), k -> { + if (a.isEmpty() || b.isEmpty()) { + return new String[] { a, b }; + } else if (a.charAt(0) == b.charAt(0)) { + return diffHelper(a.substring(1), b.substring(1), lookup); + } else { + String[] aa = diffHelper(a.substring(1), b, lookup); + String[] bb = diffHelper(a, b.substring(1), lookup); + if (aa[0].length() + aa[1].length() < bb[0].length() + bb[1].length()) { + return new String[] { a.charAt(0) + aa[0], aa[1] }; + } + return new String[] { bb[0], b.charAt(0) + bb[1] }; + } + }); + } + //end of copied from https://stackoverflow.com/questions/18344721/extract-the-difference-between-two-strings-in-java } diff --git a/io.sloeber.tests/src/io/sloeber/junit/TxtWorkAroundRegression.java b/io.sloeber.tests/src/io/sloeber/junit/TxtWorkAroundRegression.java index e574d6e36..1fd885749 100644 --- a/io.sloeber.tests/src/io/sloeber/junit/TxtWorkAroundRegression.java +++ b/io.sloeber.tests/src/io/sloeber/junit/TxtWorkAroundRegression.java @@ -11,13 +11,14 @@ import java.util.LinkedList; import org.apache.commons.io.FileUtils; -import org.apache.commons.lang.StringUtils; import org.eclipse.core.runtime.Path; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; +import io.sloeber.core.Shared; + @SuppressWarnings({ "nls", "static-method" }) @RunWith(Parameterized.class) public class TxtWorkAroundRegression { @@ -87,11 +88,14 @@ public void boardsTxt() throws Exception { String actual = boardsApplyWorkArounds(input); String cleanedExpected = clean(expected); String cleanedActual = clean(actual); - String difference = StringUtils.difference(cleanedExpected, cleanedActual); + if (!cleanedExpected.equals(cleanedActual)) { System.err.println("ERROR for " + inputFile); - System.err.println(difference); - fail(difference.substring(0, 20)); + String[] difference = Shared.difference(cleanedExpected, cleanedActual); + for (String curDiff : difference) { + System.err.println(curDiff); + } + fail(difference[0]); } } @@ -119,11 +123,13 @@ public void platformTxt() throws Exception { String expected = FileUtils.readFileToString(expectedFile, Charset.defaultCharset()); String cleanedExpected = clean(expected); - String difference = StringUtils.difference(cleanedExpected, cleanedCurrentWorkAround); if (!cleanedExpected.equals(cleanedCurrentWorkAround)) { System.err.println("ERROR for " + inputFile); - System.err.println(difference); - fail(difference.substring(0, 20)); + String[] difference = Shared.difference(cleanedExpected, cleanedCurrentWorkAround); + for (String curDiff : difference) { + System.err.println(curDiff); + } + fail(difference[0]); } } @@ -147,11 +153,14 @@ public void programmerTxt() throws Exception { String actual = programmersApplyWorkArounds(input); String cleanedExpected = clean(expected); String cleanedActual = clean(actual); - String difference = StringUtils.difference(cleanedExpected, cleanedActual); + if (!cleanedExpected.equals(cleanedActual)) { System.err.println("ERROR for " + inputFile); - System.err.println(difference); - fail(difference.substring(0, 20)); + String[] difference = Shared.difference(cleanedExpected, cleanedActual); + for (String curDiff : difference) { + System.err.println(curDiff); + } + fail(difference[0]); } } diff --git a/io.sloeber.ui.nl1/META-INF/MANIFEST.MF b/io.sloeber.ui.nl1/META-INF/MANIFEST.MF index b8b21a8b6..b7f8d3dc4 100644 --- a/io.sloeber.ui.nl1/META-INF/MANIFEST.MF +++ b/io.sloeber.ui.nl1/META-INF/MANIFEST.MF @@ -4,5 +4,5 @@ Bundle-Name: Sloeber ui language pack Bundle-SymbolicName: io.sloeber.ui.nl1;singleton:=true Bundle-Version: 4.4.1.qualifier Fragment-Host: io.sloeber.ui;bundle-version="4.2.0" -Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Bundle-RequiredExecutionEnvironment: JavaSE-17 Bundle-Vendor: baeyens.it diff --git a/io.sloeber.ui/META-INF/MANIFEST.MF b/io.sloeber.ui/META-INF/MANIFEST.MF index a1ca80f9f..fa29e0e03 100644 --- a/io.sloeber.ui/META-INF/MANIFEST.MF +++ b/io.sloeber.ui/META-INF/MANIFEST.MF @@ -13,10 +13,9 @@ Require-Bundle: org.eclipse.ui, org.eclipse.ui.forms, org.eclipse.ui.ide, org.eclipse.debug.ui -Bundle-RequiredExecutionEnvironment: JavaSE-11 +Bundle-RequiredExecutionEnvironment: JavaSE-17 Bundle-ActivationPolicy: lazy -Import-Package: org.apache.commons.io;version="2.2.0", - org.apache.commons.lang +Import-Package: org.apache.commons.io Bundle-Vendor: Sloeber.io Export-Package: io.sloeber.ui;x-internal:=true, io.sloeber.ui.actions;x-internal:=true, diff --git a/io.sloeber.ui/src/io/sloeber/ui/core/launchconfig/MainTab.java b/io.sloeber.ui/src/io/sloeber/ui/core/launchconfig/MainTab.java index 213cfe914..b2d4e7602 100644 --- a/io.sloeber.ui/src/io/sloeber/ui/core/launchconfig/MainTab.java +++ b/io.sloeber.ui/src/io/sloeber/ui/core/launchconfig/MainTab.java @@ -3,7 +3,6 @@ import java.util.ArrayList; import java.util.List; -import org.apache.commons.lang.StringUtils; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; @@ -144,7 +143,7 @@ private boolean checkConsistency() { */ private String checkErrors() { // Project is specified - if (StringUtils.isBlank(this.project.getText())) { + if (this.project.getText().isBlank()) { return Messages.launch_config_mainTab_specify_project; } From 9078f4cab9953d9f0b7af502cb5a018ea69777b5 Mon Sep 17 00:00:00 2001 From: jantje Date: Sat, 25 Nov 2023 05:09:56 +0100 Subject: [PATCH 2/4] updated the readme that the SDK needs additional setup work --- readme.md | 318 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 166 insertions(+), 152 deletions(-) diff --git a/readme.md b/readme.md index b2229d946..cce8a084f 100644 --- a/readme.md +++ b/readme.md @@ -1,152 +1,166 @@ -# Sloeber, the Arduino IDE for Eclipse - -The Eclipse IDE (Integrated Developement Environment) is a full featured programming editor with many fantastic features to help you code more quickly and easily. The Arduino IDE is great for what it does – but it doesn't do much to help writing, navigating and understanding your (and other people's) code. - -The Sloeber IDE bridges that gap and helps move you to a more powerful development environment whilst keeping the Arduino hardware and libraries that you love (and make life simple). - - Software Logic to program Open Electronic Boards in an Eclipse Runtime (SLOEBER) - -It works on MS Windows, Mac OSX and Linux. - -# Downloads -If you are not a developer and don't want to build from sources, then there are precompiled product packages and update sites available. You can find them here on github as releases. See the details at http://baeyens.it/. - -# Build from source -Below are instructions on how to download and compile the source code from the command line and from eclipse. -You only need to do one. - - -## Prerequisites -Please install [git](http://git-scm.com/downloads) and [maven](http://maven.apache.org/download.cgi). - -Java 17 is required. - -A 64-bit OS is required. - - -## Build from the command line from source for your os and the default eclipse instance -```bash -git clone https://github.com/Sloeber/arduino-eclipse-plugin sloeber -cd sloeber -mvn clean verify -DskipTests=true -``` - -## Running the Sloeber you just build - -Windows - - * win32x64.cmd (if you are on 64 bits windows) - -Mac OSX and Linux - - * ./build_then_launch_plugin.sh - - -## Build Options - -You can control the maven build with the following profiles: - -* latest (default, builds against the latest versions) -* SDK (builds a Sloeber you can program Sloeber in. With Java.) -* win64 -* linux64 -* mac64 -* macm1 - -### Examples - -* Build the latest version for the platform you are running on: - - `mvn clean verify -PNOSDK -DskipTests=true` - -* Build Eclipse + Sloeber for 64-bit Windows: - `mvn clean verify -Pwin64,latest,NOSDK -DskipTests=true` - -* Build Eclipse + Sloeber for 64-bit Linux: - `mvn clean verify -Plinux64,latest,NOSDK -DskipTests=true` - -* Build the Sloeber SDK for 64-bit Windows (for Sloeber programmers): - `mvn clean verify -PSDK,win64,latest -DskipTests=true` - -# Importing your build into another Eclipse -If you want to import the latest code based plugin to another Eclipse setup you have then it is possible to setup a local repository to install the plugin you have just built. Just add a local repository with location ```arduino-eclipse-plugin/io.sloeber.product/target/repository``` - -![alt text](images_plugin_dev_setup/add_local_repository.png "Adding a local repository") - -# Developing (Improving) the Plugin - * Fork the repository on GitHub (https://help.github.com/articles/fork-a-repo) for your changes. Note that your git link should look like this: https://github.com/YOUR_FORK/arduino-eclipse-plugin.git –– we will use it later. - * Checkout locally - * Run ```mvn clean verify -PSDK,latest -DskipTests=true``` to build - -After the build, find the Sloeber SDK product in the io.sloeber.product.sdk target directory. Unzip it somewhere in your home directory (mind you we cannot handle very long path names on windows) - - Note that Sloeber itself is NOT included in the Sloeber SDK. - - -## Install the projects into the SDK via the EGit interface. - -> File → Import → Git → Projects from Git → Existing local repository - -* Now add the repository you just cloned -* Press "Next". -* Next -* Select a wizard: Import Existing Projects -* Next -* Import Projects -* Select all the projects -* Finish - -After all it should look like this: - -![alt text](images_plugin_dev_setup/Imported_projects.png "Projects imported") - -## Set the Warning Level - -We want to keep the chance of missing a problem in the code to a minimum and to keep clean and tidy code. Development is -aiming to keep compiler warnings to a minimum (items that show up in the Problems tab under Warnings) with specific settings. -Please change your settings from default as follows: - -Go to - -> Window → Preferences → Java → Compiler → Errors/Warnings - -and change the following from their defaults. - -My current settings are as follows: - -![alt text](images_plugin_dev_setup/Screenshot-Preferences1.png "screen capture") -![alt text](images_plugin_dev_setup/Screenshot-Preferences 2.png "screen capture") -![alt text](images_plugin_dev_setup/Screenshot-Preferences 3.png "screen capture") -![alt text](images_plugin_dev_setup/Screenshot-Preferences 4.png "screen capture") -![alt text](images_plugin_dev_setup/Screenshot-Preferences 5.png "screen capture") - - * Name shadowing and conflicts: Set all to Warning. - * Unnecessary code: Set all to Warning. - * Null analysis: Set all active (not greyed out) to Warning. - * Potential programming problems: Set all to Warning. - -### Running Sloeber with local changes (Testing your stuff) -Running is very simple - just right click io.sloeber.core and select: - -> Run as → Eclipse Application - -OR, if you'd like to debug, - -> Debug as → Eclipse Application - -Eclipse will launch a new workbench disabling the installed version if any, and updating it with the plugin version loaded in the current workspace. - -![](images_plugin_dev_setup/running_check_versions.png "screen capture") - -Now, just set up fresh again with your project settings, Preferences/Arduino, to point to IDE and private libs. - -> New Project → Arduino → New Arduino Sketch - -All should work. You can set breakpoints in the launching Eclipse if you ran as debug. Happy developing! - -[](http://with-eclipse.github.io/) - -# FAQ -## There are lots of issues in the release that seem fixed. -We close issues when they have been validated as part of the nightly. Therefore the open list no longer contains items fixed in the nightly. Known issue fixed in the last nightly can be found with this query: -is:issue is:closed -label:"status: fixed in nightly" +# Sloeber, the Arduino IDE for Eclipse + +The Eclipse IDE (Integrated Developement Environment) is a full featured programming editor with many fantastic features to help you code more quickly and easily. The Arduino IDE is great for what it does – but it doesn't do much to help writing, navigating and understanding your (and other people's) code. + +The Sloeber IDE bridges that gap and helps move you to a more powerful development environment whilst keeping the Arduino hardware and libraries that you love (and make life simple). + + Software Logic to program Open Electronic Boards in an Eclipse Runtime (SLOEBER) + +It works on MS Windows, Mac OSX and Linux. + +# Downloads +If you are not a developer and don't want to build from sources, then there are precompiled product packages and update sites available. You can find them here on github as releases. See the details at http://baeyens.it/. + +# Build from source +Below are instructions on how to download and compile the source code from the command line and from eclipse. +You only need to do one. + + +## Prerequisites +Please install [git](http://git-scm.com/downloads) and [maven](http://maven.apache.org/download.cgi). + +Java 17 is required. + +A 64-bit OS is required. + + +## Build from the command line from source for your os and the default eclipse instance +```bash +git clone https://github.com/Sloeber/arduino-eclipse-plugin sloeber +cd sloeber +mvn clean verify -DskipTests=true +``` + +## Running the Sloeber you just build + +Windows + + * win32x64.cmd (if you are on 64 bits windows) + +Mac OSX and Linux + + * ./build_then_launch_plugin.sh + + +## Build Options + +You can control the maven build with the following profiles: + +* latest (default, builds against the latest versions) +* SDK (builds a Sloeber you can program Sloeber in. With Java.) +* win64 +* linux64 +* mac64 +* macm1 + +### Examples + +* Build the latest version for the platform you are running on: + + `mvn clean verify -PNOSDK -DskipTests=true` + +* Build Eclipse + Sloeber for 64-bit Windows: + `mvn clean verify -Pwin64,latest,NOSDK -DskipTests=true` + +* Build Eclipse + Sloeber for 64-bit Linux: + `mvn clean verify -Plinux64,latest,NOSDK -DskipTests=true` + +* Build the Sloeber SDK for 64-bit Windows (for Sloeber programmers): + `mvn clean verify -PSDK,win64,latest -DskipTests=true` + +# Importing your build into another Eclipse +If you want to import the latest code based plugin to another Eclipse setup you have then it is possible to setup a local repository to install the plugin you have just built. Just add a local repository with location ```arduino-eclipse-plugin/io.sloeber.product/target/repository``` + +![alt text](images_plugin_dev_setup/add_local_repository.png "Adding a local repository") + +# Developing (Improving) the Plugin + * Fork the repository on GitHub (https://help.github.com/articles/fork-a-repo) for your changes. Note that your git link should look like this: https://github.com/YOUR_FORK/arduino-eclipse-plugin.git –– we will use it later. + * Checkout locally + * Run ```mvn clean verify -PSDK,latest -DskipTests=true``` to build + +After the build, find the Sloeber SDK product in the io.sloeber.product.sdk target directory. Unzip it somewhere in your home directory (mind you we cannot handle very long path names on windows) + + Note that Sloeber itself is NOT included in the Sloeber SDK. + +## Install the maven PDE integration in your eclipse install. +In the menu select help->install new software +in the field work with enter: http://download.eclipse.org/releases/latest +in the field below enter m2e +select m2e - pde integration +select next and finish the install + + + +## Install the projects into the SDK via the EGit interface. + + +> File → Import → Git → Projects from Git → Existing local repository + +* Now add the repository you just cloned +* Press "Next". +* Next +* Select a wizard: Import Existing Projects +* Next +* Import Projects +* Select all the projects +* Finish + +After all it should look like this: + +![alt text](images_plugin_dev_setup/Imported_projects.png "Projects imported") + +## set the target platform +in the menu select windows->preferences +select plugindevelopment->target platform +select Sloeber as target platform + +## Set the Warning Level + +We want to keep the chance of missing a problem in the code to a minimum and to keep clean and tidy code. Development is +aiming to keep compiler warnings to a minimum (items that show up in the Problems tab under Warnings) with specific settings. +Please change your settings from default as follows: + +Go to + +> Window → Preferences → Java → Compiler → Errors/Warnings + +and change the following from their defaults. + +My current settings are as follows: + +![alt text](images_plugin_dev_setup/Screenshot-Preferences1.png "screen capture") +![alt text](images_plugin_dev_setup/Screenshot-Preferences 2.png "screen capture") +![alt text](images_plugin_dev_setup/Screenshot-Preferences 3.png "screen capture") +![alt text](images_plugin_dev_setup/Screenshot-Preferences 4.png "screen capture") +![alt text](images_plugin_dev_setup/Screenshot-Preferences 5.png "screen capture") + + * Name shadowing and conflicts: Set all to Warning. + * Unnecessary code: Set all to Warning. + * Null analysis: Set all active (not greyed out) to Warning. + * Potential programming problems: Set all to Warning. + +### Running Sloeber with local changes (Testing your stuff) +Running is very simple - just right click io.sloeber.core and select: + +> Run as → Eclipse Application + +OR, if you'd like to debug, + +> Debug as → Eclipse Application + +Eclipse will launch a new workbench disabling the installed version if any, and updating it with the plugin version loaded in the current workspace. + +![](images_plugin_dev_setup/running_check_versions.png "screen capture") + +Now, just set up fresh again with your project settings, Preferences/Arduino, to point to IDE and private libs. + +> New Project → Arduino → New Arduino Sketch + +All should work. You can set breakpoints in the launching Eclipse if you ran as debug. Happy developing! + +[](http://with-eclipse.github.io/) + +# FAQ +## There are lots of issues in the release that seem fixed. +We close issues when they have been validated as part of the nightly. Therefore the open list no longer contains items fixed in the nightly. Known issue fixed in the last nightly can be found with this query: +is:issue is:closed -label:"status: fixed in nightly" From 56e9862b18816d3b735cb7004ad7e69b029d88d9 Mon Sep 17 00:00:00 2001 From: jantje Date: Sun, 26 Nov 2023 15:50:51 +0100 Subject: [PATCH 3/4] checking in missing files --- .gitignore | 1 - .../org.eclipse.core.resources.prefs | 2 ++ .../org.eclipse.core.resources.prefs | 2 ++ .../.settings/org.eclipse.core.runtime.prefs | 2 ++ .../org.eclipse.core.resources.prefs | 2 ++ .../.settings/org.eclipse.core.runtime.prefs | 2 ++ .../org.eclipse.core.resources.prefs | 2 ++ .../.settings/org.eclipse.core.runtime.prefs | 2 ++ .../org.eclipse.core.resources.prefs | 2 ++ io.sloeber.core/.classpath | 1 + io.sloeber.core/.gitignore | 3 +-- .../org.eclipse.core.resources.prefs | 1 + .../.settings/org.eclipse.jdt.core.prefs | 21 +++++++++++++++++++ .../.settings/org.eclipse.jdt.ui.prefs | 1 + .../org.eclipse.core.resources.prefs | 3 +++ .../org.eclipse.core.resources.prefs | 2 ++ io.sloeber.product.sdk/.gitignore | 1 + .../org.eclipse.core.resources.prefs | 2 ++ .../org.eclipse.core.resources.prefs | 2 ++ io.sloeber.tests/.gitignore | 1 - .../.settings/org.eclipse.jdt.core.prefs | 10 +++++++++ .../org.eclipse.core.resources.prefs | 2 ++ io.sloeber.ui/.gitignore | 1 + .../org.eclipse.core.resources.prefs | 2 ++ .../org.eclipse.core.resources.prefs | 2 ++ .../org.eclipse.core.resources.prefs | 2 ++ 26 files changed, 70 insertions(+), 4 deletions(-) create mode 100644 images_plugin_dev_setup/.settings/org.eclipse.core.resources.prefs create mode 100644 io.sloeber.ManagedBuild.ui/.settings/org.eclipse.core.resources.prefs create mode 100644 io.sloeber.ManagedBuild.ui/.settings/org.eclipse.core.runtime.prefs create mode 100644 io.sloeber.ManagedBuild/.settings/org.eclipse.core.resources.prefs create mode 100644 io.sloeber.ManagedBuild/.settings/org.eclipse.core.runtime.prefs create mode 100644 io.sloeber.autoBuild.test/.settings/org.eclipse.core.resources.prefs create mode 100644 io.sloeber.autoBuild.test/.settings/org.eclipse.core.runtime.prefs create mode 100644 io.sloeber.core.nl1/.settings/org.eclipse.core.resources.prefs create mode 100644 io.sloeber.core/.settings/org.eclipse.jdt.core.prefs create mode 100644 io.sloeber.feature/.settings/org.eclipse.core.resources.prefs create mode 100644 io.sloeber.parent/.settings/org.eclipse.core.resources.prefs create mode 100644 io.sloeber.product.sdk/.settings/org.eclipse.core.resources.prefs create mode 100644 io.sloeber.product/.settings/org.eclipse.core.resources.prefs create mode 100644 io.sloeber.tests/.settings/org.eclipse.jdt.core.prefs create mode 100644 io.sloeber.ui.nl1/.settings/org.eclipse.core.resources.prefs create mode 100644 io.sloeber.ui/.settings/org.eclipse.core.resources.prefs create mode 100644 io.sloeber.updatesite/.settings/org.eclipse.core.resources.prefs create mode 100644 website/.settings/org.eclipse.core.resources.prefs diff --git a/.gitignore b/.gitignore index ef5eedafb..8deb956af 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,3 @@ /log.txt workspace/* /.metadata/ -.settings diff --git a/images_plugin_dev_setup/.settings/org.eclipse.core.resources.prefs b/images_plugin_dev_setup/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 000000000..4824b8026 --- /dev/null +++ b/images_plugin_dev_setup/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/io.sloeber.ManagedBuild.ui/.settings/org.eclipse.core.resources.prefs b/io.sloeber.ManagedBuild.ui/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 000000000..99f26c020 --- /dev/null +++ b/io.sloeber.ManagedBuild.ui/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/io.sloeber.ManagedBuild.ui/.settings/org.eclipse.core.runtime.prefs b/io.sloeber.ManagedBuild.ui/.settings/org.eclipse.core.runtime.prefs new file mode 100644 index 000000000..5a0ad22d2 --- /dev/null +++ b/io.sloeber.ManagedBuild.ui/.settings/org.eclipse.core.runtime.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +line.separator=\n diff --git a/io.sloeber.ManagedBuild/.settings/org.eclipse.core.resources.prefs b/io.sloeber.ManagedBuild/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 000000000..68a030452 --- /dev/null +++ b/io.sloeber.ManagedBuild/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=windows-1252 diff --git a/io.sloeber.ManagedBuild/.settings/org.eclipse.core.runtime.prefs b/io.sloeber.ManagedBuild/.settings/org.eclipse.core.runtime.prefs new file mode 100644 index 000000000..5a0ad22d2 --- /dev/null +++ b/io.sloeber.ManagedBuild/.settings/org.eclipse.core.runtime.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +line.separator=\n diff --git a/io.sloeber.autoBuild.test/.settings/org.eclipse.core.resources.prefs b/io.sloeber.autoBuild.test/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 000000000..99f26c020 --- /dev/null +++ b/io.sloeber.autoBuild.test/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/io.sloeber.autoBuild.test/.settings/org.eclipse.core.runtime.prefs b/io.sloeber.autoBuild.test/.settings/org.eclipse.core.runtime.prefs new file mode 100644 index 000000000..5a0ad22d2 --- /dev/null +++ b/io.sloeber.autoBuild.test/.settings/org.eclipse.core.runtime.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +line.separator=\n diff --git a/io.sloeber.core.nl1/.settings/org.eclipse.core.resources.prefs b/io.sloeber.core.nl1/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 000000000..4824b8026 --- /dev/null +++ b/io.sloeber.core.nl1/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/io.sloeber.core/.classpath b/io.sloeber.core/.classpath index 50f33be30..a44f21792 100644 --- a/io.sloeber.core/.classpath +++ b/io.sloeber.core/.classpath @@ -22,3 +22,4 @@ + \ No newline at end of file diff --git a/io.sloeber.core/.gitignore b/io.sloeber.core/.gitignore index bfa4cce0d..92145bcea 100644 --- a/io.sloeber.core/.gitignore +++ b/io.sloeber.core/.gitignore @@ -1,3 +1,2 @@ /bin/ -/target/ -.settings/* \ No newline at end of file +/target/ \ No newline at end of file diff --git a/io.sloeber.core/.settings/org.eclipse.core.resources.prefs b/io.sloeber.core/.settings/org.eclipse.core.resources.prefs index 99f26c020..80626102b 100644 --- a/io.sloeber.core/.settings/org.eclipse.core.resources.prefs +++ b/io.sloeber.core/.settings/org.eclipse.core.resources.prefs @@ -1,2 +1,3 @@ eclipse.preferences.version=1 encoding/=UTF-8 + \ No newline at end of file diff --git a/io.sloeber.core/.settings/org.eclipse.jdt.core.prefs b/io.sloeber.core/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..4b3ea0eea --- /dev/null +++ b/io.sloeber.core/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,21 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.codeComplete.argumentPrefixes= +org.eclipse.jdt.core.codeComplete.argumentSuffixes= +org.eclipse.jdt.core.codeComplete.fieldPrefixes= +org.eclipse.jdt.core.codeComplete.fieldSuffixes= +org.eclipse.jdt.core.codeComplete.localPrefixes= +org.eclipse.jdt.core.codeComplete.localSuffixes= +org.eclipse.jdt.core.codeComplete.staticFieldPrefixes= +org.eclipse.jdt.core.codeComplete.staticFieldSuffixes= +org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes= +org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes= +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 + + diff --git a/io.sloeber.core/.settings/org.eclipse.jdt.ui.prefs b/io.sloeber.core/.settings/org.eclipse.jdt.ui.prefs index ed7f68a16..a768d8687 100644 --- a/io.sloeber.core/.settings/org.eclipse.jdt.ui.prefs +++ b/io.sloeber.core/.settings/org.eclipse.jdt.ui.prefs @@ -5,3 +5,4 @@ org.eclipse.jdt.ui.gettersetter.use.is=true org.eclipse.jdt.ui.keywordthis=false org.eclipse.jdt.ui.overrideannotation=true org.eclipse.jdt.ui.text.custom_code_templates= + \ No newline at end of file diff --git a/io.sloeber.feature/.settings/org.eclipse.core.resources.prefs b/io.sloeber.feature/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 000000000..8de78e024 --- /dev/null +++ b/io.sloeber.feature/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 + diff --git a/io.sloeber.parent/.settings/org.eclipse.core.resources.prefs b/io.sloeber.parent/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 000000000..2a13ebc98 --- /dev/null +++ b/io.sloeber.parent/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 \ No newline at end of file diff --git a/io.sloeber.product.sdk/.gitignore b/io.sloeber.product.sdk/.gitignore index ae3c17260..92145bcea 100644 --- a/io.sloeber.product.sdk/.gitignore +++ b/io.sloeber.product.sdk/.gitignore @@ -1 +1,2 @@ /bin/ +/target/ \ No newline at end of file diff --git a/io.sloeber.product.sdk/.settings/org.eclipse.core.resources.prefs b/io.sloeber.product.sdk/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 000000000..4824b8026 --- /dev/null +++ b/io.sloeber.product.sdk/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/io.sloeber.product/.settings/org.eclipse.core.resources.prefs b/io.sloeber.product/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 000000000..4824b8026 --- /dev/null +++ b/io.sloeber.product/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/io.sloeber.tests/.gitignore b/io.sloeber.tests/.gitignore index 6c1b445a5..b1ee9e9ac 100644 --- a/io.sloeber.tests/.gitignore +++ b/io.sloeber.tests/.gitignore @@ -1,4 +1,3 @@ /bin/ /target/ -.settings/* .externalToolBuilders diff --git a/io.sloeber.tests/.settings/org.eclipse.jdt.core.prefs b/io.sloeber.tests/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..f78f7f772 --- /dev/null +++ b/io.sloeber.tests/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,10 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/io.sloeber.ui.nl1/.settings/org.eclipse.core.resources.prefs b/io.sloeber.ui.nl1/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 000000000..4824b8026 --- /dev/null +++ b/io.sloeber.ui.nl1/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/io.sloeber.ui/.gitignore b/io.sloeber.ui/.gitignore index ae3c17260..92145bcea 100644 --- a/io.sloeber.ui/.gitignore +++ b/io.sloeber.ui/.gitignore @@ -1 +1,2 @@ /bin/ +/target/ \ No newline at end of file diff --git a/io.sloeber.ui/.settings/org.eclipse.core.resources.prefs b/io.sloeber.ui/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 000000000..4824b8026 --- /dev/null +++ b/io.sloeber.ui/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/io.sloeber.updatesite/.settings/org.eclipse.core.resources.prefs b/io.sloeber.updatesite/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 000000000..4824b8026 --- /dev/null +++ b/io.sloeber.updatesite/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/website/.settings/org.eclipse.core.resources.prefs b/website/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 000000000..4824b8026 --- /dev/null +++ b/website/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 From 17f556160346d199f44140d5cc6642d82a108ab1 Mon Sep 17 00:00:00 2001 From: jantje Date: Sun, 26 Nov 2023 21:24:27 +0100 Subject: [PATCH 4/4] fix unit tests #1593 --- io.sloeber.core/META-INF/MANIFEST.MF | 2 +- io.sloeber.product/sloeber.target | 6 ++-- .../src/io/sloeber/core/Shared.java | 33 +++++++++---------- .../src/io/sloeber/junit/AllJUnitTests.java | 10 +++++- 4 files changed, 28 insertions(+), 23 deletions(-) diff --git a/io.sloeber.core/META-INF/MANIFEST.MF b/io.sloeber.core/META-INF/MANIFEST.MF index a9204be91..24de054ff 100644 --- a/io.sloeber.core/META-INF/MANIFEST.MF +++ b/io.sloeber.core/META-INF/MANIFEST.MF @@ -21,7 +21,7 @@ Require-Bundle: org.eclipse.cdt.managedbuilder.core, org.eclipse.ui.console, org.eclipse.debug.core, org.eclipse.core.variables, - org.apache.commons.io, + org.apache.commons.commons-io, org.apache.commons.compress Export-Package: cc.arduino.packages;x-internal:=true, cc.arduino.packages.discoverers;x-internal:=true, diff --git a/io.sloeber.product/sloeber.target b/io.sloeber.product/sloeber.target index eae14e186..d82236d8b 100644 --- a/io.sloeber.product/sloeber.target +++ b/io.sloeber.product/sloeber.target @@ -30,7 +30,7 @@ - + com.google.code.gson @@ -41,13 +41,13 @@ org.apache.commons commons-compress - 1.23.0 + 1.25.0 jar commons-io commons-io - 2.13.0 + 2.15.0 jar diff --git a/io.sloeber.tests/src/io/sloeber/core/Shared.java b/io.sloeber.tests/src/io/sloeber/core/Shared.java index b54adb8d4..f03276b00 100644 --- a/io.sloeber.tests/src/io/sloeber/core/Shared.java +++ b/io.sloeber.tests/src/io/sloeber/core/Shared.java @@ -351,25 +351,22 @@ private static void extractFile(ZipInputStream zipIn, String filePath) throws IO * make the strings equal. */ public static String[] difference(String a, String b) { - return diffHelper(a, b, new HashMap<>()); - } - - @SuppressWarnings("boxing") - private static String[] diffHelper(String a, String b, Map lookup) { - return lookup.computeIfAbsent(((long) a.length()) << 32 | b.length(), k -> { - if (a.isEmpty() || b.isEmpty()) { - return new String[] { a, b }; - } else if (a.charAt(0) == b.charAt(0)) { - return diffHelper(a.substring(1), b.substring(1), lookup); + int startDiff = 1; + while (a.substring(0, startDiff).equals(b.substring(0, startDiff))) { + startDiff++; + } + int endDiff = startDiff + 20; + if (startDiff > 10) { + int nl = a.substring(0, startDiff).lastIndexOf('\n'); + if (nl != -1) { + startDiff = nl; } else { - String[] aa = diffHelper(a.substring(1), b, lookup); - String[] bb = diffHelper(a, b.substring(1), lookup); - if (aa[0].length() + aa[1].length() < bb[0].length() + bb[1].length()) { - return new String[] { a.charAt(0) + aa[0], aa[1] }; - } - return new String[] { bb[0], b.charAt(0) + bb[1] }; + startDiff = startDiff - 5; } - }); + } else { + startDiff = 0; + } + return new String[] { a.substring(startDiff, endDiff), b.substring(startDiff, endDiff) }; } - //end of copied from https://stackoverflow.com/questions/18344721/extract-the-difference-between-two-strings-in-java + } diff --git a/io.sloeber.tests/src/io/sloeber/junit/AllJUnitTests.java b/io.sloeber.tests/src/io/sloeber/junit/AllJUnitTests.java index 8f7f09196..375e1c73f 100644 --- a/io.sloeber.tests/src/io/sloeber/junit/AllJUnitTests.java +++ b/io.sloeber.tests/src/io/sloeber/junit/AllJUnitTests.java @@ -4,9 +4,17 @@ import org.junit.runners.Suite; import org.junit.runners.Suite.SuiteClasses; +/* + * these junit tests need to be run as a junit plugin + * + * + * TxtWorkAroundRegression.class is not included as it needs a special setup to run + * The special setup is a arduinoplugin folder with "old" sloeber.txt files so the differences can be spotted + */ + @RunWith(Suite.class) @SuiteClasses({ TestPlatformWorkAround.class, TestSerialPlotterFilter.class, TestTxtFile.class, TestWorkAround.class, - TxtWorkAroundRegression.class, TestVersionCompare.class }) + TestVersionCompare.class }) public class AllJUnitTests { //no need for code here }