project restructure, add experiment for httpCompilerService

This commit is contained in:
Irmen de Jong 2020-12-27 08:26:42 +01:00
parent d37d62574c
commit ffffcdd50a
18 changed files with 204 additions and 2 deletions

2
.gitignore vendored
View File

@ -29,3 +29,5 @@ parsetab.py
.gradle
/prog8compiler.jar
sd*.img

View 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>

View 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>

View 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>

View File

@ -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>

View File

@ -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()
}

View 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'
}

View 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>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View 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)
}

View File

@ -1,3 +1,4 @@
include ':parser'
include ':compiler'
include ':dbusCompilerService'
include ':httpCompilerService'