lasote: Pushed again, please check
diff --git a/conans/client/action_recorder.py b/conans/client/action_recorder.py
index bf573d9cb..d771bf075 100644
--- a/conans/client/action_recorder.py
+++ b/conans/client/action_recorder.py
@@ -7,6 +7,8 @@ from datetime import datetime
 from collections import namedtuple, OrderedDict
 
 # Install actions
+from conans.model.ref import ConanFileReference, PackageReference
+
 INSTALL_CACHE = 0
 INSTALL_DOWNLOADED = 1
 INSTALL_BUILT = 2
@@ -32,8 +34,11 @@ class ActionRecorder(object):
     def __init__(self):
         self._inst_recipes_actions = OrderedDict()
         self._inst_packages_actions = OrderedDict()
+        self._inst_recipes_develop = set()  # Recipes being created (to set dependency=False)
 
     # ###### INSTALL METHODS ############
+    def add_recipe_being_developed(self, reference):
+        self._inst_recipes_develop.add(reference)
 
     def _add_recipe_action(self, reference, action):
         if reference not in self._inst_recipes_actions:
@@ -90,6 +95,12 @@ class ActionRecorder(object):
                 ret.append((_package_ref, _package_action))
         return ret
 
+    def in_development_recipe(self, reference):
+        return reference in self._inst_recipes_develop
+
+    def get_info(self):
+        return self.get_install_info()
+
     def get_install_info(self):
         ret = {"error": self.install_errored,
                "installed": []}
@@ -98,11 +109,15 @@ class ActionRecorder(object):
             error = None if the_action.type != INSTALL_ERROR else the_action.doc
             doc = {"id": str(the_ref),
                    "downloaded": the_action.type == INSTALL_DOWNLOADED,
-                   "built": the_action.type == INSTALL_BUILT,
                    "cache": the_action.type == INSTALL_CACHE,
                    "error": error,
                    "remote": the_action.doc.get("remote", None),
                    "time": the_action.time}
+            if isinstance(the_ref, ConanFileReference):
+                doc["dependency"] = not self.in_development_recipe(the_ref)
+            else:
+                doc["built"] = the_action.type == INSTALL_BUILT
+
             if doc["remote"] is None and error:
                 doc["remote"] = error.get("remote", None)
             return doc
@@ -111,7 +126,6 @@ class ActionRecorder(object):
             # Could be a download and then an access to cache, we want the first one
             action = actions[0]
             recipe_doc = get_doc_for_ref(ref, action)
-            del recipe_doc["built"]  # Avoid confusions
             packages = self._get_installed_packages(ref)
             tmp = {"recipe": recipe_doc,
                    "packages": []}
diff --git a/conans/client/command.py b/conans/client/command.py
index 19513161d..f805caf51 100644
--- a/conans/client/command.py
+++ b/conans/client/command.py
@@ -220,17 +220,21 @@ class Command(object):
 
         cwd = os.getcwd()
 
+        info = None
         try:
-            self._conan.create(args.path, name, version, user, channel,
-                               args.profile, args.settings, args.options,
-                               args.env, args.test_folder, args.not_export,
-                               args.build, args.keep_source, args.keep_build, args.verify,
-                               args.manifests, args.manifests_interactive,
-                               args.remote, args.update,
-                               test_build_folder=args.test_build_folder)
+            info = self._conan.create(args.path, name, version, user, channel,
+                                      args.profile, args.settings, args.options,
+                                      args.env, args.test_folder, args.not_export,
+                                      args.build, args.keep_source, args.keep_build, args.verify,
+                                      args.manifests, args.manifests_interactive,
+                                      args.remote, args.update,
+                                      test_build_folder=args.test_build_folder)
+        except ConanException as exc:
+            info = exc.info
+            raise
         finally:
