Maven原型不使用属性来创建模块名称 [英] Maven archetype not using properties to create module names

查看:176
本文介绍了Maven原型不使用属性来创建模块名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个原型,您可以在其中设置moduleName(或期望使用) 必需的属性moduleName,这是原型元数据xml(已简化,我也尝试过类似的结果)

I created an archetype where you can set the moduleName (or expect to) using a required property moduleName, here is the archetype metadata xml (reduced, which I also tried with similar results)

<?xml version="1.0" encoding="UTF-8"?>
<archetype-descriptor name="modules-archetype">

  <requiredProperties>
    <requiredProperty key="moduleName">
    </requiredProperty>
  </requiredProperties>

  <modules>
    <module id="modules-${moduleName}-api" 
            dir="modules-__moduleName__-api" 
            name="modules-${moduleName}-api">
      <fileSets>
        <fileSet encoding="UTF-8">
          <directory>src/main/java</directory>
        </fileSet>
      </fileSets>
    </module>
  </modules>

</archetype-descriptor>

在安装和生成后,在 目录名或工件标识,重传值是

After installing and generating, the moduleName value is not used in the directory name or the artifactid, the resuting values are

For the directory:        project/module-__moduleName__-api
For the pom/artifactId:   module-${moduleName}-api

该值已在项目的其他文件上正确替换,因此 我猜没有拼写问题.

The value is replaced correctly on some other files of the project, so no spelling problems I guess.

我看过很多类似的东西,但是它们都使用rootArtifactId,实际上 如果我使用rootArtifactId(作为名称的开头部分),则可以按预期工作.

I've seen a lot of similar things, but all of them using rootArtifactId, and in fact if I use rootArtifactId (as the starting part of the name) it works as expected.

找不到周围类似的问题,为什么不起作用,或如何使其起作用?

Not able to find a similar problem around, any idea why is it not working, or how to make it work?

推荐答案

我找到了一个合理的解决方法.

I found a reasonable work-around.

似乎唯一只能使用 rootArtifactId 的地方是 原型描述符中的 <module> 元素,但彼此之间 您可以轻松使用 moduleName 属性.

Seems the only place where you can only use the rootArtifactId is the <module> element in the archetype descriptor, but in every other place you can use the moduleName property without any trouble.

我做了什么:

  • 模块pom中的artifactId
  • 一些默认依赖项
  • 主pom中的模块定义 (<module>module-${moduleName}</module>)
  • artifactId in module's pom
  • some default dependencies
  • The module definition in the main pom (<module>module-${moduleName}</module>)
  • etc.

    src/main/java&中的
  • 软件包名称资源
  • package name in src/main/java & resources

工件描述符

  • 使用诸如以下的修复模块名称 模块样本1模块样本2 (当然还有其中的目录名称 工件资源以相同的方式).
  • Use a fix module name something like module-sample1 & module-sample2 (and of course name the directories inside the artifact resources the same way).

项目创建后要解决的问题

  1. 模块的目录名称
  2. 取出主pom中的模块元素 包含module-sample [12]
  1. The modules' directory name
  2. Take out the module elements in the main pom that contains module-sample[12]

所有这些都嵌入在postcreate-pom.xml中嵌入的ant脚本中 在创建项目后运行.

All of this in a ant script embedded in a postcreate-pom.xml to be run after project creation.

工作顺利.

希望它对某人有用.

感谢所有花时间阅读我的文章的人 问题,tonio.

thanks to everybody that just take the time to read my question, tonio.

这篇关于Maven原型不使用属性来创建模块名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