Yes, i got this problem too this week.
On Dec 4, 2007 7:40 AM, heimlich <[EMAIL PROTECTED]> wrote:
>
> Hi all,
>
> I'm in a bit of a pickle, and I'm hoping someone can help me out.
>
> I have an extensive Maven project with the following layout:
>
> project A, packaging: pom
> project A.A, packaging: pom
> project A.A.A, packaging: jar
> project A.A.B, packaging: jar
> project A.A.C, packaging: war
> ...
> project A.B, packaging: pom
> project A.B.A, packaging: jar
> project A.B.B, packaging: war
> project A.B.C, packaging: war
> ...
>
> And I have a global properties file used as a configuration file that I
> want
> filtered depending on which profile I run:
>
> # conf.properties
> URL_TO_SERVER1=${env.server1.address}
> URL_TO_SERVER2=${env.server1.address}
> ...
>
> And I have three filter files:
>
> #dev.properties
> env.server1.address=server1.dev.example.com
> env.server2.address=server2.dev.example.com
>
> #test.properties
> env.server1.address=server1.test.example.com
> env.server2.address=server2.test.example.com
>
> #prod.properties
> env.server1.address=server1.prod.example.com
> env.server2.address=server2.prod.example.com
>
> Now, How do I configure the top POM (project A above) to filter
> conf.properties using (say) filter dev.properties.
>
> I had a go at it with the following top POM:
>
> <project>
> <modelVersion>4.0.0</modelVersion>
> <groupId>com.example</groupId>
> <artifactId>projA</artifactId>
> <packaging>pom</packaging>
> <version>1.0-SNAPSHOT</version>
> <name>Project A</name>
> <build>
> </build>
> <modules>
> <module>A</module>
> <module>B</module>
> </modules>
> <dependencyManagement>
> ...
> </dependencyManagement>
> <dependencies>
> <dependency>
> <groupId>junit</groupId>
> <artifactId>junit</artifactId>
> <scope>test</scope>
> </dependency>
> </dependencies>
> <profiles>
> <profile>
> <id>dev</id>
> <activation>
> <activeByDefault>true</activeByDefault>
> </activation>
> <build>
> <filters>
> <filter>${basedir}/filters/dev.properties</filter>
> </filters>
> <resources>
> <resource>
> <directory>src/main/resources</directory>
> <filtering>true</filtering>
> </resource>
> </resources>
> </build>
> </profile>
> <profile>
> <id>test</id>
> <build>
> <filters>
> <filter>${basedir}/filters/test.properties</filter>
> </filters>
> <resources>
> <resource>
> <directory>src/main/resources</directory>
> <filtering>true</filtering>
> </resource>
> </resources>
> </build>
> </profile>
> <profile>
> <id>prod</id>
> <build>
> <filters>
> <filter>${basedir}/filters/prod.properties</filter>
> </filters>
> <resources>
> <resource>
> <directory>src/main/resources</directory>
> <filtering>true</filtering>
> </resource>
> </resources>
> </build>
> </profile>
> </profiles>
> </project>
>
> The problem is that each subproject tries to refer to the 'filters'
> directory IN ITS OWN directory structure,
> not the one at the top.
>
> The reason for this structure is that I want:
>
> ONE conf.properties
> ONE filter file per profile
>
> and I want the filtered conf.properties copied into src/main/resources of
> each subproject
> (I'm, willing to consider having copies of an unfiltered conf.propertiesin
> each project's resources directory).
> Can it be done (how?) or should try a different approach (any
> suggestions)?
>
> Or should I have no filtering, and just three different properties files
> (dev, test and prod)
> at the top and have them included in each concrete project (how do I do
> that)?
>
>
> Thanks,
> heimlich
>
> --
> View this message in context:
> http://www.nabble.com/Profiles-and-filtering---global-files-tf4942371s177.html#a14148383
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
--
Paulo Cesar Silva Reis
-------------------------------
Powered by GMAIL