mirror of
https://github.com/irmen/prog8.git
synced 2025-01-10 20:30:23 +00:00
project restructure, add experiment for httpCompilerService
This commit is contained in:
parent
d37d62574c
commit
ffffcdd50a
2
.gitignore
vendored
2
.gitignore
vendored
@ -29,3 +29,5 @@ parsetab.py
|
||||
|
||||
.gradle
|
||||
/prog8compiler.jar
|
||||
sd*.img
|
||||
|
||||
|
10
.idea/libraries/javax_json_api_1_1_4.xml
generated
Normal file
10
.idea/libraries/javax_json_api_1_1_4.xml
generated
Normal file
@ -0,0 +1,10 @@
|
||||
<component name="libraryTable">
|
||||
<library name="javax.json-api-1.1.4">
|
||||
<CLASSES>
|
||||
<root url="jar://$PROJECT_DIR$/httpCompilerService/lib/javax.json-api-1.1.4.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/httpCompilerService/lib/javax.json-1.1.4.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</component>
|
10
.idea/libraries/slf4j_api_1_7_30.xml
generated
Normal file
10
.idea/libraries/slf4j_api_1_7_30.xml
generated
Normal file
@ -0,0 +1,10 @@
|
||||
<component name="libraryTable">
|
||||
<library name="slf4j-api-1.7.30">
|
||||
<CLASSES>
|
||||
<root url="jar://$PROJECT_DIR$/httpCompilerService/lib/slf4j-api-1.7.30.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/httpCompilerService/lib/slf4j-simple-1.7.30.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</component>
|
12
.idea/libraries/takes_http.xml
generated
Normal file
12
.idea/libraries/takes_http.xml
generated
Normal file
@ -0,0 +1,12 @@
|
||||
<component name="libraryTable">
|
||||
<library name="takes-http">
|
||||
<CLASSES>
|
||||
<root url="jar://$PROJECT_DIR$/httpCompilerService/lib/cactoos-0.42.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/httpCompilerService/lib/commons-lang3-3.7.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/httpCompilerService/lib/commons-text-1.4.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/httpCompilerService/lib/takes-1.19.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</component>
|
1
.idea/modules.xml
generated
1
.idea/modules.xml
generated
@ -6,6 +6,7 @@
|
||||
<module fileurl="file://$PROJECT_DIR$/dbusCompilerService/dbusCompilerService.iml" filepath="$PROJECT_DIR$/dbusCompilerService/dbusCompilerService.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/docs/docs.iml" filepath="$PROJECT_DIR$/docs/docs.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/examples/examples.iml" filepath="$PROJECT_DIR$/examples/examples.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/httpCompilerService/httpCompilerService.iml" filepath="$PROJECT_DIR$/httpCompilerService/httpCompilerService.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/parser/parser.iml" filepath="$PROJECT_DIR$/parser/parser.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
|
@ -58,7 +58,7 @@ sourceSets {
|
||||
}
|
||||
}
|
||||
|
||||
startScripts.enabled = false
|
||||
startScripts.enabled = true
|
||||
|
||||
application {
|
||||
mainClassName = 'prog8.dbus.TestdbusKt'
|
||||
@ -71,7 +71,7 @@ artifacts {
|
||||
|
||||
|
||||
shadowJar {
|
||||
archiveBaseName = 'prog8compilerservice'
|
||||
archiveBaseName = 'prog8compilerservicedbus'
|
||||
archiveVersion = '1.0'
|
||||
// minimize()
|
||||
}
|
||||
|
98
httpCompilerService/build.gradle
Normal file
98
httpCompilerService/build.gradle
Normal file
@ -0,0 +1,98 @@
|
||||
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'application'
|
||||
id "org.jetbrains.kotlin.jvm" version "1.4.21"
|
||||
id 'com.github.johnrengelman.shadow' version '5.2.0'
|
||||
}
|
||||
|
||||
targetCompatibility = 11
|
||||
sourceCompatibility = 11
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
maven { url "https://kotlin.bintray.com/kotlinx" }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation project(':compiler')
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
|
||||
// implementation "org.jetbrains.kotlin:kotlin-reflect"
|
||||
implementation 'org.jetbrains.kotlinx:kotlinx-cli:0.3.1'
|
||||
implementation "org.takes:takes:1.19"
|
||||
implementation "javax.json:javax.json-api:1.1.4"
|
||||
implementation "org.glassfish:javax.json:1.1.4"
|
||||
implementation "org.slf4j:slf4j-simple:1.7.30"
|
||||
|
||||
testImplementation "org.jetbrains.kotlin:kotlin-test-junit5"
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.3.2'
|
||||
testImplementation 'org.hamcrest:hamcrest-junit:2.0.0.0'
|
||||
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.3.2'
|
||||
}
|
||||
|
||||
compileKotlin {
|
||||
kotlinOptions {
|
||||
jvmTarget = "11"
|
||||
// verbose = true
|
||||
// freeCompilerArgs += "-XXLanguage:+NewInference"
|
||||
}
|
||||
}
|
||||
|
||||
compileTestKotlin {
|
||||
kotlinOptions {
|
||||
jvmTarget = "11"
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
java {
|
||||
srcDirs = ["${project.projectDir}/src"]
|
||||
}
|
||||
resources {
|
||||
srcDirs = ["${project.projectDir}/res"]
|
||||
}
|
||||
}
|
||||
test {
|
||||
java {
|
||||
srcDirs = ["${project.projectDir}/test"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
startScripts.enabled = true
|
||||
|
||||
application {
|
||||
mainClassName = 'prog8.http.TestHttpKt'
|
||||
applicationName = 'testhttp'
|
||||
}
|
||||
|
||||
artifacts {
|
||||
archives shadowJar
|
||||
}
|
||||
|
||||
|
||||
shadowJar {
|
||||
archiveBaseName = 'prog8compilerservicehttp'
|
||||
archiveVersion = '1.0'
|
||||
// minimize()
|
||||
}
|
||||
|
||||
|
||||
test {
|
||||
// Enable JUnit 5 (Gradle 4.6+).
|
||||
useJUnitPlatform()
|
||||
|
||||
// Always run tests, even when nothing changed.
|
||||
dependsOn 'cleanTest'
|
||||
|
||||
// Show test results.
|
||||
testLogging {
|
||||
events "skipped", "failed"
|
||||
}
|
||||
}
|
||||
|
||||
task wrapper(type: Wrapper) {
|
||||
gradleVersion = '6.1.1'
|
||||
}
|
16
httpCompilerService/httpCompilerService.iml
Normal file
16
httpCompilerService/httpCompilerService.iml
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="11" jdkType="JavaSDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="KotlinJavaRuntime" level="project" />
|
||||
<orderEntry type="library" name="takes-http" level="project" />
|
||||
<orderEntry type="library" name="javax.json-api-1.1.4" level="project" />
|
||||
<orderEntry type="module" module-name="compiler" />
|
||||
<orderEntry type="library" name="slf4j-api-1.7.30" level="project" />
|
||||
</component>
|
||||
</module>
|
BIN
httpCompilerService/lib/cactoos-0.42.jar
Normal file
BIN
httpCompilerService/lib/cactoos-0.42.jar
Normal file
Binary file not shown.
BIN
httpCompilerService/lib/commons-lang3-3.7.jar
Normal file
BIN
httpCompilerService/lib/commons-lang3-3.7.jar
Normal file
Binary file not shown.
BIN
httpCompilerService/lib/commons-text-1.4.jar
Normal file
BIN
httpCompilerService/lib/commons-text-1.4.jar
Normal file
Binary file not shown.
BIN
httpCompilerService/lib/javax.json-1.1.4.jar
Normal file
BIN
httpCompilerService/lib/javax.json-1.1.4.jar
Normal file
Binary file not shown.
BIN
httpCompilerService/lib/javax.json-api-1.1.4.jar
Normal file
BIN
httpCompilerService/lib/javax.json-api-1.1.4.jar
Normal file
Binary file not shown.
BIN
httpCompilerService/lib/slf4j-api-1.7.30.jar
Normal file
BIN
httpCompilerService/lib/slf4j-api-1.7.30.jar
Normal file
Binary file not shown.
BIN
httpCompilerService/lib/slf4j-simple-1.7.30.jar
Normal file
BIN
httpCompilerService/lib/slf4j-simple-1.7.30.jar
Normal file
Binary file not shown.
BIN
httpCompilerService/lib/takes-1.19.jar
Normal file
BIN
httpCompilerService/lib/takes-1.19.jar
Normal file
Binary file not shown.
52
httpCompilerService/src/prog8/http/TestHttp.kt
Normal file
52
httpCompilerService/src/prog8/http/TestHttp.kt
Normal file
@ -0,0 +1,52 @@
|
||||
package prog8.http
|
||||
|
||||
import org.takes.Request
|
||||
import org.takes.Response
|
||||
import org.takes.Take
|
||||
import org.takes.facets.fork.FkMethods
|
||||
import org.takes.http.Exit;
|
||||
import org.takes.http.FtBasic;
|
||||
import org.takes.facets.fork.FkRegex;
|
||||
import org.takes.facets.fork.TkFork;
|
||||
import org.takes.rq.form.RqFormBase
|
||||
import org.takes.rs.RsJson
|
||||
import org.takes.tk.TkSlf4j
|
||||
import javax.json.Json
|
||||
import prog8.compiler.compileProgram
|
||||
import java.nio.file.Path
|
||||
|
||||
|
||||
class Jsonding: RsJson.Source {
|
||||
override fun toJson(): javax.json.JsonStructure {
|
||||
return Json.createObjectBuilder()
|
||||
.add("name", "irmen")
|
||||
.build()
|
||||
}
|
||||
}
|
||||
|
||||
class RequestParser : Take {
|
||||
override fun act(request: Request): Response {
|
||||
val form = RqFormBase(request)
|
||||
val names = form.names()
|
||||
val a = form.param("a").single()
|
||||
val compilationResult = compileProgram(Path.of(a), true, true, true, "c64", Path.of("."))
|
||||
return RsJson(Jsonding())
|
||||
}
|
||||
}
|
||||
|
||||
fun main() {
|
||||
FtBasic(
|
||||
TkSlf4j(
|
||||
TkFork(
|
||||
FkRegex("/", "hello, world!"),
|
||||
FkRegex("/json",
|
||||
TkFork(
|
||||
FkMethods("GET", RsJson(Jsonding())),
|
||||
FkMethods("POST", RequestParser())
|
||||
)
|
||||
),
|
||||
)
|
||||
),
|
||||
8080
|
||||
).start(Exit.NEVER)
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
include ':parser'
|
||||
include ':compiler'
|
||||
include ':dbusCompilerService'
|
||||
include ':httpCompilerService'
|
||||
|
Loading…
x
Reference in New Issue
Block a user