简体   繁体   中英

Copy/include resource from another maven project

let me explain you what I am looking for.

There is one project whose POM.xml is at path

project/ui/application/pom.xml. 

I generally build my WAR file using ui/applicatio.pom.xml.

In UI's POM I have included few modules say "applicationDTO" and whose POM is at path

project/common/applicationDTO/pom.xml.

Now in applicationDTO project there is one file "ABC.properties" that I want to include in the WAR file which I created using UI project.

In short, I want to include ABC.properties file in UI's project.

Below is what I have tried, But I am getting error message like

skip non existing resourceDirectory C:\Users\Desktop\project\ui\application\common\applicationDTO\QA

Note: project is source folder which is having both UI and applicationDTO project. I want file form applicationDTO folder to be copied in UI folder via POM.

Please excuse me if I am unable to explain my issue.

You can use maven resource plugin for this

https://maven.apache.org/plugins/maven-resources-plugin/examples/include-exclude.html

You might need to adjust path's to make it work

Update:

Considering Your folder structure is

ABC 
-ui
  - application (build here)
    - pom.xml
    - classes
-common
  - ABC.properties

Now when running your maven build from application folder, below can be the section

    <plugin>
    <artifactId>maven-resources-plugin</artifactId>
    <version>2.7</version>
    <executions>
        <execution>
            <id>copy-resources</id>
            <phase>validate</phase>
            <goals>
                <goal>copy-resources</goal>
            </goals>
            <configuration>
                <outputDirectory>./classes</outputDirectory>
                <resources>
                    <resource>
                        <includes>
                            <include>ABC.properties</include>
                        </includes>
                        <directory>../../common</directory>
                        <filtering>true</filtering>
                    </resource>
                </resources>
                <delimiters>
                    <delimiter>@{*}</delimiter>
                </delimiters>
                <useDefaultDelimiters>false</useDefaultDelimiters>
            </configuration>
        </execution>
    </executions>
</plugin>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM