0

我的 pom.xml 中有两个配置文件,dev 和 stage:

<profiles>
    <profile>
        <id>dev</id>
        <properties>
            <hostname>vl-wlp1.hk.oracle.com</hostname>
        </properties>
        <id>stage</id>
        <properties>
            <hostname>vl-wcfs.hk.oracle.com</hostname>
        </properties>
    </profile>
</profiles>

我想在我的站点文档中使用这些:

src/site/apt/index.apt

像这样:

Dev Site: ${dev.hostname}
Stage Site: ${stage.hostname}

我可以这样做或其他具有相同效果的东西吗?

4

1 回答 1

2

不是没有一个巨大的黑客,不。

如果您想独立读取两个属性值,它们必须是两个不同的属性。

像这样的务实解决方案怎么样:

<properties>
    <dev.host>vl-wlp1.hk.oracle.com</dev.host>
    <stage.host>vl-wcfs.hk.oracle.com</stage.host>
</properties>

<profiles>
    <profile>
        <id>dev</id>
        <properties>
            <hostname>${dev.host}</hostname>
        </properties>
        <id>stage</id>
        <properties>
            <hostname>${stage.host}</hostname>
        </properties>
    </profile>
</profiles>

src/site/apt/index.apt:

Dev Site: ${dev.host}
Stage Site: ${stage.host}

(上面提到的巨大黑客意味着以编程方式迭代当前项目的配置文件并手动解析每个配置文件的属性,您可以在自定义 maven 插件或使用GMaven的 Groovy 脚本中执行此操作)

于 2011-02-21T09:41:59.677 回答