Skip to content
Draft
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# th2 common library (Java) (5.14.0)
# th2 common library (Java) (5.15.0)

## Usage

Expand Down Expand Up @@ -511,6 +511,16 @@ dependencies {

## Release notes

### 5.15.0-dev

+ Provided windows compatibility
+ Updated:
+ th2 gradle plugin: `0.1.3`
+ bom: `4.8.0`
+ cradle: `5.4.2-dev`
+ grpc: `1.66.0`
+ protobuf: `3.25.5`

### 5.14.0-dev

+ Separate connections for publisher and consumer (allows to consume while publishing is blocked by RabbitMQ)
Expand Down
11 changes: 6 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
id "com.exactpro.th2.gradle.base" version "0.1.1"
id "com.exactpro.th2.gradle.publish" version "0.1.1"
id "com.exactpro.th2.gradle.base" version "0.1.3"
id "com.exactpro.th2.gradle.publish" version "0.1.3"
id "org.jetbrains.kotlin.jvm" version "$kotlin_version"
id 'org.jetbrains.kotlin.kapt' version "$kotlin_version"
id "java-library"
Expand All @@ -16,11 +16,11 @@ group = 'com.exactpro.th2'
version = release_version

ext {
grpcVersion = '1.62.2'
protobufVersion = '3.25.3'
grpcVersion = '1.66.0'
protobufVersion = '3.25.5'
serviceGeneratorVersion = '3.6.1'

cradleVersion = '5.4.1-dev'
cradleVersion = '5.4.2-dev'
junitVersion = '5.10.3'

jmhVersion = '1.37'
Expand Down Expand Up @@ -159,6 +159,7 @@ dependencies {

testImplementation 'javax.annotation:javax.annotation-api:1.3.2'
testImplementation "org.junit.jupiter:junit-jupiter:$junitVersion"
testImplementation "org.junit.jupiter:junit-jupiter-params:$junitVersion"
testImplementation "org.mockito.kotlin:mockito-kotlin:5.3.1"
testImplementation 'org.jetbrains.kotlin:kotlin-test-junit5'
testImplementation "org.testcontainers:testcontainers:1.19.8"
Expand Down
17 changes: 1 addition & 16 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,19 +1,4 @@
#
# Copyright 2022-2024 Exactpro (Exactpro Systems Limited)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
release_version=5.14.0
release_version=5.15.0
kotlin_version=1.8.22
description='th2 common library (Java)'
vcs_url=https://github.com/th2-net/th2-common-j
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Exactpro (Exactpro Systems Limited)
* Copyright 2023-2024 Exactpro (Exactpro Systems Limited)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -29,7 +29,7 @@ internal class ExactproMetaInf(
private val title: String,
private val version: String
) {
private val jarPath = Path.of(url.path).parent.parent
private val jarPath: Path = url.toPath().parent.parent

private var gitEnriched = false
private var gitHash = ""
Expand Down Expand Up @@ -85,10 +85,10 @@ internal class ExactproMetaInf(

Thread.currentThread().contextClassLoader
.getResources(GIT_PROPERTIES_FILE).asSequence()
.forEach { url -> map[Path.of(url.path).parent]?.enrich(url) }
.forEach { url -> map[url.toPath().parent]?.enrich(url) }

map.values.forEach { metaInf -> K_LOGGER.info { "$metaInf" } }
} catch (e: IOException) {
} catch (e: Exception) {
K_LOGGER.warn(e) { "Manifest searching failure" }
}
}
Expand All @@ -106,10 +106,16 @@ internal class ExactproMetaInf(
attributes.getValue(Attributes.Name.IMPLEMENTATION_VERSION)
)
}
} catch (e: IOException) {
} catch (e: Exception) {
K_LOGGER.warn(e) { "Manifest '$manifestUrl' loading failure" }
return null
}
}

internal fun URL.toPath(): Path = when (protocol) {
"jar" -> URL(file).toPath() // the code below are added to provide windows compatibility
"file" -> Path.of(path)
else -> error("The '$protocol' protocol of '$this' URL can't be handled")
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright 2024 Exactpro (Exactpro Systems Limited)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.exactpro.th2.common.schema.factory

import com.exactpro.th2.common.schema.factory.ExactproMetaInf.Companion.toPath
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.CsvSource
import java.net.URL
import java.nio.file.Path
import kotlin.test.assertEquals

class ExactproMetaInfTest {

@ParameterizedTest
@CsvSource(
"""jar:file:/C:/Users/test!user/common-0.0.0.jar!/META-INF/MANIFEST.MF,/C:/Users/test!user/common-0.0.0.jar!/META-INF/MANIFEST.MF""",
"""jar:file:/home/user/common-0.0.0-dev.jar!/META-INF/MANIFEST.MF,/home/user/common-0.0.0-dev.jar!/META-INF/MANIFEST.MF"""
)
fun `convert url to path test`(url: String, path: String) {
assertEquals(Path.of(path), URL(url).toPath())
}
}