diff --git a/conans/client/graph/graph_builder.py b/conans/client/graph/graph_builder.py index 1704247f7a6..b10b4efc4da 100644 --- a/conans/client/graph/graph_builder.py +++ b/conans/client/graph/graph_builder.py @@ -78,7 +78,7 @@ def _load_deps(self, node, down_reqs, dep_graph, public_deps, down_ref, down_opt param down_ref: ConanFileReference of who is depending on current node for this expansion """ # basic node configuration - new_reqs, new_options = self._config_node(node, down_reqs, down_ref, down_options) + new_reqs, new_options = self._config_node(node, down_reqs, down_ref, down_options, aliased) self._resolve_deps(node, aliased, update, remote_name) @@ -141,7 +141,7 @@ def _recurse(self, closure, new_reqs, new_options): return True return False - def _config_node(self, node, down_reqs, down_ref, down_options): + def _config_node(self, node, down_reqs, down_ref, down_options, aliased): """ update settings and option in the current ConanFile, computing actual requirement values, cause they can be overridden by downstream requires param settings: dict of settings values => {"os": "windows"} @@ -188,8 +188,12 @@ def _config_node(self, node, down_reqs, down_ref, down_options): conanfile.requirements() new_options = conanfile.options.deps_package_values - new_down_reqs = conanfile.requires.update(down_reqs, self._output, conanref, - down_ref) + if aliased: + for req in conanfile.requires.values(): + req.conan_reference = aliased.get(req.conan_reference, + req.conan_reference) + new_down_reqs = conanfile.requires.update(down_reqs, self._output, + conanref, down_ref) except ConanExceptionInUserConanfileMethod: raise except ConanException as e: diff --git a/conans/test/integration/alias_test.py b/conans/test/integration/alias_test.py index 146f6210171..2bbf7e8c667 100644 --- a/conans/test/integration/alias_test.py +++ b/conans/test/integration/alias_test.py @@ -8,6 +8,31 @@ class ConanAliasTest(unittest.TestCase): + def alias_overriden_test(self): + # https://github.com/conan-io/conan/issues/3353 + client = TestClient() + conanfile = """from conans import ConanFile +class Pkg(ConanFile): + pass +""" + client.save({"conanfile.py": conanfile}) + client.run("export . PkgA/0.1@user/testing") + client.run("alias PkgA/latest@user/testing PkgA/0.1@user/testing") + conanfile = """from conans import ConanFile +class Pkg(ConanFile): + requires = "PkgA/latest@user/testing" +""" + client.save({"conanfile.py": conanfile}) + client.run("export . PkgB/0.1@user/testing") + client.run("alias PkgB/latest@user/testing PkgB/0.1@user/testing") + conanfile = """from conans import ConanFile +class Pkg(ConanFile): + requires = "PkgA/latest@user/testing", "PkgB/latest@user/testing" +""" + client.save({"conanfile.py": conanfile}) + client.run("info .") + self.assertNotIn("overridden", client.out) + def test_alias_different_name(self): client = TestClient() error = client.run("alias myalias/1.0@user/channel lib/1.0@user/channel",