Skip to content

Commit

Permalink
feat: Deprecate license handling (#87395)
Browse files Browse the repository at this point in the history
* 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)
  • Loading branch information
DevDavido authored Jul 5, 2023
1 parent 776c57f commit 0b9cb2b
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 188 deletions.
24 changes: 13 additions & 11 deletions README.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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:
``<group name>-<module name>-<version>``.

=== 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.

Expand Down Expand Up @@ -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` | `<licenseDirectory>/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` | `<licenseDirectory>/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` | `<configDirectory>/icm.properties` | The absolute path of the configuration file.
|`configFilePath` | `String` | `<configDirectory>/icm.properties` | The absolute path of the configuration file.
|===

NOTE: All properties are read only.
Expand Down Expand Up @@ -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<String>` | *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<String>` | *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<String>` | *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<String>` | *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<String>` | | 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<String>` | | 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.
|===
Expand Down
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> = objectFactory.property(String::class.java)
private val configDirectoryProperty: Property<String> = objectFactory.property(String::class.java)
private val configDirectorySecProperty: Property<String> = objectFactory.property(String::class.java)
private val configProperties: Properties = Properties()
Expand All @@ -70,30 +85,16 @@ 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
}
if (configDirSecPath == null) {
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
Expand All @@ -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.")
Expand All @@ -127,7 +122,6 @@ open class DevelopmentConfiguration
tempConfigDirSecPath } else { null }
}

licenseDirectoryProperty.set(licDirPath)
configDirectoryProperty.set(configDirPath)

if (configDirSecPath != null) {
Expand All @@ -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())
Expand All @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 << """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 << """
Expand Down

0 comments on commit 0b9cb2b

Please sign in to comment.