Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the build #1593 #1594

Merged
merged 4 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@
/log.txt
workspace/*
/.metadata/
.settings
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
line.separator=\n
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=windows-1252
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
line.separator=\n
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
line.separator=\n
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8
2 changes: 1 addition & 1 deletion io.sloeber.core.nl1/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 17 additions & 6 deletions io.sloeber.core/.classpath
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<attributes>
<attribute name="module" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="lib" path="lib/jssc-2.9.4.jar"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="lib" path="lib/jsch-0.1.55.jar"/>
<classpathentry kind="lib" path="lib/jmdns-3.5.7.jar"/>
<classpathentry kind="src" output="bin" path="src">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="lib" path="lib/jsch-0.1.55.jar"/>
<classpathentry exported="true" kind="lib" path="lib/jssc-2.9.4.jar"/>
<classpathentry exported="true" kind="lib" path="lib/jmdns-3.5.7.jar"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="bin"/>
</classpath>

2 changes: 1 addition & 1 deletion io.sloeber.core/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
/bin/
/target/
/target/
1 change: 1 addition & 0 deletions io.sloeber.core/.settings/org.eclipse.core.resources.prefs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8

10 changes: 10 additions & 0 deletions io.sloeber.core/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,13 @@ 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


1 change: 1 addition & 0 deletions io.sloeber.core/.settings/org.eclipse.jdt.ui.prefs
Original file line number Diff line number Diff line change
Expand Up @@ -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=

13 changes: 6 additions & 7 deletions io.sloeber.core/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.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,
Expand Down
7 changes: 3 additions & 4 deletions io.sloeber.core/src/io/sloeber/core/Activator.java
Original file line number Diff line number Diff line change
@@ -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.*;

Expand All @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
5 changes: 3 additions & 2 deletions io.sloeber.core/src/io/sloeber/core/api/CodeDescription.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -205,6 +205,7 @@ Map<String, IPath> 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);
}
Expand Down Expand Up @@ -237,7 +238,7 @@ public ArrayList<IPath> 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());
Expand Down
6 changes: 3 additions & 3 deletions io.sloeber.core/src/io/sloeber/core/api/Defaults.java
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -32,15 +32,15 @@ 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();
}

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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
Expand Down
26 changes: 23 additions & 3 deletions io.sloeber.core/src/io/sloeber/core/common/Common.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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() {
Expand Down Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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$
}
}
5 changes: 3 additions & 2 deletions io.sloeber.core/src/io/sloeber/core/common/IndexHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
Loading
Loading