簡體   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