From: Ben Soares Date: Wed, 8 May 2019 12:43:33 +0000 (+0100) Subject: JAL-3247 Script to produce auto file association files for mac and windows installer... X-Git-Tag: Release_2_11_0~12^2^2~8 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=00b73137cd165c4781c388b1230566986aed9213;p=jalview.git JAL-3247 Script to produce auto file association files for mac and windows installer, and changes in build.gradle to read in the produced, and edited, auto files --- diff --git a/build.gradle b/build.gradle index 2f50c3d..0088845 100644 --- a/build.gradle +++ b/build.gradle @@ -1,4 +1,5 @@ import org.apache.tools.ant.filters.ReplaceTokens +//import org.apache.tools.ant.filters.ReplaceRegexp import org.gradle.internal.os.OperatingSystem buildscript { @@ -823,15 +824,37 @@ task copyInstall4jTemplate(type: Copy) { include install4jTemplate rename (install4jTemplate, install4jConfFile) filter(ReplaceTokens, beginToken: '', endToken: '', tokens: ['9999999999': JAVA_VERSION]) - filter(ReplaceTokens, beginToken: '$$', endToken: '$$', tokens: ['JAVA_VERSION': JAVA_VERSION, 'JAVA_INTEGER_VERSION': JAVA_INTEGER_VERSION, 'VERSION': JALVIEW_VERSION, 'MACOS_JAVA_VM_DIR': macosJavaVMDir, 'MACOS_JAVA_VM_TGZ': macosJavaVMTgz, 'WINDOWS_JAVA_VM_DIR': windowsJavaVMDir, 'WINDOWS_JAVA_VM_TGZ': windowsJavaVMTgz]) + filter(ReplaceTokens, beginToken: '$$', endToken: '$$', + tokens: [ + 'JAVA_VERSION': JAVA_VERSION, + 'JAVA_INTEGER_VERSION': JAVA_INTEGER_VERSION, + 'VERSION': JALVIEW_VERSION, + 'MACOS_JAVA_VM_DIR': macosJavaVMDir, + 'MACOS_JAVA_VM_TGZ': macosJavaVMTgz, + 'WINDOWS_JAVA_VM_DIR': windowsJavaVMDir, + 'WINDOWS_JAVA_VM_TGZ': windowsJavaVMTgz, + 'INSTALL4JINFOPLISTFILEASSOCIATIONS': install4jInfoPlistFileAssociations + ] + ) if (OSX_KEYPASS=="") { filter(ReplaceTokens, beginToken: 'codeSigning macEnabled="', endToken: '"', tokens: ['true':'codeSigning macEnabled="false"']) filter(ReplaceTokens, beginToken: 'runPostProcessor="true" ',endToken: 'Processor', tokens: ['post':'runPostProcessor="false" postProcessor']) } } into install4jDir - inputs.files("$install4jDir/$install4jTemplate") outputs.files(install4jConf) + + doLast { + def installerFileAssociationsXml = file("$install4jDir/$install4jInstallerFileAssociations").text + ant.replaceregexp( + byline: false, + flags: "s", + match: '', + //match: '', + replace: installerFileAssociationsXml, + file: install4jConf + ) + } } task installers(type: com.install4j.gradle.Install4jTask) { diff --git a/gradle.properties b/gradle.properties index ce21a65..8143d44 100644 --- a/gradle.properties +++ b/gradle.properties @@ -96,6 +96,8 @@ j11modules = com.sun.istack.runtime,com.sun.xml.bind,com.sun.xml.fastinfoset,com install4jResourceDir = utils/install4j install4jTemplate = install4j_template.install4j +install4jInfoPlistFileAssociations = file_associations_auto-Info_plist.xml +install4jInstallerFileAssociations = file_associations_auto-install4j.xml install4jBuildDir = build/install4j install4jMediaTypes = windows,macosArchive,linuxRPM,linuxDeb,unixArchive OSX_KEYSTORE = diff --git a/utils/auto_file_associations_info_plist.sh b/utils/auto_file_associations_info_plist.sh deleted file mode 100644 index dd00e40..0000000 --- a/utils/auto_file_associations_info_plist.sh +++ /dev/null @@ -1 +0,0 @@ -perl -n -e 's/\s+/ /g;if(m/^ ?(\w+) ?\( ?"([^"]*)" ?, ?"([^"]*)" ?, ?(true|false) ?, ?(true|false) ?\) ?$/){$m=lc($1); $n=$2; $e=$3; @es=split(m/\s*,\s*/,$e); print "\nCFBundleTypeExtensions\n\n";for $e (@es){print"$e\n";}print"\nCFBundleTypeName\n$n File\nCFBundleTypeIconFile\nJalview-File.icns\nCFBundleTypeRole\nEditor\nCFBundleTypeMIMETypes\n\napplication/x-jalview-$m\n\nLSIsAppleDefaultForType\n\n\n\n";}' src/jalview/io/FileFormat.java diff --git a/utils/install4j/auto_file_associations.pl b/utils/install4j/auto_file_associations.pl new file mode 100755 index 0000000..b46e274 --- /dev/null +++ b/utils/install4j/auto_file_associations.pl @@ -0,0 +1,81 @@ +#!/usr/bin/env perl + +use strict; + +my $fileformats = $ARGV[0]; +$fileformats = "./src/jalview/io/FileFormats.java" unless $fileformats; + +my $mactemplatefile = "file_associations_template-Info_plist.xml"; +my $i4jtemplatefile = "file_associations_template-install4j.xml"; +my $mactemplate; +my $i4jtemplate; +open(MT,"<$mactemplatefile") or dir("Could not open '$mactemplatefile' for reading"); +while(){ + $mactemplate .= $_; +} +close(MT); +open(IT,"<$i4jtemplatefile") or dir("Could not open '$i4jtemplatefile' for reading"); +while(){ + $i4jtemplate .= $_; +} +close(IT); +my $macauto; +my $i4jauto; + +my $macautofile = $mactemplatefile; +$macautofile =~ s/template/auto$1/; +my $i4jautofile = $i4jtemplatefile; +$i4jautofile =~ s/template/auto$1/; + +open(MA,">$macautofile") or die ("Could not open '$macautofile' for writing"); +print MA "CFBundleDocumentTypes\n\n\n"; +open(IA,">$i4jautofile") or die ("Could not open '$i4jautofile' for writing"); + +open(IN, "<$fileformats") or die ("Could not open '$fileformats' for reading"); +my $id = 10000; +while(my $line = ) { + $line =~ s/\s+/ /g; + $line =~ s/(^ | $)//g; + if ($line =~ m/^(\w+) ?\( ?"([^"]*)" ?, ?"([^"]*)" ?, ?(true|false) ?, ?(true|false) ?\)$/i) { + my $shortname = lc($1); + my $name = $2; + my $extensions = $3; + $extensions =~ s/\s+//g; + my @extensions = split(m/,/,$extensions); + #warn("LINE: $line\nFound extensions '".join("', '", @extensions)."' for $name Files ($shortname)'n"); + + my $macentry = $mactemplate; + my $i4jentry = $i4jtemplate; + + $macentry =~ s/\$\$NAME\$\$/$name/g; + $macentry =~ s/\$\$SHORTNAME\$\$/$shortname/g; + + $i4jentry =~ s/\$\$NAME\$\$/$name/g; + $i4jentry =~ s/\$\$SHORTNAME\$\$/$shortname/g; + + while ($macentry =~ m/\$\$([^\$]*)EXTENSIONS([^\$]*)\$\$/) { + my $pre = $1; + my $post = $2; + my $macextensions; + for my $ext (@extensions) { + $macextensions .= $pre.$ext.$post; + } + $macentry =~ s/\$\$${pre}EXTENSIONS${post}\$\$/$macextensions/g; + } + print MA $macentry; + + for my $ext (@extensions) { + my $i4jextentry = $i4jentry; + $i4jextentry =~ s/\$\$EXTENSION\$\$/$ext/g; + $i4jextentry =~ s/\$\$ID\$\$/$id/g; + $id++; + + print IA $i4jextentry; + } + + } +} +close(IN); +close(IA); +print MA "\n"; +close(MA); diff --git a/utils/install4j/Info_plist_file_associations-AUTO.xml b/utils/install4j/file_associations_auto-Info_plist.xml similarity index 99% rename from utils/install4j/Info_plist_file_associations-AUTO.xml rename to utils/install4j/file_associations_auto-Info_plist.xml index ce2e549..f799885 100644 --- a/utils/install4j/Info_plist_file_associations-AUTO.xml +++ b/utils/install4j/file_associations_auto-Info_plist.xml @@ -1,3 +1,6 @@ +CFBundleDocumentTypes + + CFBundleTypeExtensions @@ -365,3 +368,4 @@ + diff --git a/utils/install4j/file_associations_auto-install4j.xml b/utils/install4j/file_associations_auto-install4j.xml new file mode 100644 index 0000000..d82eff3 --- /dev/null +++ b/utils/install4j/file_associations_auto-install4j.xml @@ -0,0 +1,875 @@ + + + + + + Fasta File + + + fa + + + 737 + + + + ./Jalview-File.icns + + + + + com.install4j.runtime.beans.actions.desktop.MacAssociationRole + EDITOR + + + + + ./Jalview-File.ico + + + + + + + + + + + + + + Fasta File + + + fasta + + + 737 + + + + ./Jalview-File.icns + + + + + com.install4j.runtime.beans.actions.desktop.MacAssociationRole + EDITOR + + + + + ./Jalview-File.ico + + + + + + + + + + + + + + Fasta File + + + mfa + + + 737 + + + + ./Jalview-File.icns + + + + + com.install4j.runtime.beans.actions.desktop.MacAssociationRole + EDITOR + + + + + ./Jalview-File.ico + + + + + + + + + + + + + + Fasta File + + + fastq + + + 737 + + + + ./Jalview-File.icns + + + + + com.install4j.runtime.beans.actions.desktop.MacAssociationRole + EDITOR + + + + + ./Jalview-File.ico + + + + + + + + + + + + + + PFAM File + + + pfam + + + 737 + + + + ./Jalview-File.icns + + + + + com.install4j.runtime.beans.actions.desktop.MacAssociationRole + EDITOR + + + + + ./Jalview-File.ico + + + + + + + + + + + + + + Stockholm File + + + sto + + + 737 + + + + ./Jalview-File.icns + + + + + com.install4j.runtime.beans.actions.desktop.MacAssociationRole + EDITOR + + + + + ./Jalview-File.ico + + + + + + + + + + + + + + Stockholm File + + + stk + + + 737 + + + + ./Jalview-File.icns + + + + + com.install4j.runtime.beans.actions.desktop.MacAssociationRole + EDITOR + + + + + ./Jalview-File.ico + + + + + + + + + + + + + + PIR File + + + pir + + + 737 + + + + ./Jalview-File.icns + + + + + com.install4j.runtime.beans.actions.desktop.MacAssociationRole + EDITOR + + + + + ./Jalview-File.ico + + + + + + + + + + + + + + BLC File + + + BLC + + + 737 + + + + ./Jalview-File.icns + + + + + com.install4j.runtime.beans.actions.desktop.MacAssociationRole + EDITOR + + + + + ./Jalview-File.ico + + + + + + + + + + + + + + AMSA File + + + amsa + + + 737 + + + + ./Jalview-File.icns + + + + + com.install4j.runtime.beans.actions.desktop.MacAssociationRole + EDITOR + + + + + ./Jalview-File.ico + + + + + + + + + + + + + + HTML File + + + html + + + 737 + + + + ./Jalview-File.icns + + + + + com.install4j.runtime.beans.actions.desktop.MacAssociationRole + EDITOR + + + + + ./Jalview-File.ico + + + + + + + + + + + + + + RNAML File + + + xml + + + 737 + + + + ./Jalview-File.icns + + + + + com.install4j.runtime.beans.actions.desktop.MacAssociationRole + EDITOR + + + + + ./Jalview-File.ico + + + + + + + + + + + + + + RNAML File + + + rnaml + + + 737 + + + + ./Jalview-File.icns + + + + + com.install4j.runtime.beans.actions.desktop.MacAssociationRole + EDITOR + + + + + ./Jalview-File.ico + + + + + + + + + + + + + + JSON File + + + json + + + 737 + + + + ./Jalview-File.icns + + + + + com.install4j.runtime.beans.actions.desktop.MacAssociationRole + EDITOR + + + + + ./Jalview-File.ico + + + + + + + + + + + + + + PileUp File + + + pileup + + + 737 + + + + ./Jalview-File.icns + + + + + com.install4j.runtime.beans.actions.desktop.MacAssociationRole + EDITOR + + + + + ./Jalview-File.ico + + + + + + + + + + + + + + MSF File + + + msf + + + 737 + + + + ./Jalview-File.icns + + + + + com.install4j.runtime.beans.actions.desktop.MacAssociationRole + EDITOR + + + + + ./Jalview-File.ico + + + + + + + + + + + + + + Clustal File + + + aln + + + 737 + + + + ./Jalview-File.icns + + + + + com.install4j.runtime.beans.actions.desktop.MacAssociationRole + EDITOR + + + + + ./Jalview-File.ico + + + + + + + + + + + + + + PHYLIP File + + + phy + + + 737 + + + + ./Jalview-File.icns + + + + + com.install4j.runtime.beans.actions.desktop.MacAssociationRole + EDITOR + + + + + ./Jalview-File.ico + + + + + + + + + + + + + + GFF or Jalview features File + + + gff2 + + + 737 + + + + ./Jalview-File.icns + + + + + com.install4j.runtime.beans.actions.desktop.MacAssociationRole + EDITOR + + + + + ./Jalview-File.ico + + + + + + + + + + + + + + GFF or Jalview features File + + + gff3 + + + 737 + + + + ./Jalview-File.icns + + + + + com.install4j.runtime.beans.actions.desktop.MacAssociationRole + EDITOR + + + + + ./Jalview-File.ico + + + + + + + + + + + + + + PDB File + + + pdb + + + 737 + + + + ./Jalview-File.icns + + + + + com.install4j.runtime.beans.actions.desktop.MacAssociationRole + EDITOR + + + + + ./Jalview-File.ico + + + + + + + + + + + + + + PDB File + + + ent + + + 737 + + + + ./Jalview-File.icns + + + + + com.install4j.runtime.beans.actions.desktop.MacAssociationRole + EDITOR + + + + + ./Jalview-File.ico + + + + + + + + + + + + + + mmCIF File + + + cif + + + 737 + + + + ./Jalview-File.icns + + + + + com.install4j.runtime.beans.actions.desktop.MacAssociationRole + EDITOR + + + + + ./Jalview-File.ico + + + + + + + + + + + + + + Jalview File + + + jvp + + + 737 + + + + ./Jalview-File.icns + + + + + com.install4j.runtime.beans.actions.desktop.MacAssociationRole + EDITOR + + + + + ./Jalview-File.ico + + + + + + + + + + + + + + Jalview File + + + jar + + + 737 + + + + ./Jalview-File.icns + + + + + com.install4j.runtime.beans.actions.desktop.MacAssociationRole + EDITOR + + + + + ./Jalview-File.ico + + + + + + + + diff --git a/utils/install4j/file_associations_template-Info_plist.xml b/utils/install4j/file_associations_template-Info_plist.xml new file mode 100644 index 0000000..66720a1 --- /dev/null +++ b/utils/install4j/file_associations_template-Info_plist.xml @@ -0,0 +1,19 @@ + +CFBundleTypeExtensions + +$$EXTENSIONS +$$ +CFBundleTypeName +$$NAME$$ File +CFBundleTypeIconFile +Jalview-File.icns +CFBundleTypeRole +Editor +CFBundleTypeMIMETypes + +application/x-jalview-$$SHORTNAME$$ + +LSIsAppleDefaultForType + + + diff --git a/utils/install4j/file_associations_template-install4j.xml b/utils/install4j/file_associations_template-install4j.xml new file mode 100644 index 0000000..96eff1e --- /dev/null +++ b/utils/install4j/file_associations_template-install4j.xml @@ -0,0 +1,35 @@ + + + + + + $$NAME$$ File + + + $$EXTENSION$$ + + + 737 + + + + ./Jalview-File.icns + + + + + com.install4j.runtime.beans.actions.desktop.MacAssociationRole + EDITOR + + + + + ./Jalview-File.ico + + + + + + + + diff --git a/utils/install4j/install4j_template.install4j b/utils/install4j/install4j_template.install4j index 176a72c..774539e 100644 --- a/utils/install4j/install4j_template.install4j +++ b/utils/install4j/install4j_template.install4j @@ -109,7 +109,7 @@ - + @@ -142,7 +142,7 @@ - + @@ -546,6 +546,52 @@ return console.askOkCancel(message, true); + + + + + + + + + + + + + + + + + + + ${i18n:SelectAssociationsLabel} + + + + + + + + + + + + + + true + + + + + + + + showSelectionButtons + selectionButtonPosition + + + + @@ -696,33 +742,27 @@ return console.askOkCancel(message, true); context.getBooleanVariable("addToDockAction") - + - Jalview Project File + Jalview Version Locator - jvp + jvl 737 - ./Jalview-File.icns - - - - - com.install4j.runtime.beans.actions.desktop.MacAssociationRole - EDITOR + ./Jalview-Version-Locator.icns - ./Jalview-File.ico + ./Jalview-Version-Locator.ico @@ -730,28 +770,15 @@ return console.askOkCancel(message, true); - + - Jalview Version Locator + EXTENSIONS_REPLACED_BY_GRADLE - jvl - - - 737 - - - - ./Jalview-Version-Locator.icns - - - - - ./Jalview-Version-Locator.ico - + EXTENSION