Use one pom.xml for different projects

maven multi module project example
maven multi module project dependencies between modules
how to create multi module maven project in eclipse
multi module maven project spring boot
maven multi module best practices
maven module dependency
maven parent pom example
maven multi module version best practices

I use maven to build my java based program. It is work fine. But now I meet an issue which request me to build a revision for other users which is based on the same source code with a little different(e.g. different software name, and different resource file).

Does anyone have any idea about how to do it?

You need to use profiles. It's a little complicated to explain in an answer like this, but essentially, you will create different profiles within your POM for the different builds you want to do. You will choose the profile at build time, using, e.g., a variable definition in the mvn command line, and within the profile, you change any of the variables or settings that you need to change. Lots more info is available here.

maven - two different root poms, How do I run a multi module project in Maven? It's a little complicated to explain in an answer like this, but essentially, you will create different profiles within your POM for the different builds you want to do. You will choose the profile at build time, using, e.g., a variable definition in the mvn command line, and within the profile, you change any of the variables or settings that you need to change.

Depending on the type of project, the most "maven" way to do this would be to split up the project into a parent with multiple children. Your main project is put into one module and each of user specific configurations goes into a different module, which can then depend on the common code.

Each of the user specific modules can have their own resources and unique configuration, which would make producing different named configurations easier. It would also make any user specific coding tweaks easier.

Java Maven Dependency Project Tutorial, Building the same artifact for different environments has always been an annoyance. In this guide I'll explain how you can use profiles to build and package artifacts In the project descriptor, you need to configure the different profiles. There are two different ways that you can specify the use of multiple repositories. The first way is to specify in a POM which repositories you want to use: <project>

You can create different profiles within your POM for the different builds you want to do.

Here are some of the example part of POM.xml

<!-- Define profiles here and make DEV as default profile -->
<profiles>

    <!-- dev Profile -->
    <profile>
        <id>dev</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
    </profile>

    <!-- qa Profile -->
    <profile>
        <id>qa</id>
        <properties>
            <env>qa</env>
        </properties>
    </profile>

    <!-- prod Profile -->
    <profile>
        <id>prod</id>
        <properties>
            <env>prod</env>
        </properties>
    </profile>

</profiles>
...


<plugin>
    <artifactId>maven-resources-plugin</artifactId>
    <version>2.4.3</version>

    <executions>
        <execution>

Can a Maven project have multiple parents?, Let's say we have an application which consists of several modules, let it be a front-end module and a back-end module. Now, we work on both of  Some of the configuration that can be specified in the POM are the project dependencies, the plugins or goals that can be executed, the build profiles, and so on. Other information such as the project version, description, developers, mailing lists and such can also be specified.

Maven – Building For Different Environments, as the whole project with its submodules are located in single repository, how do you mange releases of different sub module versions (e.g. a bug  Let’s learn to create maven projects with parent child relationship. 1) Create Maven Parent Project. Project creation wizard. Create Maven Project Wizard. Select Project Archtype. Maven Quick Start Archtype. Fill details and create project. Create Maven Parent Project. Now change packaging from jar to pom in pom.xml.

Multi-Module Project with Maven, You need to use profiles. It's a little complicated to explain in an answer like this, but essentially, you will create different profiles within your  As seen in the introduction to the POM, Maven supports project aggregation in addition to project inheritance. This section outlines how Maven processes projects with multiple modules, and how you can work with them more effectively. The Reactor. The mechanism in Maven that handles multi-module projects is referred to as the reactor. This part of the Maven core does the following:

Maven – How to create a multi module project – Mkyong.com, Using a Different Version for Different Projects. What to do in a situation where a version X of a library must be used in the project app1 and  This meta data is in form of POM files which have jar file project information, including what other external dependencies this JAR file has. These other external dependencies are downloaded transitively into your project and become part of effective pom for the project. Table of Contents Local repository Central repository Remote repository

Comments
  • Thanks, i will find out some info about the maven profile at first.
  • Fine, after reading the profile section in Maven, I think it is not necessary for me. I need to use the pom to build all revision at the same time. My big problem is how to do some different setting for two revision at the same pom file.
  • I see a similar question here [1]. Based on that answer, it doesn't sound like this is supported. [1] stackoverflow.com/questions/4932944/…
  • I have fill all resources into my program and detect which need to use by myself. I think to depend on something which i was not familiar is a bad idea.