Skip to content

Commit

Permalink
Merge pull request #732 from kbase/dev-gradle2_upstream
Browse files Browse the repository at this point in the history
Add kb-sdk compile tasks
  • Loading branch information
MrCreosote authored Apr 19, 2024
2 parents 7e58b12 + cceb096 commit 661daf7
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 7 deletions.
81 changes: 78 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ plugins {
id 'com.github.johnrengelman.shadow' version '8.1.1'
}

var DEFAULT_URL = "https://ci.kbase.us/services/ws"

var BUILD_DOC_ROOT = "$buildDir/docs/"
var BUILD_JAVA_DOC_DIR = "$BUILD_DOC_ROOT/javadoc"
var BUILD_OTHER_DOC_DIR = "$BUILD_DOC_ROOT/otherdoc/"
Expand All @@ -25,7 +27,9 @@ var BUILD_OTHER_DOC_DIR = "$BUILD_DOC_ROOT/otherdoc/"
var IN_JAR_DOC_DIR = "/server_docs"
var IN_JAR_JAVA_DOC_DIR = "$IN_JAR_DOC_DIR/javadoc"

// TODO NOW sdk-compile all, java, and docs - commit 6
var LOC_WS_SPEC = "$rootDir/workspace.spec"
var LOC_DOC_HTML = "$rootDir/docshtml"

// 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
Expand Down Expand Up @@ -74,10 +78,10 @@ task buildDocs {
// not needed locally, fails w/o it in docker build. *shrug*
mkdir BUILD_OTHER_DOC_DIR
copy {
from "$rootDir/workspace.spec" into BUILD_OTHER_DOC_DIR
from LOC_WS_SPEC into BUILD_OTHER_DOC_DIR
}
copy {
from "$rootDir/docshtml/" into BUILD_OTHER_DOC_DIR include "*"
from LOC_DOC_HTML into BUILD_OTHER_DOC_DIR include "*"
}
exec {
commandLine "pod2html", "--infile=$rootDir/lib/Bio/KBase/workspace/Client.pm", "--outfile=$BUILD_OTHER_DOC_DIR/workspace_perl.html"
Expand Down Expand Up @@ -177,6 +181,77 @@ war {
from(BUILD_OTHER_DOC_DIR) { into "/WEB-INF/classes/$IN_JAR_DOC_DIR" }
}

/* 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_WS_SPEC"
doLast {
exec {
commandLine "script", "-qefc", cmd
}
delete LOC_SCRIPT_TYPESCRIPT
}
}

task sdkCompileLibs {
var cmd = "kb-sdk compile " +
"--out lib " +
"--jsclname javascript/workspace/Client " +
"--plclname Bio::KBase::workspace::Client " +
"--pyclname biokbase.workspace.client " +
"--url $DEFAULT_URL " +
LOC_WS_SPEC
doLast {
exec {
commandLine "script", "-qefc", cmd
}
delete LOC_SCRIPT_TYPESCRIPT
delete "$rootDir/lib/biokbase/workspace/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_WS_SPEC
doLast {
exec {
commandLine "script", "-qefc", cmd
}
delete LOC_SCRIPT_TYPESCRIPT
}
}

task sdkCompile {
dependsOn sdkCompileHTML
dependsOn sdkCompileJava
dependsOn sdkCompileLibs
}

task generateUpdateSchemaScript {
dependsOn compileJava
doLast {
Expand Down
2 changes: 1 addition & 1 deletion lib/Bio/KBase/workspace/Client.pm
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ sub new

if (!defined($url))
{
$url = 'https://kbase.us/services/ws/';
$url = 'https://ci.kbase.us/services/ws';
}

my $self = {
Expand Down
2 changes: 1 addition & 1 deletion lib/biokbase/workspace/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def __init__(
trust_all_ssl_certificates=False,
auth_svc='https://ci.kbase.us/services/auth/api/legacy/KBase/Sessions/Login'):
if url is None:
url = 'https://kbase.us/services/ws/'
url = 'https://ci.kbase.us/services/ws'
self._service_ver = None
self._client = _BaseClient(
url, timeout=timeout, user_id=user_id, password=password,
Expand Down
2 changes: 1 addition & 1 deletion lib/javascript/workspace/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function Workspace(url, auth, auth_cb, timeout, async_job_check_time_ms, service
this.service_version = service_version;

if (typeof(_url) != "string" || _url.length == 0) {
_url = "https://kbase.us/services/ws/";
_url = "https://ci.kbase.us/services/ws";
}
var _auth = auth ? auth : { 'token' : '', 'user_id' : ''};
var _auth_cb = auth_cb;
Expand Down
2 changes: 1 addition & 1 deletion src/us/kbase/workspace/WorkspaceClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class WorkspaceClient {
private static URL DEFAULT_URL = null;
static {
try {
DEFAULT_URL = new URL("https://kbase.us/services/ws/");
DEFAULT_URL = new URL("https://ci.kbase.us/services/ws");
} catch (MalformedURLException mue) {
throw new RuntimeException("Compile error in client - bad url compiled");
}
Expand Down

0 comments on commit 661daf7

Please sign in to comment.