1 import org.gradle.internal.os.OperatingSystem
2 import org.gradle.plugins.ide.eclipse.model.Output
3 import org.gradle.plugins.ide.eclipse.model.Library
5 import com.diffplug.gradle.GoomphCacheLocations
15 id 'com.diffplug.gradle.oomph.ide' version '3.18.1'
16 id 'com.diffplug.gradle.equinoxlaunch' version '3.18.1'
17 id 'com.diffplug.gradle.eclipse.mavencentral' version '3.18.1'
18 id 'com.diffplug.gradle.p2.asmaven' version '3.18.1'
21 def jalviewDirAbsolutePath = file(jalviewDir).getAbsolutePath()
22 def useIde = useGoomph.equals("true")
40 group 'eclipseDeps', {
41 repoEclipse goomph_eclipse_repo_version
42 //slicingOption 'latestVersionOnly', 'true'
43 iu 'org.eclipse.update.configurator'
46 iu 'org.eclipse.jdt.apt.core'
47 iu 'org.eclipse.jdt.core'
48 iu 'org.eclipse.jdt.annotation'
52 repo 'https://download.eclipse.org/eclipse/updates/4.13/R-4.13-201909161045/'
53 iu 'org.eclipse.debug.core'
54 iu 'org.eclipse.jdt.apt.pluggable.core'
55 iu 'org.eclipse.jdt.apt.ui'
56 iu 'org.eclipse.jdt.compiler.apt'
57 iu 'org.eclipse.jdt.compiler.tool'
58 iu 'org.eclipse.jdt.core.manipulation'
59 iu 'org.eclipse.jdt.debug'
60 iu 'org.eclipse.jdt.debug.ui'
61 iu 'org.eclipse.jdt.doc.user'
62 iu 'org.eclipse.jdt.junit'
63 iu 'org.eclipse.jdt.junit.core'
64 iu 'org.eclipse.jdt.junit4.runtime'
65 iu 'org.eclipse.jdt.junit4.runtime'
66 iu 'org.eclipse.jdt.junit5.runtime'
67 iu 'org.eclipse.jdt.launching'
68 iu 'org.eclipse.jdt.ui'
70 iu 'org.eclipse.jdt.launching.macosx'
71 iu 'org.eclipse.jdt.launching.ui.macosx'
73 group 'eclipseOrbit', {
74 repo goomph_orbit_repo
75 slicingOption 'latestVersionOnly', 'true'
78 iu 'javax.servlet.jsp'
80 iu 'org.apache.batik.constants'
81 iu 'org.apache.batik.css'
82 iu 'org.apache.batik.i18n'
83 iu 'org.apache.batik.util'
84 iu 'org.apache.commons.beanutils'
85 iu 'org.apache.commons.collections'
86 iu 'org.apache.commons.jxpath'
87 iu 'org.apache.commons.io'
88 iu 'org.apache.commons.logging'
89 iu 'org.apache.xmlgraphics'
91 iu 'org.w3c.dom.events'
101 source.addMaven('org.eclipse.platform:org.eclipse.osgi:3.14.0')
103 compile 'eclipseOrbit:org.apache.ant:1.10.5.v20190526-1402'
105 compile 'org.osgi:org.osgi.service.component:1.4.0'
109 jalviewjsIde name: 'net.sf.j2s.core-3.2.4'
110 jalviewjsIde name: 'com.seeq.eclipse.importprojects-1.4.0'
121 eclipseMavenCentral {
122 // TODO: How do I add these to the jalviewjsIde configuration and not the compile configuration?
123 release goomph_eclipse_repo_version, {
125 //def platformCode="cocoa.macosx.x86_64"
126 //compile 'org.eclipse.swt.'+platformCode
127 useNativesForRunningPlatform()
128 compile 'org.eclipse.swt'
130 compile 'org.eclipse.ant.core'
131 compile 'org.eclipse.compare.core'
132 compile 'org.eclipse.core.commands'
133 compile 'org.eclipse.core.contenttype'
134 compile 'org.eclipse.core.jobs'
135 compile 'org.eclipse.core.expressions'
136 compile 'org.eclipse.core.filesystem'
137 compile 'org.eclipse.core.resources'
138 compile 'org.eclipse.core.runtime'
139 compile 'org.eclipse.core.variables'
140 compile 'org.eclipse.equinox.common'
141 compile 'org.eclipse.equinox.ds'
142 compile 'org.eclipse.equinox.app'
143 compile 'org.eclipse.equinox.registry'
144 compile 'org.eclipse.equinox.preferences'
145 compile 'org.eclipse.jface'
146 compile 'org.eclipse.osgi'
147 compile 'org.eclipse.osgi.services'
148 compile 'org.eclipse.ui'
149 compile 'org.eclipse.ui.workbench'
150 compile 'org.eclipse.team.core'
151 compile 'org.eclipse.text'
153 compile 'org.eclipse.e4.core.commands'
154 compile 'org.eclipse.e4.core.contexts'
155 compile 'org.eclipse.e4.core.di'
156 compile 'org.eclipse.e4.core.di.annotations'
157 compile 'org.eclipse.e4.core.di.extensions.supplier'
158 compile 'org.eclipse.e4.core.services'
159 compile 'org.eclipse.e4.ui.bindings'
160 compile 'org.eclipse.e4.ui.model.workbench'
161 compile 'org.eclipse.e4.ui.workbench'
162 compile 'org.eclipse.e4.ui.workbench.swt'
163 compile 'org.eclipse.e4.ui.css.core'
164 compile 'org.eclipse.e4.ui.css.swt'
165 compile 'org.eclipse.e4.ui.css.swt.theme'
166 compile 'org.eclipse.e4.ui.services'
167 compile 'org.eclipse.e4.ui.di'
169 //compile 'org.eclipse.e4.core.di.internal.extensions'
171 // org.eclipse.update.configurator deliberately kept at 3.3.400 see https://github.com/diffplug/goomph/issues/69
172 // this module downloaded in equinoxLaunch configuration (to specify version)
173 //compile 'org.eclipse.update.configurator'
191 mainClassName = launcherClass
192 def classes = "$jalviewDir/$classesDir"
194 // configure classpath/args for j8/j11 compilation
198 def compile_source_compatibility
199 def compile_target_compatibility
202 buildProperties = jalviewDir + "/" + classesDir +"/" + buildPropertiesFile
210 def JAVA_INTEGER_VERSION
211 //def additional_compiler_args = []
212 // this property is for the Java library used in eclipse
213 def eclipse_java_runtime_name
214 if (JAVA_VERSION.equals("1.8")) {
215 JAVA_INTEGER_VERSION = "8"
218 libDistDir = j8libDir
219 compile_source_compatibility = 1.8
220 compile_target_compatibility = 1.8
221 eclipse_java_runtime_name = "JavaSE-1.8"
222 } else if (JAVA_VERSION.equals("11")) {
223 JAVA_INTEGER_VERSION = "11"
225 libDistDir = j11libDir
226 compile_source_compatibility = 11
227 compile_target_compatibility = 11
228 eclipse_java_runtime_name = "JavaSE-11"
229 /* compile without modules -- using classpath libraries
230 additional_compiler_args += [
231 '--module-path', ext.modules_compileClasspath.asPath,
232 '--add-modules', j11modules
235 } else if (JAVA_VERSION.equals("12") || JAVA_VERSION.equals("13")) {
236 JAVA_INTEGER_VERSION = JAVA_VERSION
238 libDistDir = j11libDir
239 compile_source_compatibility = JAVA_VERSION
240 compile_target_compatibility = JAVA_VERSION
241 eclipse_java_runtime_name = "JavaSE-11"
242 /* compile without modules -- using classpath libraries
243 additional_compiler_args += [
244 '--module-path', ext.modules_compileClasspath.asPath,
245 '--add-modules', j11modules
249 throw new GradleException("JAVA_VERSION=$JAVA_VERSION not currently supported by Jalview")
257 srcDirs "$jalviewDir/$sourceDir"
258 outputDir = file("$classes")
262 srcDirs "$jalviewDir/$resourceDir"
265 compileClasspath = files(sourceSets.main.java.outputDir)
266 compileClasspath += fileTree(dir: "$jalviewDir/$libDir", include: ["*.jar"])
268 runtimeClasspath = compileClasspath
275 name = eclipse_project_name
277 natures 'org.eclipse.jdt.core.javanature',
278 'org.eclipse.buildship.core.gradleprojectnature'
280 buildCommand 'org.eclipse.jdt.core.javabuilder'
281 buildCommand 'org.eclipse.buildship.core.gradleprojectbuilder'
285 //defaultOutputDir = sourceSets.main.java.outputDir
287 configurations.each{ if (it.isCanBeResolved()) {
292 minusConfigurations += removeThese
293 plusConfigurations = [ ]
297 def removeTheseToo = []
298 HashMap<String, Boolean> addedSrcPath = new HashMap<>();
299 cp.entries.each { entry ->
300 if (entry.kind == 'src') {
301 if (addedSrcPath.getAt(entry.path) || !(entry.path == "src" || entry.path == "test")) {
302 removeTheseToo += entry
304 addedSrcPath.putAt(entry.path, true)
308 cp.entries.removeAll(removeTheseToo)
310 if (file(eclipse_bin_dir+"/main").isDirectory()) {
311 cp.entries += new Output(eclipse_bin_dir+"/main")
313 if (file(helpParentDir).isDirectory()) {
314 cp.entries += new Library(fileReference(helpParentDir))
316 if (file(resourceDir).isDirectory()) {
317 cp.entries += new Library(fileReference(resourceDir))
320 HashMap<String, Boolean> addedLibPath = new HashMap<>();
322 // changing from sourcesets.main.classpath to specific Java version lib
323 //sourceSets.main.compileClasspath.each{
324 fileTree("$jalviewDir/$libDistDir").include("**/*.jar").include("*.jar").each {
325 //don't want to add outputDir as eclipse is using its own output dir in bin/main
326 if (it.isDirectory() || ! it.exists()) {
327 // don't add dirs to classpath
330 def itPath = it.toString()
331 if (itPath.startsWith(jalviewDirAbsolutePath+"/")) {
332 itPath = itPath.substring(jalviewDirAbsolutePath.length()+1)
334 if (addedLibPath.get(itPath)) {
335 //println("Not adding duplicate entry "+itPath)
337 //println("Adding entry "+itPath)
338 cp.entries += new Library(fileReference(itPath))
339 addedLibPath.put(itPath, true)
346 containers 'org.eclipse.buildship.core.gradleclasspathcontainer'
350 // for the IDE, use java 11 compatibility
351 sourceCompatibility = compile_source_compatibility
352 targetCompatibility = compile_target_compatibility
353 javaRuntimeName = eclipse_java_runtime_name
357 withProperties { props ->
358 def jalview_prefs = new Properties()
359 def ins = new FileInputStream(jalviewDirAbsolutePath+"/"+eclipse_extra_jdt_prefs_file)
360 jalview_prefs.load(ins)
362 jalview_prefs.forEach { t, v ->
363 if (props.getAt(t) == null) {
372 //synchronizationTasks eclipseClasspath
373 //autoBuildTasks eclipseClasspath
380 sourceCompatibility = compile_source_compatibility
381 targetCompatibility = compile_target_compatibility
382 //options.compilerArgs = additional_compiler_args
383 print ("Setting target compatibility to "+targetCompatibility+"\n")
389 delete sourceSets.main.java.outputDir
414 task jalviewjsSetEclipseWorkspace {
415 def eclipseWsDir = useIde?goomph_workspace:jalviewjs_eclipse_workspace
416 eclipseWorkspace = file(eclipseWsDir)
417 if (!eclipseWorkspace.exists()) {
418 eclipseWorkspace = file("${buildDir}/tmp/eclipse-workspace")
419 //eclipseWorkspace.deleteOnExit()
421 com.diffplug.gradle.GoomphCacheLocations.override_workspaces = file(eclipseWorkspace.getAbsolutePath())
422 eclipseWorkspace = oomphIde.workspaceRegistry.workspaceDir(project, file(oomphIde.ideDir))
424 println("ECLIPSE WORKSPACE: "+eclipseWorkspace.getPath())
431 repoEclipse goomph_eclipse_version
436 //executionEnvironments = [ eclipse.jdt.javaRuntimeName ]
439 //compilerComplianceLevel( JAVA_INTEGER_VERSION )
442 repo "https://download.eclipse.org/releases/${goomph_eclipse_version_name}/"
443 feature goomph_eclipse_jee_feature, goomph_eclipse_jee_version
445 //iu 'org.eclipse.osgi'
449 repo goomph_repo_buildship
450 feature goomph_feature_buildship
455 workspaceProp '.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.launching.prefs', {
456 it.put('org.eclipse.jdt.launching.PREF_VM_XML', goomph_PREF_VM_XML)
464 ideJalviewjsBuildSetup {
466 source.addConfiguration(configurations.compile)
467 source.addConfiguration(configurations.jalviewjsIde)
469 source.addMaven('eclipseOrbit:org.apache.ant:1.10.5.v20190526-1402')
470 source.addMaven('eclipseOrbit:javax.servlet:3.1.0.v201410161800')
471 source.addMaven('eclipseOrbit:javax.servlet.jsp:2.2.0.v201112011158')
472 source.addMaven('eclipseOrbit:javax.el:2.2.0.v201303151357')
473 source.addMaven('eclipseOrbit:org.apache.batik.constants:1.11.0.v20190515-0436')
474 source.addMaven('eclipseOrbit:org.apache.batik.css:1.11.0.v20190515-0436')
475 source.addMaven('eclipseOrbit:org.apache.batik.i18n:1.11.0.v20190515-0436')
476 source.addMaven('eclipseOrbit:org.apache.batik.util:1.11.0.v20190515-0436')
477 source.addMaven('eclipseOrbit:org.apache.commons.beanutils:1.8.0.v201205091237')
478 source.addMaven('eclipseOrbit:org.apache.commons.collections:3.2.2.v201511171945')
479 source.addMaven('eclipseOrbit:org.apache.xmlgraphics:2.3.0.v20190515-0436')
480 source.addMaven('eclipseOrbit:org.apache.commons.jxpath:1.3.0.v200911051830')
481 source.addMaven('eclipseOrbit:org.apache.commons.io:2.6.0.v20190123-2029')
482 source.addMaven('eclipseOrbit:org.apache.commons.logging:1.2.0.v20180409-1502')
483 source.addMaven('eclipseOrbit:org.jdom:1.1.1.v201101151400')
484 source.addMaven('eclipseOrbit:org.w3c.dom.svg:1.1.0.v201011041433')
485 source.addMaven('eclipseOrbit:org.w3c.dom.smil:1.0.1.v200903091627')
486 source.addMaven('eclipseOrbit:org.w3c.dom.events:3.0.0.draft20060413_v201105210656')
488 source.addMaven('org.eclipse.birt.runtime:com.ibm.icu:56.1.0.v201601250100')
489 source.addMaven('javax.inject:com.springsource.javax.inject:1.0.0')
490 source.addMaven('org.apache.felix:org.apache.felix.scr:2.1.16')
491 source.addMaven('org.osgi:org.osgi.framework:1.9.0')
492 source.addMaven('org.osgi:org.osgi.service.component:1.4.0')
493 source.addMaven('org.osgi:org.osgi.service.event:1.4.0')
494 source.addMaven('org.osgi:org.osgi.util.promise:1.1.1')
495 source.addMaven('org.osgi:org.osgi.util.function:1.1.0')
496 //source.addMaven('org.eclipse.jdt:org.eclipse.jdt.apt.core:3.6.500')
497 //source.addMaven('org.eclipse.jdt:org.eclipse.jdt.core:3.19.0')
498 //source.addMaven('org.eclipse.jdt:org.eclipse.jdt.annotation:2.2.300')
500 source.addMaven('ecjDeps:org.eclipse.debug.core:3.14.0.v20190812-1404')
501 source.addMaven('ecjDeps:org.eclipse.jdt.annotation:2.2.300.v20190328-1431')
502 source.addMaven('ecjDeps:org.eclipse.jdt.apt.core:3.6.500.v20190703-0914')
503 source.addMaven('ecjDeps:org.eclipse.jdt.core:3.19.0.v20190903-0936')
504 source.addMaven('ecjDeps:org.eclipse.jdt.apt.pluggable.core:1.2.400.v20190626-1334')
505 //source.addMaven('ecjDeps:org.eclipse.jdt.apt.ui:3.6.300.v20190727-1243')
506 source.addMaven('ecjDeps:org.eclipse.jdt.compiler.apt:1.3.700.v20190704-1731')
507 source.addMaven('ecjDeps:org.eclipse.jdt.compiler.tool:1.2.600.v20190322-0450')
508 //source.addMaven('ecjDeps:org.eclipse.jdt.core.manipulation:1.12.100.v20190904-0645')
509 source.addMaven('ecjDeps:org.eclipse.jdt.debug:3.13.100.v20190902-1050')
510 //source.addMaven('ecjDeps:org.eclipse.jdt.debug.ui:3.10.400.v20190815-2202')
511 source.addMaven('ecjDeps:org.eclipse.jdt.doc.user:3.15.400.v20190904-0724')
512 //source.addMaven('ecjDeps:org.eclipse.jdt.junit:3.11.500.v20190809-1613')
513 //source.addMaven('ecjDeps:org.eclipse.jdt.junit.core:3.10.400.v20190625-1910')
514 //source.addMaven('ecjDeps:org.eclipse.jdt.junit4.runtime:1.1.1000.v20190510-0840')
515 //source.addMaven('ecjDeps:org.eclipse.jdt.junit4.runtime:1.1.1000.v20190510-0840')
516 //source.addMaven('ecjDeps:org.eclipse.jdt.junit5.runtime:1.0.600.v20190610-0439')
517 source.addMaven('ecjDeps:org.eclipse.jdt.launching:3.15.0.v20190826-1639')
518 //source.addMaven('ecjDeps:org.eclipse.jdt.ui:3.19.0.v20190827-1733')
520 //source.addMaven('ecjDeps:org.eclipse.jdt.launching.macosx:3.4.300.v20190510-0639')
521 //source.addMaven('ecjDeps:org.eclipse.jdt.launching.ui.macosx:1.2.300.v20190510-0639')
523 //source.addMaven('')
525 // org.eclipse.update.configurator deliberately kept at 3.3.400 see https://github.com/diffplug/goomph/issues/69
526 source.addMaven('org.eclipse.platform:org.eclipse.update.configurator:3.3.400')
529 launchTask 'ideJalviewjsImport', {
530 it.args = ["-consoleLog", "-nosplash", "--launcher.suppressErrors", "-application", "com.seeq.eclipse.importprojects.headlessimport", "-data", eclipseWorkspace.getPath(), "-import", jalviewDirAbsolutePath ]
533 launchTask 'ideJalviewjsBuild', {
535 oomphIde.workspaceProp '.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.launching.prefs', {
536 it.put('org.eclipse.jdt.launching.PREF_VM_XML', goomph_PREF_VM_XML)
539 def args = ["-consoleLog", "-nosplash", "--launcher.suppressErrors", "-application", "org.eclipse.jdt.apt.core.aptBuild", "-data", eclipseWorkspace.getPath(), "-"+jalviewjs_eclipseBuildArg, eclipse_project_name ]
540 println("ARGS="+args)
549 task ideCopyDropins (type: Copy) {
552 def inputFiles = fileTree(jalviewjs_utils_dir+"/"+jalviewjs_eclipse_dropins_dir)
553 def outputDir = oomphIde.ideDir + "/" + com.diffplug.gradle.FileMisc.macContentsEclipse() + "/dropins"
559 outputFiles += outputDir+"/"+filename
560 println("COPYING ${filename} to ${outputFiles}")
563 outputs.files outputFiles
564 inputs.files inputFiles
569 ideSetupWorkspace.dependsOn jalviewjsSetEclipseWorkspace
570 ideSetupWorkspace.outputs.upToDateWhen {file(eclipseWorkspace).exists()}
574 dependsOn ideSetupWorkspace
591 def jalviewjsBuildDir
593 task jalviewjsSitePath {
594 if (jalviewjs_site_dir.startsWith("/")) {
595 jalviewjsSiteDir = jalviewjs_site_dir
597 def relativeBuildDir = file(jalviewDirAbsolutePath).toPath().relativize(buildDir.toPath())
598 jalviewjsBuildDir = "${relativeBuildDir}/jalviewjs"
599 jalviewjsSiteDir = jalviewjsBuildDir + "/" + jalviewjs_site_dir
604 task jalviewjsUnzipFiles {
605 dependsOn jalviewjsSitePath
607 def zipFiles = fileTree(dir: jalviewjs_utils_dir+"/"+jalviewjs_libjs_dir).include("*.zip")
608 zipFiles += jalviewjs_utils_dir+"/"+jalviewjs_swingjs_zip
611 zipFiles.each { file_zip ->
613 from zipTree(file_zip)
614 into jalviewjsSiteDir
619 inputs.files zipFiles
620 outputs.dir jalviewjsSiteDir
623 def eclipseDropinsDir
625 task jalviewjsEclipsePaths {
628 eclipseRoot = oomphIde.ideDir
629 eclipseDropinsDir = eclipseRoot+"/"+com.diffplug.gradle.FileMisc.macContentsEclipse()+"/dropins"
630 eclipseBinary = eclipseRoot+"/"+com.diffplug.common.swt.os.OS.getNative().winMacLinux("", "Contents/MacOS", "")+"/eclipse"
632 eclipseRoot = jalviewjs_eclipse_root
633 if (eclipseRoot.startsWith("~")) {
634 eclipseRoot = System.getProperty("user.home") + eclipseRoot.substring(1)
636 if (OperatingSystem.current().isMacOsX()) {
637 eclipseRoot += "/Eclipse.app"
638 eclipseDropinsDir = eclipseRoot+"/Contents/Eclipse/dropins"
639 eclipseBinary = eclipseRoot+"/Contents/MacOS/eclipse"
640 } else if (OperatingSystem.current().isWindows()) { // check these paths!!
641 eclipseDropinsDir = eclipseRoot+"/dropins"
642 eclipseBinary = eclipseRoot+"/eclipse"
643 } else { // linux or unix
644 eclipseDropinsDir = eclipseRoot+"/dropins"
645 eclipseBinary = eclipseRoot+"/eclipse"
648 //println("ECLIPSE_ROOT=${eclipseRoot}")
649 //println("ECLIPSE_BINARY=${eclipseBinary}")
652 //task jalviewjsEclipseCopyDropins (type: Copy) {
653 task jalviewjsEclipseCopyDropins {
654 dependsOn jalviewjsEclipsePaths
655 def inputFiles = fileTree(dir: jalviewjs_utils_dir+"/"+jalviewjs_eclipse_dropins_dir, include: "*.jar")
656 def outputDir = eclipseDropinsDir
658 inputs.files inputFiles
659 inputFiles.each { file ->
660 outputs.file(outputDir+"/"+file.name)
665 inputFiles.each { file ->
674 task jalviewjsEclipseSetup {
675 dependsOn jalviewjsEclipseCopyDropins
676 dependsOn jalviewjsSetEclipseWorkspace
680 task jalviewjsCreateJ2sSettings(type: WriteProperties) {
681 dependsOn jalviewjsSitePath
682 outputFile (jalviewDir+"/"+jalviewjs_j2s_settings)
683 def props = project.properties.sort { it.key }
684 def siteDirProperty = "j2s.site.directory"
685 def setSiteDir = false
686 props.each { prop, val ->
687 if (prop.startsWith("j2s.") && val != null) {
688 if (prop == siteDirProperty) {
689 if (!(val.startsWith("/") || val.startsWith("file://") )) {
690 val = jalviewjsSiteDir+"/"+val
697 property(siteDirProperty,"${jalviewjsSiteDir}")
700 outputs.file(outputFile)
703 task jalviewjsCopyResources (type: Copy) {
704 dependsOn jalviewjsSitePath
705 def inputFiles = fileTree(dir: jalviewjs_resource_dir)
706 def outputDir = jalviewjsSiteDir+"/"+jalviewjs_j2s_subdir
712 outputFiles += outputDir+"/"+filename
715 outputs.files outputFiles
716 inputs.files inputFiles
719 task jalviewjsCopySiteResources (type: Copy) {
720 dependsOn jalviewjsSitePath
721 def inputFiles = fileTree(dir: jalviewjs_utils_dir+"/"+jalviewjs_site_resource_dir)
722 def outputDir = jalviewjsSiteDir
728 outputFiles += outputDir+"/"+filename
731 outputs.files outputFiles
732 inputs.files inputFiles
735 task cleanJalviewjs {
736 dependsOn jalviewjsSitePath
738 delete jalviewDir+"/"+jalviewjsSiteDir
739 delete jalviewDir+"/"+eclipse_bin_dir
740 delete file(eclipseWorkspace.getAbsolutePath()+"/.metadata")
741 delete jalviewDir+"/"+jalviewjs_j2s_settings
745 task jalviewjsProjectImport(type: Exec) {
746 // work out how to do this!
747 dependsOn eclipseProject
748 dependsOn eclipseClasspath
750 dependsOn jalviewjsEclipsePaths
751 dependsOn jalviewjsEclipseSetup
752 executable(eclipseBinary)
753 args(["-nosplash", "--launcher.suppressErrors", "-application", "com.seeq.eclipse.importprojects.headlessimport", "-data", eclipseWorkspace.getPath(), "-import", jalviewDirAbsolutePath])
755 def projdir = eclipseWorkspace.getPath()+"/.metadata/.plugins/org.eclipse.core.resources/.projects/jalview/org.eclipse.jdt.core"
756 inputs.file(jalviewDir+"/.project")
758 outputs.upToDateWhen { file(projdir).exists() }
768 task jalviewjsTranspile(type: Exec) {
769 dependsOn jalviewjsCreateJ2sSettings
770 dependsOn jalviewjsProjectImport
771 dependsOn jalviewjsEclipsePaths
772 executable(eclipseBinary)
773 args(["-nosplash", "--launcher.suppressErrors", "-application", "org.eclipse.jdt.apt.core.aptBuild", "-data", eclipseWorkspace, "-"+jalviewjs_eclipseBuildArg, eclipse_project_name ])
778 stdout = new ByteArrayOutputStream()
779 stderr = new ByteArrayOutputStream()
780 standardOutput = new org.apache.tools.ant.util.TeeOutputStream(new FileOutputStream("${jalviewjsBuildDir}/${jalviewjs_j2s_stdout}"), stdout);
781 errorOutput = new org.apache.tools.ant.util.TeeOutputStream(new FileOutputStream("${jalviewjsBuildDir}/${jalviewjs_j2s_stderr}"), stderr);
784 if (stdout.toString().contains("Error processing ")) {
785 // j2s did not complete transpile
786 throw new GradleException("Error during transpilation:\n${stderr}\nSee eclipse transpile log files '${jalviewjsBuildDir}/${jalviewjs_j2s_stdout}' and '${jalviewjsBuildDir}/${jalviewjs_j2s_stderr}'\n")
790 inputs.dir(sourceDir)
791 outputs.dir(eclipse_bin_dir+"/main")
794 dir: jalviewjsSiteDir+"/"+jalviewjs_j2s_subdir,
795 includes: [ "**/*.js" ],
797 //jalviewjsSiteDir+"/"+jalviewjs_j2s_subdir+"/intervalstore/**",
798 //jalviewjsSiteDir+"/"+jalviewjs_j2s_subdir+"/org/json/**",
804 outputs.file(jalviewjsSiteDir+jalviewjs_server_resource)
813 jalviewjsUnzipFiles.mustRunAfter jalviewjsTranspile
814 jalviewjsTranspile.mustRunAfter jalviewjsCopyResources
815 jalviewjsTranspile.mustRunAfter jalviewjsCopySiteResources
817 task jalviewjsPrepareSite {
819 description "Prepares the website folder"
820 dependsOn jalviewjsSitePath
821 dependsOn jalviewjsUnzipFiles
822 dependsOn jalviewjsCopyResources
823 dependsOn jalviewjsCopySiteResources
826 task jalviewjsBuildSite {
828 description "Builds the whole website including transpiled code"
829 dependsOn jalviewjsPrepareSite
830 dependsOn jalviewjsTranspile
833 task jalviewjsSiteTar(type: Tar) {
835 description "Creates a tar.gz file for the website"
836 dependsOn jalviewjsBuildSite
837 def outputFilename = "jalviewjs-site-${JALVIEW_VERSION}.tar.gz"
839 archiveFileName = outputFilename
840 } catch (Exception e) {
841 archiveName = outputFilename
844 compression Compression.GZIP
846 from jalviewjsSiteDir
847 into jalviewjs_site_dir // this is inside the tar file
849 inputs.dir(jalviewjsSiteDir)
852 def jalviewjsServer = null
853 task jalviewjsServerStart {
855 description "Starts a webserver on localhost to test the website"
856 dependsOn jalviewjsSitePath
859 if (jalviewjsServer != null) {
860 println("SERVER ALREADY RUNNING. Go to "+jalviewjsServer.getResourceUrl(jalviewjs_server_resource)+" . Run gradle jalviewjsServerStop to stop.")
863 SimpleHttpFileServerFactory factory = new SimpleHttpFileServerFactory()
864 def port = Integer.valueOf(jalviewjs_server_port)
867 while(port < start+1000 && !running) {
869 def doc_root = new File(jalviewDirAbsolutePath +"/"+ jalviewjsSiteDir)
870 jalviewjsServer = factory.start(doc_root, port)
872 println("SERVER STARTED with document root ${doc_root}.\nGo to "+jalviewjsServer.getResourceUrl(jalviewjs_server_resource)+" . Run gradle --stop to stop (kills all gradle daemons).")
873 //println("Ctrl-c to stop.");java.lang.Thread.sleep(Integer.valueOf(jalviewjs_server_wait)*1000);
874 } catch (Exception e) {
885 /* server persists in gradle daemon but reference is not accessible across builds
886 task jalviewjsServerStop {
889 if (jalviewjsServer != null) {
891 println("SERVER ON PORT "+jalviewjsServer.getPort()+" STOPPING. Run gradle jalviewjsServerStart to start again.")
892 jalviewjsServer.stop()
895 println("SERVER NOT RUNNING. Run gradle jalviewjsServerStart to start.")
903 dependsOn jalviewjsSitePath
904 dependsOn jalviewjsUnzipFiles
905 dependsOn jalviewjsCopyResources
906 dependsOn jalviewjsCopySiteResources
907 // see project.afterEvaluate
908 //dependsOn ideJalviewjsBuild
915 dependsOn jalviewjsBuildSite
919 project.afterEvaluate {
921 tasks.findByName('eclipse').dependsOn tasks.findByName('jalviewjsCreateJ2sSettings')
924 tasks.findByName('ideJalviewjsImport').dependsOn eclipseProject
925 tasks.findByName('ideJalviewjsImport').dependsOn eclipseClasspath
926 tasks.findByName('ideJalviewjsImport').dependsOn eclipseJdt
927 tasks.findByName('ideJalviewjsImport').dependsOn jalviewjsSetEclipseWorkspace
929 tasks.findByName('ideJalviewjsBuild').dependsOn tasks.findByName('ideJalviewjsImport')
930 tasks.findByName('ideJalviewjsBuild').dependsOn tasks.findByName('jalviewjsCreateJ2sSettings')
932 tasks.findByName('ide').dependsOn eclipseProject
933 tasks.findByName('ide').dependsOn eclipseClasspath
934 tasks.findByName('ide').dependsOn eclipseJdt
936 ideBuildSite.dependsOn tasks.findByName('ideJalviewjsBuild')