繁体   English   中英

如何在Eclipse代码模板中获取Maven pom.xml版本?

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

我有代码样式模板,该模板定义了带有新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>

要执行您的要求,需要有一个Eclipse插件才能将变量提供给代码模板。 可以在eclipse中定义自己的模板变量的答案中有一些指向此类插件信息的链接。 您可以从m2e项目中请求此功能

一种更快的解决方案是朝另一个方向发展:让Maven编写数据,而不是让Eclipse从Maven中提取信息。 使用Maven将版本号输出到文本文件中有一些很好的说明

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM