Defining maven profiles outside of POM

Is there a way to define my maven profiles outside of the POM file, but not in .m2 / settings.xml ?
I want to define them in a separate xml file inside the application (a way to work effectively with maven 2 and 3), because I use maven 2 and intend to switch to 3 soon.

+5
source share
4 answers

Prior to Maven 2.2.1, you could define your profiles in the profiles.xml file as a separate file, but this feature has been removed with Maven 3. The question is, why do you need a separate file for profiles?

+1
source

maven , .

, pom.xml settings.xml, maven 3.

+1

I recently ported the application to maven3 from maven2. With maven 3 there is no way to have external profiles. But what can be done is to have external property files. This can be achieved using maven-properties-plugin

    <plugin>
 <groupId>org.codehaus.mojo</groupId>
 <artifactId>properties-maven-plugin</artifactId>
 <version>1.0-alpha-2</version>
 <executions>
  <!-- Associate the read-project-properties goal with the initialize phase,
   to read the properties file. -->
  <execution>
   <phase>initialize</phase>
   <goals>
    <goal>read-project-properties</goal>
   </goals>
   <configuration>
    <files>
     <file>../com.tak/build.properties</file>
    </files>
   </configuration>
  </execution>
 </executions>
</plugin>

So here I explained how to do this http://programtalk.com/java/migrate-from-maven2x-to-maven3x/

0
source
<profiles>
    <profile>
        <id>dev</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <properties>
            <build.profile.id>dev</build.profile.id>
        </properties>
    </profile>
    <profile>
        <id>prod</id>
        <properties>
            <build.profile.id>prod</build.profile.id>
        </properties>
    </profile>
    <profile>
        <id>test</id>
        <properties>
            <build.profile.id>test</build.profile.id>
        </properties>
    </profile>
</profiles>

And add a filter

<filters>
   <filter>src/test/resources/${build.profile.id}/config.properties</filter>
</filters>

And add any directory (dev, prod, test)

0
source

All Articles