Skip to content

Commit 1a348ed

Browse files
committed
database configurator
1 parent 39ada77 commit 1a348ed

File tree

7 files changed

+90
-14
lines changed

7 files changed

+90
-14
lines changed

.idea/gradle.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

modules/database/build.gradle.kts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* This file is part of "SAP Commerce Developers Toolset" plugin for IntelliJ IDEA.
3+
* Copyright (C) 2019-2025 EPAM Systems <[email protected]> and contributors
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU Lesser General Public License as
7+
* published by the Free Software Foundation, either version 3 of the
8+
* License, or (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13+
* See the GNU Lesser General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Lesser General Public License
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
19+
fun properties(key: String) = providers.gradleProperty(key)
20+
21+
plugins {
22+
id("org.jetbrains.intellij.platform.module")
23+
alias(libs.plugins.kotlin) // Kotlin support
24+
}
25+
26+
sourceSets {
27+
main {
28+
java.srcDirs("src")
29+
resources.srcDirs("resources")
30+
}
31+
test {
32+
java.srcDirs("tests")
33+
}
34+
}
35+
36+
dependencies {
37+
implementation(project(":shared-core"))
38+
implementation(project(":project-core"))
39+
implementation(project(":project-import"))
40+
41+
intellijPlatform {
42+
intellijIdeaUltimate(properties("intellij.version")) {
43+
useInstaller = false
44+
}
45+
46+
bundledPlugins(
47+
"com.intellij.database",
48+
)
49+
}
50+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<!--
2+
~ This file is part of "SAP Commerce Developers Toolset" plugin for IntelliJ IDEA.
3+
~ Copyright (C) 2019-2025 EPAM Systems <[email protected]> and contributors
4+
~
5+
~ This program is free software: you can redistribute it and/or modify
6+
~ it under the terms of the GNU Lesser General Public License as
7+
~ published by the Free Software Foundation, either version 3 of the
8+
~ License, or (at your option) any later version.
9+
~
10+
~ This program is distributed in the hope that it will be useful,
11+
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13+
~ See the GNU Lesser General Public License for more details.
14+
~
15+
~ You should have received a copy of the GNU Lesser General Public License
16+
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
-->
18+
<idea-plugin>
19+
20+
<extensions defaultExtensionNs="sap.commerce.toolset">
21+
<project.postImportConfigurator implementation="sap.commerce.toolset.database.configurator.DataSourceConfigurator"/>
22+
</extensions>
23+
24+
</idea-plugin>

src/sap/commerce/toolset/project/configurators/DataSourcesConfigurator.kt renamed to modules/database/src/sap/commerce/toolset/database/configurator/DataSourceConfigurator.kt

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
* You should have received a copy of the GNU Lesser General Public License
1616
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
*/
18-
19-
package sap.commerce.toolset.project.configurators
18+
package sap.commerce.toolset.database.configurator
2019

2120
import com.intellij.database.access.DatabaseCredentials
2221
import com.intellij.database.autoconfig.DataSourceConfigUtil
@@ -28,7 +27,6 @@ import com.intellij.database.dataSource.LocalDataSourceManager
2827
import com.intellij.database.model.DasDataSource
2928
import com.intellij.database.util.DataSourceUtil
3029
import com.intellij.database.util.DbImplUtil
31-
import com.intellij.openapi.components.Service
3230
import com.intellij.openapi.module.ModuleManager
3331
import com.intellij.openapi.project.Project
3432
import com.intellij.openapi.roots.OrderRootType
@@ -38,11 +36,18 @@ import com.intellij.openapi.vfs.VfsUtilCore
3836
import com.intellij.util.ui.classpath.SingleRootClasspathElement
3937
import sap.commerce.toolset.HybrisConstants
4038
import sap.commerce.toolset.project.PropertyService
39+
import sap.commerce.toolset.project.configurator.ProjectPostImportConfigurator
40+
import sap.commerce.toolset.project.descriptor.HybrisProjectDescriptor
41+
import sap.commerce.toolset.project.descriptor.ModuleDescriptor
4142

42-
@Service
43-
class DataSourcesConfigurator {
43+
class DataSourceConfigurator : ProjectPostImportConfigurator {
4444

45-
fun configureAfterImport(project: Project): List<() -> Unit> {
45+
override fun postImport(
46+
project: Project,
47+
refresh: Boolean,
48+
hybrisProjectDescriptor: HybrisProjectDescriptor,
49+
moduleDescriptors: List<ModuleDescriptor>
50+
): List<() -> Unit> {
4651
val projectProperties = PropertyService.getInstance(project).findAllProperties()
4752
val dataSources = mutableListOf<LocalDataSource>()
4853
val dataSourceRegistry = DataSourceRegistry(project)
@@ -86,6 +91,7 @@ class DataSourcesConfigurator {
8691
}
8792
}
8893

94+
8995
private fun loadDatabaseDriver(project: Project, dataSource: LocalDataSource) {
9096
if (DbImplUtil.hasDriverFiles(dataSource)) return
9197

@@ -112,5 +118,4 @@ class DataSourcesConfigurator {
112118
dataSource.resolveDriver()
113119
dataSource.ensureDriverConfigured()
114120
}
115-
116-
}
121+
}

resources/META-INF/plugin.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,6 @@
130130

131131
<depends optional="true" config-file="sap.commerce.toolset-javaee-core.xml">com.intellij.javaee</depends>
132132
<depends optional="true" config-file="sap.commerce.toolset-javaee-web.xml">com.intellij.javaee.web</depends>
133+
134+
<depends optional="true" config-file="sap.commerce.toolset-database.xml">com.intellij.database</depends>
133135
</idea-plugin>

src/sap/commerce/toolset/project/configurators/ConfiguratorFactory.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ package sap.commerce.toolset.project.configurators
2121
import com.intellij.openapi.components.Service
2222
import com.intellij.openapi.components.service
2323
import com.intellij.openapi.components.serviceOrNull
24-
import sap.commerce.toolset.Plugin
2524
import sap.commerce.toolset.project.configurator.*
2625
import sap.commerce.toolset.project.configurators.impl.DefaultContentRootConfigurator
2726

@@ -53,8 +52,6 @@ class ConfiguratorFactory {
5352
fun getAngularConfigurator() = serviceOrNull<AngularConfigurator>()
5453
fun getLoadedConfigurator() = service<LoadedConfigurator>()
5554

56-
fun getDataSourcesConfigurator() = Plugin.DATABASE.service(DataSourcesConfigurator::class.java)
57-
5855
companion object {
5956
fun getInstance() = service<ConfiguratorFactory>()
6057
}

src/sap/commerce/toolset/project/configurators/PostImportConfigurator.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ class PostImportConfigurator(val project: Project) {
4949
}
5050
.flatten()
5151
val oldConfigurators = listOfNotNull(
52-
getDataSourcesConfigurator()
53-
?.configureAfterImport(project),
54-
5552
getMavenConfigurator()
5653
?.configureAfterImport(project, hybrisProjectDescriptor),
5754

0 commit comments

Comments
 (0)