-
Notifications
You must be signed in to change notification settings - Fork 41
Languages: Kotlin
SAP Commerce supports multiple languages, Java is the primary one and Groovy, enabled via groovynature
extension, is mostly used for scripting and tests.
Thanks to SAP Commerce customisation capabilities and kotlinnature extension the Plugin adds support of the Kotlin language for smooth and fun development.
Prerequisites
To enable Kotlin language support kotlinnature must be part of the Project and set as a required extension.
Kotlin icon is used for kotlinnature
module to explicitly distinguish it from any other module.
- Automatic registration of the Kotlin source directories during the Project import / refresh, such as
kotlinsrc
andkotlintestsrc
.
- Automatic creation and registration of the Kotlin Facet for each module during the Project import / refresh.
Facet will be registered only for modules with
kotlinsrc
orkotlintestsrc
directory.
- Automatic configuration of the Kotlin Compiler based on
kotlinnature
settings and project JDK during the Project import / refresh.
Version of the Kotlin Compiler is taken from the project property
kotlinnature.compiler.version
.
Detailed FlexibleSearch language injection covered in the corresponding section of the FlexibleSearch: Language Injection - Java wiki.
If FlexibleSearch specific elements identified in the Kotlin string literals, FlexibleSearch language will be injected accordingly.
Injection is supported for different string literals declared as constants or variables.
- Simple string:
"SELECT {PK} FROM {Product}"
- Multiline string:
"""SELECT {PK} FROM {Product}"""
Official JetBrains documentation on Using Live Template.
ysri - injects template code for Spring dependency injection via @Resource
annotation.
import javax.annotation.Resource
...
@Resource(name = "<bean_id>")
private lateinit var <field_name>: <Bean_Class>
log4j2 - injects template code for Log4j2 Logger and takes current class name as an argument for Logger factory.
import org.apache.logging.log4j.LogManager
import org.apache.logging.log4j.Logger
...
companion object {
private val LOG by lazy { LogManager.getLogger(this::class.java.name) }
}
...
slf4j - injects template code for SLF4J Logger and takes current class name as an argument for Logger factory.
import org.slf4j.Logger
import org.slf4j.LoggerFactory
...
companion object {
private val LOG by lazy { LoggerFactory.getLogger(this::class.java.name) }
}
...
Project
Systems
Languages
Integrations
Diagrams