@@ -1397,22 +1397,35 @@ public void preprocess(String buildPath, PdePreprocessor preprocessor) throws Ru
1397
1397
}
1398
1398
}
1399
1399
1400
- copyAdditionalFilesToBuildFolderSavingOriginalFolderStructure (sketch , buildPath );
1401
-
1402
1400
// 3. then loop over the code[] and save each .java file
1403
1401
for (SketchCode sc : sketch .getCodes ()) {
1404
- if (sc .isExtension ("ino" ) || sc .isExtension ("pde" )) {
1402
+ if (sc .isExtension (SketchData .OTHER_ALLOWED_EXTENSIONS )) {
1403
+ // no pre-processing services necessary for java files
1404
+ // just write the the contents of 'program' to a .java file
1405
+ // into the build directory. uses byte stream and reader/writer
1406
+ // shtuff so that unicode bunk is properly handled
1407
+ String filename = sc .getFileName (); //code[i].name + ".java";
1408
+ try {
1409
+ BaseNoGui .saveFile (sc .getProgram (), new File (buildPath , filename ));
1410
+ } catch (IOException e ) {
1411
+ e .printStackTrace ();
1412
+ throw new RunnerException (I18n .format (_ ("Problem moving {0} to the build folder" ), filename ));
1413
+ }
1414
+
1415
+ } else if (sc .isExtension ("ino" ) || sc .isExtension ("pde" )) {
1405
1416
// The compiler and runner will need this to have a proper offset
1406
1417
sc .addPreprocOffset (headerOffset );
1407
1418
}
1408
1419
}
1420
+
1421
+ copyAdditionalFilesToBuildFolderSavingOriginalFolderStructure (sketch , buildPath );
1409
1422
}
1410
1423
1411
1424
private void copyAdditionalFilesToBuildFolderSavingOriginalFolderStructure (SketchData sketch , String buildPath ) throws RunnerException {
1412
1425
Path sketchPath = Paths .get (sketch .getFolder ().getAbsolutePath ());
1413
1426
Stream <Path > otherFilesStream ;
1414
1427
try {
1415
- otherFilesStream = Files .find (sketchPath , ADDITIONAL_FILES_COPY_MAX_DEPTH , (path , attribs ) -> !attribs .isDirectory () && FileUtils .hasExtension (path .toFile (), SketchData .OTHER_ALLOWED_EXTENSIONS ));
1428
+ otherFilesStream = Files .find (sketchPath , ADDITIONAL_FILES_COPY_MAX_DEPTH , (path , attribs ) -> !attribs .isDirectory () && isPathInASubfolder ( sketchPath , path ) && FileUtils .hasExtension (path .toFile (), SketchData .OTHER_ALLOWED_EXTENSIONS ));
1416
1429
} catch (IOException e ) {
1417
1430
throw new RunnerException (e );
1418
1431
}
@@ -1428,6 +1441,9 @@ private void copyAdditionalFilesToBuildFolderSavingOriginalFolderStructure(Sketc
1428
1441
});
1429
1442
}
1430
1443
1444
+ private boolean isPathInASubfolder (Path sketchPath , Path path ) {
1445
+ return sketchPath .relativize (path ).getNameCount () > 1 ;
1446
+ }
1431
1447
1432
1448
/**
1433
1449
* List of library folders.
0 commit comments