Skip to content

Commit

Permalink
fix classpath
Browse files Browse the repository at this point in the history
  • Loading branch information
hkiel committed Jan 19, 2023
1 parent de87c78 commit 035630d
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 32 deletions.
4 changes: 2 additions & 2 deletions resources/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,12 @@ source.repository=https://github.com/hkiel/JavaDoc.git
# This is used to compare different versions of the same Tool, and check if an
# update is available.

tool.version=3
tool.version=4


# The version as the user will see it.

tool.prettyVersion=1.0.2
tool.prettyVersion=1.0.3


# The min and max revision of Processing compatible with your Tool.
Expand Down
68 changes: 38 additions & 30 deletions src/javadoc/tool/JavaDoc.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,28 +65,45 @@ public void init(Base base) {
this.base = base;
}

public static List<String> findFiles(Path path, String fileExtension)
throws IOException {
public static List<String> findFiles(Path path, String fileExtension) throws IOException {

if (!Files.isDirectory(path)) {
throw new IllegalArgumentException("Path must be a directory!");
}
if (!Files.isDirectory(path)) {
throw new IllegalArgumentException("Path must be a directory!");
}

List<String> result;

try (Stream<Path> walk = Files.walk(path)) {
result = walk
.filter(p -> !Files.isDirectory(p))
// this is a path, not string,
// convert path to string first
.map(p -> p.toString().toLowerCase())
// this only test if pathname ends with a certain extension
.filter(f -> f.endsWith(fileExtension))
.collect(Collectors.toList());
}
List<String> result;

try (Stream<Path> walk = Files.walk(path)) {
result = walk
.filter(p -> !Files.isDirectory(p))
// this is a path, not string,
// convert path to string first
.map(p -> p.toString().toLowerCase())
// this only test if pathname ends with a certain extension
.filter(f -> f.endsWith(fileExtension))
.collect(Collectors.toList());
}

return result;
return result;
}

private String getJarsInDir(File file) {
return getJarsInDir(file.toPath());
}

private String getJarsInDir(Path path) {
String extraLibs = "";
boolean isWindows = System.getProperty("os.name").toLowerCase().startsWith("windows");
try {
List<String> files = findFiles(path, "jar");
if (!files.isEmpty()) {
extraLibs = isWindows?";":":" + String.join(isWindows?";":":", files);
}
} catch (IOException e) {
e.printStackTrace();
}
return extraLibs;
}

public void run() {
boolean isWindows = System.getProperty("os.name").toLowerCase().startsWith("windows");
Expand All @@ -100,21 +117,12 @@ public void run() {
Sketch sketch = editor.getSketch();
System.out.println("Generating JavaDoc for Sketch \""+sketch.getName()+"\"");

String extraLibs = "";
try {
List<String> files = findFiles(Paths.get(Preferences.getSketchbookPath()+(isWindows?'\\':'/')+"libraries"), "jar");
//files.forEach(x -> System.out.println(x));
if (!files.isEmpty()) {
extraLibs = isWindows?";":":" + String.join(isWindows?";":":", files);
}

} catch (IOException e) {
e.printStackTrace();
}

File folder = sketch.getFolder();
String extraLibs = getJarsInDir(Paths.get(Preferences.getSketchbookPath()+(isWindows?'\\':'/')+"libraries"));
extraLibs += getJarsInDir(folder);
extraLibs += getJarsInDir(processing.app.Platform.getContentFile("modes/java/libraries"));
SketchCode codes[] = sketch.getCode();
//System.out.println(folder.getAbsolutePath());
String mainTab = codes[0].getProgram();
if (!mainTab.contains("setup") && !mainTab.contains("draw")) {
System.err.println("Can only generate JavaDoc for sketches in dynamic mode.");
Expand Down

0 comments on commit 035630d

Please sign in to comment.