2017-09-12 22 views
0

我想创建一个自己的原型,它使用以下原型-metadata.xml中:换人只能部分地在我的Maven原型

<?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}

我在做什么错?

回答

0

出于某种原因,它现在与这个原型-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> 

我不知道为什么它不工作之前 - 因为这是第一种方法我试过了。