From: Ben Soares Date: Mon, 11 Jan 2021 21:30:56 +0000 (+0000) Subject: JAL-3789 Use j2s.config.altfileproperty in .j2s for alternative temporary build/jalvi... X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2FJalview-JS%2Fdevelop;p=jalview.git JAL-3789 Use j2s.config.altfileproperty in .j2s for alternative temporary build/jalviewjs/config/j2s settings file when running a headless build in gradle --- diff --git a/build.gradle b/build.gradle index 147c31a..180d4ad 100644 --- a/build.gradle +++ b/build.gradle @@ -460,6 +460,7 @@ ext { jalviewjsCoreClasslists = [] jalviewjsJalviewTemplateName = string(jalviewjs_name) jalviewjsJ2sSettingsFileName = string("${jalviewDir}/${jalviewjs_j2s_settings}") + jalviewjsJ2sAltSettingsFileName = string("${jalviewDir}/${jalviewjs_j2s_alt_settings}") jalviewjsJ2sProps = null jalviewjsJ2sPlugin = jalviewjs_j2s_plugin @@ -1975,6 +1976,33 @@ task j2sSetHeadlessBuild { } +task jalviewjsEnableAltFileProperty(type: WriteProperties) { + group "jalviewjs" + description "Enable the alternative J2S Config file for headless build" + + outputFile = jalviewjsJ2sSettingsFileName + def j2sPropsFile = file(jalviewjsJ2sSettingsFileName) + def j2sProps = new Properties() + if (j2sPropsFile.exists()) { + try { + def j2sPropsFileFIS = new FileInputStream(j2sPropsFile) + j2sProps.load(j2sPropsFileFIS) + j2sPropsFileFIS.close() + + j2sProps.each { prop, val -> + property(prop, val) + } + } catch (Exception e) { + println("Exception reading ${jalviewjsJ2sSettingsFileName}") + e.printStackTrace() + } + } + if (! j2sProps.stringPropertyNames().contains(jalviewjs_j2s_alt_file_property_config)) { + property(jalviewjs_j2s_alt_file_property_config, jalviewjs_j2s_alt_file_property) + } +} + + task jalviewjsSetEclipseWorkspace { def propKey = "jalviewjs_eclipse_workspace" def propVal = null @@ -2187,7 +2215,7 @@ task jalviewjsTransferUnzipAllLibs { task jalviewjsCreateJ2sSettings(type: WriteProperties) { group "JalviewJS" - description "Create the .j2s file from the j2s.* properties" + description "Create the alternative j2s file from the j2s.* properties" jalviewjsJ2sProps = project.properties.findAll { it.key.startsWith("j2s.") }.sort { it.key } def siteDirProperty = "j2s.site.directory" @@ -2206,11 +2234,11 @@ task jalviewjsCreateJ2sSettings(type: WriteProperties) { property(siteDirProperty,"${jalviewDirRelativePath}/${jalviewjsTransferSiteJsDir}") } } - outputFile = jalviewjsJ2sSettingsFileName + outputFile = jalviewjsJ2sAltSettingsFileName if (! IN_ECLIPSE) { inputs.properties(jalviewjsJ2sProps) - outputs.file(jalviewjsJ2sSettingsFileName) + outputs.file(jalviewjsJ2sAltSettingsFileName) } } @@ -2326,6 +2354,7 @@ task jalviewjsProjectImport(type: Exec) { args += [ "--launcher.appendVmargs", "-vmargs", "-Dorg.eclipse.equinox.p2.reconciler.dropins.directory=${jalviewDirAbsolutePath}/${jalviewjsBuildDir}/${jalviewjs_eclipse_tmp_dropins_dir}" ] if (!IN_ECLIPSE) { args += [ "-D${j2sHeadlessBuildProperty}=true" ] + args += [ "-D${jalviewjs_j2s_alt_file_property}=${jalviewjsJ2sAltSettingsFileName}" ] } inputs.file("${jalviewDir}/.project") @@ -2339,6 +2368,9 @@ task jalviewjsTranspile(type: Exec) { dependsOn jalviewjsEclipseSetup dependsOn jalviewjsProjectImport dependsOn jalviewjsEclipsePaths + if (!IN_ECLIPSE) { + dependsOn jalviewjsEnableAltFileProperty + } doFirst { // do not run a headless transpile when we claim to be in Eclipse @@ -2358,6 +2390,7 @@ task jalviewjsTranspile(type: Exec) { args += [ "--launcher.appendVmargs", "-vmargs", "-Dorg.eclipse.equinox.p2.reconciler.dropins.directory=${jalviewDirAbsolutePath}/${jalviewjsBuildDir}/${jalviewjs_eclipse_tmp_dropins_dir}" ] if (!IN_ECLIPSE) { args += [ "-D${j2sHeadlessBuildProperty}=true" ] + args += [ "-D${jalviewjs_j2s_alt_file_property}=${jalviewjsJ2sAltSettingsFileName}" ] } def stdout @@ -2825,7 +2858,7 @@ task cleanJalviewjsAll { if (eclipseWorkspace != null && file(eclipseWorkspace.getAbsolutePath()+"/.metadata").exists()) { delete file(eclipseWorkspace.getAbsolutePath()+"/.metadata") } - delete "${jalviewDir}/${jalviewjs_j2s_settings}" + delete jalviewjsJ2sAltSettingsFileName } outputs.upToDateWhen( { false } ) diff --git a/gradle.properties b/gradle.properties index 98c2201..cb25e71 100644 --- a/gradle.properties +++ b/gradle.properties @@ -151,6 +151,19 @@ eclipse_project_name = jalview eclipse_bin_dir = bin eclipse_debug = false +## IMPORTANT for headless build +# to enable `gradle jalviewjs` headless build you MUST set +# j2s.config.altfileproperty = org.jalview.jalviewjsj2sfilename +# (or set to whatever value jalviewjs_j2s_alt_file_property is set to) +# in your ./.j2s file +# OR run the task `gradle jalviewjsEnableAltFileProperty` to do that for you (before headless build task) +jalviewjs_j2s_alt_file_property = org.jalview.jalviewjsj2sfilename +jalviewjs_j2s_alt_settings = build/jalviewjs/config/j2s + +# these are used for actual .j2s file to pass on to alt j2s file +jalviewjs_j2s_settings = .j2s +jalviewjs_j2s_alt_file_property_config = j2s.config.altfileproperty + # for developing in Eclipse as IDE, set this to automatically copy current swingjs/net.sf.j2s.core.jar to your dropins dir jalviewjs_eclipseIDE_auto_copy_j2s_plugin = false # Override this in a local.properties file @@ -162,7 +175,7 @@ jalviewjs_j2s_plugin = swingjs/net.sf.j2s.core-j11.jar jalviewjs_libjs_dir = utils/jalviewjs/libjs jalviewjs_site_resource_dir = utils/jalviewjs/site-resources jalviewjs_classlists_dir = utils/jalviewjs/classlists -jalviewjs_j2s_settings = .j2s +jalviewjs_classlist_jalview = utils/jalviewjs/_j2sclasslist.txt #jalviewjs_eclipse_workspace = ~/tmp/eclipse-workspace # these 3 files/dirs found in build/jalviewjs jalviewjs_eclipse_tmp_dropins_dir = eclipse_dropins