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")
32 dirs jalviewjs_utils_dir+"/"+jalviewjs_eclipse_dropins_dir
45 group 'eclipseDeps', {
46 repoEclipse goomph_eclipse_repo_version
47 //slicingOption 'latestVersionOnly', 'true'
48 iu 'org.eclipse.update.configurator'
51 iu 'org.eclipse.jdt.apt.core'
52 iu 'org.eclipse.jdt.core'
53 iu 'org.eclipse.jdt.annotation'
57 repo 'https://download.eclipse.org/eclipse/updates/4.13/R-4.13-201909161045/'
58 iu 'org.eclipse.debug.core'
59 iu 'org.eclipse.jdt.apt.pluggable.core'
60 iu 'org.eclipse.jdt.apt.ui'
61 iu 'org.eclipse.jdt.compiler.apt'
62 iu 'org.eclipse.jdt.compiler.tool'
63 iu 'org.eclipse.jdt.core.manipulation'
64 iu 'org.eclipse.jdt.debug'
65 iu 'org.eclipse.jdt.debug.ui'
66 iu 'org.eclipse.jdt.doc.user'
67 iu 'org.eclipse.jdt.junit'
68 iu 'org.eclipse.jdt.junit.core'
69 iu 'org.eclipse.jdt.junit4.runtime'
70 iu 'org.eclipse.jdt.junit4.runtime'
71 iu 'org.eclipse.jdt.junit5.runtime'
72 iu 'org.eclipse.jdt.launching'
73 iu 'org.eclipse.jdt.ui'
75 iu 'org.eclipse.jdt.launching.macosx'
76 iu 'org.eclipse.jdt.launching.ui.macosx'
78 group 'eclipseOrbit', {
79 repo goomph_orbit_repo
80 slicingOption 'latestVersionOnly', 'true'
83 iu 'javax.servlet.jsp'
85 iu 'org.apache.batik.constants'
86 iu 'org.apache.batik.css'
87 iu 'org.apache.batik.i18n'
88 iu 'org.apache.batik.util'
89 iu 'org.apache.commons.beanutils'
90 iu 'org.apache.commons.collections'
91 iu 'org.apache.commons.jxpath'
92 iu 'org.apache.commons.io'
93 iu 'org.apache.commons.logging'
94 iu 'org.apache.xmlgraphics'
96 iu 'org.w3c.dom.events'
106 source.addMaven('org.eclipse.platform:org.eclipse.osgi:3.14.0')
108 compile 'eclipseOrbit:org.apache.ant:1.10.5.v20190526-1402'
110 compile 'org.osgi:org.osgi.service.component:1.4.0'
114 jalviewjsIde name: 'net.sf.j2s.core-3.2.4'
115 jalviewjsIde name: 'com.seeq.eclipse.importprojects-1.4.0'
126 eclipseMavenCentral {
127 // TODO: How do I add these to the jalviewjsIde configuration and not the compile configuration?
128 release goomph_eclipse_repo_version, {
130 //def platformCode="cocoa.macosx.x86_64"
131 //compile 'org.eclipse.swt.'+platformCode
132 useNativesForRunningPlatform()
133 compile 'org.eclipse.swt'
135 compile 'org.eclipse.ant.core'
136 compile 'org.eclipse.compare.core'
137 compile 'org.eclipse.core.commands'
138 compile 'org.eclipse.core.contenttype'
139 compile 'org.eclipse.core.jobs'
140 compile 'org.eclipse.core.expressions'
141 compile 'org.eclipse.core.filesystem'
142 compile 'org.eclipse.core.resources'
143 compile 'org.eclipse.core.runtime'
144 compile 'org.eclipse.core.variables'
145 compile 'org.eclipse.equinox.common'
146 compile 'org.eclipse.equinox.ds'
147 compile 'org.eclipse.equinox.app'
148 compile 'org.eclipse.equinox.registry'
149 compile 'org.eclipse.equinox.preferences'
150 compile 'org.eclipse.jface'
151 compile 'org.eclipse.osgi'
152 compile 'org.eclipse.osgi.services'
153 compile 'org.eclipse.ui'
154 compile 'org.eclipse.ui.workbench'
155 compile 'org.eclipse.team.core'
156 compile 'org.eclipse.text'
158 compile 'org.eclipse.e4.core.commands'
159 compile 'org.eclipse.e4.core.contexts'
160 compile 'org.eclipse.e4.core.di'
161 compile 'org.eclipse.e4.core.di.annotations'
162 compile 'org.eclipse.e4.core.di.extensions.supplier'
163 compile 'org.eclipse.e4.core.services'
164 compile 'org.eclipse.e4.ui.bindings'
165 compile 'org.eclipse.e4.ui.model.workbench'
166 compile 'org.eclipse.e4.ui.workbench'
167 compile 'org.eclipse.e4.ui.workbench.swt'
168 compile 'org.eclipse.e4.ui.css.core'
169 compile 'org.eclipse.e4.ui.css.swt'
170 compile 'org.eclipse.e4.ui.css.swt.theme'
171 compile 'org.eclipse.e4.ui.services'
172 compile 'org.eclipse.e4.ui.di'
174 //compile 'org.eclipse.e4.core.di.internal.extensions'
176 // org.eclipse.update.configurator deliberately kept at 3.3.400 see https://github.com/diffplug/goomph/issues/69
177 // this module downloaded in equinoxLaunch configuration (to specify version)
178 //compile 'org.eclipse.update.configurator'
196 mainClassName = launcherClass
197 def classes = "$jalviewDir/$classesDir"
199 // configure classpath/args for j8/j11 compilation
203 def compile_source_compatibility
204 def compile_target_compatibility
207 buildProperties = jalviewDir + "/" + classesDir +"/" + buildPropertiesFile
215 def JAVA_INTEGER_VERSION
216 //def additional_compiler_args = []
217 // this property is for the Java library used in eclipse
218 def eclipse_java_runtime_name
219 if (JAVA_VERSION.equals("1.8")) {
220 JAVA_INTEGER_VERSION = "8"
223 libDistDir = j8libDir
224 compile_source_compatibility = 1.8
225 compile_target_compatibility = 1.8
226 eclipse_java_runtime_name = "JavaSE-1.8"
227 } else if (JAVA_VERSION.equals("11")) {
228 JAVA_INTEGER_VERSION = "11"
230 libDistDir = j11libDir
231 compile_source_compatibility = 11
232 compile_target_compatibility = 11
233 eclipse_java_runtime_name = "JavaSE-11"
234 /* compile without modules -- using classpath libraries
235 additional_compiler_args += [
236 '--module-path', ext.modules_compileClasspath.asPath,
237 '--add-modules', j11modules
240 } else if (JAVA_VERSION.equals("12") || JAVA_VERSION.equals("13")) {
241 JAVA_INTEGER_VERSION = JAVA_VERSION
243 libDistDir = j11libDir
244 compile_source_compatibility = JAVA_VERSION
245 compile_target_compatibility = JAVA_VERSION
246 eclipse_java_runtime_name = "JavaSE-11"
247 /* compile without modules -- using classpath libraries
248 additional_compiler_args += [
249 '--module-path', ext.modules_compileClasspath.asPath,
250 '--add-modules', j11modules
254 throw new GradleException("JAVA_VERSION=$JAVA_VERSION not currently supported by Jalview")
262 srcDirs "$jalviewDir/$sourceDir"
263 outputDir = file("$classes")
267 srcDirs "$jalviewDir/$resourceDir"
270 compileClasspath = files(sourceSets.main.java.outputDir)
271 compileClasspath += fileTree(dir: "$jalviewDir/$libDir", include: ["*.jar"])
273 runtimeClasspath = compileClasspath
280 name = eclipse_project_name
282 natures 'org.eclipse.jdt.core.javanature',
283 'org.eclipse.buildship.core.gradleprojectnature'
285 buildCommand 'org.eclipse.jdt.core.javabuilder'
286 buildCommand 'org.eclipse.buildship.core.gradleprojectbuilder'
290 //defaultOutputDir = sourceSets.main.java.outputDir
292 configurations.each{ if (it.isCanBeResolved()) {
297 minusConfigurations += removeThese
298 plusConfigurations = [ ]
302 def removeTheseToo = []
303 HashMap<String, Boolean> addedSrcPath = new HashMap<>();
304 cp.entries.each { entry ->
305 if (entry.kind == 'src') {
306 if (addedSrcPath.getAt(entry.path) || !(entry.path == sourceDir || entry.path == "test")) {
307 removeTheseToo += entry
309 addedSrcPath.putAt(entry.path, true)
313 cp.entries.removeAll(removeTheseToo)
315 if (file(eclipse_bin_dir+"/main").isDirectory()) {
316 cp.entries += new Output(eclipse_bin_dir+"/main")
318 if (file(helpParentDir).isDirectory()) {
319 cp.entries += new Library(fileReference(helpParentDir))
321 if (file(resourceDir).isDirectory()) {
322 cp.entries += new Library(fileReference(resourceDir))
325 HashMap<String, Boolean> addedLibPath = new HashMap<>();
327 // changing from sourcesets.main.classpath to specific Java version lib
328 //sourceSets.main.compileClasspath.each{
329 fileTree("$jalviewDir/$libDistDir").include("**/*.jar").include("*.jar").each {
330 //don't want to add outputDir as eclipse is using its own output dir in bin/main
331 if (it.isDirectory() || ! it.exists()) {
332 // don't add dirs to classpath
335 def itPath = it.toString()
336 if (itPath.startsWith(jalviewDirAbsolutePath+"/")) {
337 itPath = itPath.substring(jalviewDirAbsolutePath.length()+1)
339 if (addedLibPath.get(itPath)) {
340 //println("Not adding duplicate entry "+itPath)
342 //println("Adding entry "+itPath)
343 cp.entries += new Library(fileReference(itPath))
344 addedLibPath.put(itPath, true)
351 containers 'org.eclipse.buildship.core.gradleclasspathcontainer'
355 // for the IDE, use java 11 compatibility
356 sourceCompatibility = compile_source_compatibility
357 targetCompatibility = compile_target_compatibility
358 javaRuntimeName = eclipse_java_runtime_name
362 withProperties { props ->
363 def jalview_prefs = new Properties()
364 def ins = new FileInputStream(jalviewDirAbsolutePath+"/"+eclipse_extra_jdt_prefs_file)
365 jalview_prefs.load(ins)
367 jalview_prefs.forEach { t, v ->
368 if (props.getAt(t) == null) {
377 //synchronizationTasks eclipseClasspath
378 //autoBuildTasks eclipseClasspath
385 sourceCompatibility = compile_source_compatibility
386 targetCompatibility = compile_target_compatibility
387 //options.compilerArgs = additional_compiler_args
388 print ("Setting target compatibility to "+targetCompatibility+"\n")
394 delete sourceSets.main.java.outputDir
419 task jalviewjsSetEclipseWorkspace {
420 def eclipseWsDir = useIde?goomph_workspace:jalviewjs_eclipse_workspace
421 eclipseWorkspace = file(eclipseWsDir)
422 if (!eclipseWorkspace.exists()) {
423 eclipseWorkspace = file("${buildDir}/tmp/eclipse-workspace")
424 //eclipseWorkspace.deleteOnExit()
426 com.diffplug.gradle.GoomphCacheLocations.override_workspaces = file(eclipseWorkspace.getAbsolutePath())
427 eclipseWorkspace = oomphIde.workspaceRegistry.workspaceDir(project, file(oomphIde.ideDir))
429 println("ECLIPSE WORKSPACE: "+eclipseWorkspace.getPath())
436 repoEclipse goomph_eclipse_version
441 //executionEnvironments = [ eclipse.jdt.javaRuntimeName ]
444 //compilerComplianceLevel( JAVA_INTEGER_VERSION )
447 repo "https://download.eclipse.org/releases/${goomph_eclipse_version_name}/"
448 feature goomph_eclipse_jee_feature, goomph_eclipse_jee_version
452 repo goomph_repo_buildship
453 feature goomph_feature_buildship
458 workspaceProp '.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.launching.prefs', {
459 it.put('org.eclipse.jdt.launching.PREF_VM_XML', goomph_PREF_VM_XML)
467 ideJalviewjsBuildSetup {
469 source.addConfiguration(configurations.compile)
470 source.addConfiguration(configurations.jalviewjsIde)
472 source.addMaven('eclipseOrbit:org.apache.ant:1.10.5.v20190526-1402')
473 source.addMaven('eclipseOrbit:javax.servlet:3.1.0.v201410161800')
474 source.addMaven('eclipseOrbit:javax.servlet.jsp:2.2.0.v201112011158')
475 source.addMaven('eclipseOrbit:javax.el:2.2.0.v201303151357')
476 source.addMaven('eclipseOrbit:org.apache.batik.constants:1.11.0.v20190515-0436')
477 source.addMaven('eclipseOrbit:org.apache.batik.css:1.11.0.v20190515-0436')
478 source.addMaven('eclipseOrbit:org.apache.batik.i18n:1.11.0.v20190515-0436')
479 source.addMaven('eclipseOrbit:org.apache.batik.util:1.11.0.v20190515-0436')
480 source.addMaven('eclipseOrbit:org.apache.commons.beanutils:1.8.0.v201205091237')
481 source.addMaven('eclipseOrbit:org.apache.commons.collections:3.2.2.v201511171945')
482 source.addMaven('eclipseOrbit:org.apache.xmlgraphics:2.3.0.v20190515-0436')
483 source.addMaven('eclipseOrbit:org.apache.commons.jxpath:1.3.0.v200911051830')
484 source.addMaven('eclipseOrbit:org.apache.commons.io:2.6.0.v20190123-2029')
485 source.addMaven('eclipseOrbit:org.apache.commons.logging:1.2.0.v20180409-1502')
486 source.addMaven('eclipseOrbit:org.jdom:1.1.1.v201101151400')
487 source.addMaven('eclipseOrbit:org.w3c.dom.svg:1.1.0.v201011041433')
488 source.addMaven('eclipseOrbit:org.w3c.dom.smil:1.0.1.v200903091627')
489 source.addMaven('eclipseOrbit:org.w3c.dom.events:3.0.0.draft20060413_v201105210656')
491 source.addMaven('org.eclipse.birt.runtime:com.ibm.icu:56.1.0.v201601250100')
492 source.addMaven('javax.inject:com.springsource.javax.inject:1.0.0')
493 source.addMaven('org.apache.felix:org.apache.felix.scr:2.1.16')
494 source.addMaven('org.osgi:org.osgi.framework:1.9.0')
495 source.addMaven('org.osgi:org.osgi.service.component:1.4.0')
496 source.addMaven('org.osgi:org.osgi.service.event:1.4.0')
497 source.addMaven('org.osgi:org.osgi.util.promise:1.1.1')
498 source.addMaven('org.osgi:org.osgi.util.function:1.1.0')
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 // org.eclipse.update.configurator deliberately kept at 3.3.400 see https://github.com/diffplug/goomph/issues/69
524 source.addMaven('org.eclipse.platform:org.eclipse.update.configurator:3.3.400')
527 launchTask 'ideJalviewjsImport', {
528 it.args = ["-consoleLog", "-nosplash", "--launcher.suppressErrors", "-application", "com.seeq.eclipse.importprojects.headlessimport", "-data", eclipseWorkspace.getPath(), "-import", jalviewDirAbsolutePath ]
531 launchTask 'ideJalviewjsBuild', {
533 oomphIde.workspaceProp '.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.launching.prefs', {
534 it.put('org.eclipse.jdt.launching.PREF_VM_XML', goomph_PREF_VM_XML)
537 def args = ["-consoleLog", "-nosplash", "--launcher.suppressErrors", "-application", "org.eclipse.jdt.apt.core.aptBuild", "-data", eclipseWorkspace.getPath(), "-"+jalviewjs_eclipseBuildArg, eclipse_project_name ]
538 println("ARGS="+args)
546 ideSetupWorkspace.dependsOn jalviewjsSetEclipseWorkspace
547 ideSetupWorkspace.outputs.upToDateWhen {file(eclipseWorkspace).exists()}
551 dependsOn ideSetupWorkspace
568 def jalviewjsBuildDir
570 task jalviewjsSitePath {
571 if (jalviewjs_site_dir.startsWith("/")) {
572 jalviewjsSiteDir = jalviewjs_site_dir
574 def relativeBuildDir = file(jalviewDirAbsolutePath).toPath().relativize(buildDir.toPath())
575 jalviewjsBuildDir = "${relativeBuildDir}/jalviewjs"
576 jalviewjsSiteDir = jalviewjsBuildDir + "/" + jalviewjs_site_dir
581 task jalviewjsUnzipFiles {
582 dependsOn jalviewjsSitePath
584 def zipFiles = fileTree(dir: jalviewjs_utils_dir+"/"+jalviewjs_libjs_dir).include("*.zip")
585 zipFiles += jalviewjs_utils_dir+"/"+jalviewjs_swingjs_zip
588 zipFiles.each { file_zip ->
590 from zipTree(file_zip)
591 into jalviewjsSiteDir
596 inputs.files zipFiles
597 outputs.dir jalviewjsSiteDir
600 def eclipseDropinsDir
602 task jalviewjsEclipsePaths {
605 eclipseRoot = oomphIde.ideDir
606 eclipseDropinsDir = eclipseRoot+"/"+com.diffplug.gradle.FileMisc.macContentsEclipse()+"/dropins"
607 eclipseBinary = eclipseRoot+"/"+com.diffplug.common.swt.os.OS.getNative().winMacLinux("", "Contents/MacOS", "")+"/eclipse"
609 eclipseRoot = jalviewjs_eclipse_root
610 if (eclipseRoot.startsWith("~")) {
611 eclipseRoot = System.getProperty("user.home") + eclipseRoot.substring(1)
613 if (OperatingSystem.current().isMacOsX()) {
614 eclipseRoot += "/Eclipse.app"
615 eclipseDropinsDir = eclipseRoot+"/Contents/Eclipse/dropins"
616 eclipseBinary = eclipseRoot+"/Contents/MacOS/eclipse"
617 } else if (OperatingSystem.current().isWindows()) { // check these paths!!
618 eclipseDropinsDir = eclipseRoot+"/dropins"
619 eclipseBinary = eclipseRoot+"/eclipse"
620 } else { // linux or unix
621 eclipseDropinsDir = eclipseRoot+"/dropins"
622 eclipseBinary = eclipseRoot+"/eclipse"
627 task jalviewjsEclipseCopyDropins {
628 dependsOn jalviewjsEclipsePaths
629 def inputFiles = fileTree(dir: jalviewjs_utils_dir+"/"+jalviewjs_eclipse_dropins_dir, include: "*.jar")
630 def outputDir = eclipseDropinsDir
632 inputs.files inputFiles
633 inputFiles.each { file ->
634 outputs.file(outputDir+"/"+file.name)
639 inputFiles.each { file ->
648 task jalviewjsEclipseSetup {
649 dependsOn jalviewjsEclipseCopyDropins
650 dependsOn jalviewjsSetEclipseWorkspace
654 task jalviewjsCreateJ2sSettings(type: WriteProperties) {
655 dependsOn jalviewjsSitePath
656 outputFile (jalviewDir+"/"+jalviewjs_j2s_settings)
657 def props = project.properties.sort { it.key }
658 def siteDirProperty = "j2s.site.directory"
659 def setSiteDir = false
660 props.each { prop, val ->
661 if (prop.startsWith("j2s.") && val != null) {
662 if (prop == siteDirProperty) {
663 if (!(val.startsWith("/") || val.startsWith("file://") )) {
664 val = jalviewjsSiteDir+"/"+val
671 property(siteDirProperty,"${jalviewjsSiteDir}")
674 outputs.file(outputFile)
677 task jalviewjsCopyResources (type: Copy) {
678 dependsOn jalviewjsSitePath
679 def inputFiles = fileTree(dir: jalviewjs_resource_dir)
680 def outputDir = jalviewjsSiteDir+"/"+jalviewjs_j2s_subdir
686 outputFiles += outputDir+"/"+filename
689 outputs.files outputFiles
690 inputs.files inputFiles
693 task jalviewjsCopySiteResources (type: Copy) {
694 dependsOn jalviewjsSitePath
695 def inputFiles = fileTree(dir: jalviewjs_utils_dir+"/"+jalviewjs_site_resource_dir)
696 def outputDir = jalviewjsSiteDir
702 outputFiles += outputDir+"/"+filename
705 outputs.files outputFiles
706 inputs.files inputFiles
709 task cleanJalviewjs {
710 dependsOn jalviewjsSitePath
711 delete jalviewDir+"/"+jalviewjsSiteDir
712 //delete jalviewDir+"/"+eclipse_bin_dir
713 //delete file(eclipseWorkspace.getAbsolutePath()+"/.metadata")
714 //delete jalviewDir+"/"+jalviewjs_j2s_settings
717 task jalviewjsProjectImport(type: Exec) {
718 // work out how to do this!
719 dependsOn eclipseProject
720 dependsOn eclipseClasspath
722 dependsOn jalviewjsEclipsePaths
723 dependsOn jalviewjsEclipseSetup
724 executable(eclipseBinary)
725 args(["-nosplash", "--launcher.suppressErrors", "-application", "com.seeq.eclipse.importprojects.headlessimport", "-data", eclipseWorkspace.getPath(), "-import", jalviewDirAbsolutePath])
727 def projdir = eclipseWorkspace.getPath()+"/.metadata/.plugins/org.eclipse.core.resources/.projects/jalview/org.eclipse.jdt.core"
728 inputs.file(jalviewDir+"/.project")
730 outputs.upToDateWhen { file(projdir).exists() }
740 task jalviewjsTranspile(type: Exec) {
741 dependsOn jalviewjsCreateJ2sSettings
742 dependsOn jalviewjsProjectImport
743 dependsOn jalviewjsEclipsePaths
744 executable(eclipseBinary)
745 args(["-nosplash", "--launcher.suppressErrors", "-application", "org.eclipse.jdt.apt.core.aptBuild", "-data", eclipseWorkspace, "-"+jalviewjs_eclipseBuildArg, eclipse_project_name ])
750 stdout = new ByteArrayOutputStream()
751 stderr = new ByteArrayOutputStream()
752 standardOutput = new org.apache.tools.ant.util.TeeOutputStream(new FileOutputStream("${jalviewjsBuildDir}/${jalviewjs_j2s_stdout}"), stdout);
753 errorOutput = new org.apache.tools.ant.util.TeeOutputStream(new FileOutputStream("${jalviewjsBuildDir}/${jalviewjs_j2s_stderr}"), stderr);
756 if (stdout.toString().contains("Error processing ")) {
757 // j2s did not complete transpile
758 throw new GradleException("Error during transpilation:\n${stderr}\nSee eclipse transpile log files '${jalviewjsBuildDir}/${jalviewjs_j2s_stdout}' and '${jalviewjsBuildDir}/${jalviewjs_j2s_stderr}'\n")
762 inputs.dir(sourceDir)
763 outputs.dir(eclipse_bin_dir+"/main")
766 dir: jalviewjsSiteDir+"/"+jalviewjs_j2s_subdir,
767 includes: [ "**/*.js" ],
769 //jalviewjsSiteDir+"/"+jalviewjs_j2s_subdir+"/intervalstore/**",
770 //jalviewjsSiteDir+"/"+jalviewjs_j2s_subdir+"/org/json/**",
776 outputs.file(jalviewjsSiteDir+jalviewjs_server_resource)
785 jalviewjsUnzipFiles.mustRunAfter jalviewjsTranspile
786 jalviewjsTranspile.mustRunAfter jalviewjsCopyResources
787 jalviewjsTranspile.mustRunAfter jalviewjsCopySiteResources
789 task jalviewjsPrepareSite {
791 description "Prepares the website folder including unzipping files and copying resources"
792 dependsOn jalviewjsSitePath
793 dependsOn jalviewjsUnzipFiles
794 dependsOn jalviewjsCopyResources
795 dependsOn jalviewjsCopySiteResources
798 task jalviewjsBuildSite {
800 description "Builds the whole website including transpiled code"
801 dependsOn jalviewjsPrepareSite
802 dependsOn jalviewjsTranspile
805 task jalviewjsSiteTar(type: Tar) {
807 description "Creates a tar.gz file for the website"
808 dependsOn jalviewjsBuildSite
809 def outputFilename = "jalviewjs-site-${JALVIEW_VERSION}.tar.gz"
811 archiveFileName = outputFilename
812 } catch (Exception e) {
813 archiveName = outputFilename
816 compression Compression.GZIP
818 from jalviewjsSiteDir
819 into jalviewjs_site_dir // this is inside the tar file
821 inputs.dir(jalviewjsSiteDir)
824 def jalviewjsServer = null
825 task jalviewjsServerStart {
827 description "Starts a webserver on localhost to test the website"
828 dependsOn jalviewjsSitePath
831 if (jalviewjsServer != null) {
832 println("SERVER ALREADY RUNNING. Go to "+jalviewjsServer.getResourceUrl(jalviewjs_server_resource)+" . Run gradle jalviewjsServerStop to stop.")
835 SimpleHttpFileServerFactory factory = new SimpleHttpFileServerFactory()
836 def port = Integer.valueOf(jalviewjs_server_port)
839 while(port < start+1000 && !running) {
841 def doc_root = new File(jalviewDirAbsolutePath +"/"+ jalviewjsSiteDir)
842 jalviewjsServer = factory.start(doc_root, port)
844 println("SERVER STARTED with document root ${doc_root}.\nGo to "+jalviewjsServer.getResourceUrl(jalviewjs_server_resource)+" . Run gradle --stop to stop (kills all gradle daemons).")
845 //println("Ctrl-c to stop.");java.lang.Thread.sleep(Integer.valueOf(jalviewjs_server_wait)*1000);
846 } catch (Exception e) {
857 /* server persists in gradle daemon but reference is not accessible across builds
858 task jalviewjsServerStop {
861 if (jalviewjsServer != null) {
863 println("SERVER ON PORT "+jalviewjsServer.getPort()+" STOPPING. Run gradle jalviewjsServerStart to start again.")
864 jalviewjsServer.stop()
867 println("SERVER NOT RUNNING. Run gradle jalviewjsServerStart to start.")
875 dependsOn jalviewjsSitePath
876 dependsOn jalviewjsUnzipFiles
877 dependsOn jalviewjsCopyResources
878 dependsOn jalviewjsCopySiteResources
879 /* see project.afterEvaluate
880 dependsOn ideJalviewjsBuild
889 dependsOn ideBuildSite
891 dependsOn jalviewjsBuildSite
896 project.afterEvaluate {
898 tasks.findByName('eclipse').dependsOn tasks.findByName('jalviewjsCreateJ2sSettings')
901 tasks.findByName('ideJalviewjsImport').dependsOn eclipseProject
902 tasks.findByName('ideJalviewjsImport').dependsOn eclipseClasspath
903 tasks.findByName('ideJalviewjsImport').dependsOn eclipseJdt
904 tasks.findByName('ideJalviewjsImport').dependsOn jalviewjsSetEclipseWorkspace
906 tasks.findByName('ideJalviewjsBuild').dependsOn tasks.findByName('ideJalviewjsImport')
907 tasks.findByName('ideJalviewjsBuild').dependsOn tasks.findByName('jalviewjsCreateJ2sSettings')
909 tasks.findByName('ide').dependsOn eclipseProject
910 tasks.findByName('ide').dependsOn eclipseClasspath
911 tasks.findByName('ide').dependsOn eclipseJdt
913 ideBuildSite.dependsOn tasks.findByName('ideJalviewjsBuild')