Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Convert to Gradle build #716

Closed
wants to merge 1 commit into from
Closed
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
4 changes: 1 addition & 3 deletions .classpath
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="server_scripts"/>
<classpathentry excluding=".gitignore" kind="src" path="src"/>
<classpathentry kind="src" path="performanceanddevelopment"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<attributes>
<attribute name="module" value="true"/>
Expand Down Expand Up @@ -52,7 +50,6 @@
<classpathentry kind="lib" path="/jars/lib/jars/kbase/auth/kbase-auth-0.4.4.jar"/>
<classpathentry kind="lib" path="/jars/lib/jars/junit/junit-4.12.jar"/>
<classpathentry kind="lib" path="/jars/lib/jars/hamcrest/hamcrest-core-1.3.jar"/>
<classpathentry kind="lib" path="/jars/lib/jars/kbase/auth2/kbase-auth2-test-fat-0.6.1.jar"/>
<classpathentry kind="lib" path="/jars/lib/jars/kafka/kafka-clients-2.1.0.jar"/>
<classpathentry kind="lib" path="/jars/lib/jars/kbase/shock/shock-client-0.1.0.jar"/>
<classpathentry kind="lib" path="/jars/lib/jars/amazon/V2/eventstream-1.0.1.jar"/>
Expand Down Expand Up @@ -109,5 +106,6 @@
<classpathentry kind="lib" path="/jars/lib/jars/amazon/V2/url-connection-client-2.17.214.jar"/>
<classpathentry kind="lib" path="/jars/lib/jars/amazon/V2/utils-2.17.214.jar"/>
<classpathentry kind="lib" path="/jars/lib/jars/kbase/common/kbase-common-0.2.0.jar"/>
<classpathentry kind="lib" path="/jars/lib/jars/kbase/auth2/kbase-auth2-test-fat-0.6.1.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
1 change: 0 additions & 1 deletion .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,4 @@ comment:
require_changes: no

ignore:
- "build"
- "deployment"
6 changes: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# These are explicitly windows files and should use crlf
*.bat text eol=crlf

11 changes: 3 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ jobs:
mongo: 'mongodb-linux-x86_64-ubuntu2204-7.0.4'
minio: '2019-05-23T00-29-34Z'
wired_tiger: 'true'
ant_test: 'test_quick_coverage'
gradle_test: 'testQuick'
# the current production setup
- java: '11'
mongo: 'mongodb-linux-x86_64-3.6.13'
minio: '2019-05-23T00-29-34Z'
wired_tiger: 'false'
ant_test: 'test_quick_coverage'
gradle_test: 'testQuick'
steps:
- uses: actions/checkout@v3

Expand Down Expand Up @@ -84,10 +84,6 @@ jobs:
# move to parent dir of homedir to install binaries etc
cd ..

# set up jars
git clone https://github.com/kbase/jars
export JARSDIR=$(pwd)/jars/lib/jars/

# set up arango
export ARANGODB_VER=3.9.1
export ARANGODB_V=39
Expand Down Expand Up @@ -153,8 +149,7 @@ jobs:
- name: Run tests
shell: bash
run: |
ant javadoc
ant ${{matrix.ant_test}}
./gradlew ${{matrix.gradle_test}}

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
Expand Down
247 changes: 247 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,247 @@
/*
* This file was generated by the Gradle 'init' task.
*/

// TODO TEST switch to Kotlin DSL which is now the default and apparently better
// TODO TEST avoid early configuration, see
// https://docs.gradle.org/current/userguide/task_configuration_avoidance.html
// need to avoid withType as well apparently?

plugins {
id 'java'
id 'war'
id 'jacoco'
id 'org.ajoberstar.grgit' version '4.1.1'
id 'com.github.johnrengelman.shadow' version '8.1.1'
}

// TODO NOW test shadow jar works in groups - remove JNA - commit 2
// TODO NOW get docserver working in WAR and test in docker-compose <- edit to start test server - commit 3
// TODO NOW client jar - commit 4
// TODO NOW client jar javadoc - needs java_common source - commit 4
// TODO NOW schema updater script - commit 5
// TODO NOW sdk-compile all, java, and docs - commit 6
// TODO NOW handle the git commit the same way as auth does - commit 7
// TODO NOW delete build.xml, , and Makefile - commit 8
// TODO NOW run tests from Eclipse w/o specifying classpath manually & remove sourceSets & claspath - commit 9

