Skip to content

Commit

Permalink
Merge branch 'main' of github.com:pact-foundation/pact-plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
YOU54F committed Jun 7, 2024
2 parents e17144f + 5a8e1df commit fc2c414
Show file tree
Hide file tree
Showing 30 changed files with 325 additions and 1,973 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ jobs:
operating-system: [ ubuntu-latest, windows-latest, macos-12 ]
steps:
- uses: actions/checkout@v4
- name: Set up JDK 19
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 19
java-version: 21
- name: Install Protoc
uses: arduino/setup-protoc@v3
with:
Expand All @@ -42,7 +42,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
jdk: [ 11, 16, 18 ]
jdk: [ 11, 17, 21 ]
steps:
- uses: actions/checkout@v4
- name: Set up JDK
Expand Down
19 changes: 19 additions & 0 deletions cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,3 +231,22 @@ Executable is built using `cargo`.
### Requirements

Requires Rust 1.61 or later.

## Compatibility

<details><summary>Supported Platforms</summary>

| OS | Architecture | Supported | Pact Plugin CLI Version |
| ------- | ------------ | --------- | ---------------- |
| OSX | x86_64 || All |
| Linux | x86_64 || All |
| Windows | x86_64 || All |
| OSX | arm64 || All |
| Linux | arm64 || >=0.0.4 |
| Windows | arm64 || >=0.1.2 |
| Alpine | x86_64 || >=0.1.2 |
| Alpine | arm64 || >=0.1.2 |

_Note:_ From v0.1.2, Linux executables are statically built with `musl` and as designed to work against `glibc` (eg, Debian) and `musl` (eg, Alpine) based distos.

</details>
3 changes: 3 additions & 0 deletions drivers/jvm/.sdkmanrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Enable auto-env through the sdkman_auto_env config
# Add key=value pairs of SDKs to use below
java=11.0.23-tem
18 changes: 9 additions & 9 deletions drivers/jvm/build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
id 'java'
id 'org.jetbrains.kotlin.jvm' version '1.8.22'
id 'org.jetbrains.dokka' version '1.8.20'
id 'io.gitlab.arturbosch.detekt' version '1.23.4'
id 'io.gitlab.arturbosch.detekt' version '1.23.6'
id 'maven-publish'
id 'signing'
}
Expand Down Expand Up @@ -41,7 +39,8 @@ subprojects {
}
}

task javadocJar(type: Jar, dependsOn: [javadoc, dokkaJavadoc]) {
tasks.register('javadocJar', Jar) {
dependsOn = [javadoc, dokkaJavadoc]
archiveClassifier = 'javadoc'
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
from javadoc.destinationDir, dokkaJavadoc.outputDirectory
Expand All @@ -53,10 +52,11 @@ subprojects {
from sourceSets.main.allSource
}

tasks.withType(KotlinCompile).configureEach {
kotlinOptions {
jvmTarget = "11"
}
compileKotlin {
kotlinOptions.jvmTarget = '11'
}
compileTestKotlin {
kotlinOptions.jvmTarget = '11'
}

test {
Expand Down Expand Up @@ -119,6 +119,6 @@ subprojects {
}

detekt {
config = files(rootProject.file("config/detekt-config.yml"))
config.setFrom(rootProject.file("config/detekt-config.yml"))
}
}
83 changes: 48 additions & 35 deletions drivers/jvm/core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ plugins {
id 'java-library'
id 'com.google.protobuf' version '0.9.4'
id 'groovy'
id 'au.com.dius.pact' version '4.5.8'
id 'au.com.dius.pact' version '4.5.9'
}

ext {
Expand All @@ -11,53 +11,58 @@ ext {
}

dependencies {
implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.8.22'
implementation 'org.jetbrains.kotlin:kotlin-reflect:1.8.22'
compileOnly 'org.apache.tomcat:annotations-api:6.0.53'

implementation 'au.com.dius.pact.core:model:4.5.9'
implementation 'au.com.dius.pact.core:support:4.5.9'
implementation 'com.google.guava:guava:33.2.0-jre'
implementation 'com.vdurmont:semver4j:3.1.0'
implementation 'io.grpc:grpc-protobuf:1.56.1'
implementation 'io.grpc:grpc-stub:1.56.1'
implementation 'io.grpc:grpc-netty:1.56.1'
implementation "javax.annotation:javax.annotation-api:1.3.2"
implementation 'com.google.guava:guava:31.1-jre'
implementation('io.github.oshai:kotlin-logging-jvm:5.0.1') {
implementation 'commons-codec:commons-codec:1.17.0'
implementation('io.github.oshai:kotlin-logging-jvm:6.0.9') {
exclude group: 'org.jetbrains.kotlin'
}
implementation 'javax.json:javax.json-api:1.1.4'
implementation 'org.glassfish:javax.json:1.1.4'
implementation 'commons-codec:commons-codec:1.15'
implementation 'org.apache.commons:commons-lang3:3.12.0'
implementation 'au.com.dius.pact.core:support:4.5.8'
implementation 'au.com.dius.pact.core:model:4.5.8'
implementation 'org.apache.tika:tika-core:2.8.0'
implementation 'org.apache.httpcomponents.client5:httpclient5-fluent:5.2.1'
implementation 'com.moandjiezana.toml:toml4j:0.7.2'
implementation 'io.grpc:grpc-netty:1.64.0'
implementation 'io.grpc:grpc-protobuf:1.64.0'
implementation 'io.grpc:grpc-stub:1.64.0'
implementation 'io.hotmoka:toml4j:0.7.3'
implementation 'jakarta.json:jakarta.json-api:2.1.3'
implementation 'org.apache.commons:commons-lang3:3.14.0'
implementation 'org.apache.httpcomponents.client5:httpclient5-fluent:5.3.1'
implementation 'org.apache.tika:tika-core:2.9.2'
implementation 'org.jetbrains.kotlin:kotlin-reflect:1.8.22'
implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.8.22'
implementation 'org.rauschig:jarchivelib:1.2.0'
implementation 'org.apache.commons:commons-compress:1.26.1'

protobuf files('../../../proto/')

testImplementation 'org.apache.groovy:groovy:4.0.13'
testImplementation 'org.apache.groovy:groovy-json:4.0.13'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.1'
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.10.1'
testImplementation 'org.hamcrest:hamcrest:2.2'
testImplementation 'org.spockframework:spock-core:2.3-groovy-4.0'
testImplementation 'net.bytebuddy:byte-buddy:1.9.16'
testImplementation 'org.objenesis:objenesis:3.3'
testImplementation 'au.com.dius.pact.consumer:junit5:4.5.8'
testImplementation('au.com.dius.pact.consumer:groovy:4.5.8') {
// Groovy dependencies need to be first
testImplementation 'org.apache.groovy:groovy-json:4.0.21'
testImplementation 'org.apache.groovy:groovy:4.0.21'

testImplementation 'au.com.dius.pact.consumer:junit5:4.5.9'
testImplementation('au.com.dius.pact.consumer:groovy:4.5.9') {
transitive = false
}
testImplementation 'ch.qos.logback:logback-classic:1.4.8'
testImplementation 'org.mockito:mockito-core:5.4.0'
testImplementation 'org.mockito:mockito-junit-jupiter:5.4.0'
testImplementation 'org.json:json:20230618'
testImplementation 'ch.qos.logback:logback-classic:1.5.6'
testImplementation 'net.bytebuddy:byte-buddy:1.9.16'
testImplementation 'org.eclipse.parsson:parsson:1.1.6'
testImplementation 'org.hamcrest:hamcrest:2.2'
testImplementation 'org.json:json:20240303'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.2'
testImplementation 'org.mockito:mockito-core:5.12.0'
testImplementation 'org.mockito:mockito-junit-jupiter:5.12.0'
testImplementation 'org.objenesis:objenesis:3.4'
testImplementation 'org.spockframework:spock-core:2.3-groovy-4.0'

testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.2'
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.10.2'
}

protobuf {
protoc { artifact = "com.google.protobuf:protoc:3.21.12" }
protoc { artifact = "com.google.protobuf:protoc:3.25.1" }
plugins {
grpc { artifact = "io.grpc:protoc-gen-grpc-java:1.56.1" }
grpc { artifact = "io.grpc:protoc-gen-grpc-java:1.64.0" }
}
generateProtoTasks {
all()*.plugins { grpc {} }
Expand Down Expand Up @@ -91,3 +96,11 @@ pact {
}
}
}

extractIncludeTestProto {
dependsOn(processResources)
}

test {
dependsOn(jar)
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package io.pact.plugins.jvm.core

import au.com.dius.pact.core.model.ContentType
import io.github.oshai.kotlinlogging.KotlinLogging
import io.pact.plugin.Plugin
import io.github.oshai.kotlinlogging.KLogging
import java.lang.IllegalArgumentException

private val logger = KotlinLogging.logger {}

/**
* The catalogue manager stores all the entries from the core Pact framework as well as all the loaded plugins
*/
object CatalogueManager : KLogging() {
object CatalogueManager {
private val catalogue = mutableMapOf<String, CatalogueEntry>()

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package io.pact.plugins.jvm.core

import io.github.oshai.kotlinlogging.KLogging
import io.github.oshai.kotlinlogging.KotlinLogging
import java.io.StringReader
import java.lang.Thread.sleep
import java.util.concurrent.LinkedBlockingDeque
import javax.json.Json
import javax.json.JsonObject
import javax.json.stream.JsonParsingException
import jakarta.json.Json
import jakarta.json.JsonObject
import jakarta.json.stream.JsonParsingException

private val logger = KotlinLogging.logger {}

/**
* This class manages the running child process for a plugin
Expand Down Expand Up @@ -43,7 +45,7 @@ open class ChildProcess(
if (line != null) {
logger.debug { "Plugin ${manifest.name} [${process.pid()}] || $line" }
if (line.trim().startsWith("{")) {
logger.debug("Got JSON message from plugin process")
logger.debug { "Got JSON message from plugin process" }
try {
val jsonReader = Json.createReader(StringReader(line.trim()));
channel.offer(jsonReader.readObject())
Expand Down Expand Up @@ -80,6 +82,4 @@ open class ChildProcess(
open fun destroy() {
process.destroy()
}

companion object : KLogging()
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import au.com.dius.pact.core.model.PluginData
import au.com.dius.pact.core.model.generators.Generator
import au.com.dius.pact.core.model.generators.GeneratorTestMode
import au.com.dius.pact.core.support.json.JsonValue
import io.github.oshai.kotlinlogging.KLogging
import io.github.oshai.kotlinlogging.KotlinLogging

private val logger = KotlinLogging.logger {}

/**
* Interface to a content generator
Expand All @@ -33,7 +35,7 @@ interface ContentGenerator {
): OptionalBody
}

open class CatalogueContentGenerator(override val catalogueEntry: CatalogueEntry) : ContentGenerator, KLogging() {
open class CatalogueContentGenerator(override val catalogueEntry: CatalogueEntry) : ContentGenerator {
override val isCore: Boolean
get() = catalogueEntry.providerType == CatalogueEntryProviderType.CORE

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package io.pact.plugins.jvm.core
import au.com.dius.pact.core.model.OptionalBody
import au.com.dius.pact.core.model.matchingrules.MatchingRuleGroup
import au.com.dius.pact.core.support.Result
import io.github.oshai.kotlinlogging.KLogging
import io.github.oshai.kotlinlogging.KotlinLogging

private val logger = KotlinLogging.logger {}

data class ContentMismatch(
val expected: ByteArray?,
Expand Down Expand Up @@ -104,6 +106,4 @@ data class CatalogueContentMatcher(
}
}
}

companion object : KLogging()
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package io.pact.plugins.jvm.core

import javax.json.JsonNumber
import javax.json.JsonString
import javax.json.JsonValue
import jakarta.json.JsonNumber
import jakarta.json.JsonString
import jakarta.json.JsonValue

fun toInteger(value: JsonValue?) =
if (value is JsonNumber) value.intValue()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ package io.pact.plugins.jvm.core

import au.com.dius.pact.core.support.Result
import au.com.dius.pact.core.support.isNotEmpty
import io.github.oshai.kotlinlogging.KLogging
import io.github.oshai.kotlinlogging.KotlinLogging
import jakarta.json.Json
import jakarta.json.JsonObject
import jakarta.json.JsonString
import jakarta.json.JsonValue
import org.apache.commons.codec.digest.DigestUtils
import org.apache.commons.io.FilenameUtils
import org.apache.commons.io.IOUtils
Expand All @@ -18,10 +22,9 @@ import org.rauschig.jarchivelib.ArchiverFactory
import java.io.File
import java.io.StringReader
import java.util.zip.GZIPInputStream
import javax.json.Json
import javax.json.JsonObject
import javax.json.JsonString
import javax.json.JsonValue


private val logger = KotlinLogging.logger {}

interface PluginDownloader {
/**
Expand All @@ -30,7 +33,7 @@ interface PluginDownloader {
fun installPluginFromUrl(sourceUrl: String): Result<PactPluginManifest, String>
}

object DefaultPluginDownloader: PluginDownloader, KLogging() {
object DefaultPluginDownloader: PluginDownloader {
override fun installPluginFromUrl(sourceUrl: String): Result<PactPluginManifest, String> {
val response = when (val response = fetchJsonFromUrl(sourceUrl)) {
is Result.Ok -> response.value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import com.google.protobuf.ByteString
import com.google.protobuf.BytesValue
import com.google.protobuf.Struct
import com.vdurmont.semver4j.Semver
import io.github.oshai.kotlinlogging.KLogging
import io.github.oshai.kotlinlogging.KotlinLogging
import io.grpc.CallCredentials
import io.grpc.ManagedChannel
import io.grpc.ManagedChannelBuilder
Expand All @@ -52,9 +52,11 @@ import java.lang.Runtime.getRuntime
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.Executor
import java.util.concurrent.TimeUnit
import javax.json.Json
import javax.json.JsonArray
import javax.json.JsonObject
import jakarta.json.Json
import jakarta.json.JsonArray
import jakarta.json.JsonObject

private val logger = KotlinLogging.logger {}

/**
* Type of plugin dependency
Expand Down Expand Up @@ -175,7 +177,7 @@ data class DefaultPactPluginManifest(
return map
}

companion object : KLogging() {
companion object {
@JvmStatic
fun fromJson(pluginDir: File, pluginJson: JsonObject): PactPluginManifest {
val entryPoints = if (pluginJson.containsKey("entryPoints")) {
Expand Down Expand Up @@ -366,7 +368,7 @@ interface PluginManager {
): Result<InteractionVerificationResult, String>
}

object DefaultPluginManager: KLogging(), PluginManager {
object DefaultPluginManager: PluginManager {
private val PLUGIN_MANIFEST_REGISTER: MutableMap<String, PactPluginManifest> = mutableMapOf()
private val PLUGIN_REGISTER: MutableMap<String, PactPlugin> = ConcurrentHashMap()

Expand Down Expand Up @@ -1079,7 +1081,6 @@ class BearerCredentials(private val serverKey: String?) : CallCredentials() {
}
}

override fun thisUsesUnstableApi() {}
}

/**
Expand Down
Loading

0 comments on commit fc2c414

Please sign in to comment.