替换仅在我的 Maven 原型中部分起作用
Substitution only works partially in my maven 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 class 看起来像这样:
package ${package};
// many imports...
@ApplicationPath("res")
@SwaggerDefinition(
tags = {@Tag(name = "${swaggerApiName}",
description = "${swaggerApiDescription}")})
public class JaxRsActivator extends Application {
}
我的目标是动态替换名称和描述。
根据这个答案(),它应该可以工作。但它只适用于 ${package}
.
我做错了什么?
出于某种原因,它现在适用于此原型-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>
我不确定为什么它以前不起作用 -- 因为这是我尝试的第一种方法。
我正在尝试创建一个自己的原型,它使用以下原型-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 class 看起来像这样:
package ${package};
// many imports...
@ApplicationPath("res")
@SwaggerDefinition(
tags = {@Tag(name = "${swaggerApiName}",
description = "${swaggerApiDescription}")})
public class JaxRsActivator extends Application {
}
我的目标是动态替换名称和描述。
根据这个答案(),它应该可以工作。但它只适用于 ${package}
.
我做错了什么?
出于某种原因,它现在适用于此原型-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>
我不确定为什么它以前不起作用 -- 因为这是我尝试的第一种方法。