repositories {
mavenCentral()
}
compileJava {
options.release = 11
}

tasks.withType(Test) {
/*
* TODO TEST Figure out why tests fail without this and remove. Might have something to do
* with the stfuLoggers() call in many of the tests, might kill logging for tests that
* require it
* Although it seems to make Mongo start up correctly as well which is odd
*/
forkEvery = 1
/*
* TODO TEST split tests into mongo wrapper tests & all other tests (incl. integration).
* Set up GHA to run the non-mongo tests with a single version of mongo and run the
* mongo tests with matrixed mongo versions. Combine coverage at the end somehow
*/
systemProperty "test.cfg", "./test.cfg"
maxHeapSize = "3G"
testLogging {
exceptionFormat = 'full'
showStandardStreams = true
}
filter {
// gradle thinks that classes annotated with @RunWith are tests
excludeTestsMatching "*Tester"
}
}

tasks.withType(JacocoReport) {
reports {
xml.required = true
csv.required = true
}
}

test {
finalizedBy jacocoTestReport
}

task testQuick(type: Test) {
// for Gradle 9.0 compatibility
testClassesDirs = testing.suites.test.sources.output.classesDirs
classpath = testing.suites.test.sources.runtimeClasspath

filter {
excludeTestsMatching "*LongTest"
}
finalizedBy "jacocoTestQuickReport" // must be a string, see TODOs at head of file
}

task jacocoTestQuickReport(type: JacocoReport, dependsOn: testQuick) {
executionData(testQuick)
}

// Custom java project layout
sourceSets {
main {
java {
srcDirs = ["src"]
exclude '**/test/**'
}
}
test {
java {
srcDirs = ["src"]
include '**/test/**'
}
resources {
srcDirs = ["src"]
include "**/*.properties"
include '**/*.spec'
include '**/*instance.*'
include '**/*.instance*'
include '**/*.html'
include '**/*.css'
include '**/*.gif'
include '**/*.js'
include '**/*.png'
include '**/*.txt'
include '**/*.weirdsuffix'
}
}
}

javadoc {
options {
links "https://docs.oracle.com/en/java/javase/11/docs/api/"
links "https://www.javadoc.io/doc/com.fasterxml.jackson.core/jackson-core/2.9.9/"
links "https://www.javadoc.io/doc/com.fasterxml.jackson.core/jackson-databind/2.9.9/"
}
}

war {
webXml = file('war/web.xml')
}

configurations {
// can't directly access testImplementation, so extend and access
testimpl.extendsFrom testImplementation
}

def fromURL = { url, name ->
File file = new File("$buildDir/download/${name}.jar")
file.parentFile.mkdirs()
if (!file.exists()) {
new URL(url).withInputStream { downloadStream ->
file.withOutputStream { fileOut ->
fileOut << downloadStream
}
}
}
files(file.absolutePath)
}

