【问题标题】:When are properties resolved?什么时候解决属性?
【发布时间】:2011-06-15 06:17:43
【问题描述】:

我在我的 base-pom 中定义了一个配置文件,该配置文件使用一个 由 sub-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} 在子模块中定义...

【问题讨论】:

    标签: maven-2 maven


    【解决方案1】:

    我刚刚尝试了您的问题,即使用 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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-04-13
      • 2010-09-09
      • 2016-10-06
      • 1970-01-01
      • 1970-01-01
      • 2011-03-11
      • 2020-12-22
      • 2019-03-02
      相关资源
      最近更新 更多