【问题标题】:Maven - rename files with names put in variableMaven - 重命名文件,名称放在变量中
【发布时间】:2012-08-21 19:47:37
【问题描述】:

所以这是我的问题, 我有文件,使用不同的配置文件时,每个文件都必须以不同的方式重命名。

所以我有 2 个 .properties 文件,dev.properties 和 rec.properties 在 dev.properties 你可以找到:

machineName=marin
prefix=DEV
fileOneName=node

在 rec.properties 你可以找到:

machineName=marin
prefix=REC
fileOneName=node

我现在想要的是在设置 wich 配置文件以使用时能够使用这些变量的内容:

    <profile>
        <id>dev</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <properties>
            <!-- Filter name -->
            <cogepat.filter.properties>dev.properties</cogepat.filter.properties>
        </properties>
    </profile>

但是我的变量在使用时没有被填充:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <id>run-ant-rename-war</id>
                        <phase>package</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <tasks>
                                 <copy file="mavencopyfrom/adeplacer.txt" tofile="mavencopyto/${prefix}_${fileOneName}${machineName}.txt"/>
                            </tasks>
                        </configuration>
                    </execution>
                </executions>
        </plugin>
    </plugins>
</build>

我最终得到的是一个名为:

${prefix}_${fileOneName}${machineName}.txt

【问题讨论】:

    标签: maven properties file-rename maven-antrun-plugin


    【解决方案1】:

    尝试像这样设置属性:

    <profile>
        <id>dev</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <properties>
            <machineName>marin</machineName>
            <prefix>DEV</prefix>
            <fileOneName>node</fileOneName>
        </properties>
    </profile>
    

    这应该可以解决问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-11-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-25
      • 2019-07-05
      相关资源
      最近更新 更多