-            if args.json:
-                self._outputer.json_install(self._conan.recorder.get_install_info(), args.json, cwd)
+            if args.json and info:
+                self._outputer.json_install(info, args.json, cwd)
 
     def download(self, *args):
         """Downloads recipe and binaries to the local cache, without using settings. It works
@@ -289,34 +293,38 @@ class Command(object):
         args = parser.parse_args(*args)
         cwd = os.getcwd()
 
+        info = None
         try:
             try:
                 reference = ConanFileReference.loads(args.path_or_reference)
             except ConanException:
-                self._conan.install(path=args.path_or_reference,
-                                    settings=args.settings, options=args.options,
-                                    env=args.env,
-                                    remote=args.remote,
-                                    verify=args.verify, manifests=args.manifests,
-                                    manifests_interactive=args.manifests_interactive,
-                                    build=args.build, profile_name=args.profile,
-                                    update=args.update, generators=args.generator,
-                                    no_imports=args.no_imports,
-                                    install_folder=args.install_folder)
+                info = self._conan.install(path=args.path_or_reference,
+                                           settings=args.settings, options=args.options,
+                                           env=args.env,
+                                           remote=args.remote,
+                                           verify=args.verify, manifests=args.manifests,
+                                           manifests_interactive=args.manifests_interactive,
+                                           build=args.build, profile_name=args.profile,
+                                           update=args.update, generators=args.generator,
+                                           no_imports=args.no_imports,
+                                           install_folder=args.install_folder)
             else:
-                self._conan.install_reference(reference, settings=args.settings,
-                                              options=args.options,
-                                              env=args.env,
-                                              remote=args.remote,
-                                              verify=args.verify, manifests=args.manifests,
-                                              manifests_interactive=args.manifests_interactive,
-                                              build=args.build, profile_name=args.profile,
-                                              update=args.update,
-                                              generators=args.generator,
-                                              install_folder=args.install_folder)
+                info = self._conan.install_reference(reference, settings=args.settings,
+                                                     options=args.options,
+                                                     env=args.env,
+                                                     remote=args.remote,
+                                                     verify=args.verify, manifests=args.manifests,
+                                                     manifests_interactive=args.manifests_interactive,
+                                                     build=args.build, profile_name=args.profile,
+                                                     update=args.update,
+                                                     generators=args.generator,
+                                                     install_folder=args.install_folder)
+        except ConanException as exc:
+            info = exc.info
+            raise
         finally:
-            if args.json:
-                self._outputer.json_install(self._conan.recorder.get_install_info(), args.json, cwd)
+            if args.json and info:
+                self._outputer.json_install(info, args.json, cwd)
 
     def config(self, *args):
         """Manages Conan configuration. Edits the conan.conf or installs config files.
diff --git a/conans/client/conan_api.py b/conans/client/conan_api.py
index 98ee25d5a..dd50689b2 100644
--- a/conans/client/conan_api.py
+++ b/conans/client/conan_api.py
@@ -65,15 +65,21 @@ def api_method(f):
         the_self = args[0]
         try:
             log_command(f.__name__, kwargs)
+            the_self._init_manager()
             with tools.environment_append(the_self._client_cache.conan_config.env_vars):
                 # Patch the globals in tools
-                return f(*args, **kwargs)
+                ret = f(*args, **kwargs)
+                if ret is None:  # FIXME: Probably each method should manage its return
+                    return the_self._recorder.get_info()
+                return ret
         except Exception as exc:
             msg = exception_message_safe(exc)
             try:
                 log_exception(exc, msg)
             except:
                 pass
+            if isinstance(exc, ConanException):
+                exc.info = the_self._recorder.get_info()
             raise
 
     return wrapper
@@ -207,13 +213,22 @@ class ConanAPIV1(object):
         self._user_io = user_io
         self._runner = runner
         self._remote_manager = remote_manager
-        self.recorder = ActionRecorder()
+        self._search_manager = search_manager
+        self._settings_preprocessor = _settings_preprocessor
         self._registry = RemoteRegistry(self._client_cache.registry, self._user_io.out)
-        self._manager = ConanManager(client_cache, user_io, runner, remote_manager, search_manager,
-                                     _settings_preprocessor, self.recorder, self._registry)
+        self._recorder = None
+        self._manager = None
+
         if not interactive:
             self._user_io.disable_input()
 
