From 794c28d57df247c55e8116725f18cf806a4c354d Mon Sep 17 00:00:00 2001 From: Walid Boussaffa Date: Mon, 7 Jun 2021 15:46:37 +0100 Subject: [PATCH 1/8] added recipe for openjdk --- recipes/openjdk/all/conandata.yml | 14 +++++ recipes/openjdk/all/conanfile.py | 51 +++++++++++++++++++ recipes/openjdk/all/test_package/conanfile.py | 18 +++++++ recipes/openjdk/config.yml | 3 ++ 4 files changed, 86 insertions(+) create mode 100644 recipes/openjdk/all/conandata.yml create mode 100644 recipes/openjdk/all/conanfile.py create mode 100644 recipes/openjdk/all/test_package/conanfile.py create mode 100644 recipes/openjdk/config.yml diff --git a/recipes/openjdk/all/conandata.yml b/recipes/openjdk/all/conandata.yml new file mode 100644 index 0000000000000..5f4858ad93796 --- /dev/null +++ b/recipes/openjdk/all/conandata.yml @@ -0,0 +1,14 @@ +sources: + "16.0.1": + Windows: { + url: "https://download.java.net/java/GA/jdk16.0.1/7147401fd7354114ac51ef3e1328291f/9/GPL/openjdk-16.0.1_windows-x64_bin.zip", + sha256: "733b45b09463c97133d70c2368f1b9505da58e88f2c8a84358dd4accfd06a7a4", + } + Linux: { + url: "https://download.java.net/java/GA/jdk16.0.1/7147401fd7354114ac51ef3e1328291f/9/GPL/openjdk-16.0.1_linux-x64_bin.tar.gz", + sha256: "b1198ffffb7d26a3fdedc0fa599f60a0d12aa60da1714b56c1defbce95d8b235", + } + Macos: { + url: "https://download.java.net/java/GA/jdk16.0.1/7147401fd7354114ac51ef3e1328291f/9/GPL/openjdk-16.0.1_osx-x64_bin.tar.gz", + sha256: "6098f839954439d4916444757c542c1b8778a32461706812d41cc8bbefce7f2f", + } diff --git a/recipes/openjdk/all/conanfile.py b/recipes/openjdk/all/conanfile.py new file mode 100644 index 0000000000000..f4fc3a7c2ae9a --- /dev/null +++ b/recipes/openjdk/all/conanfile.py @@ -0,0 +1,51 @@ +from conans import ConanFile, tools +from conans.errors import ConanInvalidConfiguration +import os + + +class OpenJDK(ConanFile): + name = "openjdk" + url = "https://github.com/conan-io/conan-center-index/" + description = "Java Development Kit builds, from Oracle" + homepage = "https://jdk.java.net" + license = "GPL-2.0-with-classpath-exception" + topics = ("java", "jdk", "openjdk") + settings = "os", "arch" + no_copy_source = True + + @property + def _source_subfolder(self): + return "source_subfolder" + + def configure(self): + if self.settings.arch != "x86_64": + raise ConanInvalidConfiguration("Unsupported Architecture. This package currently only supports x86_64.") + if self.settings.os not in ["Windows", "Macos", "Linux"]: + raise ConanInvalidConfiguration("Unsupported os. This package currently only support Linux/Macos/Windows") + + def source(self): + tools.get(**self.conan_data["sources"][self.version][str(self.settings.os)], + destination=self._source_subfolder, strip_root=True) + + def package(self): + if self.settings.os == "Macos": + _source_subfolder = os.path.join(self._source_subfolder, "jdk-{}.jdk".format(self.version), "Contents", "Home") + else: + _source_subfolder = self._source_subfolder + self.copy(pattern="*", dst="bin", src=os.path.join(_source_subfolder, "bin"), + excludes=("msvcp140.dll", "vcruntime140.dll", "vcruntime140_1.dll")) + self.copy(pattern="*", dst="include", src=os.path.join(_source_subfolder, "include")) + self.copy(pattern="*", dst="lib", src=os.path.join(_source_subfolder, "lib")) + self.copy(pattern="*", dst=os.path.join("lib", "jmods"), src=os.path.join(_source_subfolder, "jmods")) + self.copy(pattern="*", dst="licenses", src=os.path.join(_source_subfolder, "legal")) + # conf folder is required for security settings, to avoid + # java.lang.SecurityException: Can't read cryptographic policy directory: unlimited + # https://github.com/conan-io/conan-center-index/pull/4491#issuecomment-774555069 + self.copy(pattern="*", dst="conf", src=os.path.join(_source_subfolder, "conf")) + + def package_info(self): + self.output.info("Creating JAVA_HOME environment variable with : {0}".format(self.package_folder)) + self.env_info.JAVA_HOME = self.package_folder + + self.output.info("Appending PATH environment variable with : {0}".format(os.path.join(self.package_folder, "bin"))) + self.env_info.PATH.append(os.path.join(self.package_folder, "bin")) diff --git a/recipes/openjdk/all/test_package/conanfile.py b/recipes/openjdk/all/test_package/conanfile.py new file mode 100644 index 0000000000000..089b50f57fafc --- /dev/null +++ b/recipes/openjdk/all/test_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile +from six import StringIO + + +class TestPackage(ConanFile): + + def build(self): + pass # nothing to build, but tests should not warn + + def test(self): + test_cmd = ['java', '--version'] + output = StringIO() + self.run(test_cmd, output=output) + version_info = output.getvalue() + if "openjdk" in version_info: + pass + else: + raise Exception("java call seems not use the openjdk bin") diff --git a/recipes/openjdk/config.yml b/recipes/openjdk/config.yml new file mode 100644 index 0000000000000..7fd63e870b786 --- /dev/null +++ b/recipes/openjdk/config.yml @@ -0,0 +1,3 @@ +versions: + "16.0.1": + folder: all From fee4c00587155c4f53c7e153e7796237db520f8f Mon Sep 17 00:00:00 2001 From: boussaffawalid Date: Fri, 16 Jul 2021 08:49:52 +0100 Subject: [PATCH 2/8] Update recipes/openjdk/all/conandata.yml Co-authored-by: Anonymous Maarten --- recipes/openjdk/all/conandata.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/recipes/openjdk/all/conandata.yml b/recipes/openjdk/all/conandata.yml index 5f4858ad93796..aec60c25555a8 100644 --- a/recipes/openjdk/all/conandata.yml +++ b/recipes/openjdk/all/conandata.yml @@ -1,14 +1,11 @@ sources: "16.0.1": - Windows: { + Windows: url: "https://download.java.net/java/GA/jdk16.0.1/7147401fd7354114ac51ef3e1328291f/9/GPL/openjdk-16.0.1_windows-x64_bin.zip", sha256: "733b45b09463c97133d70c2368f1b9505da58e88f2c8a84358dd4accfd06a7a4", - } - Linux: { + Linux: url: "https://download.java.net/java/GA/jdk16.0.1/7147401fd7354114ac51ef3e1328291f/9/GPL/openjdk-16.0.1_linux-x64_bin.tar.gz", sha256: "b1198ffffb7d26a3fdedc0fa599f60a0d12aa60da1714b56c1defbce95d8b235", - } - Macos: { + Macos: url: "https://download.java.net/java/GA/jdk16.0.1/7147401fd7354114ac51ef3e1328291f/9/GPL/openjdk-16.0.1_osx-x64_bin.tar.gz", sha256: "6098f839954439d4916444757c542c1b8778a32461706812d41cc8bbefce7f2f", - } From cb45d25b6caedf40d146fbf8962dc3d8bc3c5c76 Mon Sep 17 00:00:00 2001 From: boussaffawalid Date: Fri, 16 Jul 2021 08:50:27 +0100 Subject: [PATCH 3/8] Update recipes/openjdk/all/test_package/conanfile.py Co-authored-by: Anonymous Maarten --- recipes/openjdk/all/test_package/conanfile.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/recipes/openjdk/all/test_package/conanfile.py b/recipes/openjdk/all/test_package/conanfile.py index 089b50f57fafc..784dba79a43fd 100644 --- a/recipes/openjdk/all/test_package/conanfile.py +++ b/recipes/openjdk/all/test_package/conanfile.py @@ -1,18 +1,22 @@ from conans import ConanFile -from six import StringIO +from conans.errors import ConanException +from io import StringIO + +required_conan_version = ">=1.36.0" class TestPackage(ConanFile): + test_type = "build_requires" def build(self): pass # nothing to build, but tests should not warn def test(self): - test_cmd = ['java', '--version'] output = StringIO() - self.run(test_cmd, output=output) + self.run("java --version", output=output, run_environment=True) + print(output.getvalue) version_info = output.getvalue() if "openjdk" in version_info: pass else: - raise Exception("java call seems not use the openjdk bin") + raise ConanException("java call seems not use the openjdk bin") From 1186719ea152224daa1cc50f81a436e81cf1afcc Mon Sep 17 00:00:00 2001 From: Walid Boussaffa Date: Fri, 16 Jul 2021 09:07:32 +0100 Subject: [PATCH 4/8] fixed conandata.yml format --- recipes/openjdk/all/conandata.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/recipes/openjdk/all/conandata.yml b/recipes/openjdk/all/conandata.yml index aec60c25555a8..1f874e056684d 100644 --- a/recipes/openjdk/all/conandata.yml +++ b/recipes/openjdk/all/conandata.yml @@ -1,11 +1,11 @@ sources: "16.0.1": Windows: - url: "https://download.java.net/java/GA/jdk16.0.1/7147401fd7354114ac51ef3e1328291f/9/GPL/openjdk-16.0.1_windows-x64_bin.zip", - sha256: "733b45b09463c97133d70c2368f1b9505da58e88f2c8a84358dd4accfd06a7a4", + url: "https://download.java.net/java/GA/jdk16.0.1/7147401fd7354114ac51ef3e1328291f/9/GPL/openjdk-16.0.1_windows-x64_bin.zip" + sha256: "733b45b09463c97133d70c2368f1b9505da58e88f2c8a84358dd4accfd06a7a4" Linux: - url: "https://download.java.net/java/GA/jdk16.0.1/7147401fd7354114ac51ef3e1328291f/9/GPL/openjdk-16.0.1_linux-x64_bin.tar.gz", - sha256: "b1198ffffb7d26a3fdedc0fa599f60a0d12aa60da1714b56c1defbce95d8b235", + url: "https://download.java.net/java/GA/jdk16.0.1/7147401fd7354114ac51ef3e1328291f/9/GPL/openjdk-16.0.1_linux-x64_bin.tar.gz" + sha256: "b1198ffffb7d26a3fdedc0fa599f60a0d12aa60da1714b56c1defbce95d8b235" Macos: - url: "https://download.java.net/java/GA/jdk16.0.1/7147401fd7354114ac51ef3e1328291f/9/GPL/openjdk-16.0.1_osx-x64_bin.tar.gz", - sha256: "6098f839954439d4916444757c542c1b8778a32461706812d41cc8bbefce7f2f", + url: "https://download.java.net/java/GA/jdk16.0.1/7147401fd7354114ac51ef3e1328291f/9/GPL/openjdk-16.0.1_osx-x64_bin.tar.gz" + sha256: "6098f839954439d4916444757c542c1b8778a32461706812d41cc8bbefce7f2f" From 2f69f4a510e9607c4d2df44f007ea5cab1b12b1b Mon Sep 17 00:00:00 2001 From: boussaffawalid Date: Tue, 20 Jul 2021 21:04:12 +0100 Subject: [PATCH 5/8] Update recipes/openjdk/all/conanfile.py Co-authored-by: Uilian Ries --- recipes/openjdk/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/openjdk/all/conanfile.py b/recipes/openjdk/all/conanfile.py index f4fc3a7c2ae9a..722146716ab58 100644 --- a/recipes/openjdk/all/conanfile.py +++ b/recipes/openjdk/all/conanfile.py @@ -23,7 +23,7 @@ def configure(self): if self.settings.os not in ["Windows", "Macos", "Linux"]: raise ConanInvalidConfiguration("Unsupported os. This package currently only support Linux/Macos/Windows") - def source(self): + def build(self): tools.get(**self.conan_data["sources"][self.version][str(self.settings.os)], destination=self._source_subfolder, strip_root=True) From 74d890d7c6d5fb4d54732f5dda80ad24bff1a46d Mon Sep 17 00:00:00 2001 From: Walid Boussaffa Date: Tue, 27 Jul 2021 21:05:53 +0100 Subject: [PATCH 6/8] added required_conan_version --- recipes/openjdk/all/conanfile.py | 2 ++ recipes/openjdk/all/test_package/conanfile.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/recipes/openjdk/all/conanfile.py b/recipes/openjdk/all/conanfile.py index 722146716ab58..ca7fe99201c90 100644 --- a/recipes/openjdk/all/conanfile.py +++ b/recipes/openjdk/all/conanfile.py @@ -2,6 +2,8 @@ from conans.errors import ConanInvalidConfiguration import os +required_conan_version = ">=1.33.0" + class OpenJDK(ConanFile): name = "openjdk" diff --git a/recipes/openjdk/all/test_package/conanfile.py b/recipes/openjdk/all/test_package/conanfile.py index 784dba79a43fd..3ef27ab2a48f8 100644 --- a/recipes/openjdk/all/test_package/conanfile.py +++ b/recipes/openjdk/all/test_package/conanfile.py @@ -9,7 +9,7 @@ class TestPackage(ConanFile): test_type = "build_requires" def build(self): - pass # nothing to build, but tests should not warn + pass # nothing to build, but tests should not warn def test(self): output = StringIO() From 8c87412e31adba313f57fcef8591068e6e8f44bf Mon Sep 17 00:00:00 2001 From: boussaffawalid Date: Mon, 27 Sep 2021 08:40:22 +0100 Subject: [PATCH 7/8] Update recipes/openjdk/all/test_package/conanfile.py Co-authored-by: Javier G. Sogo --- recipes/openjdk/all/test_package/conanfile.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/recipes/openjdk/all/test_package/conanfile.py b/recipes/openjdk/all/test_package/conanfile.py index 3ef27ab2a48f8..4e8b6feab5f9c 100644 --- a/recipes/openjdk/all/test_package/conanfile.py +++ b/recipes/openjdk/all/test_package/conanfile.py @@ -12,11 +12,12 @@ def build(self): pass # nothing to build, but tests should not warn def test(self): - output = StringIO() - self.run("java --version", output=output, run_environment=True) - print(output.getvalue) - version_info = output.getvalue() - if "openjdk" in version_info: - pass - else: - raise ConanException("java call seems not use the openjdk bin") + if not tools.cross_building(self): + output = StringIO() + self.run("java --version", output=output, run_environment=True) + print(output.getvalue) + version_info = output.getvalue() + if "openjdk" in version_info: + pass + else: + raise ConanException("java call seems not use the openjdk bin") From 9e093ced819bd7f6a765629a3dd46269e1b3cbaf Mon Sep 17 00:00:00 2001 From: boussaffawalid Date: Mon, 27 Sep 2021 16:00:45 +0100 Subject: [PATCH 8/8] Update recipes/openjdk/all/test_package/conanfile.py Co-authored-by: Chris Mc --- recipes/openjdk/all/test_package/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/openjdk/all/test_package/conanfile.py b/recipes/openjdk/all/test_package/conanfile.py index 4e8b6feab5f9c..1165ac6f01ab3 100644 --- a/recipes/openjdk/all/test_package/conanfile.py +++ b/recipes/openjdk/all/test_package/conanfile.py @@ -1,4 +1,4 @@ -from conans import ConanFile +from conans import ConanFile, tools from conans.errors import ConanException from io import StringIO