如何在 gradle 中添加依赖配置

How can I add dependency configuration in gradle

所以我正在尝试将此 Maven 配置转换为 gradle

        <plugin>
            <groupId>io.axoniq</groupId>
            <artifactId>axon-dataprotection-maven-plugin</artifactId>
            <version>${dataprotection-maven-plugin.version}</version>
            <configuration>
                <!-- required -->
                <packages>
                    <package>io.axoniq.demo.giftcard.api</package>
                </packages>
                <!-- optional -->
                <outputConfig>axon-data-protection-config.json</outputConfig>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

所以我尝试使用 'gradle init' 命令,但这就是我得到的

dependencies {
  implementation "io.axoniq:axon-dataprotection-maven-plugin:1.0"
}

如您所见,我丢失了配置部分,而且它是 maven 中的插件部分,不是吗?为什么 gradle 将其转换为依赖项?无论如何都需要配置部分,所以我怎样才能将它添加到 gradle.

Gradle只能迁移简单项目。使用需要配置的插件的项目,Gradle这里帮不上忙。特别是对于不是 common.

的插件

Gradle 插件门户中不存在用于 Axon 数据保护的社区插件,因此您唯一的选择是重写 Gradle 的插件,如上文所述:

If a plugin depends on the Maven project, then you will have to rewrite it. Don’t start by considering how the Maven plugin works, but look at what problem it is trying to solve. Then try to work out how to solve that problem in Gradle. You’ll probably find that the two build models are different enough that "transcribing" Maven plugin code into a Gradle plugin just won’t be effective. On the plus side, the plugin is likely to be much easier to write than the original Maven one because Gradle has a much richer build model and API.

Dealing with uncommon and custom plugins for more details. The source of the plugin is here