@@ -137,7 +137,6 @@ private static void InstallLibraries(IProgressMonitor monitor) {
137
137
* @param object
138
138
* @return
139
139
*/
140
- @ SuppressWarnings ("resource" )
141
140
static public IStatus downloadAndInstall (ArduinoPlatform platform , boolean forceDownload ,
142
141
IProgressMonitor monitor ) {
143
142
@@ -149,42 +148,10 @@ static public IStatus downloadAndInstall(ArduinoPlatform platform, boolean force
149
148
MultiStatus mstatus = new MultiStatus (status .getPlugin (), status .getCode (), status .getMessage (),
150
149
status .getException ());
151
150
152
- List <ToolDependency > tools = platform .getToolsDependencies ();
153
- // make a platform_plugin.txt file to store the tool paths
154
- File pluginFile = ConfigurationPreferences .getPlugin_Platform_File ();
155
- PrintWriter writer = null ;
156
-
157
- try {
158
- writer = new PrintWriter (pluginFile , "UTF-8" );//$NON-NLS-1$
159
- writer .println ("#This is a automatically generated file by the Arduino eclipse plugin" ); //$NON-NLS-1$
160
- writer .println ("#only edit if you know what you are doing" ); //$NON-NLS-1$
161
- writer .println ("#Have fun" ); //$NON-NLS-1$
162
- writer .println ("#Jantje" ); //$NON-NLS-1$
163
- writer .println ();
164
- } catch (FileNotFoundException | UnsupportedEncodingException e ) {
165
- mstatus .add (
166
- new Status (
167
- IStatus .WARNING , Activator .getId (), Messages .ArduinoManager_unable_to_create_file
168
- + pluginFile + '\n' + platform .getName () + Messages .ArduinoManager_will_not_work ,
169
- e ));
170
- }
171
-
172
- for (ToolDependency tool : tools ) {
151
+ for (ToolDependency tool : platform .getToolsDependencies ()) {
173
152
monitor .setTaskName (InstallProgress .getRandomMessage ());
174
- status = tool .install (monitor );
175
- if (!status .isOK ()) {
176
- mstatus .add (status );
177
- }
178
- if (writer != null ) {
179
- writer .println ("runtime.tools." + tool .getName () + ".path=" + tool .getTool ().getInstallPath ());//$NON-NLS-1$ //$NON-NLS-2$
180
- writer .println ("runtime.tools." + tool .getName () + tool .getVersion () + ".path=" //$NON-NLS-1$ //$NON-NLS-2$
181
- + tool .getTool ().getInstallPath ());
182
- }
183
- }
184
- if (writer != null ) {
185
- writer .close ();
153
+ mstatus .add (tool .install (monitor ));
186
154
}
187
-
188
155
// On Windows install make from equations.org
189
156
if (Platform .getOS ().equals (Platform .OS_WIN32 )) {
190
157
try {
@@ -203,10 +170,44 @@ static public IStatus downloadAndInstall(ArduinoPlatform platform, boolean force
203
170
}
204
171
}
205
172
173
+ mstatus .add (make_eclipse_plugin_txt_file (platform ));
206
174
return mstatus .getChildren ().length == 0 ? Status .OK_STATUS : mstatus ;
207
175
208
176
}
209
177
178
+ static public IStatus make_eclipse_plugin_txt_file (ArduinoPlatform platform ) {
179
+
180
+ // make a platform_plugin.txt file to store the tool paths
181
+ File pluginFile = ConfigurationPreferences .getPlugin_Platform_File ();
182
+
183
+ try (PrintWriter writer = new PrintWriter (pluginFile , "UTF-8" );) {
184
+
185
+ writer .println ("#This is a automatically generated file by the Arduino eclipse plugin" ); //$NON-NLS-1$
186
+ writer .println ("#only edit if you know what you are doing" ); //$NON-NLS-1$
187
+ writer .println ("#Have fun" ); //$NON-NLS-1$
188
+ writer .println ("#Jantje" ); //$NON-NLS-1$
189
+ writer .println ();
190
+
191
+ // TODO there should be a get tools and then loop over the tools as
192
+ // this implementation returns the tools several times
193
+ for (ArduinoPlatform curplatform : getPlatforms ()) {
194
+ for (ToolDependency tool : curplatform .getToolsDependencies ()) {
195
+ if (writer != null ) {
196
+ writer .println ("runtime.tools." + tool .getName () + ".path=" + tool .getTool ().getInstallPath ());//$NON-NLS-1$ //$NON-NLS-2$
197
+ writer .println ("runtime.tools." + tool .getName () + tool .getVersion () + ".path=" //$NON-NLS-1$ //$NON-NLS-2$
198
+ + tool .getTool ().getInstallPath ());
199
+ }
200
+ }
201
+ }
202
+ } catch (FileNotFoundException | UnsupportedEncodingException e ) {
203
+ return new Status (IStatus .WARNING , Activator .getId (), Messages .ArduinoManager_unable_to_create_file
204
+ + pluginFile + '\n' + platform .getName () + Messages .ArduinoManager_will_not_work , e );
205
+ }
206
+
207
+ return Status .OK_STATUS ;
208
+
209
+ }
210
+
210
211
static public void loadIndices (boolean immediatly ) {
211
212
if (immediatly ) {
212
213
internalLoadIndices ();
0 commit comments