4

我有代码样式模板,它定义了带有新 Java 类注释的默认注释(见下文)。
如何让它插入来自 Maven 的版本pom.xml?就像是

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

1 回答 1

2

要执行您的要求,需要有一个 Eclipse 插件来为代码模板提供变量。Can you define your own template variables in eclipse的答案中有一些指向此类插件信息的链接。您可以将此请求作为m2e 项目的功能。

一个更快的解决方案是朝另一个方向发展:不是让 Eclipse 从 Maven 中提取信息,而是让 Maven 写入数据。Using Maven to output the version number to a text file中有一些很好的说明

于 2013-03-09T04:56:32.280 回答