Skip to content

Commit

Permalink
♻️ Refactor protobuf compiler (#122)
Browse files Browse the repository at this point in the history
* ♻️ Refactor protobuf compiler

* 💚 Add google to default dependency repository

* 💚 Add google to default dependency repository

* 🐛 Fix repeated resource name generating bugs

* 🐛 Make all test pass

* 🔥 Remove legacy generator

* 🚨 Make ktlint happy

* 📝 Update Read Me

* ⬆️ Upgrade dependencies

* 🚨 Make ktlint happy

* Rxjava client generator (#146)

* 🐛 Start rocket mq consumer after application started

* ✨ Make client exception resolver as default client interceptor

* ✨ Remove grpc-protobuf dependency

* ♻️ Refactoring filter (#21)

* ♻️ Refactoring Jooq filter

* ♻️ Refactoring Message filter

* 🐛 Fix filter function bug

* 🎨 Add filterExpressionValue

* 🎨 Add expression value

* ✨ Add jooq filter library

* ♻️ Refactor filter

* ⬆️ Upgrade dependencies

* ✅ Fix tests

Co-authored-by: suikajy <[email protected]>
Co-authored-by: GuoDuanLZ <[email protected]>
  • Loading branch information
3 people authored Feb 26, 2021
1 parent 7e75077 commit 51161ca
Show file tree
Hide file tree
Showing 321 changed files with 15,095 additions and 8,234 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
java-version: 1.11
- uses: ButterCam/setup-sisyphus-build@v1
with:
dependency-repositories: local,central,snapshot,portal
snapshot-url: https://oss.sonatype.org/content/repositories/snapshots
dependency-repositories: local,central,jcenter,portal,google,snapshot
snapshot-url: https://s01.oss.sonatype.org/content/repositories/snapshots
- name: Build with Gradle
run: gradle build
4 changes: 1 addition & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,13 @@ jobs:
uses: actions/setup-java@v1
with:
java-version: 1.11
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v3
with:
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
- uses: ButterCam/setup-sisyphus-build@v1
with:
dependency-repositories: local,central,jcenter,portal,snapshot
dependency-repositories: local,central,jcenter,portal,google,snapshot
snapshot-url: https://s01.oss.sonatype.org/content/repositories/snapshots
snapshot-username: ${{ secrets.OSSRH_USERNAME }}
snapshot-password: ${{ secrets.OSSRH_PASSWORD }}
Expand Down
22 changes: 12 additions & 10 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Ready to rolling boulder with Sisyphus already? Hold on! We need to plan our rou

1. **System requirement**

- Gradle 6.5+
- Gradle 6.7+
- JDK 11+

2. **Configure Sisyphus with gradle.properties**
Expand All @@ -62,6 +62,8 @@ Ready to rolling boulder with Sisyphus already? Hold on! We need to plan our rou
```properties
# [DEV,RT] Set developer name for developing environment.
sisyphus.developer=higan
# [RT] Set environment for configuration artifact.
sisyphus.environment=production

# Use 'sisyphus.repository.<name>.url' Register maven repository for Sisyphus usage.
# [DEV,RT] Url of repository named 'snapshot'.
Expand Down Expand Up @@ -103,12 +105,12 @@ Ready to rolling boulder with Sisyphus already? Hold on! We need to plan our rou
plugins {
`java-library` // We build this project as a java library.
kotlin("jvm") version "1.3.72" // Use the kotlin plugin to compile .kt files
id("com.bybutter.sisyphus.project") version "0.0.5" // Use the sisyphus project management plugin.
id("com.bybutter.sisyphus.protobuf") version "0.0.5" // Use the sisyphus protobuf compiler plugin.
id("com.bybutter.sisyphus.project") version "0.0.22" // Use the sisyphus project management plugin.
id("com.bybutter.sisyphus.protobuf") version "0.0.22" // Use the sisyphus protobuf compiler plugin.
}

dependencies {
api("com.bybutter.sisyphus:sisyphus-grpc:0.0.5") // Dependent on sisyphus grpc runtime.
api("com.bybutter.sisyphus:sisyphus-grpc:0.0.22") // Dependent on sisyphus grpc runtime.
/*proto("com.foo.bar:baz:1.0.0")*/ // Use 'proto' configuration to config jars need to compile proto.
/*protoApi("com.foo.bar:baz:1.0.0")*/ // Use 'protoApi' configuration to config needed jars in proto compiling.
// All dependencies in 'implementation' configuration will auto add to 'protoApi' configuration.
Expand Down Expand Up @@ -163,11 +165,11 @@ Ready to rolling boulder with Sisyphus already? Hold on! We need to plan our rou
plugins {
`java-library`
kotlin("jvm") version "1.3.72"
id("com.bybutter.sisyphus.project") version "0.0.5"
id("com.bybutter.sisyphus.project") version "0.0.22"
}

dependencies {
api("com.bybutter.sisyphus.middleware:sisyphus-grpc-client:0.0.5") // Dependent on spring grpc runtime.
api("com.bybutter.sisyphus.middleware:sisyphus-grpc-client:0.0.22") // Dependent on spring grpc runtime.
api(project("schema:example-schema")) // Dependent on schema project.
}
```
Expand Down Expand Up @@ -210,13 +212,13 @@ Ready to rolling boulder with Sisyphus already? Hold on! We need to plan our rou
application
kotlin("jvm") version "1.3.72"
`kotlin-spring`
id("com.bybutter.sisyphus.project") version "0.0.5"
id("com.bybutter.sisyphus.project") version "0.0.22"
}

dependencies {
implementation("com.bybutter.sisyphus.starter:sisyphus-grpc-server-starter:0.0.5") // Dependent on spring grpc starter.
implementation("com.bybutter.sisyphus.starter:sisyphus-grpc-transcoding-starter:0.0.5") // [Optional] Enable the http-transcoding feature.
implementation("com.bybutter.sisyphus.starter:sisyphus-protobuf-type-server-starter:0.0.5") // [Optional] Enable the type server feature.
implementation("com.bybutter.sisyphus.starter:sisyphus-grpc-server-starter:0.0.22") // Dependent on spring grpc starter.
implementation("com.bybutter.sisyphus.starter:sisyphus-grpc-transcoding-starter:0.0.22") // [Optional] Enable the http-transcoding feature.
implementation("com.bybutter.sisyphus.starter:sisyphus-protobuf-type-server-starter:0.0.22") // [Optional] Enable the type server feature.
implementation(project("service:example-service")) // Dependent on service project.
}
```
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
}

dependencies {
implementation(platform("com.bybutter.sisyphus:sisyphus-dependencies:0.0.20"))
implementation(platform("com.bybutter.sisyphus:sisyphus-dependencies:protoc-SNAPSHOT"))
implementation("com.bybutter.sisyphus.tools:sisyphus-protobuf-gradle-plugin")
implementation("com.bybutter.sisyphus.tools:sisyphus-project-gradle-plugin")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin")
Expand Down
23 changes: 2 additions & 21 deletions buildSrc/src/main/kotlin/dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,14 @@ object Dependencies {
object Coroutines {
private const val group = "org.jetbrains.kotlinx"
const val core = "$group:kotlinx-coroutines-core"
const val reactor = "$group:kotlinx-coroutines-reactor"
const val guava = "$group:kotlinx-coroutines-guava"
const val jdk = "$group:kotlinx-coroutines-jdk8"
const val reactive = "$group:kotlinx-coroutines-reactive"
}
}

object Jackson {
private const val group = "com.fasterxml.jackson.core"
const val databind = "$group:jackson-databind"
const val core = "$group:jackson-core"
const val annotations = "$group:jackson-annotations"

object Module {
private const val group = "com.fasterxml.jackson.module"
Expand All @@ -32,7 +28,6 @@ object Dependencies {

object Dataformat {
private const val group = "com.fasterxml.jackson.dataformat"
const val xml = "$group:jackson-dataformat-xml"
const val yaml = "$group:jackson-dataformat-yaml"
const val properties = "$group:jackson-dataformat-properties"
const val cbor = "$group:jackson-dataformat-cbor"
Expand All @@ -46,8 +41,6 @@ object Dependencies {

const val webflux = "$group:spring-webflux"

const val tx = "$group:spring-tx"

const val amqp = "$group.amqp:spring-rabbit"

}
Expand All @@ -69,24 +62,16 @@ object Dependencies {

const val amqp = "$group:spring-boot-starter-amqp"

const val cp = "$group:spring-boot-configuration-processor"

const val jackson = "$group:spring-boot-starter-json"

const val actuator = "$group:spring-boot-starter-actuator"
}

object Data {
private const val group = "org.springframework.data"
const val mongo = "$group:spring-data-mongodb"
}
}

object Proto {
private const val group = "com.google.protobuf"

const val base = "$group:protobuf-java:3.13.0"
const val lite = "$group:protobuf-javalite"
const val base = "$group:protobuf-java"
const val apiCompiler = "com.google.api:api-compiler"
const val grpcProto = "com.google.api.grpc:proto-google-common-protos"
}
Expand All @@ -102,8 +87,6 @@ object Dependencies {

const val netty = "$group:grpc-netty"

const val proto = "$group:grpc-protobuf"

const val kotlin = "$group:grpc-kotlin-stub"
}

Expand All @@ -121,7 +104,7 @@ object Dependencies {
const val wagonHttp = "$group.wagon:wagon-http"
}

const val elastic5 = "org.elasticsearch.client:transport"
const val elastic = "org.elasticsearch.client:elasticsearch-rest-client"

const val mysql = "mysql:mysql-connector-java"

Expand Down Expand Up @@ -151,8 +134,6 @@ object Dependencies {

const val resilience4j = "io.github.resilience4j:resilience4j-retrofit"

const val lettuce = "io.lettuce:lettuce-core"

const val antlr4 = "org.antlr:antlr4"

const val swagger = "io.swagger.core.v3:swagger-core"
Expand Down
29 changes: 24 additions & 5 deletions buildSrc/src/main/kotlin/project.kt
Original file line number Diff line number Diff line change
@@ -1,20 +1,34 @@
import com.bybutter.sisyphus.project.gradle.SisyphusProjectPlugin
import com.github.benmanes.gradle.versions.VersionsPlugin
import org.gradle.api.JavaVersion
import org.gradle.api.Project
import org.gradle.api.plugins.JavaLibraryPlugin
import org.gradle.api.tasks.compile.JavaCompile
import org.gradle.api.tasks.testing.Test
import org.gradle.kotlin.dsl.dependencies
import org.gradle.kotlin.dsl.withType
import org.gradle.plugins.ide.idea.IdeaPlugin

val Project.next: Project
val Project.java: Project
get() {
pluginManager.apply(JavaLibraryPlugin::class.java)
pluginManager.apply(SisyphusProjectPlugin::class.java)

managedDependencies

tasks.withType<JavaCompile> {
sourceCompatibility = JavaVersion.VERSION_1_8.majorVersion
targetCompatibility = JavaVersion.VERSION_1_8.majorVersion
}
return this
}

val Project.next: Project
get() {
pluginManager.apply(IdeaPlugin::class.java)
pluginManager.apply(VersionsPlugin::class.java)
pluginManager.apply(SisyphusProjectPlugin::class.java)

kotlin.managedDependencies
java.kotlin.managedDependencies

dependencies {
add("testImplementation", Dependencies.junit)
Expand All @@ -23,6 +37,11 @@ val Project.next: Project
tasks.withType<Test> {
useJUnitPlatform()
}

tasks.withType<JavaCompile> {
sourceCompatibility = JavaVersion.VERSION_1_8.majorVersion
targetCompatibility = JavaVersion.VERSION_1_8.majorVersion
}
return this
}

Expand All @@ -49,9 +68,9 @@ val Project.lib: Project

val Project.proto: Project
get() {
group = "com.bybutter.sisyphus.proto"
java

managedDependencies
group = "com.bybutter.sisyphus.proto"

pluginManager.apply(JavaLibraryPlugin::class.java)
pluginManager.apply(SisyphusProjectPlugin::class.java)
Expand Down
38 changes: 20 additions & 18 deletions dependencies/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,36 +13,35 @@ javaPlatform {

dependencies {
api(platform(project(":sisyphus-bom")))
api(platform("org.springframework.boot:spring-boot-dependencies:2.3.3.RELEASE"))
api(platform("org.springframework.boot:spring-boot-dependencies:2.4.2"))
api(platform("io.micrometer:micrometer-bom:1.6.3"))
api(platform("org.jetbrains.kotlin:kotlin-bom:1.3.72"))
api(platform("org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.3.8"))
api(platform("org.jetbrains.kotlin:kotlin-bom:1.4.31"))
api(platform("org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.4.2"))
api(platform("org.apache.maven:maven:3.6.3"))
api(platform("io.grpc:grpc-bom:1.31.1"))
api(platform("com.google.protobuf:protobuf-bom:3.13.0"))
api(platform("io.grpc:grpc-bom:1.36.0"))
api(platform("com.google.protobuf:protobuf-bom:3.15.0"))
api(platform("org.apache.rocketmq:rocketmq-all:4.8.0"))

constraints {
api("com.squareup:kotlinpoet:1.6.0")
api("org.elasticsearch.client:transport:5.6.3")
api("com.aliyun.hbase:alihbase-client:2.8.1")
api("com.squareup:kotlinpoet:1.7.2")
api("com.aliyun.hbase:alihbase-client:2.8.4")
api("org.reflections:reflections:0.9.12")
api("com.github.os72:protoc-jar:3.11.4")
api("io.kubernetes:client-java:9.0.2")
api("io.kubernetes:client-java:11.0.0")
api("io.netty:netty-tcnative-boringssl-static:2.0.36.Final")
api("org.apache.maven.wagon:wagon-http:3.4.1")
api("org.apache.maven.wagon:wagon-http:3.4.3")
api("org.junit.jupiter:junit-jupiter:5.7.1")
api("org.reflections:reflections:0.9.12")
api("com.squareup.okhttp3:okhttp:4.8.1")
api("com.squareup.retrofit2:retrofit:2.9.0")
api("io.github.resilience4j:resilience4j-retrofit:1.7.0")
api("org.antlr:antlr4:4.8")
api("io.github.resilience4j:resilience4j-retrofit:1.5.0")
api("org.antlr:antlr4:4.9.1")
api("io.swagger.core.v3:swagger-core:2.1.6")
api("org.jooq:jooq:3.13.4")
api("com.google.api.grpc:proto-google-common-protos:2.0.1")
api("org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.72")
api("org.jetbrains.kotlin:kotlin-allopen:1.3.72")
api("org.springframework.boot:spring-boot-gradle-plugin:2.3.3.RELEASE")
api("org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.31")
api("org.jetbrains.kotlin:kotlin-allopen:1.4.31")
api("org.springframework.boot:spring-boot-gradle-plugin:2.4.2")
api("org.jlleitschuh.gradle:ktlint-gradle:9.2.1")
api("com.github.ben-manes:gradle-versions-plugin:0.28.0")
api("com.netflix.nebula:nebula-publishing-plugin:17.3.2")
Expand All @@ -52,13 +51,16 @@ dependencies {
api("com.gradle.publish:plugin-publish-plugin:0.12.0")
api("org.eclipse.jgit:org.eclipse.jgit:5.10.0.202012080955-r")
api("com.palantir.gradle.docker:gradle-docker:0.25.0")
api("io.grpc:grpc-kotlin-stub:0.1.5")
api("io.grpc:grpc-kotlin-stub:1.0.0")
api("com.google.api:api-compiler:0.0.8")
api("com.alibaba.csp:sentinel-grpc-adapter:1.8.0")
api("com.alibaba.csp:sentinel-transport-simple-http:1.8.0")
api("com.alibaba.csp:sentinel-grpc-adapter:1.8.1")
api("com.alibaba.csp:sentinel-transport-simple-http:1.8.1")
api("com.alibaba.csp:sentinel-parameter-flow-control:1.8.1")
api("com.alibaba.csp:sentinel-datasource-redis:1.8.1")
api("com.google.protobuf:protobuf-javalite:3.14.0")
api("org.mongodb:mongodb-driver-reactivestreams:4.1.1")
api("com.android.tools.build:gradle:4.1.2")
api("com.salesforce.servicelibs:rxgrpc-stub:1.0.1")
api("com.google.api:api-common:1.10.1")
}
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.2-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
1 change: 1 addition & 0 deletions lib/sisyphus-common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ description = "Common lib of Sisyphus Project"

dependencies {
compileOnly(Dependencies.Spring.Boot.boot)
api("com.salesforce.servicelibs:rxgrpc-stub")
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,9 @@ fun <T> List<T>.contentEquals(other: List<T>?): Boolean {
return false
}

for ((index, parameter) in withIndex()) {
if (parameter != other[index]) {
return false
}
return this.zip(other).all {
it.first == it.second
}

return true
}

fun <TKey, TValue> Map<TKey, TValue>.contentEquals(other: Map<TKey, TValue>?): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ val Type.kotlinType: KType
}
is ParameterizedType -> {
(this.rawType as Class<*>).kotlin.createType(
this.actualTypeArguments.map {
it.toKTypeProjection()
}
this.actualTypeArguments.map {
it.toKTypeProjection()
}
)
}
else -> throw UnsupportedOperationException("Unsupported '$this'.")
Expand Down Expand Up @@ -168,6 +168,18 @@ val KClass<*>.allProperties: List<KProperty1<out Any, *>>
}

object Reflect {
fun tryGetClass(name: String): Class<*>? {
return try {
Class.forName(name)
} catch (e: ClassNotFoundException) {
null
}
}

fun classExist(name: String): Boolean {
return tryGetClass(name) != null
}

fun <T> getPrivateField(any: Any, name: String): T? {
return getPrivateField(any.javaClass, any, name)
}
Expand Down
Loading

0 comments on commit 51161ca

Please sign in to comment.