0

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.

G.Chahar
  • 185
  • 6
  • 19

1 Answers1

1

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>
prudviraj
  • 3,634
  • 2
  • 16
  • 22
  • Will it work for the property file that is placed outside {basedir}? My POM exist in "Application" folder, Which is sub folder of project UI. and I want this file to copied in classes folder of another project which is outside the reach of "Application" project basedir. Hope you got my concern? – G.Chahar May 07 '20 at 11:10
  • I tried above code. But the path I have provided in output directory is skipped. C:\Users\Gaurav\ABC\ui\application\target\Home\WEB-INF\classes . Can I use above path as ..\ui\application\target\Home\WEB-INF\classes Will it work? – G.Chahar May 10 '20 at 20:16
  • I am sorry, If I confused you. Suppose ABC is parent folder and In ABC, UI and Common are parallel folders. In UI folder, there is subfolder named "Application" which contain POM.xml through which I build my WAR. Now I want a file from "COMMON" folder (with separate POM.xml) which is parallel to UI folder, moved to classes of "Application" folder. Hope it helps you. – G.Chahar May 10 '20 at 20:24
  • Updated my answer please check , and if application and common are independent project it should work , if they both are part of a muli-module project and which ABC is parent , you might need to add above section in parent pom.xml – prudviraj May 11 '20 at 13:29
  • 1
    Thanks man, It is now working for me. Have made some changes in root directory as well. at the end its working. – G.Chahar May 13 '20 at 09:12
  • Glad it helped @G.Chahar – prudviraj May 13 '20 at 11:17