Maven 3.0's “mvn release:perform” doesn't like a pom.xml that isn't in its git repo's root directory

后端 未结 3 1740
孤城傲影
孤城傲影 2021-02-08 15:46

I have a question about Maven, the maven-release-plugin, git integration, pom.xml\'s, and having pom.xml\'s in subdirectories of the repo\'s local copy rather than in the root.<

相关标签:
3条回答
  • 2021-02-08 16:25

    The first thing is to understand git which has it's convention that every project has it's own repository. The next thing is that Maven has it's conventions and putting the pom.xml into the root of it's project is the most obvious one. Furthermore you are trying to fight against Maven and i will predict that you will lose the combat and make your life not easy. If your projects A and B are related (same versio number or same release times) in some kind you should think about a multi-module build which results in a structure like this:

    root (Git Repos)
      +-- pom.xml
           +--- projectA (pom.xml)
           +--- projectB (pom.xml)
    

    and you can do a release of both projectA (better calling it a module) and module b in a single step from the root.

    0 讨论(0)
  • 2021-02-08 16:31

    This should do the trick:

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-release-plugin</artifactId>
        <version>2.3.2</version>
        <executions>
            <execution>
                <id>default</id>
                <goals>
                    <goal>perform</goal>
                </goals>
                <configuration>
                    <pomFileName>your_path/your_pom.xml</pomFileName>
                </configuration>
            </execution>
        </executions>
    </plugin>
    
    0 讨论(0)
  • 2021-02-08 16:43

    You can do it in the same way you normally tell Maven to run from a POM that's somewhere else: the -f option. mvn --help describes it thusly:

    -f,--file <arg>    Force the use of an alternate POM
                       file.
    

    To do that in a release, you just need to pass the appropriate option to the release plugin. You can use the perform goal's "arguments" property to do that. This property just tells the release plugin some additional arguments to append to the mvn command it runs when doing the release. You can set it from the command line by appending -D arguments="-f path/to/pom" or set it permanently in the pom in the release plugin's configuration, something like

    <plugin>
        <artifactId>maven-release-plugin</artifactId>
        <version>2.3</version>
        <configuration>
            <arguments>-f path/to/pom</arguments>
        </configuration>
    </plugin>
    
    0 讨论(0)
提交回复
热议问题