From 0b9cb2b1f86b5749593acd8919a21fc6e7a27c12 Mon Sep 17 00:00:00 2001 From: David B <997605+DevDavido@users.noreply.github.com> Date: Wed, 5 Jul 2023 08:36:27 +0200 Subject: [PATCH] feat: Deprecate license handling (#87395) * refactor: Fix typos (#87395) * feat: Deprecate license related properties and remove usage (#87395) * docs: Update README to reflect deprecated license related properties (#87395) * test: Remove license related tests (#87395) --- README.asciidoc | 24 +++--- build.gradle.kts | 4 +- .../icm/extension/DevelopmentConfiguration.kt | 57 +++++++------- ...MProjectPluginIntegrationKotlinSpec.groovy | 75 ------------------- .../ICMProjectPluginIntegrationSpec.groovy | 69 ----------------- 5 files changed, 41 insertions(+), 188 deletions(-) diff --git a/README.asciidoc b/README.asciidoc index 8d8b050..c598721 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -12,7 +12,7 @@ Intershop Commerce Management Server. == Intershop Commerce Management Cartridge Plugins -image::images/CartridgePlugins.png[Cartrdige Plugins, 500] +image::images/CartridgePlugins.png[Cartridge Plugins, 500] The abstract Cartridge plugin adds a pom property "cartridge.style" if the https://docs.gradle.org/current/userguide/publishing_maven.html[Gradle "Maven Publish Plugin"] is applied. @@ -227,19 +227,19 @@ It is not necessary to apply this plugin to a project separately, because it has WriteCartridgeDescriptor` | Creates a the Cartridge descriptor file `cartridge.descriptor`. |=== -[[anchor-1]][1] The default value of "classpath.file.enabled" is false. +[[anchor-1]][1] The default value of "classpath.file.enabled" is false. [[anchor-2]][2] Files, installed on the container of the base project, will be not copied if the base project provides a filter file. There is also a special setting in the extension possible. List entries have the following form: ``--``. -=== Public Cartrige Plugin +=== Public Cartridge Plugin This plugin applies the https://docs.gradle.org/current/userguide/publishing_maven.html[Gradle "Maven Publish Plugin"] to a project and configures the publication of a plugin for further development. It adds the project library, the source, and Java doc jars to the publication and the description and the inception year to the pom. -Furthmore the pom property "cartridge.name" is added to the publishing configuration. +Furthermore the pom property "cartridge.name" is added to the publishing configuration. It is not necessary to apply this plugin to a project separately, because it has been applied by some of the plugins above. @@ -397,21 +397,23 @@ The project information (`projectInfo`) is used in the display of the login dial |`licenseDirectory` | `String` | One of these values in the following order: + -1. value of environement variable `LICENSEDIR` + +1. value of environment variable `LICENSEDIR` + 2. value of system property `licenseDir` + 3. value of Gradle property `licenseDir` + 4. default value `$GRADLE_USER_HOME/icm-default/lic` | Path of a directory with the -Intershop license file. This is required by an ICM server instance. -|`licenseFilePath` | `String` | `/license.xml` |The absolute path of the license file. +Intershop license file. This is required by an ICM server instance. + +*Deprecated since 5.8.0:* Property licenseDirectory is unsupported. +|`licenseFilePath` | `String` | `/license.xml` |The absolute path of the license file. + +*Deprecated since 5.8.0:* Property licenseFilePath is unsupported. |`configDirectory` | `String` | One of these values in the following order: + -1. value of environement variable `CONFIGDIR` + +1. value of environment variable `CONFIGDIR` + 2. value of system property `configDir` + 3. value of Gradle property `configDir` + 4. default value `$GRADLE_USER_HOME/icm-default/conf` |Path of a directory with a local environment specific configuration file. This is necessary to overwrite an existing configuration of a server, such as the database settings. -|`configFilePath` | `String` | `/icm.properties` | The absolute path of the configuration file. +|`configFilePath` | `String` | `/icm.properties` | The absolute path of the configuration file. |=== NOTE: All properties are read only. @@ -612,8 +614,8 @@ server/config_folder` | Contains the complete configuration of a development ser |=== |Property | Type | Default value | Description | `newBaseProject` | `boolean` | `false` | If this property is true, the configuration release can be used as a new base project. -| `cartridgeListDependency` | `Property` | *optional* | If the base cartridge list configuration should not be taken from the base project, it is necessary to specify a separate configuration. -| `libFilterFileDependency` | `Property` | *optional* | If the base library filter configuration should not be taken from the base project, it is necessary to specify a separate configuration. +| `cartridgeListDependency` | `Property` | *optional* | If the base cartridge list configuration should not be taken from the base project, it is necessary to specify a separate configuration. +| `libFilterFileDependency` | `Property` | *optional* | If the base library filter configuration should not be taken from the base project, it is necessary to specify a separate configuration. | `cartridges` | `SetProperty` | | This configuration is used to extend the base cartridge list for the project. It contains a set of cartridge dependencies and project names. | `dbprepareCartridges` | `SetProperty` | | This configuration is used to extend the base cartridge list for the project for Database preparation. It contains a set of cartridge dependencies and project names. |=== diff --git a/build.gradle.kts b/build.gradle.kts index b68ed27..f3dcec4 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -118,8 +118,8 @@ gradlePlugin { create("icmAdapterCartridgePlugin") { id = "com.intershop.icm.cartridge.adapter" implementationClass = "com.intershop.gradle.icm.cartridge.AdapterPlugin" - displayName = "icm-adpater-cartridge" - description = "The adpater cartridge plugin applies all basic configurations and tasks of an external adpater cartridge." + displayName = "icm-adapter-cartridge" + description = "The adapter cartridge plugin applies all basic configurations and tasks of an external adapter cartridge." } create("icmExternalCartridgePlugin") { id = "com.intershop.icm.cartridge.external" diff --git a/src/main/kotlin/com/intershop/gradle/icm/extension/DevelopmentConfiguration.kt b/src/main/kotlin/com/intershop/gradle/icm/extension/DevelopmentConfiguration.kt index f87eb97..8045248 100644 --- a/src/main/kotlin/com/intershop/gradle/icm/extension/DevelopmentConfiguration.kt +++ b/src/main/kotlin/com/intershop/gradle/icm/extension/DevelopmentConfiguration.kt @@ -43,23 +43,38 @@ open class DevelopmentConfiguration */ val log: Logger = LoggerFactory.getLogger(this::class.java.name) + @Deprecated( + message = "Environment variable LICENSE_DIR_ENV is unsupported since 5.8.0 and no longer used", + level = DeprecationLevel.WARNING + ) const val LICENSE_DIR_ENV = "LICENSEDIR" const val CONFIG_DIR_ENV = "CONFIGDIR" const val CONFIG_DIR_SEC_ENV = "CONFIGDIR" + @Deprecated( + message = "LICENSE_DIR_SYS is unsupported since 5.8.0 and no longer used", + level = DeprecationLevel.WARNING + ) const val LICENSE_DIR_SYS = "licenseDir" const val CONFIG_DIR_SYS = "configDir" const val CONFIG_DIR_SEC_SYS = "configDir" + @Deprecated( + message = "DEFAULT_LIC_PATH is unsupported since 5.8.0 and no longer used", + level = DeprecationLevel.WARNING + ) const val DEFAULT_LIC_PATH = "icm-default/lic" const val DEFAULT_CONFIG_PATH = "icm-default/conf" const val DEFAULT_CONFIGSEC_PATH = "icm-default/confSec" + @Deprecated( + message = "LICENSE_FILE_NAME is unsupported since 5.8.0 and no longer used", + level = DeprecationLevel.WARNING + ) const val LICENSE_FILE_NAME = "license.xml" const val CONFIG_FILE_NAME = "icm.properties" } - private val licenseDirectoryProperty: Property = objectFactory.property(String::class.java) private val configDirectoryProperty: Property = objectFactory.property(String::class.java) private val configDirectorySecProperty: Property = objectFactory.property(String::class.java) private val configProperties: Properties = Properties() @@ -70,15 +85,9 @@ open class DevelopmentConfiguration val gradleUserHomePath = GradleUserHomeLookup.gradleUserHome().absolutePath with(providerFactory) { - var licDirPath = environmentVariable(LICENSE_DIR_ENV).forUseAtConfigurationTime().orNull var configDirPath = environmentVariable(CONFIG_DIR_ENV).forUseAtConfigurationTime().orNull var configDirSecPath = environmentVariable(CONFIG_DIR_SEC_ENV).forUseAtConfigurationTime().orNull - // read system if necessary - if (licDirPath == null) { - licDirPath = systemProperty(LICENSE_DIR_SYS).forUseAtConfigurationTime().orNull - } - if (configDirPath == null) { configDirPath = systemProperty(CONFIG_DIR_SYS).forUseAtConfigurationTime().orNull } @@ -86,14 +95,6 @@ open class DevelopmentConfiguration configDirSecPath = systemProperty(CONFIG_DIR_SEC_SYS).forUseAtConfigurationTime().orNull } - if (licDirPath == null) { - try { - licDirPath = gradleProperty(LICENSE_DIR_SYS).forUseAtConfigurationTime().orNull - } catch (ise: IllegalStateException) { - log.error(ise.message) - } - } - if (configDirPath == null) { try { configDirPath = gradleProperty(CONFIG_DIR_SYS).forUseAtConfigurationTime().orNull @@ -109,12 +110,6 @@ open class DevelopmentConfiguration } } - if (licDirPath == null) { - logger.warn("The default value is used for license directory, because there is no " + - "other value specified.") - licDirPath = File(File(gradleUserHomePath), DEFAULT_LIC_PATH).absolutePath - } - if (configDirPath == null) { logger.warn("The default value is used for configuration directory, because there is no " + "other value specified.") @@ -127,7 +122,6 @@ open class DevelopmentConfiguration tempConfigDirSecPath } else { null } } - licenseDirectoryProperty.set(licDirPath) configDirectoryProperty.set(configDirPath) if (configDirSecPath != null) { @@ -141,13 +135,6 @@ open class DevelopmentConfiguration } } - val licFile = File(licenseDirectory, LICENSE_FILE_NAME) - if (! licFile.exists() && ! licFile.canRead()) { - logger.error("The File {} does not exists." + - "Please specify the directory with the license file with LICENSEDIR environment or" + - "with 'licenseDir' Gradle Property or system variable.", licFile.absolutePath) - } - val configFile = File(configDirectory, CONFIG_FILE_NAME) if (configFile.exists() && configFile.canRead()) { configProperties.load(configFile.inputStream()) @@ -162,11 +149,19 @@ open class DevelopmentConfiguration /** * License directory path of the project. */ + @Deprecated( + message = "licenseDirectory is unsupported since 5.8.0 and no longer used", + level = DeprecationLevel.WARNING + ) val licenseDirectory: String - get() = licenseDirectoryProperty.get() + get() = "" + @Deprecated( + message = "licenseFilePath is unsupported since 5.8.0 and no longer used", + level = DeprecationLevel.WARNING + ) val licenseFilePath: String - get() = File(licenseDirectory, LICENSE_FILE_NAME).absolutePath + get() = "" /** * Local configuration path of the project. diff --git a/src/test/groovy/com/intershop/gradle/icm/ICMProjectPluginIntegrationKotlinSpec.groovy b/src/test/groovy/com/intershop/gradle/icm/ICMProjectPluginIntegrationKotlinSpec.groovy index cd80772..3378348 100644 --- a/src/test/groovy/com/intershop/gradle/icm/ICMProjectPluginIntegrationKotlinSpec.groovy +++ b/src/test/groovy/com/intershop/gradle/icm/ICMProjectPluginIntegrationKotlinSpec.groovy @@ -20,85 +20,10 @@ package com.intershop.gradle.icm import com.intershop.gradle.icm.util.TestRepo import com.intershop.gradle.test.AbstractIntegrationKotlinSpec -import java.util.zip.ZipFile - -import static org.gradle.testkit.runner.TaskOutcome.FAILED import static org.gradle.testkit.runner.TaskOutcome.SUCCESS class ICMProjectPluginIntegrationKotlinSpec extends AbstractIntegrationKotlinSpec { - def 'check lic configuration from extension'() { - given: - settingsFile << """ - rootProject.name="rootproject" - """.stripIndent() - - buildFile << """ - plugins { - `java` - id("com.intershop.gradle.icm.base") - } - - val sfile = File(project.gradle.gradleUserHomeDir, "icm-default/lic/license.xml") - if(! sfile.exists()) { - sfile.parentFile.mkdirs() - sfile.createNewFile() - } - - tasks.register("showLicPath") { - doLast { - val extension = project.extensions.getByName("intershop") as com.intershop.gradle.icm.extension.IntershopExtension - println(extension.developmentConfig.licenseFilePath) - } - } - - """.stripIndent() - - when: - def result = getPreparedGradleRunner() - .withArguments("showLicPath", "-s", "--warning-mode", "all") - .withGradleVersion(gradleVersion) - .build() - - then: - result.task(':showLicPath').outcome == SUCCESS - result.output.contains(".gradle/icm-default/lic/license.xml") - - when: - def result1 = getPreparedGradleRunner() - .withArguments("showLicPath", "-s", "--warning-mode", "all", "-DlicenseDir=/home/user/licdir") - .withGradleVersion(gradleVersion) - .build() - - then: - result1.task(':showLicPath').outcome == SUCCESS - result1.output.contains("/home/user/licdir/license.xml") - - when: - def result2 = getPreparedGradleRunner() - .withArguments("showLicPath", "-s", "--warning-mode", "all", "-PlicenseDir=/home/otheruser/licdir") - .withGradleVersion(gradleVersion) - .build() - - then: - result2.task(':showLicPath').outcome == SUCCESS - result2.output.contains("/home/otheruser/licdir/license.xml") - - when: - def result3 = getPreparedGradleRunner() - .withArguments("showLicPath", "-s") - .withEnvironment([ "LICENSEDIR": "/home/other/licdir" ]) - .withGradleVersion(gradleVersion) - .build() - - then: - result3.task(':showLicPath').outcome == SUCCESS - result3.output.contains("/home/other/licdir/license.xml") - - where: - gradleVersion << supportedGradleVersions - } - def 'check conf configuration from extension'() { given: settingsFile << """ diff --git a/src/test/groovy/com/intershop/gradle/icm/ICMProjectPluginIntegrationSpec.groovy b/src/test/groovy/com/intershop/gradle/icm/ICMProjectPluginIntegrationSpec.groovy index e09a55e..27e120f 100644 --- a/src/test/groovy/com/intershop/gradle/icm/ICMProjectPluginIntegrationSpec.groovy +++ b/src/test/groovy/com/intershop/gradle/icm/ICMProjectPluginIntegrationSpec.groovy @@ -16,82 +16,13 @@ */ package com.intershop.gradle.icm -import com.intershop.gradle.icm.tasks.CreateMainPackage -import com.intershop.gradle.icm.tasks.CreateTestPackage import com.intershop.gradle.icm.util.TestRepo import com.intershop.gradle.test.AbstractIntegrationGroovySpec -import java.util.zip.ZipFile - import static org.gradle.testkit.runner.TaskOutcome.SUCCESS class ICMProjectPluginIntegrationSpec extends AbstractIntegrationGroovySpec { - def 'check lic configuration from extension'() { - given: - settingsFile << """ - rootProject.name='rootproject' - """.stripIndent() - - buildFile << """ - plugins { - id 'java' - id 'com.intershop.gradle.icm.base' - } - - task showLicPath() { - doLast { - println(project.extensions.getByName("intershop").developmentConfig.licenseFilePath) - } - } - - """.stripIndent() - - when: - def result = getPreparedGradleRunner() - .withArguments("showLicPath", "-s", "--warning-mode", "all") - .withGradleVersion(gradleVersion) - .build() - - then: - result.task(':showLicPath').outcome == SUCCESS - result.output.contains(new File("gradle/icm-default/lic/license.xml").toString()) - - when: - def result1 = getPreparedGradleRunner() - .withArguments("showLicPath", "-s", "--warning-mode", "all", "-DlicenseDir=/home/user/licdir") - .withGradleVersion(gradleVersion) - .build() - - then: - result1.task(':showLicPath').outcome == SUCCESS - result1.output.contains(new File("/home/user/licdir/license.xml").toString()) - - when: - def result2 = getPreparedGradleRunner() - .withArguments("showLicPath", "-s", "--warning-mode", "all", "-PlicenseDir=/home/otheruser/licdir") - .withGradleVersion(gradleVersion) - .build() - - then: - result2.task(':showLicPath').outcome == SUCCESS - result2.output.contains(new File("/home/otheruser/licdir/license.xml").toString()) - - when: - def result3 = getPreparedGradleRunner() - .withArguments("showLicPath", "-s") - .withEnvironment([ "LICENSEDIR": "/home/other/licdir" ]) - .withGradleVersion(gradleVersion) - .build() - - then: - result3.task(':showLicPath').outcome == SUCCESS - result3.output.contains(new File("/home/other/licdir/license.xml").toString()) - - where: - gradleVersion << supportedGradleVersions - } - def 'check conf configuration from extension'() { given: settingsFile << """