This imports aren't accepting in global/src

This imports aren’t accepting in global/src, but in global/build is normal.

import com.haulmont.cuba.core.global.DesignSupport
import com.haulmont.cuba.core.entity.BaseStringIdEntity;

Hi, when I run to compile or run test there is the follow error:

Information:java: Errors occurred while compiling module 'global'
Information:javac 1.8.0_171 was used to compile java sources
Information:2018-07-18, 11:25 AM - Compilation completed with 100 errors and 0 warnings in 1 s 640 ms
/Users/felipeonofrio/IdeaProjects/muaipm/modules/global/src/ca/theaidplans/muaipm/entity/Paid.java
Error:(5, 37) java: package com.haulmont.cuba.core.global does not exist
Error:(11, 37) java: package com.haulmont.cuba.core.entity does not exist
Error:(16, 27) java: cannot find symbol
  symbol: class BaseStringIdEntity
Error:(13, 2) java: cannot find symbol
  symbol: class DesignSupport

This imports aren’t accepting in global/src, but in global/build is normal.

import  com.haulmont.cuba.core.global.DesignSupport 
import com.haulmont.cuba.core.entity.BaseStringIdEntity;

Please help me!

Hi,
How have you created the project? How do you build it?
CUBA project should be built by Gradle.
Try to assemble the project using CUBA Studio or by launching Gradle tasks in the project root folder.

Yes I did it. But still don’t recognize
package com.haulmont.cuba does not exist
and I can’t run unit tests.

Error:(4, 37) java: package com.haulmont.cuba.testsupport does not exist

Hi,
Could you share build.gradle of the project?

Not sure if this will help you, but I saw a similar problem when I created my first Cuba project.

I tried to import it into IntelliJ as a Gradle project rather than just opening the project as a directory and allowing IntelliJ to sort it out for itself. This seemed to cause problems in the class path.

You should use gradle in order to generate .ipr file and then open it using Intellij:

gradlew idea

Import as Gradle will be supporred in 6.10 version.

buildscript {
    ext.cubaVersion = '6.7.11'
    repositories {
        maven {
            url 'https://repo.cuba-platform.com/content/groups/work'
            credentials {
                username(rootProject.hasProperty('repoUser') ? rootProject['repoUser'] : 'cuba')
                password(rootProject.hasProperty('repoPass') ? rootProject['repoPass'] : 'cuba123')
            }
        }
        maven {
            url 'https://repo.cuba-platform.com/content/groups/premium'
            credentials {
                username(rootProject.hasProperty('premiumRepoUser') ? rootProject['premiumRepoUser'] : System.getenv('CUBA_PREMIUM_USER'))
                password(rootProject.hasProperty('premiumRepoPass') ? rootProject['premiumRepoPass'] : System.getenv('CUBA_PREMIUM_PASSWORD'))
            }
        }
        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }
    dependencies {
        classpath "com.haulmont.gradle:cuba-plugin:$cubaVersion"
        classpath "com.moowork.gradle:gradle-node-plugin:1.2.0"
    }
}

apply plugin: "com.moowork.node"

def globalModule = project(':app-global')
def coreModule = project(':app-core')
def guiModule = project(':app-gui')
def webModule = project(':app-web')
def polymerClientModule = project(':app-polymer-client')

def servletApi = 'org.apache.tomcat:tomcat-servlet-api:8.0.26'
apply(plugin: 'eclipse')
apply(plugin: 'java')
apply(plugin: 'idea')
apply(plugin: 'cuba')

cuba {
    artifact {
        group = 'ca.theaidplans.muaipm'
        version = '0.1'
        isSnapshot = true
    }
    tomcat {
        dir = "$project.rootDir/deploy/tomcat"
    }
    ide {
        vcs = 'Git'
    }
}

dependencies {
    appComponent("com.haulmont.cuba:cuba-global:$cubaVersion")
    appComponent("com.haulmont.reports:reports-global:$cubaVersion")

}

def postgres = 'org.postgresql:postgresql:9.4.1212'

configure([globalModule, coreModule, guiModule, webModule]) {
    apply(plugin: 'java')
    apply(plugin: 'maven')
    apply(plugin: 'eclipse')
apply(plugin: 'idea')
apply(plugin: 'cuba')

    dependencies {
        testCompile('junit:junit:4.12')
    }

    task sourceJar(type: Jar) {
        from file('src')
        classifier = 'sources'
    }

    artifacts {
        archives sourceJar
    }
}

