【问题标题】:How to override the auto generated mule-artifact.json with mule extension如何使用 mule 扩展覆盖自动生成的 mule-artifact.json
【发布时间】:2022-09-27 22:01:28
【问题描述】:

创建自定义 mule 扩展时是否可以覆盖自动生成的 mule-artifact.json?

  • 为什么要覆盖它?你有什么问题?

标签: mule mule4 mule-sdk


【解决方案1】:

是的,它可以被覆盖,您需要将您的自定义 mule-artifact.json 放在下面META-INF/mule-artifact/mule-artifact.json在您项目的src/main/resources 中。

【讨论】:

  • 我在${project.home}/src/main/resources/META-INF/mule-artifact 中有我的mule-artifact.json,但是当我运行maven test 时,会在target\classes\META-INF\mule-artifact 中创建一个生成的版本。当我运行maven generate-sources 时,我的版本被复制到target\classes\META-INF\mule-artifact
  • 不太确定测试,也许您需要在src/test/resources 下维护它的副本?不过不太确定。
  • 出于好奇,您需要自定义工件 json 进行测试是什么?我经常看到将它覆盖到export 你的某些资源,但我认为你不需要导出任何东西进行测试。我可能是错的。
  • 我有需要导出以进行测试和部署的包。在我的测试中,我实例化了自定义类,但由于它们是依赖项的一部分,因此它们是不可见的。
  • @user1932673 mvn test 与如何生成包无关。如果您真的想看看它的实际外观,您可以改用mvn clean install
【解决方案2】:

覆盖自动生成的mule-artifact.json 的解决方法是将maven-resources-plugin 添加到您的pom 并在mule-extensions-maven-plugin 创建文件后运行它。这是我使用的:

<plugin>
    <artifactId>maven-resources-plugin</artifactId>
    <executions>
        <execution>
            <id>copy-custom-artifact</id>
            <phase>process-classes</phase>
            <goals>
                <goal>copy-resources</goal>
            </goals>
            <configuration>
                <outputDirectory>${basedir}/target</outputDirectory>
                <resources>
                    <resource>
                        <directory>src/main/resources/META-INF/mule-artifact</directory>
                        <targetPath>classes/META-INF/mule-artifact</targetPath>
                    </resource>
                </resources>
                <overwrite>true</overwrite>
            </configuration>
        </execution>
    </executions>
</plugin>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-05-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-08-19
    • 1970-01-01
    • 1970-01-01
    • 2019-10-11
    相关资源
    最近更新 更多