How to get Maven pom.xml version in Eclipse code template?

I have a code style template that defines default annotated comments for new Java classes (see below).
How do I embed a version from Maven pom.xml

? Something like

@since ${pom.project.version}

      

CodeStyle_codetemplates.xml

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- 
Code Style Code Template 
To start using open Window -> Preferences
Java \ Code Style \ Code Template
Press [Import...] button and select this file.
 -->
<templates>
<template autoinsert="false" context="newtype_context" deleted="false" description="Newly created files" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.newtype" name="newtype">${filecomment}
${package_declaration}

/**
 * 
 * @since ${date}
 * @author ${user} 
 * Reviewer 
 */
${typecomment}
${type_declaration}</template></templates>

      

+3


source to share


1 answer


To do what you ask there must be an Eclipse plugin to expose variables to the code template. There are several links to information about this type of plugin in the answers to Can you define your own template variables in eclipse . You can request this as a feature from the m2e project.



A faster solution would be to go in a different direction: instead of having Eclipse fetching information from Maven, Maven writes the data. There are some helpful instructions. Using Maven to output the version number to a text file

+2


source







All Articles