简体   繁体   中英

Substitution only works partially in my maven archetype

I am trying to create an own archetype which uses the following 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>

The pom.xml of the archetype looks like this:

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

There is a JaxRsActivator class which looks like this:

package ${package};

// many imports...

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

My goal is to replace the name and description dynamically. According to this answer ( https://stackoverflow.com/a/25523766/5444681 ) it should work. But it only works for ${package} .

What am I doing wrong?

For some reason it works now with this 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>

I am not sure why it wasn't working before -- since this was the first approach I tried.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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