From e84a9bc3d5ca92a026f49664d03aeff77a2f3e18 Mon Sep 17 00:00:00 2001 From: David Schulz Date: Wed, 12 Jun 2024 10:34:43 +0200 Subject: [PATCH] WorkspaceProject: exclude user file and define scheme url by default Change-Id: I359682a0010a42f00591c103c93b7f41c7f987fd Reviewed-by: Marcus Tillmanns --- src/plugins/lua/wizards/plugin/project.json | 2 ++ src/plugins/projectexplorer/workspaceproject.cpp | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/plugins/lua/wizards/plugin/project.json b/src/plugins/lua/wizards/plugin/project.json index f537bf2ea9d..b7879f50d77 100644 --- a/src/plugins/lua/wizards/plugin/project.json +++ b/src/plugins/lua/wizards/plugin/project.json @@ -1,4 +1,6 @@ { + "$schema": "https://download.qt.io/official_releases/qtcreator/latest/installer_source/jsonschemas/project.json", + "files.exclude": [".qtcreator/project.json.user"], "targets": [ { "name": "Qt Creator", diff --git a/src/plugins/projectexplorer/workspaceproject.cpp b/src/plugins/projectexplorer/workspaceproject.cpp index 5b0a92ba6c9..6cbb858921b 100644 --- a/src/plugins/projectexplorer/workspaceproject.cpp +++ b/src/plugins/projectexplorer/workspaceproject.cpp @@ -253,7 +253,12 @@ public: : Project(FOLDER_MIMETYPE, file.isDir() ? file / ".qtcreator" / "project.json" : file) { QTC_CHECK(projectFilePath().absolutePath().ensureWritableDir()); - QTC_CHECK(projectFilePath().ensureExistingFile()); + if (!projectFilePath().exists() && QTC_GUARD(projectFilePath().ensureExistingFile())) { + QJsonObject projectJson; + projectJson.insert("$schema", "https://download.qt.io/official_releases/qtcreator/latest/installer_source/jsonschemas/project.json"); + projectJson.insert(FILES_EXCLUDE_KEY, QJsonArray{QJsonValue(".qtcreator/project.json.user")}); + projectFilePath().writeFileContents(QJsonDocument(projectJson).toJson()); + } setId(Id::fromString(WORKSPACE_PROJECT_ID)); setDisplayName(projectDirectory().fileName());