Skip to content

Commit

Permalink
Merge pull request #83 from RADAR-base/release-0.13.2
Browse files Browse the repository at this point in the history
Release 0.13.2
  • Loading branch information
blootsvoets committed Apr 15, 2021
2 parents 53a8bec + 0d852d8 commit 6b9755e
Show file tree
Hide file tree
Showing 11 changed files with 72 additions and 44 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ repositories {
}
dependencies {
implementation group: 'org.radarbase', name: 'radar-commons', version: '0.13.1'
implementation group: 'org.radarbase', name: 'radar-commons', version: '0.13.2'
}
```

Expand Down Expand Up @@ -69,7 +69,7 @@ repositories {
}
dependencies {
implementation group: 'org.radarbase', name: 'radar-commons-server', version: '0.13.1'
implementation group: 'org.radarbase', name: 'radar-commons-server', version: '0.13.2'
}
```

Expand All @@ -82,7 +82,7 @@ repositories {
}
dependencies {
testImplementation group: 'org.radarbase', name: 'radar-commons-testing', version: '0.13.1'
testImplementation group: 'org.radarbase', name: 'radar-commons-testing', version: '0.13.2'
}
```

Expand All @@ -94,7 +94,7 @@ repositories {
}
dependencies {
runtimeOnly group: 'org.radarbase', name: 'radar-commons-unsafe', version: '0.13.1'
runtimeOnly group: 'org.radarbase', name: 'radar-commons-unsafe', version: '0.13.2'
}
```

Expand All @@ -119,7 +119,7 @@ configurations.all {
}
dependencies {
compile group: 'org.radarbase', name: 'radar-commons', version: '0.13.2-SNAPSHOT'
compile group: 'org.radarbase', name: 'radar-commons', version: '0.13.3-SNAPSHOT'
}
```

Expand Down
35 changes: 23 additions & 12 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,38 @@
*/
plugins {
id 'com.commercehub.gradle.plugin.avro' version '0.19.1'
id("io.github.gradle-nexus.publish-plugin") version "1.0.0"
id("com.github.ben-manes.versions") version "0.38.0"
}

subprojects {
// Apply the plugins
apply plugin: 'java'
apply plugin: 'java-library'
apply plugin: 'idea'
apply plugin: 'com.github.ben-manes.versions'

//---------------------------------------------------------------------------//
// Configuration //
//---------------------------------------------------------------------------//

version = '0.13.1'
version = '0.13.2'
group = 'org.radarbase'
ext.githubRepoName = 'RADAR-base/radar-commons'

ext.slf4jVersion = '1.7.30'
ext.kafkaVersion = '2.7.0'
ext.kafkaVersion = '6.1.1-ce'
ext.avroVersion = '1.9.2'
ext.confluentVersion = '5.5.3'
ext.jacksonVersion = '2.12.1'
ext.jacksonYamlVersion = '2.12.1'
ext.confluentVersion = '6.1.1'
ext.jacksonVersion = '2.12.3'
ext.jacksonYamlVersion = '2.12.3'
ext.okhttpVersion = '4.9.1'
ext.junitVersion = '4.13.2'
ext.mockitoVersion = '3.7.7'
ext.mockitoVersion = '3.9.0'
ext.hamcrestVersion = '1.3'
ext.codacyVersion = '7.9.0'
ext.radarSchemasVersion = '0.5.15'
ext.orgJsonVersion = '20201115'
ext.codacyVersion = '11.15.0'
ext.radarSchemasVersion = '0.6.0'
ext.orgJsonVersion = '20210307'

ext.githubUrl = "https://github.com/$githubRepoName"
ext.issueUrl = "https://github.com/$githubRepoName/issues"
Expand All @@ -53,9 +56,8 @@ subprojects {
// Dependencies //
//---------------------------------------------------------------------------//
repositories {
jcenter()
mavenCentral()
maven { url 'https://packages.confluent.io/maven/' }
maven { url 'https://dl.bintray.com/typesafe/maven-releases' }
flatDir {
dirs "${project.rootDir}/libs"
}
Expand Down Expand Up @@ -108,6 +110,15 @@ subprojects {
}
}

nexusPublishing {
repositories {
sonatype {
username = project.hasProperty("ossrh.user") ? project.property("ossrh.user") : System.getenv("OSSRH_USER")
password = project.hasProperty("ossrh.password") ? project.property("ossrh.password") : System.getenv("OSSRH_PASSWORD")
}
}
}

wrapper {
gradleVersion '6.8.3'
gradleVersion '7.0'
}
14 changes: 0 additions & 14 deletions gradle/publishing.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,6 @@ publishing {
}
}
}

repositories {
maven {
name = "OSSRH"
credentials {
username = project.hasProperty("ossrh.user") ? project.property("ossrh.user") : System.getenv("OSSRH_USER")
password = project.hasProperty("ossrh.password") ? project.property("ossrh.password") : System.getenv("OSSRH_PASSWORD")
}

def releasesRepoUrl = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
def snapshotsRepoUrl = uri("https://oss.sonatype.org/content/repositories/snapshots/")
url = version.toString().endsWith("SNAPSHOT") ? snapshotsRepoUrl : releasesRepoUrl
}
}
}

signing {
Expand Down
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.8.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion radar-commons-server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ dependencies {
testImplementation group: 'org.mockito', name: 'mockito-core', version: mockitoVersion
// Direct producer uses KafkaAvroSerializer if initialized
testImplementation group: 'io.confluent', name: 'kafka-avro-serializer', version: confluentVersion
testImplementation group: 'org.radarcns', name: 'radar-schemas-commons', version: radarSchemasVersion
testImplementation group: 'org.radarbase', name: 'radar-schemas-commons', version: radarSchemasVersion
// Direct producer uses KafkaAvroSerializer if initialized
testImplementation group: 'junit', name: 'junit', version: junitVersion
testRuntimeOnly group: 'org.slf4j', name: 'slf4j-simple', version: slf4jVersion
Expand Down
4 changes: 2 additions & 2 deletions radar-commons-testing/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ dependencies {
api project(':radar-commons')
api project(':radar-commons-server')
api group: 'org.apache.avro', name: 'avro', version: avroVersion
api group: 'org.radarcns', name: 'radar-schemas-commons', version: radarSchemasVersion
api group: 'org.radarbase', name: 'radar-schemas-commons', version: radarSchemasVersion

implementation group: 'com.opencsv', name: 'opencsv', version: '5.3'
implementation group: 'com.opencsv', name: 'opencsv', version: '5.4'
implementation group: 'com.fasterxml.jackson.core' , name: 'jackson-databind' , version: jacksonVersion
implementation group: 'org.apache.kafka', name: 'kafka-clients', version: kafkaVersion
implementation (group: 'io.confluent', name: 'kafka-avro-serializer', version: confluentVersion) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@
import java.io.Closeable;
import java.io.IOException;
import java.lang.reflect.Method;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Base64;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -59,7 +62,6 @@ public class MockCsvParser<K extends SpecificRecord> implements Closeable {
*/
public MockCsvParser(MockDataConfig config, Path root)
throws IOException, CsvValidationException {
//noinspection unchecked
topic = config.parseAvroTopic();

bufferedReader = Files.newBufferedReader(config.getDataFile(root));
Expand All @@ -72,7 +74,7 @@ public MockCsvParser(MockDataConfig config, Path root)
currentLine = csvReader.readNext();
}

public AvroTopic getTopic() {
public AvroTopic<K, SpecificRecord> getTopic() {
return topic;
}

Expand Down Expand Up @@ -111,15 +113,21 @@ private <V extends SpecificRecord> V parseRecord(String[] rawValues,
V record = (V) SpecificData.newInstance(recordClass, schema);

for (Field field : schema.getFields()) {
String fieldString = rawValues[header.get(field.name())];
Integer fieldHeader = header.get(field.name());
if (fieldHeader == null) {
throw new IllegalArgumentException(
"Cannot map record field " + field.name()
+ ": no corresponding header in " + header.keySet());
}
String fieldString = rawValues[fieldHeader];
Object fieldValue = parseValue(field.schema(), fieldString);
record.put(field.pos(), fieldValue);
}

return record;
}

private static Object parseValue(Schema schema, String fieldString) {
public static Object parseValue(Schema schema, String fieldString) {
switch (schema.getType()) {
case INT:
return Integer.parseInt(fieldString);
Expand All @@ -139,12 +147,20 @@ private static Object parseValue(Schema schema, String fieldString) {
return parseUnion(schema, fieldString);
case ENUM:
return parseEnum(schema, fieldString);
case BYTES:
return parseBytes(fieldString);
default:
throw new IllegalArgumentException("Cannot handle schemas of type "
+ schema.getType());
}
}

private static ByteBuffer parseBytes(String fieldString) {
byte[] result = Base64.getDecoder()
.decode(fieldString.getBytes(StandardCharsets.UTF_8));
return ByteBuffer.wrap(result);
}

private static Object parseUnion(Schema schema, String fieldString) {
if (schema.getTypes().size() != 2) {
throw new IllegalArgumentException(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.radarbase.mock.data;

import static org.junit.Assert.assertArrayEquals;

import java.nio.ByteBuffer;
import org.apache.avro.Schema;
import org.junit.Test;

public class MockCsvParserTest {
@Test
public void parseValue() {
Schema schema = new Schema.Parser().parse("{\"type\":\"bytes\"}");
ByteBuffer buffer = (ByteBuffer) MockCsvParser.parseValue(schema, "ab");
assertArrayEquals(new byte[] { 105 }, buffer.array());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public void validateMissingKeyField() throws Exception {
writer.append("test,a,1,2,1\n");
}

assertValidateThrows(NullPointerException.class, config);
assertValidateThrows(IllegalArgumentException.class, config);
}

@Test
Expand All @@ -165,7 +165,7 @@ public void validateMissingValueField() throws Exception {
writer.append("test,a,b,1,2\n");
}

assertValidateThrows(NullPointerException.class, config);
assertValidateThrows(IllegalArgumentException.class, config);
}

@Test
Expand Down
3 changes: 1 addition & 2 deletions radar-commons-unsafe/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ sourceCompatibility = '1.8'
// Sources and classpath configurations //
//---------------------------------------------------------------------------//

configurations.compile {
configurations.implementation {
resolutionStrategy.cacheChangingModulesFor 0, 'SECONDS'
}

// In this section you declare where to find the dependencies of your project
repositories {
maven { url 'https://jitpack.io' }
maven { url 'https://oss.jfrog.org/artifactory/oss-snapshot-local' }
}

// In this section you declare the dependencies for your production and test code
Expand Down
2 changes: 1 addition & 1 deletion radar-commons/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ dependencies {
implementation group: 'org.slf4j', name:'slf4j-api', version: slf4jVersion

testImplementation group: 'com.fasterxml.jackson.core' , name: 'jackson-databind' , version: jacksonVersion
testImplementation group: 'org.radarcns', name: 'radar-schemas-commons', version: radarSchemasVersion
testImplementation group: 'org.radarbase', name: 'radar-schemas-commons', version: radarSchemasVersion
testImplementation group: 'junit', name: 'junit', version: junitVersion
testImplementation group: 'org.mockito', name: 'mockito-core', version: mockitoVersion
testImplementation group: 'com.squareup.okhttp3', name: 'mockwebserver', version: okhttpVersion
Expand Down

0 comments on commit 6b9755e

Please sign in to comment.