#!/bin/bash FIJI_ROOT_PATH='/Applications/Fiji.app' function ensure_maven_in_installed() { sudo port install maven32 sudo port select --set maven maven32 } function accept_maven_scijava_org_certificate() { # fixes (using the nice description in https://commandlinefanatic.com/cgi-bin/showarticle.cgi?article=art032) the following error when executing "mvn -Dimagej.app.directory=/Applications/Fiji.app" # [INFO] ------------------------------------------------------------------------ # [ERROR] Failed to execute goal on project example-script-collection: Could not resolve dependencies for project org.scijava:example-script-collection:jar:0.1.0-SNAPSHOT: Failed to collect dependencies at net.imagej:imagej:jar:2.0.0-rc-71: Failed to read artifact descriptor for net.imagej:imagej:jar:2.0.0-rc-71: Could not transfer artifact net.imagej:imagej:pom:2.0.0-rc-71 from/to scijava.public (https://maven.scijava.org/content/groups/public): sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target -> [Help 1] # [ERROR] # [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. local java_home=$(/usr/libexec/java_home) #[1]graffy@pr079234:~/toto/example-script-collection[15:43:02]>/usr/libexec/java_home #/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home local jre_home="$java_home/jre" keytool -list -keystore $jre_home/lib/security/cacerts # just press enter on the password prompt # [1]graffy@pr079234:~/toto/example-script-collection[15:44:43]>keytool -list -keystore /Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home/jre/lib/security/cacerts # Enter keystore password: # ***************** WARNING WARNING WARNING ***************** # * The integrity of the information stored in your keystore * # * has NOT been verified! In order to verify its integrity, * # * you must provide your keystore password. * # ***************** WARNING WARNING WARNING ***************** # Keystore type: JKS # Keystore provider: SUN # Your keystore contains 93 entries # digicertassuredidrootca, Apr 16, 2008, trustedCertEntry, # Certificate fingerprint (SHA1): 05:63:B8:63:0D:62:D7:5A:BB:C8:AB:1E:4B:DF:B5:A8:99:B2:4D:43 # ... # godaddyrootg2ca, Jul 19, 2014, trustedCertEntry, # Certificate fingerprint (SHA1): 47:BE:AB:C9:22:EA:E8:0E:78:78:34:62:A7:9F:45:C2:54:FD:E6:8B keytool -printcert -rfc -sslserver maven.scijava.org # [1]graffy@pr079234:~/toto/example-script-collection[16:06:05]>keytool -printcert -rfc -sslserver maven.scijava.org # -----BEGIN CERTIFICATE----- # MIIFWDCCBECgAwIBAgISA7zwf4Rs4UhVp5fLyHh58bjtMA0GCSqGSIb3DQEBCwUAMEoxCzAJBgNV # ... # Ob5k02cDAcqlcJqIzqhxANh7UDoLw7h36hBnyIHDMbMMkfrtgMv5WSa0DZ2mZf63P6iYGUmr5dtz # ciAu0w== # -----END CERTIFICATE----- # -----BEGIN CERTIFICATE----- # MIIFWDCCBECgAwIBAgISA7zwf4Rs4UhVp5fLyHh58bjtMA0GCSqGSIb3DQEBCwUAMEoxCzAJBgNV # ... # Ob5k02cDAcqlcJqIzqhxANh7UDoLw7h36hBnyIHDMbMMkfrtgMv5WSa0DZ2mZf63P6iYGUmr5dtz # ciAu0w== # -----END CERTIFICATE----- # -----BEGIN CERTIFICATE----- # MIIEkjCCA3qgAwIBAgIQCgFBQgAAAVOFc2oLheynCDANBgkqhkiG9w0BAQsFADA/MSQwIgYDVQQK # ... # TZ+sOPAveyxindmjkW8lGy+QsRlGPfZ+G6Z6h7mjem0Y+iWlkYcV4PIWL1iwBi8saCbGS5jN2p8M # +X+Q7UNKEkROb3N6KOqkqm57TH2H3eDJAkSnh6/DNFu0Qg== # -----END CERTIFICATE----- # split output into: # - /tmp/cert1.pem # - /tmp/cert2.pem # - /tmp/cert3.pem keytool -importcert -file /tmp/cert1.pem -keystore $jre_home/lib/security/cacerts # password : changeit # [1]graffy@pr079234:~/toto/example-script-collection[17:12:30]>sudo keytool -importcert -file /tmp/cert1.pem -keystore $jre_home/lib/security/cacerts # Password: # Sorry, try again. # Password: # Enter keystore password: # Owner: CN=maven.imagej.net # Issuer: CN=Let's Encrypt Authority X3, O=Let's Encrypt, C=US # Serial number: 3bcf07f846ce14855a797cbc87879f1b8ed # Valid from: Sat Aug 17 07:39:53 CEST 2019 until: Fri Nov 15 06:39:53 CET 2019 # Certificate fingerprints: # MD5: 05:B4:5A:31:AE:1F:36:71:0E:24:FB:0F:72:AE:BD:BD # SHA1: E5:3E:B0:CC:8E:D0:C6:A3:EF:2F:42:93:45:60:82:C2:1B:A3:BD:F3 # SHA256: 74:3C:C7:2C:E6:C5:FE:9F:79:F5:F7:9D:7E:2A:4F:C9:BA:51:A0:88:95:1C:FC:15:8D:DC:EC:B0:99:BD:0E:61 # Signature algorithm name: SHA256withRSA # Version: 3 # Extensions: # #1: ObjectId: 1.3.6.1.4.1.11129.2.4.2 Criticality=false # 0000: 04 81 F2 00 F0 00 76 00 74 7E DA 83 31 AD 33 10 ......v.t...1.3. # 0010: 91 21 9C CE 25 4F 42 70 C2 BF FD 5E 42 20 08 C6 .!..%OBp...^B .. # 0020: 37 35 79 E6 10 7B CC 56 00 00 01 6C 9E 4D C8 C6 75y....V...l.M.. # 0030: 00 00 04 03 00 47 30 45 02 20 1C DB D8 F3 9D 77 .....G0E. .....w # 0040: 48 BB B3 D7 0E 50 C4 0F C0 DF 65 94 A7 C4 23 E2 H....P....e...#. # 0050: 19 C3 88 4D 8D 6D D9 82 D3 BA 02 21 00 AC CC 93 ...M.m.....!.... # 0060: BE 28 59 5C 2E BC A0 8E 36 4D 23 FB 1D 4B 0F FE .(Y\....6M#..K.. # 0070: F4 38 9F C6 D1 13 53 91 62 25 0F C9 71 00 76 00 .8....S.b%..q.v. # 0080: 29 3C 51 96 54 C8 39 65 BA AA 50 FC 58 07 D4 B7 ) mykey, Sep 20, 2019, trustedCertEntry, #> Certificate fingerprint (SHA1): E5:3E:B0:CC:8E:D0:C6:A3:EF:2F:42:93:45:60:82:C2:1B:A3:BD:F3 #export MAVEN_OPTS="-Xmx512m -Djavax.net.ssl.trustStore=trust.jks \ # -Djavax.net.ssl.trustStorePassword= \ # -Djavax.net.ssl.keyStore=/tmp/cert1.pem \ # -Djavax.net.ssl.keyStoreType=pem } function create_test_jar() { git clone https://github.com/imagej/example-script-collection.git pushd example-script-collection rm -R src/test/java ensure_maven_in_installed accept_maven_scijava_org_certificate mvn -Dimagej.app.directory=/Applications/Fiji.app popd } function install_lipase_libs_in_fiji() { # https://imagej.net/Jython_Scripting mkdir -p "$FIJI_ROOT_PATH/jars/Lib" # cp -R ./src/* "$FIJI_ROOT_PATH/jars/Lib" pushd src find ./lipase -name "*.py" > /tmp/files.txt jar cvf $FIJI_ROOT_PATH/jars/Lib/fr.univ-rennes1.ip.lipase.lib.jar @/tmp/files.txt popd } function install_lipase_in_fiji() { install_lipase_libs_in_fiji mkdir -p $FIJI_ROOT_PATH/plugins/Ipr rsync -a ./src/ij-plugins/Ipr/ $FIJI_ROOT_PATH/plugins/Ipr/ } install_lipase_in_fiji