繁体   English   中英

替换仅在我的Maven原型中部分起作用

[英]Substitution only works partially in my maven archetype

我正在尝试创建一个使用以下archetype-metadata.xml的原型:

<?xml version="1.0" encoding="UTF-8"?>
<archetype-descriptor name="basic">
  <fileSets>
    <fileSet filtered="true">
      <directory>src/main/java/__packageInPathFormat__</directory>
      <includes>
        <include>**/*.java</include>
      </includes>
    </fileSet>
  </fileSets>
</archetype-descriptor>

原型的pom.xml如下所示:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>my.test</groupId>
  <artifactId>my-archetype</artifactId>
  <version>1.0-SNAPSHOT</version>
  <name>Archetype - my-archetype</name>

  <properties>
    <swaggerApiName>GreatApiName</swaggerApiName>
  </properties>
</project>

有一个JaxRsActivator类看起来像这样:

package ${package};

// many imports...

@ApplicationPath("res")
@SwaggerDefinition(
    tags = {@Tag(name = "${swaggerApiName}",
                 description = "${swaggerApiDescription}")})
public class JaxRsActivator extends Application {
}

我的目标是动态替换名称和描述。 根据此答案( https://stackoverflow.com/a/25523766/5444681 ),它应该可以工作。 但这仅适用于${package}

我究竟做错了什么?

由于某种原因,它现在可以与此archetype-metadata.xml一起使用:

<?xml version="1.0" encoding="UTF-8"?>
<archetype-descriptor name="basic">
  <requiredProperties>
    <requiredProperty key="swaggerApiName"/>

    <requiredProperty key="swaggerApiDescription">
      <defaultValue></defaultValue>
    </requiredProperty>
  </requiredProperties>

  <fileSets>
    <fileSet filtered="true">
      <directory>src/main/java/__packageInPathFormat__</directory>
      <includes>
        <include>**/*.java</include>
      </includes>
    </fileSet>
  </fileSets>
</archetype-descriptor>

我不确定为什么以前不起作用-因为这是我尝试的第一种方法。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM