From 9f582bf321b545eb569bd1d9a4d8aa62eacb9bdc Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Mon, 2 Sep 2019 17:03:18 +0100 Subject: [PATCH] JAL-3210 cleaning up dependencies in build.gradle and added a [not currently working] HTTP server for localhost --- build.gradle | 42 +++++++++++++++++++++++++++++++++++------- gradle.properties | 7 +++++-- 2 files changed, 40 insertions(+), 9 deletions(-) diff --git a/build.gradle b/build.gradle index 7890fd0..184e71e 100644 --- a/build.gradle +++ b/build.gradle @@ -135,7 +135,7 @@ eclipse { } cp.entries.removeAll(removeTheseToo) - cp.entries += new Output("bin/main") + cp.entries += new Output(eclipse_bin_dir+"/main") cp.entries += new Library(fileReference(helpParentDir)) cp.entries += new Library(fileReference(resourceDir)) @@ -290,11 +290,11 @@ def tempEclipseWorkspace = "" task jalviewjsSetTempEclipseWorkspace { tempEclipseWorkspace = file(jalviewjs_eclipse_workspace) - if (!tempEclipseWorkspace.exists() && jalviewjs_eclipse_workspace.startsWith(File.separator)) { + if (!tempEclipseWorkspace.exists()) { tempEclipseWorkspace = File.createTempDir() - print("ECLIPSE WORKSPACE: "+tempEclipseWorkspace.getPath()) tempEclipseWorkspace.deleteOnExit() } + println("ECLIPSE WORKSPACE: "+tempEclipseWorkspace.getPath()) } task jalviewjsEclipseSetup { @@ -345,8 +345,11 @@ task jalviewjsCopySiteResources (type: Copy) { inputs.files inputFiles } -task cleanJalviewjsSite { - delete jalviewjs_site_dir +task cleanJalviewjs { + delete jalviewDir+"/"+jalviewjs_site_dir + delete jalviewDir+"/"+eclipse_bin_dir + delete file(tempEclipseWorkspace.getAbsolutePath()+"/.metadata") + delete jalviewDir+"/"+jalviewjs_j2s_settings } task jalviewjsProjectImport(type: Exec) { @@ -365,10 +368,15 @@ task jalviewjsProjectImport(type: Exec) { } task jalviewjsTranspile(type: Exec) { + dependsOn jalviewjsCreateJ2sSettings dependsOn jalviewjsProjectImport dependsOn jalviewjsEclipsePaths executable(eclipseBinary) args(["-nosplash", "--launcher.suppressErrors", "-application", "org.eclipse.jdt.apt.core.aptBuild", "-data", tempEclipseWorkspace, "-"+jalviewjs_eclipseBuildArg, eclipse_project_name ]) + inputs.dir(sourceDir) + outputs.dir(eclipse_bin_dir+"/main") + outputs.file(eclipse_bin_dir+"/main/jalview/bin/Jalview.class") + outputs.dir(jalviewjs_site_dir+"/"+jalviewjs_j2s_subdir) } task jalviewjsBuildSite { @@ -390,13 +398,33 @@ task jalviewjsSiteTar(type: Tar) { compression Compression.GZIP from jalviewjs_site_dir - into jalviewjs_site_dir + into jalviewjs_site_dir // this is inside the tar file inputs.dir(jalviewjs_site_dir) } task jalviewjs { - dependsOn jalviewjsCreateJ2sSettings dependsOn jalviewjsBuildSite } +task jalviewjsServer { + //dependsOn jalviewjsBuildSite + + doLast { + SimpleHttpFileServerFactory factory = new SimpleHttpFileServerFactory() + def port = Integer.valueOf(jalviewjs_server_port) + def add = 0 + def running = false + while(add < 1000) { + try { + HttpFileServer server = factory.start(new File(jalviewDirAbsolutePath+"/"+jalviewjs_site_dir), port) + running = true + } catch (Exception e) { + port++; + add++; + } + } + println("SERVER STARTED on http://localhost:"+port+"/ . Ctrc+C to kill it") + java.lang.Thread.sleep(Integer.valueOf(jalviewjs_server_wait)*1000); + } +} diff --git a/gradle.properties b/gradle.properties index e30dcb5..4f3a34b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -24,6 +24,7 @@ application_codebase = *.jalview.org mainClass = jalview.bin.Jalview launcherClass = jalview.bin.Jalview eclipse_project_name = jalview +eclipse_bin_dir = bin gradlePluginsDir = gradle/plugins @@ -48,8 +49,10 @@ jalviewjs_j2s_subdir = swingjs/j2s jalviewjs_j2s_settings_file = dot_j2s jalviewjs_j2s_settings = .j2s jalviewjs_eclipse_workspace = ../tmp/eclipse-workspace -jalviewjs_eclipseBuildArg = build -#jalviewjs_eclipseBuildArg = cleanBuild +#jalviewjs_eclipseBuildArg = build +jalviewjs_eclipseBuildArg = cleanBuild +jalviewjs_server_port = 9001 +jalviewjs_server_wait = 10 j2s.compiler.status = enable -- 1.7.10.2