diff options
author | Adam J. Stewart <ajstewart426@gmail.com> | 2020-08-18 13:17:08 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-18 20:17:08 +0200 |
commit | 00e9e1b3c7bda5db7b47416932728a5832ff3e06 (patch) | |
tree | 26bec8e28d63b6448019b795b740c5e818411036 /var | |
parent | 1ed70d0e2cc67de34850107f86ca4f16ba1d3c07 (diff) | |
download | spack-00e9e1b3c7bda5db7b47416932728a5832ff3e06.tar.gz spack-00e9e1b3c7bda5db7b47416932728a5832ff3e06.tar.bz2 spack-00e9e1b3c7bda5db7b47416932728a5832ff3e06.tar.xz spack-00e9e1b3c7bda5db7b47416932728a5832ff3e06.zip |
Java: add spack external find support (#18006)
Diffstat (limited to 'var')
-rw-r--r-- | var/spack/repos/builtin/packages/jdk/package.py | 19 | ||||
-rw-r--r-- | var/spack/repos/builtin/packages/openjdk/package.py | 15 |
2 files changed, 30 insertions, 4 deletions
diff --git a/var/spack/repos/builtin/packages/jdk/package.py b/var/spack/repos/builtin/packages/jdk/package.py index a90ddff904..31510d739e 100644 --- a/var/spack/repos/builtin/packages/jdk/package.py +++ b/var/spack/repos/builtin/packages/jdk/package.py @@ -3,11 +3,11 @@ # # SPDX-License-Identifier: (Apache-2.0 OR MIT) -from spack.util.prefix import Prefix -from spack import * +import os +import re import llnl.util.tty as tty -import os +from spack.util.prefix import Prefix class Jdk(Package): @@ -79,6 +79,19 @@ class Jdk(Package): # can symlink all *.jar files to `prefix.lib.ext` extendable = True + executables = ['^java$'] + + @classmethod + def determine_version(cls, exe): + output = Executable(exe)('-version', output=str, error=str) + + # Make sure this is actually Oracle JDK, not OpenJDK + if 'openjdk' in output: + return None + + match = re.search(r'\(build (\S+)\)', output) + return match.group(1).replace('+', '_') if match else None + @property def home(self): """Most of the time, ``JAVA_HOME`` is simply ``spec['java'].prefix``. diff --git a/var/spack/repos/builtin/packages/openjdk/package.py b/var/spack/repos/builtin/packages/openjdk/package.py index 9b520ded99..4c50bdfc2c 100644 --- a/var/spack/repos/builtin/packages/openjdk/package.py +++ b/var/spack/repos/builtin/packages/openjdk/package.py @@ -3,9 +3,9 @@ # # SPDX-License-Identifier: (Apache-2.0 OR MIT) -from spack import * import os import platform +import re # If you need to add a new version, please be aware that: @@ -60,6 +60,19 @@ class Openjdk(Package): # can symlink all *.jar files to `prefix.lib.ext` extendable = True + executables = ['^java$'] + + @classmethod + def determine_version(cls, exe): + output = Executable(exe)('-version', output=str, error=str) + + # Make sure this is actually OpenJDK, not Oracle JDK + if 'openjdk' not in output: + return None + + match = re.search(r'\(build (\S+)\)', output) + return match.group(1).replace('+', '_') if match else None + @property def home(self): """Most of the time, ``JAVA_HOME`` is simply ``spec['java'].prefix``. |