mavenyamlarchetypes

Yaml and Maven Archetype


I have my Archetype and inside I have a yaml file where I add the variable ${artifactId}, but when I create the project using the Archetype, the yaml file does not change the variable to the value and became like that.

server: 
  ssl: 
    enabled: false
    key-alias: ${artifactId}-dev

metadata

  <?xml version="1.0" encoding="UTF-8"?>
  <archetype-descriptor
      xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype- 
    plugin/archetype-descriptor/1.0.0 http://maven.apache.org/xsd/archetype- 
     descriptor-1.0.0.xsd"
    name="${rootArtifactId}-parent"
    xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype- 
descriptor/1.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<requiredProperties>

    <requiredProperty key="project-name" >
        <defaultValue>${artifactId}</defaultValue>
    </requiredProperty>
    <requiredProperty key="enabler-name" >
        <defaultValue>Add your enabler name</defaultValue>
    </requiredProperty>        

</requiredProperties>

<fileSets>
    <fileSet filtered="true" encoding="UTF-8">
        <directory></directory>
        <includes>
            <include>README.md</include>
            <include>Dockerfile</include>
            <include>Jenkinsfile</include>
            <include>**/*.launch</include>
            <include>**/*.json</include>
        </includes>
    </fileSet>

    <fileSet filtered="true" packaged="true" encoding="UTF-8">
        <directory>src/main/java</directory>
        <includes>
            <include>**/*.java</include>
        </includes>
    </fileSet>

    <fileSet filtered="true" packaged="true" encoding="UTF-8">
        <directory>src/test/java</directory>
        <includes>
            <include>**/*.java</include>
        </includes>
    </fileSet>

    <fileSet encoding="UTF-8">
        <directory>src/main/resources</directory>
        <includes>
            <include>*.xml</include>
            <include>*.yml</include>
            <include>*.yaml</include>
            <include>*.properties</include>
            <include>**/*.properties</include>
        </includes>
        <excludes>
            <exclude>*.txt</exclude>
        </excludes>            
    </fileSet>
</fileSets>

Any idea if works inside yaml file? Thanks


Solution

  • Your need to set filtered="true" for the resources as well.