summaryrefslogtreecommitdiff
path: root/var
diff options
context:
space:
mode:
authorsnehring <snehring@users.noreply.github.com>2019-01-31 12:54:28 -0600
committerPeter Scheibel <scheibel1@llnl.gov>2019-01-31 12:54:28 -0600
commit21afd258a4784aa08f424647f897a64dfce466d5 (patch)
treee53219f6ecb7facd8650c308e0401cb9648f1332 /var
parentec78d362d21d420fe6ee24bf888cb6fc2af37611 (diff)
downloadspack-21afd258a4784aa08f424647f897a64dfce466d5.tar.gz
spack-21afd258a4784aa08f424647f897a64dfce466d5.tar.bz2
spack-21afd258a4784aa08f424647f897a64dfce466d5.tar.xz
spack-21afd258a4784aa08f424647f897a64dfce466d5.zip
New package: openjdk (#9861)
Closes #2622 This retrieves and installs the binary of Oracle's OpenJDK (an open-source JDK implementation). The logic is largely based on the Spack JDK package (Oracle's closed-source JDK implementation). For now this is only supports Linux. If the download could be customized based on OS (for the same version), binaries are also available for MacOS and Windows.
Diffstat (limited to 'var')
-rw-r--r--var/spack/repos/builtin/packages/openjdk/package.py98
1 files changed, 98 insertions, 0 deletions
diff --git a/var/spack/repos/builtin/packages/openjdk/package.py b/var/spack/repos/builtin/packages/openjdk/package.py
new file mode 100644
index 0000000000..7d9e4e56d0
--- /dev/null
+++ b/var/spack/repos/builtin/packages/openjdk/package.py
@@ -0,0 +1,98 @@
+# Copyright 2013-2019 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+from spack import *
+import os
+
+
+class Openjdk(Package):
+ """The free and opensource java implementation"""
+
+ homepage = "https://jdk.java.net"
+ url = "https://download.java.net/java/GA/jdk11/13/GPL/openjdk-11.0.1_linux-x64_bin.tar.gz"
+
+ version('11.0.1', sha256='7a6bb980b9c91c478421f865087ad2d69086a0583aeeb9e69204785e8e97dcfd')
+
+ provides('java')
+ provides('java@11', when='@11.0:11.99')
+
+ # FIXME:
+ # 1. `extends('java')` doesn't work, you need to use `extends('openjdk')`
+ # 2. Packages cannot extend multiple packages, see #987
+ # 3. Update `YamlFilesystemView.merge` to allow a Package to completely
+ # override how it is symlinked into a view prefix. Then, spack activate
+ # can symlink all *.jar files to `prefix.lib.ext`
+ extendable = True
+
+ @property
+ def home(self):
+ """Most of the time, ``JAVA_HOME`` is simply ``spec['java'].prefix``.
+ However, if the user is using an externally installed JDK, it may be
+ symlinked. For example, on macOS, the ``java`` executable can be found
+ in ``/usr/bin``, but ``JAVA_HOME`` is actually
+ ``/Library/Java/JavaVirtualMachines/jdk-10.0.1.jdk/Contents/Home``.
+ Users may not know the actual installation directory and add ``/usr``
+ to their ``packages.yaml`` unknowingly. Run ``java_home`` if it exists
+ to determine exactly where it is installed. Specify which version we
+ are expecting in case multiple Java versions are installed.
+ See ``man java_home`` for more details."""
+
+ prefix = self.prefix
+ java_home = prefix.libexec.java_home
+ if os.path.exists(java_home):
+ java_home = Executable(java_home)
+ version = str(self.version.up_to(2))
+ prefix = java_home('--version', version, output=str).strip()
+ prefix = Prefix(prefix)
+
+ return prefix
+
+ @property
+ def libs(self):
+ """Depending on the version number and whether the full JDK or just
+ the JRE was installed, Java libraries can be in several locations:
+
+ * ``lib/libjvm.so``
+ * ``jre/lib/libjvm.dylib``
+
+ Search recursively to find the correct library location."""
+
+ return find_libraries(['libjvm'], root=self.home, recursive=True)
+
+ def install(self, spec, prefix):
+ install_tree('.', prefix)
+
+ def setup_environment(self, spack_env, run_env):
+ """Set JAVA_HOME."""
+
+ run_env.set('JAVA_HOME', self.home)
+
+ def setup_dependent_environment(self, spack_env, run_env, dependent_spec):
+ """Set JAVA_HOME and CLASSPATH.
+
+ CLASSPATH contains the installation prefix for the extension and any
+ other Java extensions it depends on."""
+
+ spack_env.set('JAVA_HOME', self.home)
+
+ class_paths = []
+ for d in dependent_spec.traverse(deptype=('build', 'run', 'test')):
+ if d.package.extends(self.spec):
+ class_paths.extend(find(d.prefix, '*.jar'))
+
+ classpath = os.pathsep.join(class_paths)
+ spack_env.set('CLASSPATH', classpath)
+
+ # For runtime environment set only the path for
+ # dependent_spec and prepend it to CLASSPATH
+ if dependent_spec.package.extends(self.spec):
+ class_paths = find(dependent_spec.prefix, '*.jar')
+ classpath = os.pathsep.join(class_paths)
+ run_env.prepend_path('CLASSPATH', classpath)
+
+ def setup_dependent_package(self, module, dependent_spec):
+ """Allows spec['java'].home to work."""
+
+ self.spec.home = self.home