From 3dafcc7e1464749e744bc77bbd589db37a12894b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Hohwiller?= Date: Fri, 17 Jan 2025 20:10:10 +0100 Subject: [PATCH] #919: improve license agreement and prevent license agreement being asked when opening a new shell --- .../tools/ide/context/AbstractIdeContext.java | 39 +++++++++---------- cli/src/main/package/setup | 21 +++++----- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/cli/src/main/java/com/devonfw/tools/ide/context/AbstractIdeContext.java b/cli/src/main/java/com/devonfw/tools/ide/context/AbstractIdeContext.java index 4b998aea1..c7acdbf12 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/context/AbstractIdeContext.java +++ b/cli/src/main/java/com/devonfw/tools/ide/context/AbstractIdeContext.java @@ -68,7 +68,7 @@ public abstract class AbstractIdeContext implements IdeContext { private static final GitUrl IDE_URLS_GIT = new GitUrl("https://github.com/devonfw/ide-urls.git", null); - + private static final String LICENSE_URL = "https://github.com/devonfw/IDEasy/blob/main/documentation/LICENSE.adoc"; private final IdeStartContextImpl startContext; @@ -894,14 +894,11 @@ private ValidationResult applyAndRun(CliArguments arguments, Commandlet cmd) { private void ensureLicenseAgreement() { - if ((this.ideRoot == null) || isTest()) { - return; // error: IDE_ROOT undefined - } - Path ideBase = this.ideRoot.resolve(FOLDER_IDE); - if (!Files.isDirectory(ideBase)) { - return; // error: $IDE_ROOT/_ide does not exist, broken installation + if (isTest()) { + return; // ignore for tests } - Path licenseAgreement = ideBase.resolve(FILE_LICENSE_AGREEMENT); + getFileAccess().mkdirs(this.userHomeIde); + Path licenseAgreement = this.userHomeIde.resolve(FILE_LICENSE_AGREEMENT); if (Files.isRegularFile(licenseAgreement)) { return; // success, license already accepted } @@ -915,18 +912,20 @@ private void ensureLicenseAgreement() { } StringBuilder sb = new StringBuilder(1180); sb.append(LOGO).append(""" - Welcome to IDEasy! - This product (with its included 3rd party components) is open-source software and can be used free (also commercially). - It supports automatic download and installation of arbitrary 3rd party tools. - By default only open-source 3rd party tools are used (downloaded, installed, executed). - But if explicitly configured, also commercial software that requires an additional license may be used. - This happens e.g. if you configure "ultimate" edition of IntelliJ or "docker" edition of Docker (Docker Desktop). - You are solely responsible for all risk implied by using this software. - Before using IDEasy you need to read and accept the license agreement with all involved licenses. - You will be able to find it online under the following URL: - """).append(LICENSE_URL) - .append("\n\nAlso it is included in the documentation that you can find here:\n"). - append(ideBase.resolve("IDEasy.pdf").toString()).append("\n"); + Welcome to IDEasy! + This product (with its included 3rd party components) is open-source software and can be used free (also commercially). + It supports automatic download and installation of arbitrary 3rd party tools. + By default only open-source 3rd party tools are used (downloaded, installed, executed). + But if explicitly configured, also commercial software that requires an additional license may be used. + This happens e.g. if you configure "ultimate" edition of IntelliJ or "docker" edition of Docker (Docker Desktop). + You are solely responsible for all risk implied by using this software. + Before using IDEasy you need to read and accept the license agreement with all involved licenses. + You will be able to find it online under the following URL: + """).append(LICENSE_URL); + if (this.ideRoot != null) { + sb.append("\n\nAlso it is included in the documentation that you can find here:\n"). + append(this.ideRoot.resolve(FOLDER_IDE).resolve("IDEasy.pdf").toString()).append("\n"); + } info(sb.toString()); askToContinue("Do you accept these terms of use and all license agreements?"); diff --git a/cli/src/main/package/setup b/cli/src/main/package/setup index 7f1feae1f..017e510e2 100755 --- a/cli/src/main/package/setup +++ b/cli/src/main/package/setup @@ -1,15 +1,10 @@ #!/bin/bash -function createFile() { - local fileName=$1 - touch "$fileName" - echo "Created ${fileName}" -} - function createFileIfNotExists() { - local fileName=$1 - if [ ! -f "${fileName}" ]; then - createFile "$fileName" + local file=$1 + if [ ! -f "${file}" ]; then + touch "$file" + echo "Created ${file}" fi } @@ -35,8 +30,14 @@ if [ "${PWD/*\//}" != "_ide" ]; then fi echo "Setting up IDEasy in ${PWD}" cd .. +if [ "${PWD/*\//}" != "projects" ]; then + echo -e "\033[93mYour IDE_ROOT folder is $PWD - you need to rename ${PWD/*\//} to 'projects'.\033[39m" >&2 + exit 1 +fi export IDE_ROOT=${PWD} -source "$IDE_ROOT/_ide/functions" +source "$IDE_ROOT/_ide/functions" || exit 255 +# enforce license agreement +ide -v || exit 255 doSetupInConfigFile ~/.bashrc doSetupInConfigFile ~/.zshrc