configure(globalModule) {
    task enhance(type: CubaEnhancing)


}

configure(coreModule) {

    configurations {
        jdbc
        dbscripts
    }

    dependencies {
        compile(globalModule)
        provided(servletApi)
        jdbc(postgres)
        testRuntime(postgres)

    }

    task cleanConf(description: 'Cleans up conf directory') {
        doLast {
            def dir = new File(cuba.tomcat.dir, '/conf/app-core')
            if (dir.isDirectory()) {
                ant.delete(includeemptydirs: true) {
                    fileset(dir: dir, includes: '**/*', excludes: 'local.app.properties')
                }
            }
        }
    }

    task deploy(dependsOn: [assemble, cleanConf], type: CubaDeployment) {
        appName = 'app-core'
        appJars('app-global', 'app-core')
    }

    task createDb(dependsOn: assembleDbScripts, description: 'Creates local database', type: CubaDbCreation) {
        dbms = 'postgres'
        host = 'localhost'
        dbName = 'muaipm'
        dbUser = 'postgres'
        dbPassword = '83dEsg@27'
    }

    task updateDb(dependsOn: assembleDbScripts, description: 'Updates local database', type: CubaDbUpdate) {
        dbms = 'postgres'
        host = 'localhost'
        dbName = 'muaipm'
        dbUser = 'postgres'
        dbPassword = '83dEsg@27'
    }

    task startTestDb(type: CubaHsqlStart){
        dbPort = 8081
        dbName = 'muaipm_test'

    }

    task createTestDb(dependsOn: assembleDbScripts, description: 'Creates local database', type: CubaDbCreation) {
        dbms = 'postgres'
        host = 'localhost'
        dbName = 'muaipm_test'
        dbUser = 'postgres'
        dbPassword = '83dEsg@27'
    }



}

configure(guiModule) {
    dependencies {
        compile(globalModule)

    }

    task deployConf(type: Copy) {
        from file('src')
        include "ca/theaidplans/muaipm/**"
        into "$cuba.tomcat.dir/conf/app"
    }
}

configure(webModule) {
    configurations {
        webcontent
    }

    dependencies {
        provided(servletApi)
        compile(guiModule)

    }

    task webArchive(type: Zip) {
        from file("$buildDir/web")
        from file('web')
        classifier = 'web'
    }

    artifacts {
        archives webArchive
    }

    task deployConf(type: Copy) {
        from file('src')
        include "ca/theaidplans/muaipm/**"
        into "$cuba.tomcat.dir/conf/app"
    }

    task clearMessagesCache(type: CubaClearMessagesCache) {
        appName = 'app'
    }
    deployConf.dependsOn clearMessagesCache

    task cleanConf(description: 'Cleans up conf directory') {
        doLast {
            def dir = new File(cuba.tomcat.dir, '/conf/app')
            if (dir.isDirectory()) {
                ant.delete(includeemptydirs: true) {
                    fileset(dir: dir, includes: '**/*', excludes: 'local.app.properties')
                }
            }
        }
    }

    task deploy(dependsOn: [assemble, cleanConf], type: CubaDeployment) {
        appName = 'app'
        appJars('app-global', 'app-gui', 'app-web')
    }
}

configure(polymerClientModule) {
    apply(plugin: 'eclipse')
apply(plugin: 'idea')
apply(plugin: 'cuba')

    task assemble()

    task deploy(type: Copy) {
        from file('build/bundled')
        into "$cuba.tomcat.dir/webapps/app-front"
    }
}

task undeploy(type: Delete, dependsOn: ':app-web:cleanConf') {
    delete("$cuba.tomcat.dir/shared")
    delete("$cuba.tomcat.dir/webapps/app-core")
    delete("$cuba.tomcat.dir/webapps/app")
    delete("$cuba.tomcat.dir/webapps/app-front")
}

task restart(dependsOn: ['stop', ':app-core:deploy', ':app-web:deploy'], description: 'Redeploys applications and restarts local Tomcat') {
    doLast {
        ant.waitfor(maxwait: 6, maxwaitunit: 'second', checkevery: 2, checkeveryunit: 'second') {
            not {
                socket(server: 'localhost', port: '8787')
            }
        }
        start.execute()
    }
}

task wrapper(type: Wrapper) {
    gradleVersion = '3.4'
}

apply from: 'extra.gradle'

