Skip to content

Commit

Permalink
Merge pull request #31 from cloudoptlab/3.x
Browse files Browse the repository at this point in the history
3.0.0.0-BETA7
  • Loading branch information
T-baby authored Apr 9, 2021
2 parents 87c06d2 + 859ee93 commit b6725a7
Show file tree
Hide file tree
Showing 40 changed files with 607 additions and 246 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ file-uploads/
/*/build
/plugins/*/build/**
/captures
*.iml
*.apk
*.ap_
*.dex
*.class
bin/
gen/
proguard/
*.log
/venv
/*/generated/
129 changes: 87 additions & 42 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
plugins {
id "java"
id "org.jetbrains.kotlin.jvm" version "1.4.0"
id "com.jfrog.bintray" version "1.8.4"
id("org.jetbrains.dokka") version "1.4.30"
}

allprojects {
group = "net.cloudopt.next"
version = property("project_version")
sourceCompatibility = property("java_version") as Integer
sourceCompatibility = property("java_version")
repositories {
maven { url "http://maven.aliyun.com/nexus/content/repositories/central/" }
maven { url "https://maven.aliyun.com/nexus/content/repositories/central/" }
maven { url "https://maven.aliyun.com/nexus/content/groups/public" }
mavenCentral()
jcenter()
}
}

