Domanda

I want, from my archetype, to create an xml file which name has two variables concatenated together.

Example: archetype-metadata.xml

<requiredProperties>
    <requiredProperty key="category"/>
    <requiredProperty key="description"/>
</requiredProperties>

Given category="MyCategory" and description="MyDescription", I want my file to be named "MyCateogryMyDescription.xml". Not "MyCategory-MyDescription.xml" nor anything else with something between the two.

The reason behind this weird, specific, inflexible requirement is, well, obviously backward compatibility with standards I don't want to touch.

My first try was the obvious __category____description__.xml, but it turns out that the generated file is named "MyCategory__description__.xml". If I add something between them, like a dash as __category__-__description__.xml it resolves correctly to "MyCategory-MyDescription.xml", but that's not what I want as I said before.

È stato utile?

Soluzione

you could define an additional requiredProperty, which default value corresponds to the combination of the description and category tags values (i.e. accessible by means of the usual ${...} notation).

Therefore, considering the above cited example, you could insert the following snippet in the archetype-metadata.xml file

<requiredProperties>
    <requiredProperty key="category"/>
    <requiredProperty key="description"/>
    <requiredProperty key="categoryDescriptionComposition">
        <defaultValue>${category}${description}</defaultValue>
    </requiredProperty>
</requiredProperties>

and finally name your file as __categoryDescriptionComposition__.xml.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top