task jelasticBuildWar(type: CubaWarBuilding) {
    appHome = '..'
    webXmlPath = 'modules/web/web/WEB-INF/single-war-web.xml'
    appProperties = ['cuba.automaticDatabaseUpdate' : true]
    includeJdbcDriver = true
    includeContextXml = true
    coreContextXmlPath = 'modules/core/web/META-INF/jelastic-context.xml'
    // Specify the folder where the front end is placed
    polymerBuildDir = 'bundled'
}

task jelasticDeployWar(type: CubaJelasticDeploy, dependsOn: jelasticBuildWar) {
    context = 'app'
    email = rootProject.hasProperty('jelasticEmail') ? rootProject['jelasticEmail'] : ''
    password = rootProject.hasProperty('jelasticPassword') ? rootProject['jelasticPassword'] : ''
    hostUrl = 'app.jelastic.eapps.com'
    environment = 'env-3827508'
}

buildscript {
    ext.cubaVersion = '6.7.11'
    repositories {
        maven {
            url 'https://repo.cuba-platform.com/content/groups/work'
            credentials {
                username(rootProject.hasProperty('repoUser') ? rootProject['repoUser'] : 'cuba')
                password(rootProject.hasProperty('repoPass') ? rootProject['repoPass'] : 'cuba123')
            }
        }
        maven {
            url 'https://repo.cuba-platform.com/content/groups/premium'
            credentials {
                username(rootProject.hasProperty('premiumRepoUser') ? rootProject['premiumRepoUser'] : System.getenv('CUBA_PREMIUM_USER'))
                password(rootProject.hasProperty('premiumRepoPass') ? rootProject['premiumRepoPass'] : System.getenv('CUBA_PREMIUM_PASSWORD'))
            }
        }
        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }
    dependencies {
        classpath "com.haulmont.gradle:cuba-plugin:$cubaVersion"
        classpath "com.moowork.gradle:gradle-node-plugin:1.2.0"
    }
}

apply plugin: "com.moowork.node"

def globalModule = project(':app-global')
def coreModule = project(':app-core')
def guiModule = project(':app-gui')
def webModule = project(':app-web')
def polymerClientModule = project(':app-polymer-client')

def servletApi = 'org.apache.tomcat:tomcat-servlet-api:8.0.26'
apply(plugin: 'eclipse')
apply(plugin: 'java')
apply(plugin: 'idea')
apply(plugin: 'cuba')

cuba {
    artifact {
        group = 'ca.theaidplans.muaipm'
        version = '0.1'
        isSnapshot = true
    }
    tomcat {
        dir = "$project.rootDir/deploy/tomcat"
    }
    ide {
        vcs = 'Git'
    }
}

dependencies {
    appComponent("com.haulmont.cuba:cuba-global:$cubaVersion")
    appComponent("com.haulmont.reports:reports-global:$cubaVersion")

}

def postgres = 'org.postgresql:postgresql:9.4.1212'

configure([globalModule, coreModule, guiModule, webModule]) {
    apply(plugin: 'java')
    apply(plugin: 'maven')
    apply(plugin: 'eclipse')
apply(plugin: 'idea')
apply(plugin: 'cuba')

    dependencies {
        testCompile('junit:junit:4.12')
    }

    task sourceJar(type: Jar) {
        from file('src')
        classifier = 'sources'
    }

    artifacts {
        archives sourceJar
    }
}

configure(globalModule) {
    task enhance(type: CubaEnhancing)


}

configure(coreModule) {

    configurations {
        jdbc
        dbscripts
    }

    dependencies {
        compile(globalModule)
        provided(servletApi)
        jdbc(postgres)
        testRuntime(postgres)

    }

    task cleanConf(description: 'Cleans up conf directory') {
        doLast {
            def dir = new File(cuba.tomcat.dir, '/conf/app-core')
            if (dir.isDirectory()) {
                ant.delete(includeemptydirs: true) {
                    fileset(dir: dir, includes: '**/*', excludes: 'local.app.properties')
                }
            }
        }
    }

    task deploy(dependsOn: [assemble, cleanConf], type: CubaDeployment) {
        appName = 'app-core'
        appJars('app-global', 'app-core')
    }

    task createDb(dependsOn: assembleDbScripts, description: 'Creates local database', type: CubaDbCreation) {
        dbms = 'postgres'
        host = 'localhost'
        dbName = 'muaipm'
        dbUser = 'postgres'
        dbPassword = '83dEsg@27'
    }

    task updateDb(dependsOn: assembleDbScripts, description: 'Updates local database', type: CubaDbUpdate) {
        dbms = 'postgres'
        host = 'localhost'
        dbName = 'muaipm'
        dbUser = 'postgres'
        dbPassword = '83dEsg@27'
    }

    task startTestDb(type: CubaHsqlStart){
        dbPort = 8081
        dbName = 'muaipm_test'

    }

    task createTestDb(dependsOn: assembleDbScripts, description: 'Creates local database', type: CubaDbCreation) {
        dbms = 'postgres'
        host = 'localhost'
        dbName = 'muaipm_test'
        dbUser = 'postgres'
        dbPassword = '83dEsg@27'
    }



}

