-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #91 from kbase/dev-gradle
Add gradle
- Loading branch information
Showing
17 changed files
with
614 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# | ||
# https://help.github.com/articles/dealing-with-line-endings/ | ||
# | ||
# Linux start script should use lf | ||
/gradlew text eol=lf | ||
|
||
# These are Windows script files and should use crlf | ||
*.bat text eol=crlf | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,13 @@ | ||
**master:** [![Build Status](https://travis-ci.org/kbase/narrative_method_store.svg?branch=master)](https://travis-ci.org/kbase/narrative_method_store) | **staging:** [![Build Status](https://travis-ci.org/kbase/narrative_method_store.svg?branch=staging)](https://travis-ci.org/kbase/narrative_method_store) | **develop:** [![Build Status](https://travis-ci.org/kbase/narrative_method_store.svg?branch=develop)](https://travis-ci.org/kbase/narrative_method_store) | ||
|
||
Narrative Method Store | ||
====================== | ||
|
||
A KBase service for dynamically listing and accessing specifications and documentation for Narrative methods, apps, types, and categories of methods/apps. The Narrative Interface loads available methods/apps from this service. Specifications and documentation are pulled from a github repo named [narrative_method_specs](https://github.com/kbase/narrative_method_specs). Updates to specifications and documentation on the configured branch are reflected by this service within some referesh rate, usually set to every 1-2 minutes. Additional documentation on how to construct a specification can be found in the narrative_method_specs repository. | ||
|
||
The Narrative Method Store has a CLI for developers and documenters to check the status of the method store, list and fetch specifications and documentation, and validate local changes to specifications/documentation. Instructions on deploying the CLI can be found at [docs/CLI_Deployment_Guide.md](docs/CLI_Deployment_Guide.md). | ||
|
||
The Narrative Method Store can be deployed within a standard KBase runtime environment with the standard KBase deployment process. Briefly, from within the dev_container, clone this repo into the modules directory. Rebuild any environment variables by running the dev_container bootstrap script and sourcing the user-env.sh file. Within this repo directory, run `make`, optionally `make test`, and finally `make deploy TARGET=[deployment_directory]`. | ||
|
||
Test requirements: | ||
|
||
* The `mongod` executable must be on the path | ||
|
||
To run tests: | ||
|
||
* Copy `test.cfg.example` to `test.cfg` and make any adjustments necessary | ||
* `ant test` | ||
* `./gradlew test` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,260 @@ | ||
/* | ||
* This file was generated by the Gradle 'init' task. | ||
*/ | ||
|
||
plugins { | ||
id 'java' | ||
id 'war' | ||
id 'jacoco' | ||
} | ||
|
||
var DEFAULT_URL = "https://ci.kbase.us/services/narrative_method_store/rpc" | ||
|
||
var LOC_NMS_SPEC = "$rootDir/NarrativeMethodStore.spec" | ||
var LOC_DOC_HTML = "$rootDir/docshtml" | ||
|
||
// TODO NOW update dockerfile | ||
// TODO NOW delete build.xml and Makefile | ||
// TODO NOW run tests from Eclipse w/o specifying classpath manually & remove sourceSets & classpath | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
compileJava { | ||
// TODO BUILD remove when we no longer support java 8, use `options.release = 11` if needed | ||
java.sourceCompatibility = JavaVersion.VERSION_1_8 | ||
java.targetCompatibility = JavaVersion.VERSION_1_8 | ||
} | ||
|
||
javadoc { | ||
/* We don't actually need the full javadoc for anything, so just hijack this task for | ||
* building the client javadocs. If we ever need the full javadocs make a new task for the | ||
* client java docs | ||
*/ | ||
// TODO DOCS currently java-common and auth links don't work. ROI for fixing them is low. | ||
failOnError = false // fixing this would be a lot of work | ||
options { | ||
// I don't know why this isn't working, but it's not worth spending time on right now | ||
links "https://docs.oracle.com/javase/8/docs/api/" | ||
} | ||
include "**/narrativemethodstore/*.java" | ||
exclude "**/narrativemethodstore/NarrativeMethodStoreServer.java" | ||
exclude "**/narrativemethodstore/ImageServlet.java" | ||
include "**/common/service/Tuple*.java" | ||
} | ||
|
||
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 | ||
systemProperty "test.cfg", "./test.cfg" | ||
testLogging { | ||
exceptionFormat = 'full' | ||
showStandardStreams = true | ||
} | ||
finalizedBy jacocoTestReport | ||
} | ||
|
||
// TODO TEST add a test that starts the server in a docker container and checks some simple cmds | ||
|
||
jacocoTestReport { | ||
reports { | ||
xml.required = true | ||
csv.required = true | ||
} | ||
} | ||
|
||
jar { | ||
// Much like javadoc, we hijack this task to build the client jar, since we don't need | ||
// a service jar | ||
include "us/kbase/narrativemethodstore/*.class" | ||
exclude "us/kbase/narrativemethodstore/NarrativeMethodStoreServer*.class" // exclude anonymous classes | ||
exclude "us/kbase/narrativemethodstore/ImageServlet*.class" // exclude anonymous classes | ||
include "us/kbase/common/service/Tuple*.class" | ||
archiveAppendix = 'client' | ||
} | ||
|
||
war { | ||
webXml = file('war/web.xml') | ||
} | ||
|
||
/* SDK compile notes: | ||
* kb-sdk starts a docker container in interactive mode. Gradle's commandLine doesn't allocate | ||
* a tty so the command fails. | ||
* I tried using a ProcessBuilder and | ||
* https://docs.oracle.com/en%2Fjava%2Fjavase%2F11%2Fdocs%2Fapi%2F%2F/java.base/java/lang/ProcessBuilder.html#inheritIO() | ||
* but that failed also with no useful output. | ||
* | ||
* The current solution is to precede the kb-sdk call with a script call, which either | ||
* allocates a tty or fools kb-sdk into thinking there is one - not quite sure. | ||
* https://man7.org/linux/man-pages/man1/script.1.html | ||
* I tried to redirect the script log file to /dev/null with -O and --log-out but script didn't | ||
* recognize either option, hence the delete. | ||
* | ||
* This is, generally speaking, a janky mess and if someone can find a better way to do this | ||
* that'd be fantastic. | ||
*/ | ||
|
||
var LOC_SCRIPT_TYPESCRIPT = "$rootDir/typescript" | ||
|
||
// TODO GRADLE is there some way to DRY these 3 compile tasks up? Not a huge deal | ||
task sdkCompileHTML { | ||
// We want to check in the HTML so we don't put it in the build dir | ||
var cmd = "kb-sdk compile --html --out $LOC_DOC_HTML $LOC_NMS_SPEC" | ||
doLast { | ||
exec { | ||
commandLine "script", "-qefc", cmd | ||
} | ||
delete LOC_SCRIPT_TYPESCRIPT | ||
} | ||
} | ||
|
||
task sdkCompileLibs { | ||
var cmd = "kb-sdk compile " + | ||
"--out lib " + | ||
"--jsclname javascript/NarrativeMethodStore/Client " + | ||
"--plclname Bio::KBase::NarrativeMethodStore::Client " + | ||
"--pyclname biokbase.narrative_method_store.client " + | ||
"--url $DEFAULT_URL " + | ||
LOC_NMS_SPEC | ||
doLast { | ||
exec { | ||
commandLine "script", "-qefc", cmd | ||
} | ||
delete LOC_SCRIPT_TYPESCRIPT | ||
delete "$rootDir/lib/biokbase/narrative_method_store/authclient.py" | ||
} | ||
} | ||
|
||
task sdkCompileJava { | ||
// TODO GRADLE is there a variable for src/main/java when we move the code locations? | ||
var cmd = "kb-sdk compile " + | ||
"--java " + | ||
"--javasrc $rootDir/src " + | ||
"--javasrv " + | ||
"--out . " + | ||
"--url $DEFAULT_URL " + | ||
LOC_NMS_SPEC | ||
doLast { | ||
exec { | ||
commandLine "script", "-qefc", cmd | ||
} | ||
delete LOC_SCRIPT_TYPESCRIPT | ||
} | ||
} | ||
|
||
task sdkCompile { | ||
dependsOn sdkCompileHTML | ||
dependsOn sdkCompileJava | ||
dependsOn sdkCompileLibs | ||
} | ||
|
||
// Custom java project layout | ||
sourceSets { | ||
main { | ||
java { | ||
srcDirs = ["src"] | ||
exclude '**/test/**' | ||
} | ||
} | ||
test { | ||
java { | ||
srcDirs = ["src"] | ||
include '**/test/**' | ||
} | ||
resources { | ||
srcDirs = ["src"] | ||
include "**/*.properties" | ||
} | ||
} | ||
} | ||
|
||
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 'org.ini4j:ini4j:0.5.2' | ||
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.2.3' | ||
implementation 'com.fasterxml.jackson.core:jackson-databind:2.2.3' | ||
implementation 'org.mongodb:mongo-java-driver:3.10.1' | ||
implementation 'com.github.docker-java:docker-java:1.3.0' | ||
implementation 'org.yaml:snakeyaml:1.11' | ||
implementation 'org.apache.velocity:velocity:1.7' | ||
|
||
// ### | ||
// Server dependencies, specifically for java_common JsonServerServlet and | ||
// NarrativeMethodServer | ||
// ### | ||
|
||
implementation fromURL( | ||
'https://github.com/kbase/jars/raw/master/lib/jars/kbase/common/kbase-common-0.0.22.jar', | ||
'kbase-common-0.0.22' | ||
) | ||
implementation 'ch.qos.logback:logback-classic:1.1.2' | ||
implementation 'org.slf4j:slf4j-api:1.7.7' | ||
// TODO DEPS 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' | ||
) | ||
implementation 'javax.annotation:javax.annotation-api:1.2' | ||
implementation 'javax.servlet:servlet-api:2.5' | ||
// 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' | ||
// needed for syslog4j | ||
implementation 'net.java.dev.jna:jna:3.4.0' | ||
|
||
// ### Blobstore / Shock client and dependencies ### | ||
// TODO BUILD can the code that uses these be removed? I don't think the NMS | ||
// talks to Shock any more | ||
|
||
implementation fromURL( | ||
'https://github.com/kbase/jars/raw/master/lib/jars/kbase/shock/shock-client-0.0.15.jar', | ||
'shock-client-0.0.15' | ||
) | ||
implementation 'org.apache.httpcomponents:httpclient:4.3.1' | ||
implementation 'org.apache.httpcomponents:httpmime:4.3.1' | ||
|
||
// ### Test ### | ||
|
||
testImplementation 'junit:junit:4.12' | ||
testImplementation 'org.mockito:mockito-core:3.0.0' | ||
testImplementation 'org.apache.commons:commons-lang3:3.5' | ||
} | ||
|
||
task showTestClassPath { | ||
doLast { | ||
configurations.testimpl.each { println it } | ||
} | ||
} | ||
|
Oops, something went wrong.