subprojects {

buildscript {
repositories {
maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' }
gradlePluginPortal()
}
dependencies {
Expand All @@ -34,62 +35,106 @@ subprojects {
}

apply plugin: "java"
apply plugin: "maven-publish"
apply plugin: "kotlin"
apply plugin: "maven-publish"
apply plugin: "signing"
apply plugin: "org.jetbrains.dokka"

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:${property('kotlin_version')}"
implementation "org.jetbrains.kotlin:kotlin-stdlib:${property('kotlinx_version')}"
implementation "org.jetbrains.kotlin:kotlin-reflect:${property('kotlin_version')}"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:${property('kotlin_version')}"
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:${property('kotlin_version')}"
testImplementation "org.jetbrains.kotlin:kotlin-test-junit:${property('kotlin_version')}"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:${property('kotlinx_version')}"
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:${property('kotlinx_version')}"
testImplementation "org.jetbrains.kotlin:kotlin-test-junit:${property('dokka_version')}"
testImplementation "org.junit.jupiter:junit-jupiter-api:5.6.0"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.6.0"
}

compileJava {
sourceCompatibility = rootProject.property("java_version")
targetCompatibility = rootProject.property("java_version")
[compileJava]*.options*.encoding = "UTF-8"
}
compileTestJava {
sourceCompatibility = rootProject.property("java_version")
targetCompatibility = rootProject.property("java_version")
[compileTestJava]*.options*.encoding = "UTF-8"
}
compileKotlin {
kotlinOptions.jvmTarget = rootProject.property("java_version") as String
kotlinOptions.jvmTarget = rootProject.property("java_version")
kotlinOptions.useIR = true
}
compileTestKotlin {
kotlinOptions.jvmTarget = rootProject.property("java_version") as String
kotlinOptions.jvmTarget = rootProject.property("java_version")
kotlinOptions.useIR = true
}

task sourceJar(type: Jar, dependsOn: classes) { from sourceSets.main.allSource }

apply plugin: "maven-publish"
apply plugin: "com.jfrog.bintray"
dokkaJavadoc{
outputDirectory.set(new File(buildDir, "javadoc"))
}

publishing {
publications {
Publication(MavenPublication) {
groupId 'net.cloudopt.next'
artifactId "$project.name"
version "${property('project_version')}" // This is defined on the subproject
from components.java
artifact sourceJar {
classifier "sources"
}
}
}
java {
withJavadocJar()
withSourcesJar()
}

if (
project.name != "plugins"
) {
plugins.withId("maven-publish") {
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
pom {
name = project.group + ":" + project.name
url = "https://github.com/cloudoptlab/cloudopt-next"
afterEvaluate {
// description is not available until evaluated.
description = project.description
}

scm {
connection = "scm:git:https://github.com/cloudoptlab/cloudopt-next.git"
developerConnection = "scm:git:[email protected]:cloudoptlab/cloudopt-next.git"
url = "https://github.com/cloudoptlab/cloudopt-next"
}

licenses {
license {
name = "Apache 2.0"
url = "https://opensource.org/licenses/Apache-2.0"
}
}

bintray {
user = System.getenv("BINTRAY_USER")
key = System.getenv("BINTRAY_KEY")
pkg {
repo = "maven"
name = project.name
userOrg = "cloudopt"
licenses = ["Apache-2.0"]
vcsUrl = "https://github.com/cloudoptlab/cloudopt-next.git"
version {
name = "${property('project_version')}"
developers {
developer {
id = "cloudopt.net"
name = "Cloudopt"
email = "[email protected]"
url = "https://www.cloudopt.net/"
organization = "Cloudopt"
organizationUrl = "https://www.cloudopt.net/"
}
}
}
}
}
repositories {
maven {
def releaseUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
def snapshotUrl = "https://oss.sonatype.org/content/repositories/snapshots"
url = version.endsWith('SNAPSHOT') ? snapshotUrl : releaseUrl
credentials {
username findProperty("sonatypeUsername") as String
password findProperty("sonatypePassword") as String
}
}
}
}
publications = ['Publication']
publish = true
}
signing {
sign publishing.publications.mavenJava
}
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@
*/
package net.cloudopt.next.json

import com.fasterxml.jackson.databind.MapperFeature
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule
import io.vertx.core.json.Json
import io.vertx.core.json.JsonArray
import io.vertx.core.json.JsonObject
import kotlin.reflect.KClass
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule
import io.vertx.core.json.jackson.DatabindCodec
import kotlin.reflect.KClass


class DefaultJSONProvider : JsonProvider {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ object Resourcer {
* @param fileName Specify the file name
* @return File
*/
fun getFile(fileName: String): File? {
fun getFile(fileName: String): File {
return if (File(getRootClassPath() + "/" + fileName).exists()) {
File(URLDecoder.decode(getRootClassPath() + "/" + fileName), "UTF-8")
File(URLDecoder.decode(getRootClassPath() + "/" + fileName, "UTF-8"))
} else {
File(URLDecoder.decode(Resourcer::class.java.getResource("/$fileName").file, "UTF-8"))
}
Expand All @@ -47,16 +47,12 @@ object Resourcer {
* @param fileName Specify the file name
* @return FileInputStream
*/
fun getFileInputStream(fileName: String): InputStream? {
return getFile(fileName)?.inputStream()
fun getFileInputStream(fileName: String): InputStream {
return getFile(fileName).inputStream()
}

fun getFileString(fileName: String, isJson: Boolean = false): String {
return inputStreamToString(getFileInputStream(fileName)!!, isJson)
}

fun exist(fileName: String): Boolean {
return getFileInputStream(fileName) != null
return inputStreamToString(getFileInputStream(fileName), isJson)
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ object NextLauncher {

@JvmStatic
fun main(args: Array<String>) {
var args: Array<String> = arrayOf("run", "--redeploy=**/*.class", "--launcher-class=${args[0]}")
Launcher().dispatch(args)
val inputs: Array<String> = arrayOf("run", "--redeploy=**/*.class", "--launcher-class=${args[0]}")
Launcher().dispatch(inputs)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package net.cloudopt.next.web

import io.vertx.core.Vertx
import io.vertx.core.http.HttpMethod
import net.cloudopt.next.json.JsonProvider
import net.cloudopt.next.json.Jsoner
Expand Down Expand Up @@ -87,7 +86,7 @@ object NextServer {
* Scan by annotation and register as a route.
*/
private fun scan() {
ConfigManager.config.vertxDeployment.workerPoolName = verticleID
ConfigManager.config.deploymentOptions.workerPoolName = verticleID

//Set log color
Logger.configuration.color = ConfigManager.config.logColor
Expand Down Expand Up @@ -137,24 +136,24 @@ object NextServer {
annotation?.interceptor?.forEach { inClass ->
var url = annotation.value
if (url.endsWith("/")) {
url = url + "*"
url = "$url*"
} else {
url = url + "/*"
url = "$url/*"
}
if (interceptors.containsKey(url)) {
interceptors.get(url)!!.add(inClass)
interceptors[url]!!.add(inClass)
} else {
interceptors.put(url, mutableListOf(inClass))
interceptors[url] = mutableListOf(inClass)
}

}

//Get methods annotation
var functions = clazz.functions
val functions = clazz.functions

functions.forEach { function ->

var functionsAnnotations = function.annotations
val functionsAnnotations = function.annotations

var resourceUrl = ""

Expand Down Expand Up @@ -202,19 +201,19 @@ object NextServer {
}

if (resourceUrl.isNotBlank()) {
var temp = mutableMapOf<HttpMethod, Array<KClass<out Validator>>>()
temp.put(httpMethod, valids)
val temp = mutableMapOf<HttpMethod, Array<KClass<out Validator>>>()
temp[httpMethod] = valids
if (validators.containsKey(resourceUrl)) {
validators.get(resourceUrl)?.putAll(temp)
validators[resourceUrl]?.putAll(temp)
} else {
validators.put(resourceUrl, temp)
validators[resourceUrl] = temp
}
}

}

if (resourceUrl.isNotBlank()) {
var resourceTable = ResourceTable(
val resourceTable = ResourceTable(
resourceUrl,
httpMethod,
clazz,
Expand Down Expand Up @@ -333,11 +332,11 @@ object NextServer {
*/
@JvmStatic
fun startPlugins() {
NextServer.plugins.forEach { plugin ->
plugins.forEach { plugin ->
if (plugin.start()) {
NextServer.logger.info("[PLUGIN] Registered plugin:" + plugin.javaClass.name)
logger.info("[PLUGIN] Registered plugin:" + plugin.javaClass.name)
} else {
NextServer.logger.info("[PLUGIN] Started plugin was error:" + plugin.javaClass.name)
logger.info("[PLUGIN] Started plugin was error:" + plugin.javaClass.name)
}
}
}
Expand All @@ -347,9 +346,9 @@ object NextServer {
*/
@JvmStatic
fun stopPlugins() {
NextServer.plugins.forEach { plugin ->
plugins.forEach { plugin ->
if (!plugin.stop()) {
NextServer.logger.info("[PLUGIN] Stoped plugin was error:${plugin.javaClass.name}")
logger.info("[PLUGIN] Stoped plugin was error:${plugin.javaClass.name}")
}
}
}
Expand All @@ -366,7 +365,7 @@ object NextServer {
stopPlugins()
Worker.undeploy("net.cloudopt.next.web.CloudoptServerVerticle")
Worker.close()
NextServer.logger.info("Next has exited.")
logger.info("Next has exited.")
}


Expand Down
Loading

0 comments on commit b6725a7

Please sign in to comment.