+    def _init_manager(self):
+        """Every api call gets a new recorder and new manager"""
+        self._recorder = ActionRecorder()
+        self._manager = ConanManager(self._client_cache, self._user_io, self._runner,
+                                     self._remote_manager, self._search_manager,
+                                     self._settings_preprocessor, self._recorder, self._registry)
+
     @api_method
     def new(self, name, header=False, pure_c=False, test=False, exports_sources=False, bare=False,
             cwd=None, visual_versions=None, linux_gcc_versions=None, linux_clang_versions=None,
@@ -319,6 +334,7 @@ class ConanAPIV1(object):
                                          "or it doesn't have a conanfile.py" % tf)
 
         test_conanfile_path = get_test_conanfile_path(test_folder)
+        self._recorder.add_recipe_being_developed(reference)
 
         if test_conanfile_path:
             pt = PackageTester(self._manager, self._user_io)
diff --git a/conans/errors.py b/conans/errors.py
index 256f20a3f..e5b73a087 100644
--- a/conans/errors.py
+++ b/conans/errors.py
@@ -68,7 +68,9 @@ class ConanException(Exception):
     """
          Generic conans exception
     """
-    pass
+    def __init__(self, *args, **kwargs):
+        self.info = None
+        super(ConanException, self).__init__(*args, **kwargs)
 
 
 class NoRemoteAvailable(ConanException):

Issues with the JSON created by conan create
Conan version: 1.2.0

Command: `conan create --json ./foo.json . myteam/unstable`

The generated JSON does not separate the dependency packages of the built project, from the built package. This makes it difficult to parse.
diff --git a/conans/test/command/json_output_test.py b/conans/test/command/json_output_test.py
index a9f64b87a..0cf3ba030 100644
--- a/conans/test/command/json_output_test.py
+++ b/conans/test/command/json_output_test.py
@@ -23,6 +23,7 @@ class JsonOutputTest(unittest.TestCase):
         my_json = json.loads(load(os.path.join(self.client.current_folder, "myfile.json")))
         self.assertFalse(my_json["error"])
         self.assertEquals(my_json["installed"][0]["recipe"]["id"], "CC/1.0@private_user/channel")
+        self.assertFalse(my_json["installed"][0]["recipe"]["dependency"])
         self.assertTrue(my_json["installed"][0]["recipe"]["cache"])
         self.assertIsNone(my_json["installed"][0]["recipe"]["remote"])
         self.assertTrue(my_json["installed"][0]["packages"][0]["built"])
@@ -37,6 +38,7 @@ class JsonOutputTest(unittest.TestCase):
         self.assertIn("T", the_time_str) # Weak validation of the ISO 8601
         self.assertFalse(my_json["error"])
         self.assertEquals(my_json["installed"][0]["recipe"]["id"], "CC/1.0@private_user/channel")
+        self.assertTrue(my_json["installed"][0]["recipe"]["dependency"])
         self.assertFalse(my_json["installed"][0]["recipe"]["cache"])
         self.assertTrue(my_json["installed"][0]["recipe"]["downloaded"])
         self.assertIsNotNone(my_json["installed"][0]["recipe"]["remote"])
@@ -164,6 +166,10 @@ AA*: CC/1.0@private_user/channel
         my_json = load(os.path.join(self.client.current_folder, "myfile.json"))
         my_json = json.loads(my_json)
 
+        self.assertTrue(my_json["installed"][0]["recipe"]["dependency"])
+        self.assertTrue(my_json["installed"][1]["recipe"]["dependency"])
+        self.assertTrue(my_json["installed"][2]["recipe"]["dependency"])
+
         # Installed the build require CC with two options
         self.assertEquals(len(my_json["installed"][2]["packages"]), 2)
         self.assertEquals(my_json["installed"][2]["recipe"]["id"], "CC/1.0@private_user/channel")
