Get values from a yaml file into pom.xml

2019-03-06 15:02发布

Ive been searching for an answer to this and I see people trying to get values from a pom.xml into a yml file but not the other way around.

Say I have plugin.yml

main: main
name: CustomPlugin
version: 0.03
author: Me

How would I get the value of "version" into my pom.xml so that I don't have to update version in both the yml and pom.xml. Note I DO NOT want to go from pom.xml to yml.

I'm thinking something like this but I don't know enough about maven and pom's to be sure: pom.xml

<property file="src/plugin.yml" prefix="plugin"/>

and then use ${plugin.version}?

1条回答
疯言疯语
2楼-- · 2019-03-06 15:38

You should put the plugin.yml file into src/main/resources and configure in Maven filter.

<project>
  ...
  <build>
    ...
    <resources>
      <resource>
        <directory>src/main/resources</directory>
        <filtering>true</filtering>
      </resource>
      ...
    </resources>
    ...
  </build>
  ...
</project>
查看更多
登录 后发表回答