我有一个如下的插件

class AbstractConfigExtension {
    public static final String NAME = "abstract_extension"
    Project project

    // Configuration extension properties
    String service
    String substrate
    String region
    String group
    String pod
    Map<String,InstanceGridDetails> instanceGridDetails  = new HashMap<String,InstanceGridDetails>()
    // new HashMap<String,String>()
    List<String> tags = new ArrayList<>()
    List<String> instances = ["i01"]
    int numInstances = 1
    boolean generateServiceFiles = true
}

我有一个名为的其他类InstanceGridDetails.groovy
class InstanceGridDetails {
    // Grid Properties
    String grid
    String dsName
    String ddName

    public AcdsInstanceGridDetails () {

    }

    String getGrid() {
        return this.grid
    }

    void grid(String grid) {
        this.grid = grid
    }

    String dsName() {
        return this.dsName
    }

    void dsName(String dsName) {
        this.dsName = dsName
    }

    String ddName() {
        return this.ddName
    }

    void ddName(String ddName) {
        this.ddName = ddName
    }
}

使用build.gradle将其称为插件,如下所示
apply plugin: 'java'
apply plugin: HoconConfigPlugin
apply plugin: GriddableCaacRpmPlugin

abstract_extension {
    service "relay"
    substrate "1p"
    region "xrd"
    instanceGridDetails = ["i01": InstanceGridDetails { gridName "grid1"
                                                            dsName "ds1"
                                                            ddName "dd1"} ]
    numInstances 1
    tags = ["medium_mem"]
}

当我如上所述做时,我得到如下问题

最佳答案

您的构造函数仍称为AcdsInstanceGridDetails,而您的类称为InstanceGridDetails。它们应该具有相同的名称。

尝试用InstanceGridDetails替换所有出现的AcdsInstanceGridDetails

关于gradle - 如何在build.gradle中定义Map <String,CustomObject>,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/60306934/

10-10 08:22