@@ -65,28 +65,45 @@ public void init(Base base) {
6565 this .base = base ;
6666 }
6767
68- public static List <String > findFiles (Path path , String fileExtension )
69- throws IOException {
68+ public static List <String > findFiles (Path path , String fileExtension ) throws IOException {
7069
71- if (!Files .isDirectory (path )) {
72- throw new IllegalArgumentException ("Path must be a directory!" );
73- }
70+ if (!Files .isDirectory (path )) {
71+ throw new IllegalArgumentException ("Path must be a directory!" );
72+ }
7473
75- List <String > result ;
76-
77- try (Stream <Path > walk = Files .walk (path )) {
78- result = walk
79- .filter (p -> !Files .isDirectory (p ))
80- // this is a path, not string,
81- // convert path to string first
82- .map (p -> p .toString ().toLowerCase ())
83- // this only test if pathname ends with a certain extension
84- .filter (f -> f .endsWith (fileExtension ))
85- .collect (Collectors .toList ());
86- }
74+ List <String > result ;
75+
76+ try (Stream <Path > walk = Files .walk (path )) {
77+ result = walk
78+ .filter (p -> !Files .isDirectory (p ))
79+ // this is a path, not string,
80+ // convert path to string first
81+ .map (p -> p .toString ().toLowerCase ())
82+ // this only test if pathname ends with a certain extension
83+ .filter (f -> f .endsWith (fileExtension ))
84+ .collect (Collectors .toList ());
85+ }
8786
88- return result ;
87+ return result ;
88+ }
89+
90+ private String getJarsInDir (File file ) {
91+ return getJarsInDir (file .toPath ());
92+ }
93+
94+ private String getJarsInDir (Path path ) {
95+ String extraLibs = "" ;
96+ boolean isWindows = System .getProperty ("os.name" ).toLowerCase ().startsWith ("windows" );
97+ try {
98+ List <String > files = findFiles (path , "jar" );
99+ if (!files .isEmpty ()) {
100+ extraLibs = isWindows ?";" :":" + String .join (isWindows ?";" :":" , files );
101+ }
102+ } catch (IOException e ) {
103+ e .printStackTrace ();
89104 }
105+ return extraLibs ;
106+ }
90107
91108 public void run () {
92109 boolean isWindows = System .getProperty ("os.name" ).toLowerCase ().startsWith ("windows" );
@@ -100,21 +117,12 @@ public void run() {
100117 Sketch sketch = editor .getSketch ();
101118 System .out .println ("Generating JavaDoc for Sketch \" " +sketch .getName ()+"\" " );
102119
103- String extraLibs = "" ;
104- try {
105- List <String > files = findFiles (Paths .get (Preferences .getSketchbookPath ()+(isWindows ?'\\' :'/' )+"libraries" ), "jar" );
106- //files.forEach(x -> System.out.println(x));
107- if (!files .isEmpty ()) {
108- extraLibs = isWindows ?";" :":" + String .join (isWindows ?";" :":" , files );
109- }
110-
111- } catch (IOException e ) {
112- e .printStackTrace ();
113- }
114120
115121 File folder = sketch .getFolder ();
122+ String extraLibs = getJarsInDir (Paths .get (Preferences .getSketchbookPath ()+(isWindows ?'\\' :'/' )+"libraries" ));
123+ extraLibs += getJarsInDir (folder );
124+ extraLibs += getJarsInDir (processing .app .Platform .getContentFile ("modes/java/libraries" ));
116125 SketchCode codes [] = sketch .getCode ();
117- //System.out.println(folder.getAbsolutePath());
118126 String mainTab = codes [0 ].getProgram ();
119127 if (!mainTab .contains ("setup" ) && !mainTab .contains ("draw" )) {
120128 System .err .println ("Can only generate JavaDoc for sketches in dynamic mode." );
0 commit comments