configure(guiModule) {
    dependencies {
        compile(globalModule)

    }

    task deployConf(type: Copy) {
        from file('src')
        include "ca/theaidplans/muaipm/**"
        into "$cuba.tomcat.dir/conf/app"
    }
}

configure(webModule) {
    configurations {
        webcontent
    }

    dependencies {
        provided(servletApi)
        compile(guiModule)

    }

    task webArchive(type: Zip) {
        from file("$buildDir/web")
        from file('web')
        classifier = 'web'
    }

    artifacts {
        archives webArchive
    }

    task deployConf(type: Copy) {
        from file('src')
        include "ca/theaidplans/muaipm/**"
        into "$cuba.tomcat.dir/conf/app"
    }

    task clearMessagesCache(type: CubaClearMessagesCache) {
        appName = 'app'
    }
    deployConf.dependsOn clearMessagesCache

    task cleanConf(description: 'Cleans up conf directory') {
        doLast {
            def dir = new File(cuba.tomcat.dir, '/conf/app')
            if (dir.isDirectory()) {
                ant.delete(includeemptydirs: true) {
                    fileset(dir: dir, includes: '**/*', excludes: 'local.app.properties')
                }
            }
        }
    }

    task deploy(dependsOn: [assemble, cleanConf], type: CubaDeployment) {
        appName = 'app'
        appJars('app-global', 'app-gui', 'app-web')
    }
}

configure(polymerClientModule) {
    apply(plugin: 'eclipse')
apply(plugin: 'idea')
apply(plugin: 'cuba')

    task assemble()

    task deploy(type: Copy) {
        from file('build/bundled')
        into "$cuba.tomcat.dir/webapps/app-front"
    }
}

task undeploy(type: Delete, dependsOn: ':app-web:cleanConf') {
    delete("$cuba.tomcat.dir/shared")
    delete("$cuba.tomcat.dir/webapps/app-core")
    delete("$cuba.tomcat.dir/webapps/app")
    delete("$cuba.tomcat.dir/webapps/app-front")
}

task restart(dependsOn: ['stop', ':app-core:deploy', ':app-web:deploy'], description: 'Redeploys applications and restarts local Tomcat') {
    doLast {
        ant.waitfor(maxwait: 6, maxwaitunit: 'second', checkevery: 2, checkeveryunit: 'second') {
            not {
                socket(server: 'localhost', port: '8787')
            }
        }
        start.execute()
    }
}

task wrapper(type: Wrapper) {
    gradleVersion = '3.4'
}

apply from: 'extra.gradle'

task jelasticBuildWar(type: CubaWarBuilding) {
    appHome = '..'
    webXmlPath = 'modules/web/web/WEB-INF/single-war-web.xml'
    appProperties = ['cuba.automaticDatabaseUpdate' : true]
    includeJdbcDriver = true
    includeContextXml = true
    coreContextXmlPath = 'modules/core/web/META-INF/jelastic-context.xml'
    // Specify the folder where the front end is placed
    polymerBuildDir = 'bundled'
}

task jelasticDeployWar(type: CubaJelasticDeploy, dependsOn: jelasticBuildWar) {
    context = 'app'
    email = rootProject.hasProperty('jelasticEmail') ? rootProject['jelasticEmail'] : ''
    password = rootProject.hasProperty('jelasticPassword') ? rootProject['jelasticPassword'] : ''
    hostUrl = 'app.jelastic.eapps.com'
    environment = 'env-3827508'
}

Hi,
It seems everything is OK with the build.gradle. But I cannot understand why do I see “javac” in the log?

Could you describe your actions “step by step”:
How have you created the project?
How have you assembled it?
Which task causes the error?