Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
317 views
in Technique[技术] by (71.8m points)

DataGrip org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:

I am unable to run some basic groovy code with abstraction. I have read thru this link and auto generated pojos and rest controllers from Data Grip.

  1. On DataGrip I right-click, hit "Scripted Extensions" and
  2. select a Groovy file. If the file is written exactly as "Groovy Pojos.groovy" (see in link) then it works.
  3. If I want to use some basic abstraction and designs around reusability it fails to work. Cant even get to import classes in Groovy.

Simple code snippet of what I tried

class abstract AGenerate {
abstract def getPackageName() ;
abstract def getFileSuffix() ;
abstract def generateClassFiles()
abstract def generate(output, className, fields) ;
def typeMapping = [
(~/(?i)int/) : "Integer",
(~/(?i)bigint/) : "Long",
(~/(?i)float/): "Double", : "Float",
(~/(?i)double|decimal|real/) : "Double",
(~/(?i)datetime|timestamp/) : "java.sql.Timestamp",
(~/(?i)date/) : "java.sql.Date",
(~/(?i)time/) : "java.sql.Time",
(~/(?i)/) : "String"
]
...  

package com.companyname.autogenerate ;
import com.intellij.database.model.DasTable
import com.intellij.database.model.ObjectKind
import com.intellij.database.util.Case
import com.intellij.database.util.DasUtil
FILES.chooseDirectoryAndSave("Choose directory", "Choose where to store generated files") { dir ->
    SELECTION.filter { it instanceof DasTable && it.getKind() == ObjectKind.TABLE }.each { generateFolderFromTable(it, dir) }
}
class GenerateEntityClass extends AGenerate {
    def getFileSuffix() {
        return "Entity.java"
    }
    def getPackageName() {
        return "com.sample;" ;
    }
...

Notice I have defined a super class AGenerate and then child classes GenerateEntityClass, I get a error when try to run AutoGenerate at the import line itself

import com.intellij.database.model.DasTable
import com.intellij.database.model.ObjectKind

import com.mycompany.autogenerate.GenerateEntityClass

 def GenerateEntityClass entityClass = new GenerateEntityClass();
        FILES.chooseDirectoryAndSave("Choose directory", "Choose where to store generated files") { dir ->        
            SELECTION.filter { it instanceof DasTable && it.getKind() == ObjectKind.TABLE }.each { entityClass.generateFolderFromTable(it, dir) }
        }

I get an error

12:06 AM AutoGenerate.groovy: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script24.groovy: 4: unable to resolve class com.companyname.autogenerate.GenerateEntityClass @ line 4, column 1. import com.companyname.autogenerate.GenerateEntityClass;

Edit: Folder Structure Project

-->scripts
----->AutoGenerate.groovy (call this from DataGrip)
----->com
-------->companyname
----------->autogenerate
-------------->AGenerate.groovy
-------------->GenerateEntityClass.groovy
-->src
question from:https://stackoverflow.com/questions/65890657/datagrip-org-codehaus-groovy-control-multiplecompilationerrorsexception-startup

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...