Skip to content

Commit 0ef2071

Browse files
boussaffawalidmadebruilianriesjgsogoprince-chrismc
authored
(#5792) added recipe for openjdk
* added recipe for openjdk * Update recipes/openjdk/all/conandata.yml Co-authored-by: Anonymous Maarten <[email protected]> * Update recipes/openjdk/all/test_package/conanfile.py Co-authored-by: Anonymous Maarten <[email protected]> * fixed conandata.yml format * Update recipes/openjdk/all/conanfile.py Co-authored-by: Uilian Ries <[email protected]> * added required_conan_version * Update recipes/openjdk/all/test_package/conanfile.py Co-authored-by: Javier G. Sogo <[email protected]> * Update recipes/openjdk/all/test_package/conanfile.py Co-authored-by: Chris Mc <[email protected]> Co-authored-by: Anonymous Maarten <[email protected]> Co-authored-by: Uilian Ries <[email protected]> Co-authored-by: Javier G. Sogo <[email protected]> Co-authored-by: Chris Mc <[email protected]>
1 parent 4c2d804 commit 0ef2071

File tree

4 files changed

+90
-0
lines changed

4 files changed

+90
-0
lines changed

recipes/openjdk/all/conandata.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
sources:
2+
"16.0.1":
3+
Windows:
4+
url: "https://download.java.net/java/GA/jdk16.0.1/7147401fd7354114ac51ef3e1328291f/9/GPL/openjdk-16.0.1_windows-x64_bin.zip"
5+
sha256: "733b45b09463c97133d70c2368f1b9505da58e88f2c8a84358dd4accfd06a7a4"
6+
Linux:
7+
url: "https://download.java.net/java/GA/jdk16.0.1/7147401fd7354114ac51ef3e1328291f/9/GPL/openjdk-16.0.1_linux-x64_bin.tar.gz"
8+
sha256: "b1198ffffb7d26a3fdedc0fa599f60a0d12aa60da1714b56c1defbce95d8b235"
9+
Macos:
10+
url: "https://download.java.net/java/GA/jdk16.0.1/7147401fd7354114ac51ef3e1328291f/9/GPL/openjdk-16.0.1_osx-x64_bin.tar.gz"
11+
sha256: "6098f839954439d4916444757c542c1b8778a32461706812d41cc8bbefce7f2f"

recipes/openjdk/all/conanfile.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
from conans import ConanFile, tools
2+
from conans.errors import ConanInvalidConfiguration
3+
import os
4+
5+
required_conan_version = ">=1.33.0"
6+
7+
8+
class OpenJDK(ConanFile):
9+
name = "openjdk"
10+
url = "https://github.com/conan-io/conan-center-index/"
11+
description = "Java Development Kit builds, from Oracle"
12+
homepage = "https://jdk.java.net"
13+
license = "GPL-2.0-with-classpath-exception"
14+
topics = ("java", "jdk", "openjdk")
15+
settings = "os", "arch"
16+
no_copy_source = True
17+
18+
@property
19+
def _source_subfolder(self):
20+
return "source_subfolder"
21+
22+
def configure(self):
23+
if self.settings.arch != "x86_64":
24+
raise ConanInvalidConfiguration("Unsupported Architecture. This package currently only supports x86_64.")
25+
if self.settings.os not in ["Windows", "Macos", "Linux"]:
26+
raise ConanInvalidConfiguration("Unsupported os. This package currently only support Linux/Macos/Windows")
27+
28+
def build(self):
29+
tools.get(**self.conan_data["sources"][self.version][str(self.settings.os)],
30+
destination=self._source_subfolder, strip_root=True)
31+
32+
def package(self):
33+
if self.settings.os == "Macos":
34+
_source_subfolder = os.path.join(self._source_subfolder, "jdk-{}.jdk".format(self.version), "Contents", "Home")
35+
else:
36+
_source_subfolder = self._source_subfolder
37+
self.copy(pattern="*", dst="bin", src=os.path.join(_source_subfolder, "bin"),
38+
excludes=("msvcp140.dll", "vcruntime140.dll", "vcruntime140_1.dll"))
39+
self.copy(pattern="*", dst="include", src=os.path.join(_source_subfolder, "include"))
40+
self.copy(pattern="*", dst="lib", src=os.path.join(_source_subfolder, "lib"))
41+
self.copy(pattern="*", dst=os.path.join("lib", "jmods"), src=os.path.join(_source_subfolder, "jmods"))
42+
self.copy(pattern="*", dst="licenses", src=os.path.join(_source_subfolder, "legal"))
43+
# conf folder is required for security settings, to avoid
44+
# java.lang.SecurityException: Can't read cryptographic policy directory: unlimited
45+
# https://github.com/conan-io/conan-center-index/pull/4491#issuecomment-774555069
46+
self.copy(pattern="*", dst="conf", src=os.path.join(_source_subfolder, "conf"))
47+
48+
def package_info(self):
49+
self.output.info("Creating JAVA_HOME environment variable with : {0}".format(self.package_folder))
50+
self.env_info.JAVA_HOME = self.package_folder
51+
52+
self.output.info("Appending PATH environment variable with : {0}".format(os.path.join(self.package_folder, "bin")))
53+
self.env_info.PATH.append(os.path.join(self.package_folder, "bin"))
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from conans import ConanFile, tools
2+
from conans.errors import ConanException
3+
from io import StringIO
4+
5+
required_conan_version = ">=1.36.0"
6+
7+
8+
class TestPackage(ConanFile):
9+
test_type = "build_requires"
10+
11+
def build(self):
12+
pass # nothing to build, but tests should not warn
13+
14+
def test(self):
15+
if not tools.cross_building(self):
16+
output = StringIO()
17+
self.run("java --version", output=output, run_environment=True)
18+
print(output.getvalue)
19+
version_info = output.getvalue()
20+
if "openjdk" in version_info:
21+
pass
22+
else:
23+
raise ConanException("java call seems not use the openjdk bin")

recipes/openjdk/config.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
versions:
2+
"16.0.1":
3+
folder: all

0 commit comments

Comments
 (0)