Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Version 3.3.0
=============
- Upgrade build to Gradle 8.1.1
- Use [Nashorn OpenJDK](https://github.com/openjdk/nashorn) instead of Java's built-in Nashorn which is deprecated
- Upgrade Dockerfile to Java 17 (Amazon Corretto 17 on Amazon Linux 2023)
- Fix a regression in Java 11+ where the `emit` function was evaluated as `null`
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM openjdk:8-jdk as builder
FROM amazoncorretto:17-al2023-jdk as builder

RUN apt-get -qq update && apt-get install -y \
RUN yum update -y && yum install -y \
git

RUN mkdir /tmp/csv2db
Expand All @@ -9,7 +9,7 @@ COPY . .
RUN ./gradlew clean build


FROM openjdk:8-jre
FROM amazoncorretto:17-al2023-jdk

RUN mkdir -p /usr/share/csv2db
COPY --from=builder /tmp/csv2db/build/libs/* /usr/share/csv2db/
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ CompanyName, CompanyNumber,RegAddress.CareOf,RegAddress.POBox,RegAddress.Address

#### functions.js

Since version 2.2.0 csv2db will use [Nashorn JavaScript engine](http://openjdk.java.net/projects/nashorn/) (built-in to Java 8+) and fallback to [Rhino](https://www.mozilla.org/rhino/) if running on Java 7 and below. There's no switch to control this behavior.
Version 3.3.0 uses [Nashorn OpenJDK](https://github.com/openjdk/nashorn). Older versions used [Rhino](https://www.mozilla.org/rhino/) on Java 7 and below, this configuration is not supported anymore.

Note: Nashorn is not a drop-in replacement for Rhino, so some things may stop working.

Expand Down
76 changes: 36 additions & 40 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,76 +1,72 @@
import com.bmuschko.gradle.docker.tasks.image.DockerBuildImage
import org.gradle.internal.jvm.Jvm

repositories {
mavenCentral()
}

buildscript {
repositories {
jcenter()
gradlePluginPortal()
}

dependencies {
classpath 'com.bmuschko:gradle-docker-plugin:3.0.11'
classpath 'com.bmuschko:gradle-docker-plugin:9.3.1'
}
}

allprojects {
apply plugin: 'eclipse'

group = 'com.anjlab'
version = '3.2.8'
version = '3.3.0'
}

apply plugin: 'java'
apply plugin: 'maven'

def javaVersion = org.gradle.internal.jvm.Jvm.current().javaVersion
def javaVersion = Jvm.current().javaVersion

sourceCompatibility = javaVersion.java8Compatible ? javaVersion.name : 1.7
sourceCompatibility = javaVersion.java8Compatible ? javaVersion : 1.7
targetCompatibility = sourceCompatibility

println "Building for Java ${targetCompatibility}"

[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

dependencies {
testCompile 'junit:junit:4.8.2'
testCompile 'org.apache.derby:derby:10.9.1.0'
testCompile 'org.postgresql:postgresql:9.+'

compile 'net.sf.opencsv:opencsv:2.3'
compile 'commons-cli:commons-cli:1.2'
compile 'commons-io:commons-io:2.4'
compile 'com.google.code.gson:gson:2.2.2'
compile 'org.apache.commons:commons-lang3:3.1'
compile 'io.dropwizard.metrics:metrics-core:3.1.2'
compile 'org.apache.commons:commons-compress:1.10'

runtime 'commons-codec:commons-codec:1.10'
runtime 'joda-time:joda-time:2.9.9'
}
testImplementation 'junit:junit:4.13.1'
testImplementation 'org.apache.derby:derby:10.14.2.0'
testImplementation 'org.postgresql:postgresql:42.6.0'

repositories {
mavenLocal()
mavenCentral()
}
if (!project.hasProperty("jdbcDriver")) {
ext.jdbcDriver = 'org.postgresql:postgresql:42.6.0'
}

task downloadJdbcDriver {
doLast {
dependencies {
if (!project.hasProperty("jdbcDriver")) {
ext.jdbcDriver = 'org.postgresql:postgresql:9.+'
}
implementation jdbcDriver

runtime jdbcDriver
}
}
implementation 'net.sf.opencsv:opencsv:2.3'
implementation 'commons-cli:commons-cli:1.2'
implementation 'commons-io:commons-io:2.7'
implementation 'com.google.code.gson:gson:2.8.9'
implementation 'org.apache.commons:commons-lang3:3.1'
implementation 'io.dropwizard.metrics:metrics-core:3.1.2'
implementation 'org.apache.commons:commons-compress:1.21'

implementation 'commons-codec:commons-codec:1.13'
implementation 'joda-time:joda-time:2.9.9'

implementation 'org.openjdk.nashorn:nashorn-core:15.4'
}

tasks.register('downloadJdbcDriver')

classes.dependsOn downloadJdbcDriver

task copyDeps(type: Copy) {
tasks.register('copyDeps', Copy) {
into "$buildDir/libs/lib"
from configurations.runtime
from configurations.runtimeClasspath
}

task copyShellScripts(type: Copy) {
tasks.register('copyShellScripts', Copy) {
into "$buildDir/libs"
from 'src/main/shell'
}
Expand All @@ -80,7 +76,7 @@ jar { dependsOn copyDeps, copyShellScripts }

apply plugin: 'com.bmuschko.docker-remote-api'

task dockerBuildImage(type: DockerBuildImage) {
tasks.register('dockerBuildImage', DockerBuildImage) {
inputDir = projectDir
tags = [ 'anjlab/csv2db:latest', 'anjlab/csv2db:' + version ]
images.addAll(['anjlab/csv2db:latest', 'anjlab/csv2db:' + version])
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-all.zip
3 changes: 2 additions & 1 deletion src/main/java/com/anjlab/csv2db/Importer.java
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,8 @@ private Runnable createConsumer(final Mediator mediator, final int threadId)
StringBuilder emitFunctionDeclaration = new StringBuilder()
.append("function ").append(threadLocalEmit).append("(nameValues) {")
.append(threadLocalStrategy).append(".handleRecord(nameValues);")
.append("}");
.append("};")
.append(threadLocalEmit);

try
{
Expand Down