[英]Change the {user} for a Maven project
我已經添加了:
<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
<comments>A business-friendly OSS license</comments>
</license>
</licenses>
到我的pom文件中,並且Apache許可證整齊地出現在我創建的每個新源文件中。 但是,許可證文本顯示為:
/*
* Copyright 2013 MyUserName.
*
* Licensed under the Apache License, Version 2.0 (the "License");
...
*/
我希望它成為
/*
* Copyright 2013 OldCurmudgeon <--- Note the new name.
*
* Licensed under the Apache License, Version 2.0 (the "License");
...
*/
此字段看起來像是來自{user}
屬性,因此模板建議使用。 有什么方法可以針對每個項目進行更改嗎?
經過嘗試以下提供的選項后的答案 。
我對pom文件更改是正確的。
我選擇了Apache-2.0許可證。 顯然,您將需要對許可證的選擇進行調整。
添加到您的pom文件中:
<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
<comments>A business-friendly OSS license</comments>
</license>
</licenses>
更改Java模板(工具/模板/ Java / Java類(以及您需要的任何其他類)/在編輯器中打開(按鈕)) :
更改:
...
* @author ${user}
...
至
...
* @author ${project.property.user}
...
然后更改許可證文件(工具/模板/許可證/您選擇的許可證/在編輯器中打開(按鈕)) :
...
${licensePrefix}Copyright ${date?date?string("yyyy")} ${project.organization!user}.
...
至
...
${licensePrefix}Copyright ${date?date?string("yyyy")} ${project.property.user}.
...
然后添加到您的pom文件中:
<properties>
<!-- For the License -->
<user>OldCurmudgeon</user>
</properties>
這樣就完成了。 可惜我不得不更改許可證文件。 也許在以后的NetBeans版本中,這不是必需的。
選擇工具--->模板,然后單擊設置按鈕。
編輯User.properties file
以建立user property
:例如, user=your full name <your email/contact info>
默認情況下, User.properties file
的user property
被注釋掉 。 取消注釋並編輯此行以為模板處理器提供漂亮的字符串。 請注意,可以向該文件添加其他屬性,然后在自定義模板中使用它們。
希望對您有所幫助。
如果要使用特定於PROJECT的方式(User.properties為全局),則必須更改許可證標頭模板。 將值從$ {user}更改為$ {project.property.user},然后在每個項目的pom.xml文件中,在project / properties pom元素中聲明一個“ user”屬性。 看到這個netbeans.org問題
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.