Comment by Maven archetype

I use Maven to create an archetype. I can get the archetype for creating a fine and a project template that generates work as expected. The only problem is my shell scripts. Everything that is commented out in the script is deleted, leaving only the commands. I searched high and low, and all I managed to find was another user, faced with a similar problem with java comments. https://stackoverflow.com/questions/18797333/maven-archetype-generation-is-stripping-java-comments This question remains unanswered, so I suggest that I ask again. Does anyone know why Maven archetypes post comments or how to prevent this?

+4
source share
3 answers

Using the #set command itself to set the #hash variable to "#", which allows me to support shell comments in archetype-generated scripts. This may become relatively ugly when using 80 # characters per line in the header, but that is another matter ...

+2
source

Maven uses Apache Velocity to perform replacements / replacements when copying archetype template files to project locations. The '#' character is used to start directives, for example. #set, in Velocity. I assume that Velocity does not recognize your comment as a valid directive and silently deletes it during the replacement process.

, - (\), Velocity . .

+1

I also had a similar problem with hashes. On the page http://johnjianfang.blogspot.com/2009/03/escape-properties-in-maven-archetypes.html I found the answer.

Something like this works fine in my case:

#set($hash = '#')
${hash}

Conclusion:

#
0
source

Source: https://habr.com/ru/post/1542493/


All Articles