diff --git a/conans/test/model/version_ranges_test.py b/conans/test/model/version_ranges_test.py
index 71012b623..919b29a8c 100644
--- a/conans/test/model/version_ranges_test.py
+++ b/conans/test/model/version_ranges_test.py
@@ -1,4 +1,5 @@
 import unittest
+
 from conans.test.utils.tools import TestBufferConanOutput
 from conans.paths import CONANFILE
 import os
diff --git a/conans/test/util/action_recorder_test.py b/conans/test/util/action_recorder_test.py
index 0a93a1570..ac85817b5 100644
--- a/conans/test/util/action_recorder_test.py
+++ b/conans/test/util/action_recorder_test.py
@@ -19,9 +19,11 @@ class ActionRecorderTest(unittest.TestCase):
     def incomplete_process_test(self):
         tracer = ActionRecorder()
         tracer.recipe_install_error(self.ref1, INSTALL_ERROR_NETWORK, "SSL wtf", "http://drl.com")
-        install_info = tracer.get_install_info()
+        tracer.add_recipe_being_developed(self.ref1)
+        install_info = tracer.get_info()
         self.assertTrue(install_info["error"])
         self.assertEquals(install_info["installed"][0]["packages"], [])
+        self.assertEquals(install_info["installed"][0]["recipe"]["dependency"], False)
 
     def double_actions_test(self):
         tracer = ActionRecorder()
@@ -30,7 +32,7 @@ class ActionRecorderTest(unittest.TestCase):
         tracer.package_downloaded(self.ref_p1, "http://drl.com")
         tracer.package_fetched_from_cache(self.ref_p1)
 
-        install_info = tracer.get_install_info()
+        install_info = tracer.get_info()
         self.assertFalse(install_info["error"])
 
         first_installed = install_info["installed"][0]
@@ -55,12 +57,15 @@ class ActionRecorderTest(unittest.TestCase):
 
         tracer.recipe_fetched_from_cache(self.ref3)
         tracer.package_built(self.ref_p3)
+        tracer.add_recipe_being_developed(self.ref1)
 
-        install_info = tracer.get_install_info()
+        install_info = tracer.get_info()
         self.assertTrue(install_info["error"])
 
         first_installed = install_info["installed"][0]
+
         self.assertTrue(first_installed["recipe"]["cache"])
+        self.assertFalse(first_installed["recipe"]["dependency"])
         self.assertFalse(first_installed["recipe"]["downloaded"])
         self.assertIsNone(first_installed["recipe"]["error"])
         self.assertEquals(str(first_installed["recipe"]["id"]), "lib1/1.0@conan/stable")
@@ -73,6 +78,7 @@ class ActionRecorderTest(unittest.TestCase):
 
         second_installed = install_info["installed"][1]
         self.assertFalse(second_installed["recipe"]["cache"])
+        self.assertTrue(second_installed["recipe"]["dependency"])
         self.assertTrue(second_installed["recipe"]["downloaded"])
         self.assertIsNone(second_installed["recipe"]["error"])
         self.assertEquals(str(second_installed["recipe"]["id"]), "lib2/1.0@conan/stable")
@@ -85,6 +91,7 @@ class ActionRecorderTest(unittest.TestCase):
         self.assertEquals(str(second_installed["packages"][0]["id"]), "2")
 
         third_installed = install_info["installed"][2]
+        self.assertTrue(third_installed["recipe"]["dependency"])
         self.assertFalse(third_installed["packages"][0]["cache"])
         self.assertFalse(third_installed["packages"][0]["error"])
         self.assertTrue(third_installed["packages"][0]["built"])

