开发者

When are properties resolved?

开发者 https://www.devze.com 2023-02-06 10:46 出处:网络
I defined a profile at my base-pom which uses a property that is defined by a sub-pom (deploy-location of the appserver-module). The profile shall be used after the initial full-build and thus be inhe

I defined a profile at my base-pom which uses a property that is defined by a sub-pom (deploy-location of the appserver-module). The profile shall be used after the initial full-build and thus be inherited to all sub-poms.

The question is: how/when are such properties resolved: when doing the initial full build or when do开发者_运维知识库ing a local build of a specific submodule ?

<profile>
  <id>quickdeploy</id>
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <configuration>
          <outputDirectory>${ear.path}</outputDirectory>
        </configuration>
      </plugin>
    </plugins>
  </build>
</profile>

${ear.path} is defined in a submodule ...


I just tried out your question a created two artifacts with m2eclipse. The first is q4794952.base which is a simple maven project and has its type set to pom. Then I created the second artifact from (right click on the base project, New => Maven => Maven Module ) which automatically creates the parent tag and the (sub)module inside the base artifact.

When using a module structure like created by the process above (or in genereal where the module is known by the tag) the property from the submodule is know to the "base" and will be resolved in the "full-Build" (as can be seen by using help:effective-pom and the build result of course). If you build just the submodule it's resolved as well because the profile is taken from the parent pom and the property is set in the (sub)module.

Here's my "basepom":

<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.stackoverflow</groupId>
  <artifactId>q4794952.base</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>pom</packaging>
  <profiles>
    <profile>
    <id>quickdeploy</id>
    <build>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-jar-plugin</artifactId>
          <configuration>
            <outputDirectory>${ear.path}</outputDirectory>
          </configuration>
        </plugin>
      </plugins>
    </build>
  </profile>
  </profiles>
  <modules>
    <module>q4794952.sub</module>
  </modules>
</project>
0

精彩评论

暂无评论...
验证码 换一张
取 消