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