pip install -e .[dev]
parse_log_pytest
requirements.txt
nose nose-cov pytest
apt-get update apt-get install -y gcc
3.6
conans/requirements.txt conans/requirements_osx.txt conans/requirements_server.txt conans/requirements_dev.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
asn1crypto==1.5.1
astroid==1.6.6
attrs==22.2.0
beautifulsoup4==4.12.3
bottle==0.12.25
certifi==2021.5.30
cffi==1.15.1
charset-normalizer==2.0.12
codecov==2.1.13
colorama==0.3.9
-e git+https://github.com/conan-io/conan.git@35c00decd88eb8dfb87871209907ddce4f7ce170#egg=conan
cov-core==1.15.0
coverage==4.2
cryptography==2.1.4
deprecation==2.0.7
distro==1.1.0
fasteners==0.19
future==0.16.0
idna==3.10
importlib-metadata==4.8.3
iniconfig==1.1.1
isort==5.10.1
lazy-object-proxy==1.7.1
mccabe==0.7.0
mock==1.3.0
ndg-httpsclient==0.4.4
node-semver==0.2.0
nose==1.3.7
nose-cov==1.6
packaging==21.3
parameterized==0.8.1
patch==1.16
pbr==6.1.1
pluggy==1.0.0
pluginbase==0.7
py==1.11.0
pyasn==1.5.0b7
pyasn1==0.5.1
pycparser==2.21
Pygments==2.14.0
PyJWT==1.7.1
pylint==1.8.4
pyOpenSSL==17.5.0
pyparsing==3.1.4
pytest==7.0.1
PyYAML==3.12
requests==2.27.1
six==1.17.0
soupsieve==2.3.2.post1
tomli==1.2.3
typing_extensions==4.1.1
urllib3==1.26.20
waitress==2.0.0
WebOb==1.8.9
WebTest==2.0.35
wrapt==1.16.0
zipp==3.6.0

name: conan
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2021.5.30=py36h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.3=he6710b0_2
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=21.2.2=py36h06a4308_0
  - python=3.6.13=h12debd9_1
  - readline=8.2=h5eee18b_0
  - setuptools=58.0.4=py36h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - asn1crypto==1.5.1
      - astroid==1.6.6
      - attrs==22.2.0
      - beautifulsoup4==4.12.3
      - bottle==0.12.25
      - cffi==1.15.1
      - charset-normalizer==2.0.12
      - codecov==2.1.13
      - colorama==0.3.9
      - cov-core==1.15.0
      - coverage==4.2
      - cryptography==2.1.4
      - deprecation==2.0.7
      - distro==1.1.0
      - fasteners==0.19
      - future==0.16.0
      - idna==3.10
      - importlib-metadata==4.8.3
      - iniconfig==1.1.1
      - isort==5.10.1
      - lazy-object-proxy==1.7.1
      - mccabe==0.7.0
      - mock==1.3.0
      - ndg-httpsclient==0.4.4
      - node-semver==0.2.0
      - nose==1.3.7
      - nose-cov==1.6
      - packaging==21.3
      - parameterized==0.8.1
      - patch==1.16
      - pbr==6.1.1
      - pluggy==1.0.0
      - pluginbase==0.7
      - py==1.11.0
      - pyasn==1.5.0b7
      - pyasn1==0.5.1
      - pycparser==2.21
      - pygments==2.14.0
      - pyjwt==1.7.1
      - pylint==1.8.4
      - pyopenssl==17.5.0
      - pyparsing==3.1.4
      - pytest==7.0.1
      - pyyaml==3.12
      - requests==2.27.1
      - six==1.17.0
      - soupsieve==2.3.2.post1
      - tomli==1.2.3
      - typing-extensions==4.1.1
      - urllib3==1.26.20
      - waitress==2.0.0
      - webob==1.8.9
      - webtest==2.0.35
      - wrapt==1.16.0
      - zipp==3.6.0
prefix: /opt/conda/envs/conan

conans/test/util/action_recorder_test.py::ActionRecorderTest::test_install
conans/test/command/json_output_test.py::JsonOutputTest::test_errors conans/test/command/json_output_test.py::JsonOutputTest::test_json_generation conans/test/command/json_output_test.py::JsonOutputTest::test_simple_fields
conans/test/model/version_ranges_test.py::VersionRangesTest::test_local_basic conans/test/model/version_ranges_test.py::VersionRangesTest::test_remote_basic
conans/client/conan_api.py conans/errors.py conans/client/action_recorder.py conans/client/command.py
conans/client/conan_api.py conans/errors.py conans/client/action_recorder.py conans/client/command.py