簡體   English   中英

使用位於項目根目錄的maven復制資源文件

[英]Copy a resource file with maven located at the root of the project

因此,我的pom.xml具有以下內容:

    <build>
        <resources>
            <resource>
                <directory>.</directory>
                <excludes>
                    <exclude>.settings/</exclude>
                    <exclude>src/</exclude>
                    <exclude>target/</exclude>
                    <exclude>.classpath</exclude>
                    <exclude>.gitignore</exclude>
                    <exclude>.project</exclude>
                    <exclude>logging.log</exclude>
                    <exclude>mvn_cmd.bat</exclude>
                    <exclude>pom.xml</exclude>
                </excludes>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
            </resource>
        </resources>
       ...

我的目標是復制位於項目根目錄的單個文件(例如config.properties ),並在使用Eclipse執行Maven > Update時將其復制到目標/類中。 到目前為止,我發現解決此問題的唯一方法是手動從${basedir}目錄中排除所有文件。

我相信可以使用maven本機命令直接輕松地完成此操作,但是我還需要使用m2eclipse進行此操作。

我想最好的方法是使用正則表達式排除config.properties所有內容,但是我不知道maven是否具有這種功能。

嘗試使用包含而不是排除,並注意該目錄是項目的根目錄,如下所示:

<resources>
    <resource>
        <directory>${project.basedir}</directory>
        <includes>
            <include>config.properties</include>
        </includes>
    </resource>
    <resource>
        <directory>src/main/resources</directory>
    </resource>
<resources>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM