[英]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.