How to Develop a CUBA component

Hi,
I’m trying to figure out how to develop a CUBA component and test it on my main project.

Let say I have a project A, and an other module B which is a CUBA component.
I want to be able to develop component B while testing it on my project A (running on port 8080)?

Is this possible, could you help me on this how should I configure gradle files?
PS: Using IntelliJ as IDE

What I’m looking for is to avoid installing the component into my local maven repository, then restart the app.
Anyone any sugestion how to do that with gradle ?

Hi,

Now it is possible only if you manually write a special build.gradle/settings.gradle, where you define modules from both the component and the app, and dependencies between them. Then IntelliJ will show it as a single project and you will be able to build and deploy it with a single command.

However, Studio cannot open such projects, so you will still have to work with the component and the app in separate Studio windows.

Do you need an example of such project?

@knstvk I would love an example project :slightly_smiling_face:

Please see the attached ZIP archive.
composite-project.zip (202.5 KB)

It contains three projects:

  • comp1: the app component,
  • myapp: the application,
  • all: composite project combining both.

settings.gradle of the composite project defines modules of the nested projects as subprojects:

rootProject.name = 'all'
include(":app-global", ":app-core", ":app-gui", ":app-web",
    ":comp1-global", ":comp1-core", ":comp1-gui", ":comp1-web")

project(":app-global").projectDir = new File(settingsDir, '../myapp/modules/global')
project(":app-core").projectDir = new File(settingsDir, '../myapp/modules/core')
project(":app-web").projectDir = new File(settingsDir, '../myapp/modules/web')

project(":comp1-global").projectDir = new File(settingsDir, '../comp1/modules/global')
project(":comp1-core").projectDir = new File(settingsDir, '../comp1/modules/core')
project(":comp1-web").projectDir = new File(settingsDir, '../comp1/modules/web')

build.gradle of the composite project (which was actually copied from myapp and changed) configures all modules:

//...
def appGlobalModule = project(":${appModulePrefix}-global")
def appCoreModule = project(":${appModulePrefix}-core")
def appWebModule = project(":${appModulePrefix}-web")

def comp1GlobalModule = project(":${comp1ModulePrefix}-global")
def comp1CoreModule = project(":${comp1ModulePrefix}-core")
def comp1WebModule = project(":${comp1ModulePrefix}-web")
//...
configure([appGlobalModule, appCoreModule, appWebModule, comp1GlobalModule, comp1CoreModule, comp1WebModule]) {
    //...
}

configure(comp1GlobalModule) {
    //...
}

configure(appGlobalModule) {
    dependencies {
        compile(comp1GlobalModule)
    }
    //...
}

configure(comp1CoreModule) {
    //...
    dependencies {
        compile(comp1GlobalModule)
        //...
    }
}

configure(appCoreModule) {
    //...
    dependencies {
        compile(appGlobalModule)
        compile(comp1CoreModule)
        //...
    }

// and so on...

After creating these Gradle files, you can work with the composite project from the command line and in the IntelliJ:

cd all
gradle wrapper

gradlew startDb createDb
gradlew setupTomcat deploy start

gradlew idea
2 Likes