2

I have a parent project with a .properties file, this file is filtering according to profiles defined over the project, this project has child projects or modules, I would like the .properties file filtered was available to use for the child projects and I can access properties of file using resourceBoundle in java or whatever.

Im tried to use, no luck How to share a filter file among Maven2 modules? -> MojoHaus Project

parent pom

<?xml version="1.0" encoding="UTF-8"?>
<project 
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <groupId>com.data</groupId>
    <artifactId>data2</artifactId>
    <version>data-SNAPSHOT</version>
    <packaging>pom</packaging>
    <name>dataNameapp</name>

    <modules>
        <module>child  1</module>
        <module>child  2</module>
        </modules>
.....
</project>

child project

reference parent properties in pom some code In guess

using over java code
child1/test.java

ResourceBundle resourceBundleProperties= ResourceBundle.getBundle("parentproperties")

Update

In mi parent project this file in extras is filtered and when I pass it i would like it update other inner file properties

parent--extras/filtered.properties (file filtered)
   child
   --filters/filtered.properties (get from parent)  
   --resources/final.properties  (filtered of filtered.properties)
qleoz12
  • 513
  • 5
  • 15

1 Answers1

2

You can try Maven's resources plugin to copy the file from parent project, like:

    <project>
      ...
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-resources-plugin</artifactId>
            <version>3.1.0</version>
            <executions>
              <execution>
                <id>copy-resources</id>
                <phase>process-resourcesphase>
                <goals>
                  <goal>copy-resources</goal>
                </goals>
                <configuration>
                  <outputDirectory>${basedir}/target/resources</outputDirectory>
                  <resources>          
                    <resource>
                      <directory>${project.parent.basedir}/src/resources/extras</directory>
                      <filtering>true</filtering>
                    </resource>
                  </resources>              
                </configuration>            
              </execution>
            </executions>
          </plugin>
        </plugins>
        ...
      </build>
      ...
    </project>
madhead
  • 31,729
  • 16
  • 153
  • 201
  • Hi, i test it i works like a charm ,but I would like it works only on specific childs...thank you for your knowledge (I think the documentation is short or could you give me (please) a advice to read apache projects documentation) つ ◕_◕ ༽つ (NE) – qleoz12 Aug 14 '19 at 23:21
  • 1
    What about putting that snippet inside those specific children only? – madhead Aug 14 '19 at 23:23