Skip to content

Commit

Permalink
Upgrade dependencies, switch to stand-alone distribution
Browse files Browse the repository at this point in the history
  • Loading branch information
shrimpza committed Apr 6, 2024
1 parent 5db272e commit 74dffa5
Show file tree
Hide file tree
Showing 11 changed files with 147 additions and 89 deletions.
19 changes: 10 additions & 9 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,37 @@ type: docker

steps:
- name: test
image: gradle:8.1.1-jdk17-jammy
image: gradle:8.7-jdk17-jammy
commands:
- gradle test
- export BUILD_NUMBER=${DRONE_BUILD_NUMBER}
- gradle test --no-daemon

- name: publish
image: gradle:8.1.1-jdk17-jammy
image: gradle:8.7-jdk17-jammy
volumes:
- name: build-output
path: /tmp/build/jar/
path: /tmp/build/
environment:
ARTEFACTS_USER:
from_secret: ARTEFACTS_USER
ARTEFACTS_PASSWORD:
from_secret: ARTEFACTS_PASSWORD
commands:
- apt-get update && apt-get install -y curl
- gradle execJar publish
- cp ./build/libs/* /tmp/build/jar/
- export BUILD_NUMBER=${DRONE_BUILD_NUMBER}
- gradle --no-daemon --build-cache jlinkTar publish
- cp ./build/minimum-effort-search.tgz /tmp/build/minimum-effort-search.tgz
when:
event: tag

- name: release
image: plugins/github-release
volumes:
- name: build-output
path: /tmp/build/jar/
path: /tmp/build/
settings:
api_key:
from_secret: GH_TOKEN
files: /tmp/build/jar/*
files: /tmp/build/minimum-effort-search.tgz
when:
event: tag

Expand Down
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
# Minimum Effort Search

A simple REST service exposing some RedisSearch functionality to support
simple self-hosted full-text search functionality.
A simple REST-like service exposing some
[Redis Search](https://redis.io/docs/interact/search-and-query/)
functionality to support self-hosted full-text search functionality.

## Runtime Requirements

- Java 17 JRE
- A [RediSearch](https://redis.io/docs/stack/search/) instance to connect to
- A [Redis Stack](https://redis.io/docs/install/install-stack/) instance to connect to

## Build

The project is built using Gradle and a Java 17 JDK:

```
$ ./gradlew execJar
$ ./gradlew jlinkTar
```

This generates a fat/uber jar in the `build/libs/` directory which may be
This generates a release .tgz archive in the `build/` directory which may be
used to run the service.

## Configuration and Running
Expand All @@ -26,7 +26,7 @@ The service and index schema are configured using a simple YAML config file.
A sample file may be generated by simply running:

```
java -jar minimum-effort-search-exec.jar > config.yml
bin/minimum-effort-search > config.yml
```

The above will write the file `config.yml` with some example parameters which
Expand All @@ -35,7 +35,7 @@ you may customise.
Thereafter, run the service with the config file as the first parameter:

```
java -jar minimum-effort-search-exec.jar config.yml
bin/minimum-effort-search config.yml
```

The service will start up, listening on the port you specifier in the config
Expand Down Expand Up @@ -83,7 +83,7 @@ file.
"title": "Rooi Rokkie",
...
}
},
}
]
```

Expand All @@ -92,10 +92,11 @@ file.
`GET /search?q=shirt&limit=10&offset=0`

Parameters:

- `q`: Search query string
- `limit`: Limit the result set to this number of documents
- `offset`: Return documents starting at this offset. In combination with
`limit`, allows for pagination through results.
`limit`, allows for pagination through results.

```json
{
Expand Down
103 changes: 68 additions & 35 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,36 @@ plugins {
id 'application'
id 'maven-publish'
id 'jacoco'

id 'org.gradlex.extra-java-module-info' version '1.8'
id 'org.beryx.jlink' version '3.0.1'
}

group = 'net.shrimpworks'
version = "1.6"

mainClassName = 'net.shrimpworks.mes.Main'
version = "1.7"
if (System.getenv().containsKey("BUILD_NUMBER")) {
version += ".${System.env.BUILD_NUMBER}"
} else version += ".DEV"

application {
mainClassName = 'net.shrimpworks.mes.Main'
mainModule = 'shrimpworks.redisearch'
}

compileJava {
options.release = 17
}

if (System.getenv().containsKey("DRONE_BUILD_NUMBER")) {
version = "${version}.${System.env.DRONE_BUILD_NUMBER}"
jlink {
mergedModuleName = "unreal.archive.umodrepack.merged"
options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']

imageName = "${project.name}"
imageDir = file("${buildDir}/${project.name}")

jpackage {
installerType = project.findProperty('installerType')
}
}

repositories {
Expand All @@ -25,6 +42,22 @@ repositories {
}
}

def tarBinary = artifacts.add('archives', layout.buildDirectory.file("${project.name}.tgz").get().asFile) {
type 'tgz'
builtBy 'jlinkTar'
}

tasks.register('jlinkTar', Tar) {
dependsOn jlinkZip
archiveFileName = "${jlink.imageName.get()}.tgz"
destinationDirectory = layout.buildDirectory
compression = Compression.GZIP

into("${jlink.imageName.get()}") {
from jlink.imageDir
}
}

publishing {
repositories {
maven {
Expand All @@ -43,56 +76,56 @@ publishing {
maven(MavenPublication) {
from components.java
}
mavenLatest(MavenPublication) {
pom {
version = "latest"
}
artifact tarBinary
}
}
}

dependencies {
implementation 'redis.clients:jedis:4.4.0'
implementation 'io.undertow:undertow-core:2.3.4.Final'
implementation 'redis.clients:jedis:5.1.2'
implementation 'io.undertow:undertow-core:2.3.12.Final'

implementation 'com.fasterxml.jackson.core:jackson-databind:2.14.2'
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.14.2'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.17.0'
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.17.0'

implementation 'org.slf4j:slf4j-api:2.0.5'
implementation 'org.slf4j:slf4j-simple:2.0.5'
implementation 'org.slf4j:slf4j-api:2.0.12'
implementation 'org.slf4j:slf4j-simple:2.0.12'

testImplementation 'org.junit.jupiter:junit-jupiter:5.9.2'
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.2'
}

jar {
manifest {
attributes(
'Implementation-Title': project.name,
'Implementation-Version': project.version,
'Main-Class': mainClassName,
)
}
}
extraJavaModuleInfo {
failOnMissingModuleInfo.set(false)

task execJar(type: Jar) {
// exclude jar signatures - else it invalidates our fat jar
exclude('META-INF/*.RSA', 'META-INF/*.SF', 'META-INF/*.DSA')
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
module("org.jboss.xnio:xnio-api", "xnio.api") {
exports("org.xnio")
}

archiveClassifier = "exec"
archiveFileName = "${archiveBaseName.get()}-${archiveClassifier.get()}.${archiveExtension.get()}"
from sourceSets.main.output
module("io.undertow:undertow-core", "undertow.core") {
requires("xnio.api")

dependsOn configurations.runtimeClasspath
exports("io.undertow")
exports("io.undertow.io")
exports("io.undertow.predicate")
exports("io.undertow.server")
exports("io.undertow.server.handlers")
exports("io.undertow.server.handlers.encoding")
exports("io.undertow.util")
}
}

jar {
manifest {
attributes(
'Implementation-Title': project.name,
'Implementation-Version': project.version,
'Main-Class': mainClassName,
'Class-Path': configurations.runtimeClasspath.files.collect { it.getName() }.join(' ')
)
}

// build the fat executable jar file
from {
configurations.runtimeClasspath.findAll { it.name.endsWith('jar') }.collect { zipTree(it) }
}
}

test {
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
29 changes: 17 additions & 12 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -133,26 +131,29 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -197,11 +198,15 @@ if "$cygwin" || "$msys" ; then
done
fi

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Expand Down
20 changes: 10 additions & 10 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand All @@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down
18 changes: 18 additions & 0 deletions src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
open module shrimpworks.redisearch {
requires java.base;
requires java.net.http;
requires java.desktop;

requires org.slf4j;
requires org.slf4j.simple;

requires com.fasterxml.jackson.core;
requires com.fasterxml.jackson.databind;
requires com.fasterxml.jackson.dataformat.yaml;

requires org.apache.commons.pool2;
requires redis.clients.jedis;

requires xnio.api;
requires undertow.core;
}
Loading

0 comments on commit 74dffa5

Please sign in to comment.