X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=build.gradle;fp=build.gradle;h=9aef0ff759048c6b8bd5b60c0d94e2f671cbafe3;hb=7837ecd37305f0fd7c220c43d63561fbca691f31;hp=dec0765052989b8c48bf411f85099431a57bbe5b;hpb=fbe0e3fc9fe05c1ac6182172fa923c9c0d5fe1f7;p=jalview.git diff --git a/build.gradle b/build.gradle index dec0765..9aef0ff 100644 --- a/build.gradle +++ b/build.gradle @@ -2,7 +2,8 @@ import org.apache.tools.ant.filters.ReplaceTokens import org.gradle.internal.os.OperatingSystem import org.gradle.plugins.ide.eclipse.model.* import groovy.transform.ExternalizeMethods -import org.eclipse.osgi.* +//import org.eclipse.osgi.* +import com.diffplug.gradle.GoomphCacheLocations /* buildscript { @@ -293,6 +294,20 @@ clean { + + + + + + + + + + + + + +GoomphCacheLocations.override_workspaces = file(jalviewDirAbsolutePath+"/"+goomph_workspace) oomphIde { repoEclipse goomph_eclipse_version jdt { @@ -358,18 +373,32 @@ ideJalviewjsBuild.dependsOn ideCopyDropins -def tempEclipseWorkspace = "" +def jalviewjsBuildDir +def jalviewjsSiteDir +task jalviewjsSitePath { + if (jalviewjs_site_dir.startsWith("/")) { + jalviewjsSiteDir = jalviewjs_site_dir + } else { + def relativeBuildDir = file(jalviewDirAbsolutePath).toPath().relativize(buildDir.toPath()) + jalviewjsBuildDir = "${relativeBuildDir}/jalviewjs" + jalviewjsSiteDir = jalviewjsBuildDir + "/" + jalviewjs_site_dir + } +} + +def tempEclipseWorkspace task jalviewjsSetTempEclipseWorkspace { tempEclipseWorkspace = file(jalviewjs_eclipse_workspace) if (!tempEclipseWorkspace.exists()) { - tempEclipseWorkspace = File.createTempDir() - tempEclipseWorkspace.deleteOnExit() + tempEclipseWorkspace = file("${buildDir}/tmp/eclipse-workspace") + //tempEclipseWorkspace.deleteOnExit() } println("ECLIPSE WORKSPACE: "+tempEclipseWorkspace.getPath()) } task jalviewjsUnzipFiles { + dependsOn jalviewjsSitePath + def zipFiles = fileTree(dir: jalviewjs_utils_dir+"/"+jalviewjs_libjs_dir).include("*.zip") zipFiles += jalviewjs_utils_dir+"/"+jalviewjs_swingjs_zip @@ -377,18 +406,17 @@ task jalviewjsUnzipFiles { zipFiles.each { file_zip -> copy { from zipTree(file_zip) - into jalviewjs_site_dir + into jalviewjsSiteDir } } } inputs.files zipFiles - outputs.dir jalviewjs_site_dir + outputs.dir jalviewjsSiteDir } -def eclipseBinary def eclipseDropinsDir -def eclipsePluginsDir +def eclipseBinary task jalviewjsEclipsePaths { def eclipseRoot = jalviewjs_eclipse_root if (eclipseRoot.startsWith("~")) { @@ -397,18 +425,14 @@ task jalviewjsEclipsePaths { if (OperatingSystem.current().isMacOsX()) { eclipseRoot += "/Eclipse.app" eclipseDropinsDir = eclipseRoot+"/Contents/Eclipse/dropins" - eclipsePluginsDir = eclipseRoot+"/Contents/Eclipse/plugins" eclipseBinary = eclipseRoot+"/Contents/MacOS/eclipse" } else if (OperatingSystem.current().isWindows()) { // check these paths!! eclipseDropinsDir = eclipseRoot+"/dropins" - eclipsePluginsDir = eclipseRoot+"/plugins" eclipseBinary = eclipseRoot+"/eclipse" } else { // linux or unix eclipseDropinsDir = eclipseRoot+"/dropins" - eclipsePluginsDir = eclipseRoot+"/plugins" eclipseBinary = eclipseRoot+"/eclipse" } - println("ECLIPSE ROOT: "+eclipseRoot) } task jalviewjsEclipseCopyDropins (type: Copy) { @@ -427,43 +451,39 @@ task jalviewjsEclipseCopyDropins (type: Copy) { inputs.files inputFiles } -task jalviewjsEclipseCopyPlugins (type: Copy) { - dependsOn jalviewjsEclipsePaths - def inputFiles = fileTree(jalviewjs_utils_dir+"/"+jalviewjs_eclipse_plugins_dir) - def outputDir = eclipsePluginsDir - - from inputFiles - into outputDir - def outputFiles = [] - rename { filename -> - outputFiles += outputDir+"/"+filename - null - } - outputs.files outputFiles - inputs.files inputFiles -} - task jalviewjsEclipseSetup { dependsOn jalviewjsEclipseCopyDropins - dependsOn jalviewjsEclipseCopyPlugins dependsOn jalviewjsSetTempEclipseWorkspace } task jalviewjsCreateJ2sSettings(type: WriteProperties) { + dependsOn jalviewjsSitePath outputFile (jalviewDir+"/"+jalviewjs_j2s_settings) def props = project.properties.sort { it.key } + def siteDirProperty = "j2s.site.directory" + def setSiteDir = false props.each { prop, val -> if (prop.startsWith("j2s.") && val != null) { + if (prop == siteDirProperty) { + if (!(val.startsWith("/") || val.startsWith("file://") )) { + val = jalviewjsSiteDir+"/"+val + } + setSiteDir = true + } property(prop,val) } + if (!setSiteDir) { + property(siteDirProperty,"${jalviewjsSiteDir}") + } } outputs.file(outputFile) } task jalviewjsCopyResources (type: Copy) { + dependsOn jalviewjsSitePath def inputFiles = fileTree(dir: jalviewjs_resource_dir) - def outputDir = jalviewjs_site_dir+"/"+jalviewjs_j2s_subdir + def outputDir = jalviewjsSiteDir+"/"+jalviewjs_j2s_subdir from inputFiles into outputDir @@ -477,8 +497,9 @@ task jalviewjsCopyResources (type: Copy) { } task jalviewjsCopySiteResources (type: Copy) { + dependsOn jalviewjsSitePath def inputFiles = fileTree(dir: jalviewjs_utils_dir+"/"+jalviewjs_site_resource_dir) - def outputDir = jalviewjs_site_dir + def outputDir = jalviewjsSiteDir from inputFiles into outputDir @@ -492,8 +513,9 @@ task jalviewjsCopySiteResources (type: Copy) { } task cleanJalviewjs { + dependsOn jalviewjsSitePath /* - delete jalviewDir+"/"+jalviewjs_site_dir + delete jalviewDir+"/"+jalviewjsSiteDir delete jalviewDir+"/"+eclipse_bin_dir delete file(tempEclipseWorkspace.getAbsolutePath()+"/.metadata") delete jalviewDir+"/"+jalviewjs_j2s_settings @@ -510,24 +532,58 @@ task jalviewjsProjectImport(type: Exec) { executable(eclipseBinary) args(["-nosplash", "--launcher.suppressErrors", "-application", "com.seeq.eclipse.importprojects.headlessimport", "-data", tempEclipseWorkspace.getPath(), "-import", jalviewDirAbsolutePath]) - def projdir = tempEclipseWorkspace.getPath()+"/.metadata/.plugins/org.eclipse.core.resources/.projects/jalview/org.eclipse.jdt.core/" + def projdir = tempEclipseWorkspace.getPath()+"/.metadata/.plugins/org.eclipse.core.resources/.projects/jalview/org.eclipse.jdt.core" inputs.file(jalviewDir+"/.project") outputs.dir(projdir) + outputs.upToDateWhen { file(projdir).exists() } } + + + + + + + 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 ]) + + def stdout + def stderr + doFirst { + stdout = new ByteArrayOutputStream() + stderr = new ByteArrayOutputStream() + standardOutput = new org.apache.tools.ant.util.TeeOutputStream(new FileOutputStream("${jalviewjsBuildDir}/${jalviewjs_j2s_stdout}"), stdout); + errorOutput = new org.apache.tools.ant.util.TeeOutputStream(new FileOutputStream("${jalviewjsBuildDir}/${jalviewjs_j2s_stderr}"), stderr); + } + doLast { + if (stdout.toString().contains("Error processing ")) { + // j2s did not complete transpile + throw new TaskExecutionException("Error during transpilation:\n${stderr}\n") + } + } + 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) + outputs.dir(jalviewjsSiteDir+"/"+jalviewjs_j2s_subdir) + outputs.file(jalviewjsSiteDir+jalviewjs_server_resource) + outputs.upToDateWhen { file(jalviewjsSiteDir+jalviewjs_server_resource).exists() } + } + + + + + + + task jalviewjsBuildSite { + dependsOn jalviewjsSitePath dependsOn jalviewjsUnzipFiles dependsOn jalviewjsCopyResources dependsOn jalviewjsCopySiteResources @@ -545,10 +601,10 @@ task jalviewjsSiteTar(type: Tar) { compression Compression.GZIP - from jalviewjs_site_dir + from jalviewjsSiteDir into jalviewjs_site_dir // this is inside the tar file - inputs.dir(jalviewjs_site_dir) + inputs.dir(jalviewjsSiteDir) } task jalviewjs { @@ -557,6 +613,7 @@ task jalviewjs { def jalviewjsServer = null task jalviewjsServerStart { + dependsOn jalviewjsSitePath doLast { if (jalviewjsServer != null) { @@ -569,9 +626,10 @@ task jalviewjsServerStart { def running = false while(port < start+1000 && !running) { try { - jalviewjsServer = factory.start(new File(jalviewDirAbsolutePath+"/"+jalviewjs_site_dir), port) + def doc_root = new File(jalviewDirAbsolutePath +"/"+ jalviewjsSiteDir) + jalviewjsServer = factory.start(doc_root, port) running = true - println("SERVER STARTED. Go to "+jalviewjsServer.getResourceUrl(jalviewjs_server_resource)+" . Run gradle jalviewjsServerStop to stop.") + println("SERVER STARTED with document root ${doc_root}.\nGo to "+jalviewjsServer.getResourceUrl(jalviewjs_server_resource)+" . Run gradle jalviewjsServerStop to stop.") //println("Ctrl-c to stop.");java.lang.Thread.sleep(Integer.valueOf(jalviewjs_server_wait)*1000); } catch (Exception e) { port++;