dependencies {

// ### General application dependencies ###

implementation fromURL(
'https://github.com/kbase/jars/raw/master/lib/jars/kbase/auth/kbase-auth-0.4.4.jar',
'kbase-auth-0.4.4'
)
implementation fromURL(
'https://github.com/kbase/jars/raw/master/lib/jars/kbase/kidl/kbase-kidl-parser-1409261812-7863aef.jar',
'kbase-kidl-parser-1409261812-7863aef'
)
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.9.9'
implementation 'com.fasterxml.jackson.core:jackson-core:2.9.9'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.9.9'
implementation 'org.ini4j:ini4j:0.5.2'
implementation 'commons-io:commons-io:2.4'
implementation 'org.apache.commons:commons-lang3:3.1'
implementation 'commons-codec:commons-codec:1.8'
implementation 'info.picocli:picocli:4.6.1'
implementation 'org.mongodb:mongodb-driver-core:4.11.1'
implementation 'org.mongodb:mongodb-driver-sync:4.11.1'
implementation 'org.mongodb:bson-record-codec:4.11.1'
implementation 'org.mongodb:bson:4.11.1'
implementation 'org.slf4j:slf4j-api:1.7.30'
implementation 'ch.qos.logback:logback-classic:1.1.2'
implementation 'com.google.guava:guava:14.0.1'
implementation 'com.github.ben-manes.caffeine:caffeine:2.9.3'
implementation 'org.apache.kafka:kafka-clients:2.1.0'
implementation fromURL(
'https://github.com/kbase/jars/raw/master/lib/jars/kbase/handle/AbstractHandleClient-1.0.0.jar',
'AbstractHandleClient-1.0.0'
)
implementation fromURL(
'https://github.com/kbase/jars/raw/master/lib/jars/kbase/sample/SampleServiceClient-0.1.1.jar',
'SampleServiceClient-0.1.1'
)

// ### Server dependencies, specifically for java_common JsonServerServlet ###

implementation fromURL(
'https://github.com/kbase/jars/raw/master/lib/jars/kbase/common/kbase-common-0.2.0.jar',
'kbase-common-0.2.0'
)
// joda-time is required for kbase-common and syslog4j
implementation 'joda-time:joda-time:2.2'
// this is OOOOOOLD. But that probably means updating java_common
implementation 'org.eclipse.jetty.aggregate:jetty-all:7.0.0.v20091005'
implementation 'javax.servlet:servlet-api:2.5'
implementation 'javax.annotation:javax.annotation-api:1.3.2'
// Syslog4j 0.9.46 doesn't appear to be available on Maven. It apparently lives in
// a JetBrains artifact server, but that's too much trouble and there's only one version there
// anyway.
// https://mvnrepository.com/artifact/org.jetbrains/syslog4j/0.9.46
// Need to rework the java common logger to not use syslog4j at all since it's abandonware
// and has a ton of CVEs, even in the newer versions.
implementation fromURL(
'https://github.com/kbase/jars/raw/master/lib/jars/syslog4j/syslog4j-0.9.46.jar',
'syslog4j-0.9.46'
)
// needed for syslog4j
implementation 'net.java.dev.jna:jna:3.4.0'

// ### Blobstore / Shock client and dependencies ###

implementation fromURL(
'https://github.com/kbase/jars/raw/master/lib/jars/kbase/shock/shock-client-0.1.0.jar',
'shock-client-0.1.0'
)
implementation 'org.apache.httpcomponents:httpclient:4.5.9'
implementation 'org.apache.httpcomponents:httpmime:4.5.8'

// ### Amazon S3 ###

implementation('software.amazon.awssdk:s3:2.17.214') {
exclude module: 'apache-client'
exclude module: 'netty-nio-client'
}
implementation 'software.amazon.awssdk:url-connection-client:2.17.214'

// ### Test ###

testImplementation 'junit:junit:4.12'
testImplementation 'org.hamcrest:hamcrest-core:1.3'
testImplementation 'com.github.zafarkhaja:java-semver:0.9.0'
testImplementation 'nl.jqno.equalsverifier:equalsverifier:3.1.10'
testImplementation 'com.arangodb:arangodb-java-driver:6.7.2'
testImplementation 'org.mockito:mockito-core:3.0.0'

testImplementation 'commons-lang:commons-lang:2.4'
testImplementation fromURL(
'https://github.com/kbase/jars/raw/master/lib/jars/kbase/auth2/kbase-auth2-test-shadow-all-0.7.0.jar',
'kbase-auth2-test-shadow-all-0.7.0'
)
}

task showTestClassPath {
doLast {
configurations.testimpl.each { println it }
}
}

5 changes: 4 additions & 1 deletion docsource/releasenotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ VERSION: 0.14.3 (Released 2/22/2024)

UPDATES:

* The MongoDB clients have been updated to the most recent version and the service tested against Mongo 7.
* The MongoDB clients have been updated to the most recent version and the service tested
against Mongo 7.
* Gradle has replaced Ant as the build tool. As a consequence, all the built artifacts are now
located in the build directory, including the ``update_workspace_database_schema`` script.


VERSION: 0.14.2 (Released 11/9/2023)
Expand Down
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 5 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading
Loading