属性什么时候解决?

发布于 2024-10-14 04:42:51 字数 676 浏览 0 评论 0原文

我在我的 base-pom 中定义了一个配置文件,它使用由子 pom 定义的属性(应用程序服务器的部署位置)模块)。该配置文件应在初始完整构建后使用,从而继承到所有子 pom。

问题是:如何/何时解决这些属性:何时进行初始完整构建或何时进行特定子模块的本地构建?

<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} 在子模块中定义...

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 doing 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 ...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无声静候 2024-10-21 04:42:51

我刚刚尝试了你的问题,并使用 m2eclipse 创建了两个工件。第一个是 q4794952.base,它是一个简单的 Maven 项目,其类型设置为 pom。然后我创建了第二个工件(右键单击基础项目, New => Maven => Maven Module ),它自动在基础工件内创建父标签和(子)模块。

当使用由上述过程创建的模块结构时(或者一般情况下,模块由标签已知),子模块的属性是“基础”已知的,并将在“完整构建”中解析(可以当然可以通过使用 help: effective-pom 和构建结果来查看)。如果您只构建子模块,它也会被解析,因为配置文件是从父 pom 中获取的,并且属性是在(子)模块中设置的。

这是我的“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>

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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文