|
13 | 13 | import java.io.InputStream;
|
14 | 14 | import java.io.InputStreamReader;
|
15 | 15 | import java.net.URI;
|
16 |
| -import java.net.URISyntaxException; |
17 |
| -import java.net.URL; |
18 | 16 | import java.util.ArrayList;
|
19 | 17 | import java.util.Calendar;
|
20 | 18 | import java.util.Date;
|
|
56 | 54 | import org.eclipse.core.resources.IWorkspace;
|
57 | 55 | import org.eclipse.core.resources.ResourcesPlugin;
|
58 | 56 | import org.eclipse.core.runtime.CoreException;
|
59 |
| -import org.eclipse.core.runtime.FileLocator; |
60 | 57 | import org.eclipse.core.runtime.IPath;
|
61 | 58 | import org.eclipse.core.runtime.IProgressMonitor;
|
62 | 59 | import org.eclipse.core.runtime.IStatus;
|
|
67 | 64 | import org.eclipse.ui.console.IConsole;
|
68 | 65 | import org.eclipse.ui.console.IConsoleManager;
|
69 | 66 | import org.eclipse.ui.console.MessageConsole;
|
70 |
| -import org.osgi.framework.Bundle; |
71 | 67 |
|
72 | 68 | /**
|
73 | 69 | * ArduinoHelpers is a static class containing general purpose functions
|
@@ -771,22 +767,55 @@ public static void setTheEnvironmentVariables(IProject project, ICConfigurationD
|
771 | 767 | ArduinoInstancePreferences.getLastUsedBoardsFile()));
|
772 | 768 | IPath localPlatformFilename = new Path(Common.getBuildEnvironmentVariable(confDesc, ArduinoConst.ENV_KEY_JANTJE_PLATFORM_FILE, ""));
|
773 | 769 |
|
774 |
| - Bundle bundle = Platform.getBundle(ArduinoConst.CORE_PLUGIN_ID); |
775 |
| - URL fileURL = bundle.getEntry("config/arduino_eclipse_plugin.txt"); |
776 |
| - File file = null; |
777 |
| - try { |
778 |
| - file = new File(FileLocator.resolve(fileURL).toURI()); |
779 |
| - } catch (URISyntaxException e1) { |
780 |
| - e1.printStackTrace(); |
781 |
| - } catch (IOException e1) { |
782 |
| - e1.printStackTrace(); |
783 |
| - } |
784 |
| - if (file == null) { |
785 |
| - Common.log(new Status(IStatus.ERROR, ArduinoConst.CORE_PLUGIN_ID, |
786 |
| - "Your setup has gotten corruptes. Missing config/arduino_eclipse_plugin.txt file.")); |
787 |
| - return; |
788 |
| - } |
789 |
| - IPath arduinoEclipsePluginFile = new Path(file.getAbsolutePath()); |
| 770 | + /* |
| 771 | + * Trying to find the file in the plugin as described here :http://blog.vogella.com/2010/07/06/reading-resources-from-plugin/ |
| 772 | + */ |
| 773 | + // Bundle bundle = Platform.getBundle(ArduinoConst.CORE_PLUGIN_ID); |
| 774 | + // URL fileURL = bundle.getEntry("config/arduino_eclipse_plugin.txt"); |
| 775 | + // File file = null; |
| 776 | + // try { |
| 777 | + // file = new File(FileLocator.resolve(fileURL).toURI()); |
| 778 | + // } catch (URISyntaxException e1) { |
| 779 | + // e1.printStackTrace(); |
| 780 | + // } catch (IOException e1) { |
| 781 | + // e1.printStackTrace(); |
| 782 | + // } |
| 783 | + // if (file == null) { |
| 784 | + // Common.log(new Status(IStatus.ERROR, ArduinoConst.CORE_PLUGIN_ID, |
| 785 | + // "Your setup has gotten corrupt. Missing config/arduino_eclipse_plugin.txt file.")); |
| 786 | + // return; |
| 787 | + // } |
| 788 | + // IPath arduinoEclipsePluginFile = new Path(file.getAbsolutePath()); |
| 789 | + |
| 790 | + /* |
| 791 | + * try the second method as the first method fails |
| 792 | + */ |
| 793 | + // URL url; |
| 794 | + // try { |
| 795 | + // url = new URL("platform:/plugin/it.baeyens.arduino.core/config/arduino_eclipse_plugin.txt"); |
| 796 | + // } catch (MalformedURLException e) { |
| 797 | + // // TODO Auto-generated catch block |
| 798 | + // e.printStackTrace(); |
| 799 | + // return; |
| 800 | + // } |
| 801 | + // File file = null; |
| 802 | + // try { |
| 803 | + // URL resolved_url = FileLocator.resolve(url); |
| 804 | + // URI resolverdURI = resolved_url.toURI(); |
| 805 | + // file = new File(resolverdURI); |
| 806 | + // } catch (URISyntaxException e1) { |
| 807 | + // e1.printStackTrace(); |
| 808 | + // } catch (IOException e1) { |
| 809 | + // e1.printStackTrace(); |
| 810 | + // } catch (Exception e1) { |
| 811 | + // e1.printStackTrace(); |
| 812 | + // } |
| 813 | + // if (file == null) { |
| 814 | + // Common.log(new Status(IStatus.ERROR, ArduinoConst.CORE_PLUGIN_ID, |
| 815 | + // "Your setup has gotten corrupt. Missing config/arduino_eclipse_plugin.txt file.")); |
| 816 | + // return; |
| 817 | + // } |
| 818 | + // IPath arduinoEclipsePluginFile = new Path(file.getAbsolutePath()); |
790 | 819 |
|
791 | 820 | String boardID = Common.getBuildEnvironmentVariable(confDesc, ArduinoConst.ENV_KEY_JANTJE_BOARD_ID, "");
|
792 | 821 | String architecture = Common.getBuildEnvironmentVariable(confDesc, ArduinoConst.ENV_KEY_JANTJE_ARCITECTURE_ID, "");
|
@@ -828,10 +857,10 @@ public static void setTheEnvironmentVariables(IProject project, ICConfigurationD
|
828 | 857 | setTheEnvironmentVariablesAddtheBoardsTxt(contribEnv, confDesc, boardsFile, boardID, true);
|
829 | 858 |
|
830 | 859 | // also process the file as part of the plugin
|
831 |
| - if (arduinoEclipsePluginFile.toFile().exists()) { |
832 |
| - ArduinoBoards myBoardsFile = new ArduinoBoards(arduinoEclipsePluginFile.toOSString()); |
833 |
| - setTheEnvironmentVariablesAddtheBoardsTxt(contribEnv, confDesc, myBoardsFile, boardID, false); |
834 |
| - } |
| 860 | + // if (arduinoEclipsePluginFile.toFile().exists()) { |
| 861 | + // ArduinoBoards myBoardsFile = new ArduinoBoards(arduinoEclipsePluginFile.toOSString()); |
| 862 | + // setTheEnvironmentVariablesAddtheBoardsTxt(contribEnv, confDesc, myBoardsFile, boardID, false); |
| 863 | + // } |
835 | 864 |
|
836 | 865 | // Do some post processing
|
837 | 866 | setTheEnvironmentVariablesPostProcessing(contribEnv, confDesc);
|
|
0 commit comments