Repository: conan-io/conan

Issue:
conan download --recipe does not download export_source
Conan version 1.15.0
Python 3.7.3
`uname -srmo` => `Linux 4.19.33-un-def-alt0.M80P.1 x86_64 GNU/Linux`

I am attempting to clone a package from a chosen remote, to have it locally in a "buildable" state. This is not achievable (with exception of dirty hacks mentinoned below).

If I attempt to download only the recipe with `conan download --recipe`, conan does not download the export_source directory, therefore, the downloaded package is not buildable without access to the remote.

Example 1:
```
$ conan remote list
conan-center: https://conan.bintray.com [Verify SSL: True]

$ rm -rf ~/.conan/data

$ conan download zlib/1.2.11@conan/stable --recipe --remote conan-center
( ... successful download output ... )

$ conan copy zlib/1.2.11@conan/stable my/stable
Downloading conan_sources.tgz
[==================================================] 7.1KB/7.1KB      
Decompressing conan_sources.tgz: 100%|██████████| 6.91k/6.91k [00:00<00:00, 1.13MB/s]
Copied zlib/1.2.11@conan/stable to zlib/1.2.11@my/stable
Copied sources zlib/1.2.11@conan/stable to zlib/1.2.11@my/stable
```

(`conan copy` still performs some downloading, while the copy operation is probably assumed to be local)

Example 2:
```
$ rm -rf ~/.conan/data
$ conan download zlib/1.2.11@conan/stable --recipe --remote conan-center
( ... successful download output ... )
$ conan remote remove conan-center
$ conan copy zlib/1.2.11@conan/stable my/stable
ERROR: Error while trying to get recipe sources for zlib/1.2.11@conan/stable. No remote defined
```

This behavior is a bit strange in my opinion, especially considering the fact that documentation explicitly states:

> Using exports_sources the package recipe can be self-contained, containing the source code like in a snapshot, and then not requiring downloading or retrieving the source code from other origins (git, download) with the source() method when it is necessary to build from sources.

and:

> The main difference with exports is that exports files are always retrieved (even if pre-compiled packages exist), while exports_sources files are only retrieved when it is necessary to build a package from sources.

https://docs.conan.io/en/latest/reference/conanfile/attributes.html#exports-sources

Actually it works a kind of opposite, because if I don't specify `--recipe` and try to download any binary package (even non-existent one!) conan DOES download export_source directory:

```
$ conan download zlib/1.2.11@conan/stable --package something-nonexistent --remote conan-center
( ... downloading progress ... )
zlib/1.2.11@conan/stable: Downloading zlib/1.2.11@conan/stable:something-nonexistent
zlib/1.2.11@conan/stable: Retrieving package something-nonexistent from remote 'conan-center' 
ERROR: Binary package not found: 'zlib/1.2.11@conan/stable:something-nonexistent'

$ ls -a ~/.conan/data/zlib/1.2.11/conan/stable
.  ..  export  export_source  metadata.json  metadata.json.lock
```

The only reasonable workaround I've found is:
- `conan download $PACKAGE_ID --package something-nonexistent --remote conan-center || true`
- `mkdir -p ~/.conan/data/PACKAGE/PATH/export_source` (because the packages which don't have `exports_sources` and rely on `source()` method instead don't create the directory, and `conan copy` command breaks in `complete_recipe_sources` method (client/source.py:15) - I will provide the reproduction scenario if requested).

---

- [X] I've read the [CONTRIBUTING guide](https://github.com/conan-io/conan/blob/develop/.github/CONTRIBUTING.md).
- [X] I've specified the Conan version, operating system version and any tool that can be relevant.
- [X] I've explained the steps to reproduce the error or the motivation/use case of the question/suggestion.




Discussion:

Resolving patch:
diff --git a/conans/client/cmd/download.py b/conans/client/cmd/download.py
--- a/conans/client/cmd/download.py
+++ b/conans/client/cmd/download.py
@@ -18,10 +18,10 @@ def download(ref, package_ids, remote, recipe, remote_manager,
     conan_file_path = cache.package_layout(ref).conanfile()
     conanfile = loader.load_class(conan_file_path)
 
-    if not recipe:  # Not only the recipe
-        # Download the sources too, don't be lazy
-        complete_recipe_sources(remote_manager, cache, conanfile, ref, remotes)
+    # Download the sources too, don't be lazy
+    complete_recipe_sources(remote_manager, cache, conanfile, ref, remotes)
 
+    if not recipe:  # Not only the recipe
         if not package_ids:  # User didn't specify a specific package binary
             output.info("Getting the complete package list from '%s'..." % ref.full_repr())
             packages_props = remote_manager.search_packages(remote, ref, None)


Test patch:
diff --git a/conans/test/functional/command/download_test.py b/conans/test/functional/command/download_test.py
--- a/conans/test/functional/command/download_test.py
+++ b/conans/test/functional/command/download_test.py
@@ -40,13 +40,13 @@ class Pkg(ConanFile):
         client.run("download pkg/0.1@lasote/stable --recipe")
 
         self.assertIn("Downloading conanfile.py", client.out)
-        self.assertNotIn("Downloading conan_sources.tgz", client.out)
+        self.assertIn("Downloading conan_sources.tgz", client.out)
         self.assertNotIn("Downloading conan_package.tgz", client.out)
         export = client.cache.package_layout(ref).export()
         self.assertTrue(os.path.exists(os.path.join(export, "conanfile.py")))
         self.assertEqual(conanfile, load(os.path.join(export, "conanfile.py")))
         source = client.cache.package_layout(ref).export_sources()
-        self.assertFalse(os.path.exists(os.path.join(source, "file.h")))
+        self.assertTrue(os.path.exists(os.path.join(source, "file.h")))
         conan = client.cache.package_layout(ref).base_folder()
         self.assertFalse(os.path.exists(os.path.join(conan, "package")))