mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
Run app with Java Mode
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
plugins {
|
||||
id("java")
|
||||
id("antlr")
|
||||
}
|
||||
|
||||
repositories{
|
||||
mavenCentral()
|
||||
maven { url = uri("https://jogamp.org/deployment/maven") }
|
||||
}
|
||||
|
||||
sourceSets{
|
||||
main{
|
||||
java{
|
||||
srcDirs("src", "generated")
|
||||
}
|
||||
resources{
|
||||
srcDirs("../build/shared/", "src/main/resources/")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies{
|
||||
implementation(project(":app"))
|
||||
implementation(project(":core"))
|
||||
|
||||
antlr("org.antlr:antlr4:4.13.1")
|
||||
|
||||
implementation("org.eclipse.jdt:org.eclipse.jdt.core:3.37.0")
|
||||
implementation("com.google.classpath-explorer:classpath-explorer:1.0")
|
||||
implementation("org.netbeans.api:org-netbeans-swing-outline:RELEASE210")
|
||||
implementation("org.apache.ant:ant:1.10.14")
|
||||
implementation("org.eclipse.lsp4j:org.eclipse.lsp4j:0.22.0")
|
||||
implementation("org.jsoup:jsoup:1.17.2")
|
||||
}
|
||||
|
||||
|
||||
tasks.register<Copy>("extraResources"){
|
||||
from(".")
|
||||
include("keywords.txt")
|
||||
into("build/resources/main")
|
||||
}
|
||||
tasks.jar { dependsOn("extraResources") }
|
||||
tasks.processResources{ finalizedBy("extraResources") }
|
||||
@@ -1,201 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="EclipseModuleManager">
|
||||
<libelement value="jar://$MODULE_DIR$/mode/antlr-4.7.2-complete.jar!/" />
|
||||
<libelement value="jar://$MODULE_DIR$/mode/classpath-explorer-1.0.jar!/" />
|
||||
<libelement value="jar://$MODULE_DIR$/mode/com.ibm.icu.jar!/" />
|
||||
<libelement value="jar://$MODULE_DIR$/mode/jdtCompilerAdapter.jar!/" />
|
||||
<libelement value="jar://$MODULE_DIR$/mode/jsoup-1.7.1.jar!/" />
|
||||
<libelement value="jar://$MODULE_DIR$/mode/org.eclipse.core.contenttype.jar!/" />
|
||||
<libelement value="jar://$MODULE_DIR$/mode/org.eclipse.core.jobs.jar!/" />
|
||||
<libelement value="jar://$MODULE_DIR$/mode/org.eclipse.core.resources.jar!/" />
|
||||
<libelement value="jar://$MODULE_DIR$/mode/org.eclipse.core.runtime.jar!/" />
|
||||
<libelement value="jar://$MODULE_DIR$/mode/org.eclipse.equinox.common.jar!/" />
|
||||
<libelement value="jar://$MODULE_DIR$/mode/org.eclipse.equinox.preferences.jar!/" />
|
||||
<libelement value="jar://$MODULE_DIR$/mode/org.eclipse.jdt.core.jar!/" />
|
||||
<libelement value="jar://$MODULE_DIR$/mode/org.eclipse.osgi.jar!/" />
|
||||
<libelement value="jar://$MODULE_DIR$/mode/org.eclipse.text.jar!/" />
|
||||
<libelement value="jar://$MODULE_DIR$/mode/org.netbeans.swing.outline.jar!/" />
|
||||
<libelement value="jar://$MODULE_DIR$/test/lib/junit-4.8.1.jar!/" />
|
||||
<src_description expected_position="0">
|
||||
<src_folder value="file://$MODULE_DIR$/generated" expected_position="0" />
|
||||
<src_folder value="file://$MODULE_DIR$/src" expected_position="1" />
|
||||
</src_description>
|
||||
</component>
|
||||
<component name="NewModuleRootManager">
|
||||
<output url="file://$MODULE_DIR$/bin" />
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/generated" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="processing4-app" />
|
||||
<orderEntry type="module" module-name="processing4-core" />
|
||||
<orderEntry type="module-library">
|
||||
<library name="antlr-4.7.2-complete.jar">
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/mode/antlr-4.7.2-complete.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library name="classpath-explorer-1.0.jar">
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/mode/classpath-explorer-1.0.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library name="com.ibm.icu.jar">
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/mode/com.ibm.icu.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library name="jdtCompilerAdapter.jar">
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/mode/jdtCompilerAdapter.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library name="jsoup-1.7.1.jar">
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/mode/jsoup-1.7.1.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library name="org.eclipse.core.contenttype.jar">
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/mode/org.eclipse.core.contenttype.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library name="org.eclipse.core.jobs.jar">
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/mode/org.eclipse.core.jobs.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library name="org.eclipse.core.resources.jar">
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/mode/org.eclipse.core.resources.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library name="org.eclipse.core.runtime.jar">
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/mode/org.eclipse.core.runtime.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library name="org.eclipse.equinox.common.jar">
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/mode/org.eclipse.equinox.common.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library name="org.eclipse.equinox.preferences.jar">
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/mode/org.eclipse.equinox.preferences.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library name="org.eclipse.jdt.core.jar">
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/mode/org.eclipse.jdt.core.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library name="org.eclipse.osgi.jar">
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/mode/org.eclipse.osgi.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library name="org.eclipse.text.jar">
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/mode/org.eclipse.text.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library name="org.netbeans.swing.outline.jar">
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/mode/org.netbeans.swing.outline.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library name="org.eclipse.lsp4j">
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/mode/org.eclipse.lsp4j.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="jar://$MODULE_DIR$/mode/org.eclipse.lsp4j.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library name="org.eclipse.lsp4j.jsonrpc">
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/mode/org.eclipse.lsp4j.jsonrpc.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library name="gson">
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/mode/gson.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
</component>
|
||||
</module>
|
||||
@@ -25,6 +25,9 @@ package processing.mode.java;
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.file.*;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@@ -56,7 +59,58 @@ public class JavaMode extends Mode {
|
||||
public String getTitle() {
|
||||
return "Java";
|
||||
}
|
||||
|
||||
File resourcesFolder;
|
||||
|
||||
@Override
|
||||
public File[] getKeywordFiles() {
|
||||
var url = JavaMode.class.getClassLoader().getResource("keywords.txt");
|
||||
if(url != null) {
|
||||
if(resourcesFolder == null){
|
||||
try {
|
||||
resourcesFolder = Files.createTempDirectory("processing").toFile();
|
||||
copyFromJar("/", resourcesFolder.toPath());
|
||||
return new File[] { new File(resourcesFolder, "keywords.txt") };
|
||||
} catch (IOException | URISyntaxException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}else{
|
||||
return new File[] { new File(resourcesFolder, "keywords.txt") };
|
||||
}
|
||||
|
||||
return new File[] { new File(url.getFile()) };
|
||||
}
|
||||
return new File[] { new File(folder, "keywords.txt") };
|
||||
}
|
||||
public static void copyFromJar(String source, final Path target) throws URISyntaxException, IOException {
|
||||
var resource = JavaMode.class.getResource("").toURI();
|
||||
var fileSystem = FileSystems.newFileSystem(
|
||||
resource,
|
||||
Collections.<String, String>emptyMap()
|
||||
);
|
||||
|
||||
|
||||
final Path jarPath = fileSystem.getPath(source);
|
||||
|
||||
Files.walkFileTree(jarPath, new SimpleFileVisitor<Path>() {
|
||||
|
||||
private Path currentTarget;
|
||||
|
||||
@Override
|
||||
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
|
||||
currentTarget = target.resolve(jarPath.relativize(dir).toString());
|
||||
Files.createDirectories(currentTarget);
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
|
||||
Files.copy(file, target.resolve(jarPath.relativize(file).toString()), StandardCopyOption.REPLACE_EXISTING);
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
||||
|
||||
|
||||
Reference in New Issue
Block a user